Blender V2.61 - r43446
Classes | Defines | Typedefs | Functions | Variables

jpeg.c File Reference

#include <stdio.h>
#include <setjmp.h>
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "imbuf.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
#include "IMB_metadata.h"
#include "IMB_filetype.h"
#include "jpeglib.h"
#include "jerror.h"

Go to the source code of this file.

Classes

struct  my_error_mgr
struct  buffer_struct
struct  my_source_mgr

Defines

#define IS_jpg(x)   (x->ftype & JPG)
#define IS_stdjpg(x)   ((x->ftype & JPG_MSK) == JPG_STD)
#define IS_vidjpg(x)   ((x->ftype & JPG_MSK) == JPG_VID)
#define IS_jstjpg(x)   ((x->ftype & JPG_MSK) == JPG_JST)
#define IS_maxjpg(x)   ((x->ftype & JPG_MSK) == JPG_MAX)
#define MAKESTMT(stuff)   do { stuff } while (0)
#define INPUT_VARS(cinfo)
#define INPUT_SYNC(cinfo)
#define INPUT_RELOAD(cinfo)
#define MAKE_BYTE_AVAIL(cinfo, action)
#define INPUT_BYTE(cinfo, V, action)
#define INPUT_2BYTES(cinfo, V, action)

Typedefs

typedef struct my_error_mgr my_error_mgr
typedef my_error_mgrmy_error_ptr
typedef my_source_mgrmy_src_ptr

Functions

static void jpeg_error (j_common_ptr cinfo)
static void init_source (j_decompress_ptr cinfo)
static boolean fill_input_buffer (j_decompress_ptr cinfo)
static void skip_input_data (j_decompress_ptr cinfo, long num_bytes)
static void term_source (j_decompress_ptr cinfo)
static void memory_source (j_decompress_ptr cinfo, unsigned char *buffer, size_t size)
static boolean handle_app1 (j_decompress_ptr cinfo)
static ImBufibJpegImageFromCinfo (struct jpeg_decompress_struct *cinfo, int flags)
int imb_is_a_jpeg (unsigned char *mem)
ImBufimb_load_jpeg (unsigned char *buffer, size_t size, int flags)
static void write_jpeg (struct jpeg_compress_struct *cinfo, struct ImBuf *ibuf)
static int init_jpeg (FILE *outfile, struct jpeg_compress_struct *cinfo, struct ImBuf *ibuf)
static int save_stdjpeg (const char *name, struct ImBuf *ibuf)
static int save_vidjpeg (const char *name, struct ImBuf *ibuf)
static int save_jstjpeg (const char *name, struct ImBuf *ibuf)
static int save_maxjpeg (const char *name, struct ImBuf *ibuf)
int imb_savejpeg (struct ImBuf *ibuf, const char *name, int flags)

Variables

static int jpeg_default_quality
static int ibuf_ftype

Detailed Description

Definition in file jpeg.c.


Define Documentation

#define INPUT_2BYTES (   cinfo,
  V,
  action 
)
Value:
MAKESTMT( MAKE_BYTE_AVAIL(cinfo,action); \
          bytes_in_buffer--; \
          V = ((unsigned int) GETJOCTET(*next_input_byte++)) << 8; \
          MAKE_BYTE_AVAIL(cinfo,action); \
          bytes_in_buffer--; \
          V += GETJOCTET(*next_input_byte++); )

Definition at line 241 of file jpeg.c.

Referenced by handle_app1().

#define INPUT_BYTE (   cinfo,
  V,
  action 
)
Value:
MAKESTMT( MAKE_BYTE_AVAIL(cinfo,action); \
          bytes_in_buffer--; \
          V = GETJOCTET(*next_input_byte++); )

Definition at line 233 of file jpeg.c.

Referenced by handle_app1().

#define INPUT_RELOAD (   cinfo)
Value:
( next_input_byte = datasrc->next_input_byte,  \
      bytes_in_buffer = datasrc->bytes_in_buffer )

Definition at line 214 of file jpeg.c.

#define INPUT_SYNC (   cinfo)
Value:
( datasrc->next_input_byte = next_input_byte,  \
      datasrc->bytes_in_buffer = bytes_in_buffer )

Definition at line 209 of file jpeg.c.

Referenced by handle_app1().

#define INPUT_VARS (   cinfo)
Value:
struct jpeg_source_mgr * datasrc = (cinfo)->src;  \
    const JOCTET * next_input_byte = datasrc->next_input_byte;  \
    size_t bytes_in_buffer = datasrc->bytes_in_buffer

Definition at line 203 of file jpeg.c.

Referenced by handle_app1().

#define IS_jpg (   x)    (x->ftype & JPG)

