Blender  V2.93
Classes | Macros | Typedefs | Functions | Variables
jpeg.c File Reference
#include <setjmp.h>
#include <stdio.h>
#include "MEM_guardedalloc.h"
#include "BLI_fileops.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BKE_idprop.h"
#include "DNA_ID.h"
#include "IMB_filetype.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
#include "IMB_metadata.h"
#include "imbuf.h"
#include "jerror.h"
#include "jpeglib.h"
#include "IMB_colormanagement.h"
#include "IMB_colormanagement_intern.h"

Go to the source code of this file.

Classes

struct  my_error_mgr
 
struct  my_source_mgr
 
struct  NeoGeo_Word
 

Macros

#define MAKESTMT(stuff)
 
#define INPUT_VARS(cinfo)
 
#define INPUT_SYNC(cinfo)    (datasrc->next_input_byte = next_input_byte, datasrc->bytes_in_buffer = bytes_in_buffer)
 
#define INPUT_RELOAD(cinfo)    (next_input_byte = datasrc->next_input_byte, bytes_in_buffer = datasrc->bytes_in_buffer)
 
#define MAKE_BYTE_AVAIL(cinfo, action)
 
#define INPUT_BYTE(cinfo, V, action)    MAKESTMT(MAKE_BYTE_AVAIL(cinfo, action); bytes_in_buffer--; V = GETJOCTET(*next_input_byte++);)
 
#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) ATTR_NORETURN
 
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, const unsigned char *buffer, size_t size)
 
static boolean handle_app1 (j_decompress_ptr cinfo)
 
static ImBufibJpegImageFromCinfo (struct jpeg_decompress_struct *cinfo, int flags)
 
bool imb_is_a_jpeg (const unsigned char *mem, const size_t size)
 
 BLI_STATIC_ASSERT (sizeof(struct NeoGeo_Word)==4, "Must be 4 bytes")
 
ImBufimb_load_jpeg (const unsigned char *buffer, size_t size, int flags, char colorspace[IM_MAX_SPACE])
 
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 bool save_stdjpeg (const char *name, struct ImBuf *ibuf)
 
bool imb_savejpeg (struct ImBuf *ibuf, const char *filepath, int flags)
 

Variables

static const uchar jpeg_default_quality = 75
 
static uchar ibuf_quality
 

Macro Definition Documentation

◆ INPUT_2BYTES

#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++);)
#define MAKESTMT(stuff)
Definition: jpeg.c:181
#define MAKE_BYTE_AVAIL(cinfo, action)
Definition: jpeg.c:203

Definition at line 221 of file jpeg.c.

◆ INPUT_BYTE

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

Definition at line 215 of file jpeg.c.

◆ INPUT_RELOAD

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

Definition at line 196 of file jpeg.c.

◆ INPUT_SYNC

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

Definition at line 192 of file jpeg.c.

◆ INPUT_VARS

#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 186 of file jpeg.c.

◆ MAKE_BYTE_AVAIL

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

Definition at line 203 of file jpeg.c.

◆ MAKESTMT

#define MAKESTMT (   stuff)
Value:
do { \
stuff \
} while (0)

Definition at line 181 of file jpeg.c.

Typedef Documentation

◆ my_error_mgr

typedef struct my_error_mgr my_error_mgr

◆ my_error_ptr

Definition at line 81 of file jpeg.c.

◆ my_src_ptr

Definition at line 116 of file jpeg.c.

Function Documentation

◆ BLI_STATIC_ASSERT()

BLI_STATIC_ASSERT ( sizeof(struct NeoGeo_Word = =4,
"Must be 4 bytes"   
)

◆ fill_input_buffer()

static boolean fill_input_buffer ( j_decompress_ptr  cinfo)
static

Definition at line 123 of file jpeg.c.

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

Referenced by memory_source().

◆ handle_app1()

static boolean handle_app1 ( j_decompress_ptr  cinfo)
static

◆ ibJpegImageFromCinfo()

static ImBuf * ibJpegImageFromCinfo ( struct jpeg_decompress_struct *  cinfo,
int  flags 
)
static

◆ imb_is_a_jpeg()

bool imb_is_a_jpeg ( const unsigned char *  mem,
const size_t  size 
)

Definition at line 62 of file jpeg.c.

References magic(), and size().

Referenced by imb_load_jpeg().

◆ imb_load_jpeg()

ImBuf* imb_load_jpeg ( const unsigned char *  buffer,
size_t  size,
int  flags,
char  colorspace[IM_MAX_SPACE] 
)

◆ imb_savejpeg()

bool imb_savejpeg ( struct ImBuf ibuf,
const char *  filepath,
int  flags 
)

Definition at line 659 of file jpeg.c.

◆ init_jpeg()

static int init_jpeg ( FILE *  outfile,
struct jpeg_compress_struct *  cinfo,
struct ImBuf ibuf 
)
static

◆ init_source()

static void init_source ( j_decompress_ptr  cinfo)
static

Definition at line 118 of file jpeg.c.

Referenced by memory_source().

◆ jpeg_error()

static void jpeg_error ( j_common_ptr  cinfo)
static

Definition at line 83 of file jpeg.c.

References err.

Referenced by imb_load_jpeg(), and save_stdjpeg().

◆ memory_source()

static void memory_source ( j_decompress_ptr  cinfo,
const unsigned char *  buffer,
size_t  size 
)
static

◆ save_stdjpeg()

static bool save_stdjpeg ( const char *  name,
struct ImBuf ibuf 
)
static

◆ skip_input_data()

static void skip_input_data ( j_decompress_ptr  cinfo,
long  num_bytes 
)
static

Definition at line 139 of file jpeg.c.

References if(), and my_source_mgr::pub.

Referenced by memory_source().

◆ term_source()

static void term_source ( j_decompress_ptr  cinfo)
static

Definition at line 153 of file jpeg.c.

Referenced by memory_source().

◆ write_jpeg()

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

Variable Documentation

◆ ibuf_quality

uchar ibuf_quality
static

Definition at line 60 of file jpeg.c.

Referenced by handle_app1(), and ibJpegImageFromCinfo().

◆ jpeg_default_quality

const uchar jpeg_default_quality = 75
static

Definition at line 59 of file jpeg.c.

Referenced by ibJpegImageFromCinfo(), and init_jpeg().