35 #define JP2_FILEHEADER_SIZE 12
38 0x0, 0x0, 0x0, 0x0C, 0x6A, 0x50, 0x20, 0x20, 0x0D, 0x0A, 0x87, 0x0A};
39 static const char J2K_HEAD[] = {0xFF, 0x4F, 0xFF, 0x51, 0x00};
82 return OPJ_CODEC_UNKNOWN;
95 FILE *stream = (FILE *)client_data;
96 fprintf(stream,
"[ERROR] %s", msg);
103 FILE *stream = (FILE *)client_data;
104 fprintf(stream,
"[WARNING] %s", msg);
111 static void info_callback(
const char *msg,
void *client_data)
113 FILE *stream = (FILE *)client_data;
114 fprintf(stream,
"[INFO] %s", msg);
118 #define PIXEL_LOOPER_BEGIN(_rect) \
119 for (y = h - 1; y != (unsigned int)(-1); y--) { \
120 for (i = y * w, i_next = (y + 1) * w; i < i_next; i++, _rect += 4) {
122 #define PIXEL_LOOPER_BEGIN_CHANNELS(_rect, _channels) \
123 for (y = h - 1; y != (unsigned int)(-1); y--) { \
124 for (i = y * w, i_next = (y + 1) * w; i < i_next; i++, _rect += _channels) {
126 #define PIXEL_LOOPER_END \
148 struct BufInfo *p_file = p_user_data;
149 OPJ_UINT32 l_nb_read;
151 if (p_file->
cur + p_nb_bytes < p_file->
buf + p_file->
len) {
152 l_nb_read = p_nb_bytes;
155 l_nb_read = (OPJ_UINT32)(p_file->
buf + p_file->
len - p_file->
cur);
157 memcpy(p_buffer, p_file->
cur, l_nb_read);
158 p_file->
cur += l_nb_read;
160 return l_nb_read ? l_nb_read : ((OPJ_SIZE_T)-1);
164 static OPJ_SIZE_T opj_write_from_buffer(
void *p_buffer, OPJ_SIZE_T p_nb_bytes,
void *p_user_data)
166 struct BufInfo *p_file = p_user_data;
167 memcpy(p_file->
cur, p_buffer, p_nb_bytes);
168 p_file->
cur += p_nb_bytes;
169 p_file->
len += p_nb_bytes;
176 struct BufInfo *p_file = p_user_data;
177 if (p_file->
cur + p_nb_bytes < p_file->
buf + p_file->
len) {
178 p_file->
cur += p_nb_bytes;
182 return (OPJ_OFF_T)-1;
187 struct BufInfo *p_file = p_user_data;
188 if (p_nb_bytes < p_file->
len) {
189 p_file->
cur = p_file->
buf + p_nb_bytes;
203 OPJ_BOOL p_is_read_stream)
205 opj_stream_t *l_stream = opj_stream_create(p_size, p_is_read_stream);
206 if (l_stream ==
NULL) {
210 opj_stream_set_user_data_length(l_stream, p_file->
len);
213 opj_stream_set_write_function(l_stream, opj_write_from_buffer);
229 FILE *f = p_user_data;
235 FILE *p_file = p_user_data;
236 OPJ_OFF_T file_length = 0;
238 fseek(p_file, 0, SEEK_END);
239 file_length = ftell(p_file);
240 fseek(p_file, 0, SEEK_SET);
242 return (OPJ_UINT64)file_length;
247 FILE *p_file = p_user_data;
248 OPJ_SIZE_T l_nb_read = fread(p_buffer, 1, p_nb_bytes, p_file);
249 return l_nb_read ? l_nb_read : (OPJ_SIZE_T)-1;
254 FILE *p_file = p_user_data;
255 return fwrite(p_buffer, 1, p_nb_bytes, p_file);
260 FILE *p_file = p_user_data;
261 if (fseek(p_file, p_nb_bytes, SEEK_CUR)) {
269 FILE *p_file = p_user_data;
270 if (fseek(p_file, p_nb_bytes, SEEK_SET)) {
283 OPJ_BOOL p_is_read_stream,
286 FILE *p_file =
BLI_fopen(filepath, p_is_read_stream ?
"rb" :
"wb");
287 if (p_file ==
NULL) {
291 opj_stream_t *l_stream = opj_stream_create(p_size, p_is_read_stream);
292 if (l_stream ==
NULL) {
313 OPJ_CODEC_FORMAT p_format,
330 &buf_wrapper, OPJ_J2K_STREAM_CHUNK_SIZE,
true);
332 opj_stream_destroy(stream);
341 filepath, OPJ_J2K_STREAM_CHUNK_SIZE,
true, &p_file);
346 if (fread(mem,
sizeof(mem), 1, p_file) !=
sizeof(mem)) {
347 opj_stream_destroy(stream);
351 fseek(p_file, 0, SEEK_SET);
355 opj_stream_destroy(stream);
360 const OPJ_CODEC_FORMAT
format,
364 if (
format == OPJ_CODEC_UNKNOWN) {
369 bool use_float =
false;
370 bool use_alpha =
false;
372 long signed_offsets[4] = {0, 0, 0, 0};
373 int float_divs[4] = {1, 1, 1, 1};
375 unsigned int i, i_next,
w, h,
planes;
381 opj_image_t *image =
NULL;
382 opj_codec_t *codec =
NULL;
388 opj_set_default_decoder_parameters(&
parameters);
393 codec = opj_create_decompress(
format);
399 opj_set_info_handler(codec, info_callback, stderr);
403 if (opj_setup_decoder(codec, &
parameters) ==
false) {
407 if (opj_read_header(stream, codec, &image) ==
false) {
408 printf(
"OpenJPEG error: failed to read the header\n");
413 if (opj_decode(codec, stream, image) ==
false) {
414 fprintf(stderr,
"ERROR -> j2k_to_image: failed to decode image!\n");
418 if ((image->numcomps * image->x1 * image->y1) == 0) {
419 fprintf(stderr,
"\nError: invalid raw image parameters\n");
423 w = image->comps[0].w;
424 h = image->comps[0].h;
426 switch (image->numcomps) {
446 if (image->comps[i].prec > 8) {
450 if (image->comps[i].sgnd) {
451 signed_offsets[i] = 1 << (image->comps[i].prec - 1);
455 float_divs[i] = (1 << image->comps[i].prec) - 1;
464 ibuf->
ftype = IMB_FTYPE_JP2;
475 if (image->numcomps < 3) {
476 r = image->comps[0].data;
477 a = (use_alpha) ? image->comps[1].data :
NULL;
481 a = image->comps[1].data;
485 rect_float[3] = (
a[i] + signed_offsets[1]) / float_divs[1];
499 r = image->comps[0].data;
500 g = image->comps[1].data;
501 b = image->comps[2].data;
505 a = image->comps[3].data;
526 unsigned char *rect_uchar = (
unsigned char *)ibuf->
rect;
528 if (image->numcomps < 3) {
529 r = image->comps[0].data;
530 a = (use_alpha) ? image->comps[1].data :
NULL;
534 a = image->comps[3].data;
536 rect_uchar[0] = rect_uchar[1] = rect_uchar[2] = (
r[i] + signed_offsets[0]);
537 rect_uchar[3] =
a[i] + signed_offsets[1];
543 rect_uchar[0] = rect_uchar[1] = rect_uchar[2] = (
r[i] + signed_offsets[0]);
550 r = image->comps[0].data;
551 g = image->comps[1].data;
552 b = image->comps[2].data;
556 a = image->comps[3].data;
558 rect_uchar[0] =
r[i] + signed_offsets[0];
559 rect_uchar[1] = g[i] + signed_offsets[1];
560 rect_uchar[2] = b[i] + signed_offsets[2];
561 rect_uchar[3] =
a[i] + signed_offsets[3];
567 rect_uchar[0] =
r[i] + signed_offsets[0];
568 rect_uchar[1] = g[i] + signed_offsets[1];
569 rect_uchar[2] = b[i] + signed_offsets[2];
585 opj_destroy_codec(codec);
589 opj_image_destroy(image);
596 static opj_image_t *rawtoimage(
const char *filename,
598 raw_cparameters_t *raw_cp)
605 # define UPSAMPLE_8_TO_12(_val) ((_val << 4) | (_val & ((1 << 4) - 1)))
606 # define UPSAMPLE_8_TO_16(_val) ((_val << 8) + _val)
608 # define DOWNSAMPLE_FLOAT_TO_8BIT(_val) \
609 (_val) <= 0.0f ? 0 : ((_val) >= 1.0f ? 255 : (int)(255.0f * (_val)))
610 # define DOWNSAMPLE_FLOAT_TO_12BIT(_val) \
611 (_val) <= 0.0f ? 0 : ((_val) >= 1.0f ? 4095 : (int)(4095.0f * (_val)))
612 # define DOWNSAMPLE_FLOAT_TO_16BIT(_val) \
613 (_val) <= 0.0f ? 0 : ((_val) >= 1.0f ? 65535 : (int)(65535.0f * (_val)))
618 return (_val << 4) | (_val & ((1 << 4) - 1));
622 return (_val << 8) + _val;
627 return (_val) <= 0.0f ? 0 : ((_val) >= 1.0f ? 255 : (
int)(255.0f * (_val)));
631 return (_val) <= 0.0f ? 0 : ((_val) >= 1.0f ? 4095 : (
int)(4095.0f * (_val)));
635 return (_val) <= 0.0f ? 0 : ((_val) >= 1.0f ? 65535 : (
int)(65535.0f * (_val)));
650 #define CINEMA_24_CS 1302083
651 #define CINEMA_48_CS 651041
652 #define COMP_24_CS 1041666
653 #define COMP_48_CS 520833
661 POC[0].resno1 = numres - 1;
663 POC[0].prg1 = OPJ_CPRL;
665 POC[1].resno0 = numres - 1;
668 POC[1].resno1 = numres;
670 POC[1].prg1 = OPJ_CPRL;
716 case OPJ_CINEMA2K_24:
717 case OPJ_CINEMA2K_48:
721 if (!((image->comps[0].w == 2048) || (image->comps[0].h == 1080))) {
723 "Image coordinates %u x %u is not 2K compliant.\nJPEG Digital Cinema Profile-3 "
724 "(2K profile) compliance requires that at least one of coordinates match 2048 x "
735 case OPJ_CINEMA4K_24:
742 if (!((image->comps[0].w == 4096) || (image->comps[0].h == 2160))) {
744 "Image coordinates %u x %u is not 4K compliant.\nJPEG Digital Cinema Profile-4"
745 "(4K profile) compliance requires that at least one of coordinates match 4096 x "
762 case OPJ_CINEMA2K_24:
763 case OPJ_CINEMA4K_24:
764 for (i = 0; i <
parameters->tcp_numlayers; i++) {
766 if (img_fol->
rates[i] == 0) {
767 parameters->tcp_rates[0] = ((
float)(image->numcomps * image->comps[0].w *
768 image->comps[0].h * image->comps[0].prec)) /
769 (
CINEMA_24_CS * 8 * image->comps[0].dx * image->comps[0].dy);
772 temp_rate = ((
float)(image->numcomps * image->comps[0].w * image->comps[0].h *
773 image->comps[0].prec)) /
774 (img_fol->
rates[i] * 8 * image->comps[0].dx * image->comps[0].dy);
776 parameters->tcp_rates[i] = ((
float)(image->numcomps * image->comps[0].w *
777 image->comps[0].h * image->comps[0].prec)) /
789 case OPJ_CINEMA2K_48:
790 for (i = 0; i <
parameters->tcp_numlayers; i++) {
792 if (img_fol->
rates[i] == 0) {
793 parameters->tcp_rates[0] = ((
float)(image->numcomps * image->comps[0].w *
794 image->comps[0].h * image->comps[0].prec)) /
795 (
CINEMA_48_CS * 8 * image->comps[0].dx * image->comps[0].dy);
798 temp_rate = ((
float)(image->numcomps * image->comps[0].w * image->comps[0].h *
799 image->comps[0].prec)) /
800 (img_fol->
rates[i] * 8 * image->comps[0].dx * image->comps[0].dy);
802 parameters->tcp_rates[0] = ((
float)(image->numcomps * image->comps[0].w *
803 image->comps[0].h * image->comps[0].prec)) /
828 unsigned char *rect_uchar;
831 unsigned int subsampling_dx =
parameters->subsampling_dx;
832 unsigned int subsampling_dy =
parameters->subsampling_dy;
834 unsigned int i, i_next, numcomps,
w, h, prec;
837 OPJ_COLOR_SPACE color_space;
838 opj_image_cmptparm_t cmptparm[4];
839 opj_image_t *image =
NULL;
857 if (ibuf->
x == 4096 || ibuf->
y == 2160) {
870 for (i = 0; i <
parameters->tcp_numlayers; i++) {
876 color_space = (ibuf->
foptions.
flag & JP2_YCC) ? OPJ_CLRSPC_SYCC : OPJ_CLRSPC_SRGB;
882 color_space = (ibuf->
foptions.
flag & JP2_YCC) ? OPJ_CLRSPC_SYCC : OPJ_CLRSPC_SRGB;
896 numcomps = (ibuf->
planes == 32) ? 4 : 3;
903 memset(&cmptparm, 0,
sizeof(opj_image_cmptparm_t[4]));
904 for (i = 0; i < numcomps; i++) {
905 cmptparm[i].prec = prec;
906 cmptparm[i].bpp = prec;
907 cmptparm[i].sgnd = 0;
908 cmptparm[i].dx = subsampling_dx;
909 cmptparm[i].dy = subsampling_dy;
914 image = opj_image_create(numcomps, &cmptparm[0], color_space);
916 printf(
"Error: opj_image_create() failed\n");
923 image->x1 = image->x0 + (
w - 1) * subsampling_dx + 1 + image->x0;
924 image->y1 = image->y0 + (h - 1) * subsampling_dy + 1 + image->y0;
927 rect_uchar = (
unsigned char *)ibuf->
rect;
931 r = image->comps[0].data;
932 g = image->comps[1].data;
933 b = image->comps[2].data;
934 a = (numcomps == 4) ? image->comps[3].data :
NULL;
947 if (channels_in_float == 4) {
957 else if (channels_in_float == 3) {
976 if (channels_in_float == 4) {
985 else if (channels_in_float == 3) {
1004 if (numcomps == 4) {
1005 if (channels_in_float == 4) {
1015 else if (channels_in_float == 3) {
1034 if (channels_in_float == 4) {
1043 else if (channels_in_float == 3) {
1062 if (numcomps == 4) {
1063 if (channels_in_float == 4) {
1073 else if (channels_in_float == 3) {
1092 if (channels_in_float == 4) {
1101 else if (channels_in_float == 3) {
1124 if (numcomps == 4) {
1126 r[i] = rect_uchar[0];
1127 g[i] = rect_uchar[1];
1128 b[i] = rect_uchar[2];
1129 a[i] = rect_uchar[3];
1135 r[i] = rect_uchar[0];
1136 g[i] = rect_uchar[1];
1137 b[i] = rect_uchar[2];
1144 if (numcomps == 4) {
1164 if (numcomps == 4) {
1186 parameters->tcp_mct = image->numcomps == 3 ? 1 : 0;
1192 if (img_fol.
rates) {
1204 filepath, OPJ_J2K_STREAM_CHUNK_SIZE,
false,
NULL);
1205 if (stream ==
NULL) {
1209 opj_stream_destroy(stream);
1219 opj_image_t *image =
NULL;
1222 opj_set_default_encoder_parameters(&
parameters);
1227 parameters.tcp_rates[0] = ((100 - quality) / 90.0f * 99.0f) + 1;
1234 opj_codec_t *codec =
NULL;
1239 OPJ_CODEC_FORMAT
format = OPJ_CODEC_JP2;
1247 codec = opj_create_compress(
format);
1253 opj_set_info_handler(codec, info_callback, stderr);
1257 if (opj_setup_encoder(codec, &
parameters, image) ==
false) {
1261 if (opj_start_compress(codec, image, stream) ==
false) {
1264 if (opj_encode(codec, stream) ==
false) {
1267 if (opj_end_compress(codec, stream) ==
false) {
1277 opj_destroy_codec(codec);
1282 opj_image_destroy(image);
1286 fprintf(stderr,
"failed to encode image\n");
typedef float(TangentPoint)[2]
File and directory operations.
FILE * BLI_fopen(const char *filename, const char *mode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
MINLINE void premul_to_straight_v4_v4(float straight[4], const float premul[4])
float linearrgb_to_srgb(float c)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble GLdouble r _GL_VOID_RET _GL_VOID GLfloat GLfloat r _GL_VOID_RET _GL_VOID GLint GLint r _GL_VOID_RET _GL_VOID GLshort GLshort r _GL_VOID_RET _GL_VOID GLdouble GLdouble r
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
@ COLOR_ROLE_DEFAULT_BYTE
struct ImBuf * IMB_allocImBuf(unsigned int x, unsigned int y, unsigned char planes, unsigned int flags)
void IMB_rect_from_float(struct ImBuf *ibuf)
Contains defines and structs used throughout the imbuf module.
@ IMB_COLORMANAGE_IS_DATA
Read Guarded memory(de)allocation.
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
void colorspace_set_default_role(char *colorspace, int size, int role)
#define PIXEL_LOOPER_BEGIN_CHANNELS(_rect, _channels)
static OPJ_SIZE_T opj_read_from_buffer(void *p_buffer, OPJ_SIZE_T p_nb_bytes, void *p_user_data)
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)
static void cinema_parameters(opj_cparameters_t *parameters)
static OPJ_CODEC_FORMAT format_from_header(const unsigned char mem[JP2_FILEHEADER_SIZE], const size_t size)
static opj_image_t * ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters)
static OPJ_SIZE_T opj_write_from_file(void *p_buffer, OPJ_SIZE_T p_nb_bytes, void *p_user_data)
ImBuf * imb_load_jp2_filepath(const char *filepath, int flags, char colorspace[IM_MAX_SPACE])
static OPJ_BOOL opj_seek_from_buffer(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 const char J2K_HEAD[]
BLI_INLINE int UPSAMPLE_8_TO_12(const unsigned char _val)
static opj_stream_t * opj_stream_create_from_buffer(struct BufInfo *p_file, OPJ_UINT32 p_size, OPJ_BOOL p_is_read_stream)
#define JP2_FILEHEADER_SIZE
BLI_INLINE int UPSAMPLE_8_TO_16(const unsigned char _val)
BLI_INLINE int DOWNSAMPLE_FLOAT_TO_16BIT(const float _val)
static void opj_read_from_buffer_free(void *UNUSED(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 void cinema_setup_encoder(opj_cparameters_t *parameters, opj_image_t *image, img_fol_t *img_fol)
static void warning_callback(const char *msg, void *client_data)
static float channel_colormanage_noop(float value)
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)
static OPJ_UINT64 opj_get_data_length_from_file(void *p_user_data)
bool imb_is_a_jp2(const unsigned char *buf, size_t size)
static OPJ_OFF_T opj_skip_from_file(OPJ_OFF_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)
ImBuf * imb_load_jp2(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
static bool check_jp2(const unsigned char *mem, const size_t size)
static int init_4K_poc(opj_poc_t *POC, int numres)
static void error_callback(const char *msg, void *client_data)
struct img_folder img_fol_t
static ImBuf * imb_load_jp2_stream(opj_stream_t *stream, OPJ_CODEC_FORMAT p_format, int flags, char colorspace[IM_MAX_SPACE])
BLI_INLINE int DOWNSAMPLE_FLOAT_TO_8BIT(const float _val)
static void opj_free_from_file(void *p_user_data)
static bool check_j2k(const unsigned char *mem, const size_t size)
#define PIXEL_LOOPER_BEGIN(_rect)
static const char JP2_HEAD[]
BLI_INLINE int DOWNSAMPLE_FLOAT_TO_12BIT(const float _val)
double parameters[NUM_PARAMETERS]
void(* MEM_freeN)(void *vmemh)
void *(* MEM_mallocN)(size_t len, const char *str)
const unsigned char * buf
const unsigned char * cur
ImbFormatOptions foptions
struct ColorSpace * float_colorspace