Blender  V3.3
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)
 
#define JPEG_MARKER_MSB   (0xFF)
 
#define JPEG_MARKER_SOI   (0xD8)
 
#define JPEG_MARKER_APP1   (0xE1)
 
#define JPEG_APP1_MAX   (1 << 16)
 

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, int max_size, size_t *r_width, size_t *r_height)
 
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])
 
struct ImBufimb_thumbnail_jpeg (const char *filepath, const int flags, const size_t max_thumb_size, char colorspace[IM_MAX_SPACE], size_t *r_width, size_t *r_height)
 
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:170
#define MAKE_BYTE_AVAIL(cinfo, action)
Definition: jpeg.c:192

Definition at line 210 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 204 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 185 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 181 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
SyclQueue void void * src

Definition at line 175 of file jpeg.c.

◆ JPEG_APP1_MAX

#define JPEG_APP1_MAX   (1 << 16)

Definition at line 487 of file jpeg.c.

◆ JPEG_MARKER_APP1

#define JPEG_MARKER_APP1   (0xE1)

Definition at line 486 of file jpeg.c.

◆ JPEG_MARKER_MSB

#define JPEG_MARKER_MSB   (0xFF)

Definition at line 484 of file jpeg.c.

◆ JPEG_MARKER_SOI

#define JPEG_MARKER_SOI   (0xD8)

Definition at line 485 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
SyclQueue void void size_t num_bytes void

Definition at line 192 of file jpeg.c.

◆ MAKESTMT

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

Definition at line 170 of file jpeg.c.

Typedef Documentation

◆ my_error_mgr

typedef struct my_error_mgr my_error_mgr

◆ my_error_ptr

Definition at line 70 of file jpeg.c.

◆ my_src_ptr

Definition at line 105 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 112 of file jpeg.c.

References src.

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,
int  max_size,
size_t *  r_width,
size_t *  r_height 
)
static

◆ imb_is_a_jpeg()

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

Definition at line 51 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 752 of file jpeg.c.

◆ imb_thumbnail_jpeg()

struct ImBuf* imb_thumbnail_jpeg ( const char *  filepath,
const int  flags,
const size_t  max_thumb_size,
char  colorspace[IM_MAX_SPACE],
size_t *  r_width,
size_t *  r_height 
)

◆ 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 107 of file jpeg.c.

References void.

Referenced by memory_source().

◆ jpeg_error()

static void jpeg_error ( j_common_ptr  cinfo)
static

Definition at line 72 of file jpeg.c.

References err.

Referenced by imb_load_jpeg(), imb_thumbnail_jpeg(), and save_stdjpeg().

◆ memory_source()

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

Definition at line 147 of file jpeg.c.

References buffer, fill_input_buffer(), init_source(), NULL, size(), skip_input_data(), src, and term_source().

Referenced by imb_load_jpeg().

◆ 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 128 of file jpeg.c.

References if(), and src.

Referenced by memory_source().

◆ term_source()

static void term_source ( j_decompress_ptr  cinfo)
static

Definition at line 142 of file jpeg.c.

References void.

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

Referenced by handle_app1(), and ibJpegImageFromCinfo().

◆ jpeg_default_quality

const uchar jpeg_default_quality = 75
static

Definition at line 48 of file jpeg.c.

Referenced by ibJpegImageFromCinfo(), and init_jpeg().