34 #define JP2_SIG_TYPE 0x6A502020
35 #define JP2_SIG_VALUE 0x0D0A870A
44 return image->comps[0].dx == image->comps[1].dx &&
45 image->comps[1].dx == image->comps[2].dx &&
46 image->comps[0].dy == image->comps[1].dy &&
47 image->comps[1].dy == image->comps[2].dy &&
48 image->comps[0].prec == image->comps[1].prec &&
49 image->comps[1].prec == image->comps[2].prec;
56 opj_set_default_decoder_parameters(&ctx->
dec_params);
70 void *
data,
int *data_size,
73 uint8_t *buf = avpkt->
data;
74 int buf_size = avpkt->
size;
91 dec = opj_create_decompress(CODEC_JP2);
97 dec = opj_create_decompress(CODEC_J2K);
104 opj_set_event_mgr((opj_common_ptr)dec,
NULL,
NULL);
106 ctx->
dec_params.cp_limit_decoding = LIMIT_TO_MAIN_HEADER;
109 stream = opj_cio_open((opj_common_ptr)dec, buf, buf_size);
112 opj_destroy_decompress(dec);
117 image = opj_decode_with_info(dec, stream,
NULL);
118 opj_cio_close(stream);
121 opj_destroy_decompress(dec);
124 width = image->x1 - image->x0;
125 height = image->y1 - image->y0;
132 switch(image->numcomps)
143 case 4: has_alpha = 1;
146 default:
av_log(avctx,
AV_LOG_ERROR,
"%d components unsupported.\n", image->numcomps);
160 ctx->
dec_params.cp_limit_decoding = NO_LIMITATION;
164 stream = opj_cio_open((opj_common_ptr)dec, buf, buf_size);
167 opj_destroy_decompress(dec);
172 image = opj_decode_with_info(dec, stream,
NULL);
173 opj_cio_close(stream);
175 for(x = 0; x < image->numcomps; x++) {
176 adjust[x] =
FFMAX(image->comps[x].prec - 8, 0);
179 for(y = 0; y < avctx->
height; y++) {
180 index = y*avctx->
width;
182 for(x = 0; x < avctx->
width; x++, index++) {
183 *img_ptr++ = image->comps[0].data[
index] >> adjust[0];
185 *img_ptr++ = image->comps[1].data[
index] >> adjust[1];
186 *img_ptr++ = image->comps[2].data[
index] >> adjust[2];
188 *img_ptr++ = image->comps[3].data[
index] >> adjust[3];
193 *output = ctx->
image;
198 opj_image_destroy(image);
199 opj_destroy_decompress(dec);
214 .
name =
"libopenjpeg",