Definition at line 50 of file jpeg.c.

#define IS_jstjpg (   x)    ((x->ftype & JPG_MSK) == JPG_JST)

Definition at line 53 of file jpeg.c.

Referenced by imb_savejpeg().

#define IS_maxjpg (   x)    ((x->ftype & JPG_MSK) == JPG_MAX)

Definition at line 54 of file jpeg.c.

Referenced by imb_savejpeg().

#define IS_stdjpg (   x)    ((x->ftype & JPG_MSK) == JPG_STD)

Definition at line 51 of file jpeg.c.

Referenced by imb_savejpeg().

#define IS_vidjpg (   x)    ((x->ftype & JPG_MSK) == JPG_VID)

Definition at line 52 of file jpeg.c.

#define MAKE_BYTE_AVAIL (   cinfo,
  action 
)
Value:
if (bytes_in_buffer == 0) {                                               \
        if (! (*datasrc->fill_input_buffer) (cinfo))                          \
            { action; }                                                       \
        INPUT_RELOAD(cinfo);  \
    }

Definition at line 222 of file jpeg.c.

#define MAKESTMT (   stuff)    do { stuff } while (0)

Definition at line 201 of file jpeg.c.


Typedef Documentation

typedef struct my_error_mgr my_error_mgr

Definition at line 99 of file jpeg.c.

Definition at line 132 of file jpeg.c.


Function Documentation

static boolean fill_input_buffer ( j_decompress_ptr  cinfo) [static]

Definition at line 140 of file jpeg.c.

References my_source_mgr::pub, my_source_mgr::terminal, and TRUE.

Referenced by memory_source().

static boolean handle_app1 ( j_decompress_ptr  cinfo) [static]

Definition at line 251 of file jpeg.c.

References BIG_LONG, FALSE, i, ibuf_ftype, INPUT_2BYTES, INPUT_BYTE, INPUT_SYNC, INPUT_VARS, length(), and TRUE.

Referenced by ibJpegImageFromCinfo().

static ImBuf * ibJpegImageFromCinfo ( struct jpeg_decompress_struct *  cinfo,
int  flags 
) [static]
int imb_is_a_jpeg ( unsigned char *  mem)

Definition at line 83 of file jpeg.c.

Referenced by imb_load_jpeg().

ImBuf* imb_load_jpeg ( unsigned char *  buffer,
size_t  size,
int  flags 
) [read]
int imb_savejpeg ( struct ImBuf ibuf,
const char *  name,
int  flags 
)
static int init_jpeg ( FILE *  outfile,
struct jpeg_compress_struct *  cinfo,
struct ImBuf ibuf 
) [static]

Definition at line 559 of file jpeg.c.

References ImBuf::ftype, jpeg_default_quality, ImBuf::planes, TRUE, ImBuf::x, and ImBuf::y.

Referenced by save_maxjpeg(), save_stdjpeg(), and save_vidjpeg().

static void init_source ( j_decompress_ptr  cinfo) [static]

Definition at line 134 of file jpeg.c.

Referenced by memory_source().

static void jpeg_error ( j_common_ptr  cinfo) [static]

Definition at line 101 of file jpeg.c.

References err, and my_error_mgr::setjmp_buffer.

Referenced by imb_load_jpeg(), save_maxjpeg(), save_stdjpeg(), and save_vidjpeg().

static void memory_source ( j_decompress_ptr  cinfo,
unsigned char *  buffer,
size_t  size 
) [static]
static int save_jstjpeg ( const char *  name,
struct ImBuf ibuf 
) [static]
static int save_maxjpeg ( const char *  name,
struct ImBuf ibuf 
) [static]
static int save_stdjpeg ( const char *  name,
struct ImBuf ibuf 
) [static]
static int save_vidjpeg ( const char *  name,
struct ImBuf ibuf 
) [static]
static void skip_input_data ( j_decompress_ptr  cinfo,
long  num_bytes 
) [static]

Definition at line 157 of file jpeg.c.

References my_source_mgr::pub.

Referenced by memory_source().

static void term_source ( j_decompress_ptr  cinfo) [static]

Definition at line 171 of file jpeg.c.

Referenced by memory_source().

static void write_jpeg ( struct jpeg_compress_struct *  cinfo,
struct ImBuf ibuf 
) [static]

Variable Documentation

int ibuf_ftype [static]

Definition at line 81 of file jpeg.c.

Referenced by handle_app1(), ibJpegImageFromCinfo(), and write_jpeg().

int jpeg_default_quality [static]

Definition at line 80 of file jpeg.c.

Referenced by init_jpeg(), save_maxjpeg(), save_stdjpeg(), and save_vidjpeg().