Blender V5.3
format_jpeg.cc File Reference
#include <algorithm>
#include <csetjmp>
#include <cstdio>
#include <limits>
#include "MEM_guardedalloc.h"
#include "BLI_fileops.hh"
#include "BLI_listbase.hh"
#include "BLI_math_base.hh"
#include "BLI_string.hh"
#include "BLI_string_utf8.hh"
#include "BLI_utildefines.hh"
#include "BKE_idprop.hh"
#include "DNA_ID.h"
#include "IMB_colormanagement.hh"
#include "IMB_filetype.hh"
#include "IMB_imbuf.hh"
#include "IMB_imbuf_types.hh"
#include "IMB_metadata.hh"
#include "CLG_log.h"
#include <cstring>
#include <jerror.h>
#include <jpeglib.h>

Go to the source code of this file.

Classes

struct  blender::my_error_mgr
struct  blender::my_source_mgr
struct  blender::NeoGeo_Word

Namespaces

namespace  blender
 BMesh Iterators.

Functions

JPG Magic Check
bool blender::imb_is_a_jpeg (const uchar *mem, const size_t size)
Load JPG Image
static ImBuf * blender::ibJpegImageFromCinfo (jpeg_decompress_struct *cinfo, ImBufFlags flags, int max_size, size_t *r_width, size_t *r_height)
ImBuf * blender::imb_load_jpeg (const uchar *buffer, size_t size, ImBufFlags flags, ImFileColorSpace &)

Variables

static CLG_LogRef blender::LOG = {"image.jpeg"}
static const uchar blender::jpeg_default_quality = 75
static uchar blender::ibuf_quality
Format: JPEG (#IMB_FTYPE_JPG)
const char * blender::imb_file_extensions_jpeg [] = {".jpg", ".jpeg", nullptr}

APP1 Marker Handling

#define MAKESTMT(stuff)
#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)
static boolean blender::handle_app1 (j_decompress_ptr cinfo)
 blender::BLI_STATIC_ASSERT (sizeof(NeoGeo_Word)==4, "Must be 4 bytes")

Load JPG Thumbnail

#define JPEG_MARKER_MSB   (0xFF)
#define JPEG_MARKER_SOI   (0xD8)
#define JPEG_MARKER_APP1   (0xE1)
#define JPEG_APP1_MAX   (1 << 16)
ImBuf * blender::imb_thumbnail_jpeg (const char *filepath, const ImBufFlags flags, const size_t max_thumb_size, ImFileColorSpace &r_colorspace, size_t *r_width, size_t *r_height)

Save JPG Image

#define MAX_LIBJPEG_MARKER_LENGTH   65533
static void blender::write_jpeg (jpeg_compress_struct *cinfo, ImBuf *ibuf)
static double blender::jpeg_density_from_ppm (const double ppm[2], const double unit_scale, UINT16 r_density[2])
static int blender::init_jpeg (FILE *outfile, jpeg_compress_struct *cinfo, ImBuf *ibuf)
static bool blender::save_stdjpeg (const char *filepath, ImBuf *ibuf)
bool blender::imb_savejpeg (ImBuf *ibuf, const char *filepath, ImBufFlags flags)

JPG Error Handling

using blender::my_error_ptr = my_error_mgr *
static void blender::jpeg_error (j_common_ptr cinfo) ATTR_NORETURN

Input Handler from Memory

using blender::my_src_ptr = my_source_mgr *
static void blender::init_source (j_decompress_ptr cinfo)
static boolean blender::fill_input_buffer (j_decompress_ptr cinfo)
static void blender::skip_input_data (j_decompress_ptr cinfo, long num_bytes)
static void blender::term_source (j_decompress_ptr cinfo)
static void blender::memory_source (j_decompress_ptr cinfo, const uchar *buffer, size_t size)

Macro Definition Documentation

◆ INPUT_2BYTES

#define INPUT_2BYTES ( cinfo,
V,
action )
Value:
MAKESTMT(MAKE_BYTE_AVAIL(cinfo, action); bytes_in_buffer--; \
V = uint(GETJOCTET(*next_input_byte++)) << 8; \
MAKE_BYTE_AVAIL(cinfo, action); \
bytes_in_buffer--; \
V += GETJOCTET(*next_input_byte++);)
#define MAKESTMT(stuff)
#define MAKE_BYTE_AVAIL(cinfo, action)
CCL_NAMESPACE_BEGIN struct Window V

Definition at line 224 of file format_jpeg.cc.

Referenced by blender::handle_app1().

◆ INPUT_BYTE

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

Definition at line 218 of file format_jpeg.cc.

Referenced by blender::handle_app1().

◆ INPUT_RELOAD

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

Definition at line 199 of file format_jpeg.cc.

◆ INPUT_SYNC

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

Definition at line 195 of file format_jpeg.cc.

Referenced by blender::handle_app1().

◆ INPUT_VARS

#define INPUT_VARS ( cinfo)
Value:
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 189 of file format_jpeg.cc.

Referenced by blender::handle_app1().

◆ JPEG_APP1_MAX

#define JPEG_APP1_MAX   (1 << 16)

Definition at line 528 of file format_jpeg.cc.

Referenced by blender::imb_thumbnail_jpeg().

◆ JPEG_MARKER_APP1

#define JPEG_MARKER_APP1   (0xE1)

Definition at line 527 of file format_jpeg.cc.

Referenced by blender::imb_thumbnail_jpeg().

◆ JPEG_MARKER_MSB

#define JPEG_MARKER_MSB   (0xFF)

Definition at line 525 of file format_jpeg.cc.

Referenced by blender::imb_thumbnail_jpeg().

◆ JPEG_MARKER_SOI

#define JPEG_MARKER_SOI   (0xD8)

Definition at line 526 of file format_jpeg.cc.

Referenced by blender::imb_thumbnail_jpeg().

◆ 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 206 of file format_jpeg.cc.

◆ MAKESTMT

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

Definition at line 184 of file format_jpeg.cc.

◆ MAX_LIBJPEG_MARKER_LENGTH

#define MAX_LIBJPEG_MARKER_LENGTH   65533

Definition at line 613 of file format_jpeg.cc.

Referenced by blender::write_jpeg().