Blender
V3.3
|
#include "MEM_guardedalloc.h"
#include "BLI_fileops.h"
#include "BLI_math.h"
#include "IMB_filetype.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
#include "IMB_colormanagement.h"
#include "IMB_colormanagement_intern.h"
#include "openjpeg.h"
Go to the source code of this file.
Classes | |
struct | img_folder |
struct | BufInfo |
Macros | |
#define | JP2_FILEHEADER_SIZE 12 |
#define | PIXEL_LOOPER_BEGIN(_rect) |
#define | PIXEL_LOOPER_BEGIN_CHANNELS(_rect, _channels) |
#define | PIXEL_LOOPER_END |
#define | CINEMA_24_CS 1302083 /* Code-stream length for 24fps. */ |
#define | CINEMA_48_CS 651041 /* Code-stream length for 48fps. */ |
#define | COMP_24_CS 1041666 /* Maximum size per color component for 2K & 4K @ 24fps. */ |
#define | COMP_48_CS 520833 /* Maximum size per color component for 2K @ 48fps. */ |
Typedefs | |
typedef struct img_folder | img_fol_t |
Functions | |
static bool | check_jp2 (const unsigned char *mem, const size_t size) |
static bool | check_j2k (const unsigned char *mem, const size_t size) |
static OPJ_CODEC_FORMAT | format_from_header (const unsigned char mem[JP2_FILEHEADER_SIZE], const size_t size) |
bool | imb_is_a_jp2 (const unsigned char *buf, size_t size) |
static void | error_callback (const char *msg, void *client_data) |
static void | warning_callback (const char *msg, void *client_data) |
static ImBuf * | imb_load_jp2_stream (opj_stream_t *stream, OPJ_CODEC_FORMAT p_format, int flags, char colorspace[IM_MAX_SPACE]) |
ImBuf * | imb_load_jp2 (const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]) |
ImBuf * | imb_load_jp2_filepath (const char *filepath, int flags, char colorspace[IM_MAX_SPACE]) |
BLI_INLINE int | UPSAMPLE_8_TO_12 (const unsigned char _val) |
BLI_INLINE int | UPSAMPLE_8_TO_16 (const unsigned char _val) |
BLI_INLINE int | DOWNSAMPLE_FLOAT_TO_8BIT (const float _val) |
BLI_INLINE int | DOWNSAMPLE_FLOAT_TO_12BIT (const float _val) |
BLI_INLINE int | DOWNSAMPLE_FLOAT_TO_16BIT (const float _val) |
static int | init_4K_poc (opj_poc_t *POC, int numres) |
static void | cinema_parameters (opj_cparameters_t *parameters) |
static void | cinema_setup_encoder (opj_cparameters_t *parameters, opj_image_t *image, img_fol_t *img_fol) |
static float | channel_colormanage_noop (float value) |
static opj_image_t * | ibuftoimage (ImBuf *ibuf, opj_cparameters_t *parameters) |
bool | imb_save_jp2_stream (struct ImBuf *ibuf, opj_stream_t *stream, int flags) |
bool | imb_save_jp2 (struct ImBuf *ibuf, const char *filepath, int flags) |
bool | imb_save_jp2_stream (struct ImBuf *ibuf, opj_stream_t *stream, int UNUSED(flags)) |
Buffer Stream | |
static void | opj_read_from_buffer_free (void *UNUSED(p_user_data)) |
static OPJ_SIZE_T | opj_read_from_buffer (void *p_buffer, OPJ_SIZE_T p_nb_bytes, void *p_user_data) |
static OPJ_OFF_T | opj_skip_from_buffer (OPJ_OFF_T p_nb_bytes, void *p_user_data) |
static OPJ_BOOL | opj_seek_from_buffer (OPJ_OFF_T p_nb_bytes, void *p_user_data) |
static opj_stream_t * | opj_stream_create_from_buffer (struct BufInfo *p_file, OPJ_UINT32 p_size, OPJ_BOOL p_is_read_stream) |
File Stream | |
static void | opj_free_from_file (void *p_user_data) |
static OPJ_UINT64 | opj_get_data_length_from_file (void *p_user_data) |
static OPJ_SIZE_T | opj_read_from_file (void *p_buffer, OPJ_SIZE_T p_nb_bytes, void *p_user_data) |
static OPJ_SIZE_T | opj_write_from_file (void *p_buffer, OPJ_SIZE_T p_nb_bytes, void *p_user_data) |
static OPJ_OFF_T | opj_skip_from_file (OPJ_OFF_T p_nb_bytes, void *p_user_data) |
static OPJ_BOOL | opj_seek_from_file (OPJ_OFF_T p_nb_bytes, void *p_user_data) |
static opj_stream_t * | opj_stream_create_from_file (const char *filepath, OPJ_UINT32 p_size, OPJ_BOOL p_is_read_stream, FILE **r_file) |
Variables | |
static const char | JP2_HEAD [] |
static const char | J2K_HEAD [] = {0xFF, 0x4F, 0xFF, 0x51, 0x00} |
#define PIXEL_LOOPER_BEGIN | ( | _rect | ) |
#define PIXEL_LOOPER_BEGIN_CHANNELS | ( | _rect, | |
_channels | |||
) |
typedef struct img_folder img_fol_t |
Definition at line 807 of file jp2.c.
Referenced by ibuftoimage().
|
static |
Definition at line 50 of file jp2.c.
References J2K_HEAD, and size().
Referenced by format_from_header(), and imb_is_a_jp2().
|
static |
Definition at line 42 of file jp2.c.
References JP2_HEAD, and size().
Referenced by format_from_header(), and imb_is_a_jp2().
|
static |
|
static |
Definition at line 694 of file jp2.c.
References CINEMA_24_CS, CINEMA_48_CS, COMP_24_CS, COMP_48_CS, float(), image(), init_4K_poc(), parameters, and img_folder::rates.
Referenced by ibuftoimage().
BLI_INLINE int DOWNSAMPLE_FLOAT_TO_12BIT | ( | const float | _val | ) |
Definition at line 615 of file jp2.c.
Referenced by ibuftoimage().
BLI_INLINE int DOWNSAMPLE_FLOAT_TO_16BIT | ( | const float | _val | ) |
Definition at line 619 of file jp2.c.
Referenced by ibuftoimage().
BLI_INLINE int DOWNSAMPLE_FLOAT_TO_8BIT | ( | const float | _val | ) |
Definition at line 611 of file jp2.c.
Referenced by ibuftoimage().
sample error callback expecting a FILE* client object
Definition at line 79 of file jp2.c.
Referenced by imb_load_jp2_stream(), and imb_save_jp2_stream().
|
static |
Definition at line 58 of file jp2.c.
References check_j2k(), check_jp2(), and size().
Referenced by imb_load_jp2(), and imb_load_jp2_filepath().
|
static |
Definition at line 812 of file jp2.c.
References Freestyle::a, usdtokens::b(), channel_colormanage_noop(), ImBuf::channels, cinema_parameters(), cinema_setup_encoder(), ImBuf::colormanage_flag, DOWNSAMPLE_FLOAT_TO_12BIT(), DOWNSAMPLE_FLOAT_TO_16BIT(), DOWNSAMPLE_FLOAT_TO_8BIT(), ImbFormatOptions::flag, float(), ImBuf::float_colorspace, ImBuf::foptions, usdtokens::g(), image(), IMB_COLORMANAGE_IS_DATA, linearrgb_to_srgb(), MEM_freeN, MEM_mallocN, NULL, parameters, PIXEL_LOOPER_BEGIN, PIXEL_LOOPER_BEGIN_CHANNELS, PIXEL_LOOPER_END, ImBuf::planes, premul_to_straight_v4_v4(), r, img_folder::rates, ImBuf::rect, ImBuf::rect_float, UPSAMPLE_8_TO_12(), UPSAMPLE_8_TO_16(), w(), ImBuf::x, y, and ImBuf::y.
Referenced by imb_save_jp2_stream().
bool imb_is_a_jp2 | ( | const unsigned char * | buf, |
size_t | size | ||
) |
Definition at line 71 of file jp2.c.
References check_j2k(), check_jp2(), and size().
ImBuf* imb_load_jp2 | ( | const unsigned char * | mem, |
size_t | size, | ||
int | flags, | ||
char | colorspace[IM_MAX_SPACE] | ||
) |
Definition at line 303 of file jp2.c.
References BufInfo::buf, format_from_header(), imb_load_jp2_stream(), JP2_FILEHEADER_SIZE, opj_stream_create_from_buffer(), and size().
ImBuf* imb_load_jp2_filepath | ( | const char * | filepath, |
int | flags, | ||
char | colorspace[IM_MAX_SPACE] | ||
) |
Definition at line 322 of file jp2.c.
References format_from_header(), imb_load_jp2_stream(), JP2_FILEHEADER_SIZE, NULL, and opj_stream_create_from_file().
|
static |
Definition at line 345 of file jp2.c.
References Freestyle::a, usdtokens::b(), COLOR_ROLE_DEFAULT_BYTE, colorspace_set_default_role(), error_callback(), ImbFormatOptions::flag, ImBuf::flags, float(), ImBuf::foptions, ImBuf::ftype, usdtokens::g(), IB_rect, IB_rectfloat, if(), IM_MAX_SPACE, image(), IMB_allocImBuf(), IMB_rect_from_float(), NULL, parameters, PIXEL_LOOPER_BEGIN, PIXEL_LOOPER_END, ImBuf::planes, r, ImBuf::rect, ImBuf::rect_float, w(), warning_callback(), and y.
Referenced by imb_load_jp2(), and imb_load_jp2_filepath().
Definition at line 1187 of file jp2.c.
References ImBuf::flags, imb_save_jp2_stream(), NULL, and opj_stream_create_from_file().
Referenced by imb_save_jp2().
Definition at line 1200 of file jp2.c.
References error_callback(), ImbFormatOptions::flag, ImBuf::foptions, ibuftoimage(), image(), NULL, parameters, ImbFormatOptions::quality, and warning_callback().
|
static |
Definition at line 641 of file jp2.c.
Referenced by cinema_setup_encoder().
Definition at line 213 of file jp2.c.
Referenced by opj_stream_create_from_file().
|
static |
Definition at line 219 of file jp2.c.
Referenced by opj_stream_create_from_file().
|
static |
Definition at line 132 of file jp2.c.
References BufInfo::buf, BufInfo::cur, and BufInfo::len.
Referenced by opj_stream_create_from_buffer().
Definition at line 127 of file jp2.c.
Referenced by opj_stream_create_from_buffer().
|
static |
Definition at line 231 of file jp2.c.
Referenced by opj_stream_create_from_file().
|
static |
Definition at line 171 of file jp2.c.
References BufInfo::buf, BufInfo::cur, len, and BufInfo::len.
Referenced by opj_stream_create_from_buffer().
|
static |
Definition at line 253 of file jp2.c.
Referenced by opj_stream_create_from_file().
|
static |
Definition at line 160 of file jp2.c.
References BufInfo::buf, BufInfo::cur, and BufInfo::len.
Referenced by opj_stream_create_from_buffer().
|
static |
Definition at line 244 of file jp2.c.
Referenced by opj_stream_create_from_file().
|
static |
Stream wrapper for memory buffer (would be nice if this was supported by the API).
Definition at line 187 of file jp2.c.
References BufInfo::len, NULL, opj_read_from_buffer(), opj_read_from_buffer_free(), opj_seek_from_buffer(), and opj_skip_from_buffer().
Referenced by imb_load_jp2().
|
static |
Stream wrapper for memory file (would be nice if this was supported by the API).
Definition at line 267 of file jp2.c.
References BLI_fopen(), NULL, opj_free_from_file(), opj_get_data_length_from_file(), opj_read_from_file(), opj_seek_from_file(), opj_skip_from_file(), and opj_write_from_file().
Referenced by imb_load_jp2_filepath(), and imb_save_jp2().
|
static |
Definition at line 238 of file jp2.c.
Referenced by opj_stream_create_from_file().
BLI_INLINE int UPSAMPLE_8_TO_12 | ( | const unsigned char | _val | ) |
Definition at line 602 of file jp2.c.
Referenced by ibuftoimage().
BLI_INLINE int UPSAMPLE_8_TO_16 | ( | const unsigned char | _val | ) |
Definition at line 606 of file jp2.c.
Referenced by ibuftoimage().
sample warning callback expecting a FILE* client object
Definition at line 87 of file jp2.c.
Referenced by imb_load_jp2_stream(), and imb_save_jp2_stream().
|
static |
Definition at line 25 of file jp2.c.
Referenced by check_j2k().
|
static |
Definition at line 23 of file jp2.c.
Referenced by check_jp2().