46 #define JP2_SIG_TYPE 0x6A502020
47 #define JP2_SIG_VALUE 0x0D0A870A
48 #define JP2_CODESTREAM 0x6A703263
49 #define JP2_HEADER 0x6A703268
151 if (
s->bit_index == 0) {
152 s->bit_index = 7 + (bytestream2_get_byte(&
s->g) != 0xFFu);
155 res |= (bytestream2_peek_byte(&
s->g) >>
s->bit_index) & 1;
162 if (bytestream2_get_byte(&
s->g) == 0xff)
172 int sp = -1, curval = 0;
179 while (node && !node->
vis) {
187 curval = stack[
sp]->
val;
189 while (curval < threshold && sp >= 0) {
190 if (curval < stack[
sp]->
val)
191 curval = stack[
sp]->
val;
192 while (curval < threshold) {
202 stack[
sp]->
val = curval;
209 int bpc, uint32_t log2_chroma_wh,
int pal8)
216 if (
desc->nb_components != components) {
220 switch (components) {
222 match = match &&
desc->comp[3].depth >= bpc &&
223 (log2_chroma_wh >> 14 & 3) == 0 &&
224 (log2_chroma_wh >> 12 & 3) == 0;
226 match = match &&
desc->comp[2].depth >= bpc &&
227 (log2_chroma_wh >> 10 & 3) ==
desc->log2_chroma_w &&
228 (log2_chroma_wh >> 8 & 3) ==
desc->log2_chroma_h;
230 match = match &&
desc->comp[1].depth >= bpc &&
231 (log2_chroma_wh >> 6 & 3) ==
desc->log2_chroma_w &&
232 (log2_chroma_wh >> 4 & 3) ==
desc->log2_chroma_h;
235 match = match &&
desc->comp[0].depth >= bpc &&
236 (log2_chroma_wh >> 2 & 3) == 0 &&
237 (log2_chroma_wh & 3) == 0 &&
245 #define RGB_PIXEL_FORMATS AV_PIX_FMT_PAL8,AV_PIX_FMT_RGB24,AV_PIX_FMT_RGBA,AV_PIX_FMT_RGB48,AV_PIX_FMT_RGBA64
246 #define GRAY_PIXEL_FORMATS AV_PIX_FMT_GRAY8,AV_PIX_FMT_GRAY8A,AV_PIX_FMT_GRAY16,AV_PIX_FMT_YA16
247 #define YUV_PIXEL_FORMATS AV_PIX_FMT_YUV410P,AV_PIX_FMT_YUV411P,AV_PIX_FMT_YUVA420P, \
248 AV_PIX_FMT_YUV420P,AV_PIX_FMT_YUV422P,AV_PIX_FMT_YUVA422P, \
249 AV_PIX_FMT_YUV440P,AV_PIX_FMT_YUV444P,AV_PIX_FMT_YUVA444P, \
250 AV_PIX_FMT_YUV420P9,AV_PIX_FMT_YUV422P9,AV_PIX_FMT_YUV444P9, \
251 AV_PIX_FMT_YUVA420P9,AV_PIX_FMT_YUVA422P9,AV_PIX_FMT_YUVA444P9, \
252 AV_PIX_FMT_YUV420P10,AV_PIX_FMT_YUV422P10,AV_PIX_FMT_YUV444P10, \
253 AV_PIX_FMT_YUVA420P10,AV_PIX_FMT_YUVA422P10,AV_PIX_FMT_YUVA444P10, \
254 AV_PIX_FMT_YUV420P12,AV_PIX_FMT_YUV422P12,AV_PIX_FMT_YUV444P12, \
255 AV_PIX_FMT_YUV420P14,AV_PIX_FMT_YUV422P14,AV_PIX_FMT_YUV444P14, \
256 AV_PIX_FMT_YUV420P16,AV_PIX_FMT_YUV422P16,AV_PIX_FMT_YUV444P16, \
257 AV_PIX_FMT_YUVA420P16,AV_PIX_FMT_YUVA422P16,AV_PIX_FMT_YUVA444P16
258 #define XYZ_PIXEL_FORMATS AV_PIX_FMT_XYZ12
276 uint32_t log2_chroma_wh = 0;
278 int possible_fmts_nb = 0;
288 s->avctx->profile = bytestream2_get_be16u(&
s->g);
289 s->width = bytestream2_get_be32u(&
s->g);
290 s->height = bytestream2_get_be32u(&
s->g);
291 s->image_offset_x = bytestream2_get_be32u(&
s->g);
292 s->image_offset_y = bytestream2_get_be32u(&
s->g);
293 s->tile_width = bytestream2_get_be32u(&
s->g);
294 s->tile_height = bytestream2_get_be32u(&
s->g);
295 s->tile_offset_x = bytestream2_get_be32u(&
s->g);
296 s->tile_offset_y = bytestream2_get_be32u(&
s->g);
297 ncomponents = bytestream2_get_be16u(&
s->g);
304 if (ncomponents <= 0) {
310 if (ncomponents > 4) {
316 if (
s->tile_offset_x < 0 ||
s->tile_offset_y < 0 ||
317 s->image_offset_x <
s->tile_offset_x ||
318 s->image_offset_y <
s->tile_offset_y ||
319 s->tile_width + (
int64_t)
s->tile_offset_x <=
s->image_offset_x ||
320 s->tile_height + (
int64_t)
s->tile_offset_y <=
s->image_offset_y
326 if (
s->image_offset_x >=
s->width ||
s->image_offset_y >=
s->height) {
331 if (
s->reduction_factor && (
s->image_offset_x ||
s->image_offset_y) ){
332 av_log(
s->avctx,
AV_LOG_ERROR,
"reduction factor with image offsets is not fully implemented");
336 s->ncomponents = ncomponents;
338 if (
s->tile_width <= 0 ||
s->tile_height <= 0) {
340 s->tile_width,
s->tile_height);
345 av_log(
s->avctx,
AV_LOG_ERROR,
"Insufficient space for %d components in SIZ\n",
s->ncomponents);
349 for (
i = 0;
i <
s->ncomponents;
i++) {
350 if (
s->cdef[
i] < 0) {
351 for (
i = 0;
i <
s->ncomponents;
i++) {
354 if ((
s->ncomponents & 1) == 0)
355 s->cdef[
s->ncomponents-1] = 0;
361 for (
i = 0;
i <
s->ncomponents;
i++)
362 cdef_used |= 1<<
s->cdef[
i];
365 if (cdef_used != ((
int[]){0,2,3,14,15})[
s->ncomponents])
368 for (
i = 0;
i <
s->ncomponents;
i++) {
369 uint8_t x = bytestream2_get_byteu(&
s->g);
370 s->cbps[
i] = (x & 0x7f) + 1;
371 s->precision =
FFMAX(
s->cbps[
i],
s->precision);
372 s->sgnd[
i] = !!(x & 0x80);
373 s->cdx[
i] = bytestream2_get_byteu(&
s->g);
374 s->cdy[
i] = bytestream2_get_byteu(&
s->g);
375 if ( !
s->cdx[
i] ||
s->cdx[
i] == 3 ||
s->cdx[
i] > 4
376 || !
s->cdy[
i] ||
s->cdy[
i] == 3 ||
s->cdy[
i] > 4) {
380 int i_remapped =
s->cdef[
i] ?
s->cdef[
i]-1 : (
s->ncomponents-1);
382 log2_chroma_wh |=
s->cdy[
i] >> 1 << i_remapped * 4 |
s->cdx[
i] >> 1 << i_remapped * 4 + 2;
389 if (
s->numXtiles * (uint64_t)
s->numYtiles > INT_MAX/
sizeof(*
s->tile) ||
392 s->numXtiles =
s->numYtiles = 0;
398 s->numXtiles =
s->numYtiles = 0;
402 for (
i = 0;
i <
s->numXtiles *
s->numYtiles;
i++) {
412 s->reduction_factor);
414 s->reduction_factor);
417 for (
i = 1;
i <
s->ncomponents;
i++) {
431 switch (
s->colour_space) {
451 && !
pix_fmt_match(
s->avctx->pix_fmt, ncomponents,
s->precision, log2_chroma_wh,
s->pal8))
454 for (
i = 0;
i < possible_fmts_nb; ++
i) {
455 if (
pix_fmt_match(possible_fmts[
i], ncomponents,
s->precision, log2_chroma_wh,
s->pal8)) {
456 s->avctx->pix_fmt = possible_fmts[
i];
461 if (
i == possible_fmts_nb) {
462 if (ncomponents == 4 &&
463 s->cdy[0] == 1 &&
s->cdx[0] == 1 &&
464 s->cdy[1] == 1 &&
s->cdx[1] == 1 &&
465 s->cdy[2] ==
s->cdy[3] &&
s->cdx[2] ==
s->cdx[3]) {
466 if (
s->precision == 8 &&
s->cdy[2] == 2 &&
s->cdx[2] == 2 && !
s->pal8) {
474 }
else if (ncomponents == 3 &&
s->precision == 8 &&
475 s->cdx[0] ==
s->cdx[1] &&
s->cdx[0] ==
s->cdx[2] &&
476 s->cdy[0] ==
s->cdy[1] &&
s->cdy[0] ==
s->cdy[2]) {
479 }
else if (ncomponents == 2 &&
s->precision == 8 &&
480 s->cdx[0] ==
s->cdx[1] &&
s->cdy[0] ==
s->cdy[1]) {
483 }
else if (ncomponents == 1 &&
s->precision == 8) {
490 if (
i == possible_fmts_nb) {
492 "Unknown pix_fmt, profile: %d, colour_space: %d, "
493 "components: %d, precision: %d\n"
494 "cdx[0]: %d, cdy[0]: %d\n"
495 "cdx[1]: %d, cdy[1]: %d\n"
496 "cdx[2]: %d, cdy[2]: %d\n"
497 "cdx[3]: %d, cdy[3]: %d\n",
498 s->avctx->profile,
s->colour_space, ncomponents,
s->precision,
501 ncomponents > 1 ?
s->cdx[1] : 0,
502 ncomponents > 1 ?
s->cdy[1] : 0,
503 ncomponents > 2 ?
s->cdx[2] : 0,
504 ncomponents > 2 ?
s->cdy[2] : 0,
505 ncomponents > 3 ?
s->cdx[3] : 0,
506 ncomponents > 3 ?
s->cdy[3] : 0);
509 s->avctx->bits_per_raw_sample =
s->precision;
525 c->nreslevels = bytestream2_get_byteu(&
s->g) + 1;
531 if (
c->nreslevels <=
s->reduction_factor) {
536 av_log(
s->avctx,
AV_LOG_ERROR,
"reduction_factor too large for this bitstream, max is %d\n",
c->nreslevels - 1);
537 s->reduction_factor =
c->nreslevels - 1;
542 c->nreslevels2decode =
c->nreslevels -
s->reduction_factor;
544 c->log2_cblk_width = (bytestream2_get_byteu(&
s->g) & 15) + 2;
545 c->log2_cblk_height = (bytestream2_get_byteu(&
s->g) & 15) + 2;
547 if (
c->log2_cblk_width > 10 ||
c->log2_cblk_height > 10 ||
548 c->log2_cblk_width +
c->log2_cblk_height > 12) {
553 c->cblk_style = bytestream2_get_byteu(&
s->g);
554 if (
c->cblk_style != 0) {
559 c->transform = bytestream2_get_byteu(&
s->g);
569 for (
i = 0;
i <
c->nreslevels;
i++) {
570 byte = bytestream2_get_byte(&
s->g);
571 c->log2_prec_widths[
i] =
byte & 0x0F;
572 c->log2_prec_heights[
i] = (
byte >> 4) & 0x0F;
574 if (
c->log2_prec_widths[
i] == 0 ||
c->log2_prec_heights[
i] == 0) {
576 c->log2_prec_widths[
i],
c->log2_prec_heights[
i]);
577 c->log2_prec_widths[
i] =
c->log2_prec_heights[
i] = 1;
582 memset(
c->log2_prec_widths , 15,
sizeof(
c->log2_prec_widths ));
583 memset(
c->log2_prec_heights, 15,
sizeof(
c->log2_prec_heights));
600 tmp.csty = bytestream2_get_byteu(&
s->g);
603 tmp.prog_order = bytestream2_get_byteu(&
s->g);
605 tmp.nlayers = bytestream2_get_be16u(&
s->g);
606 tmp.mct = bytestream2_get_byteu(&
s->g);
608 if (
tmp.mct &&
s->ncomponents < 3) {
610 "MCT %"PRIu8
" with too few components (%d)\n",
611 tmp.mct,
s->ncomponents);
618 for (compno = 0; compno <
s->ncomponents; compno++)
619 if (!(properties[compno] &
HAD_COC))
620 memcpy(
c + compno, &
tmp,
sizeof(
tmp));
637 compno = bytestream2_get_byteu(&
s->g);
639 if (compno >=
s->ncomponents) {
641 "Invalid compno %d. There are %d components in the image.\n",
642 compno,
s->ncomponents);
649 c->csty = bytestream2_get_byteu(&
s->g);
664 compno = (
s->ncomponents < 257)? bytestream2_get_byte(&
s->g):
665 bytestream2_get_be16u(&
s->g);
666 if (bytestream2_get_byte(&
s->g)) {
673 if (compno < s->ncomponents) {
675 if (
s->curtileno == -1) {
676 v = bytestream2_get_byte(&
s->g);
679 s->roi_shift[compno] = v;
681 if (
s->tile[
s->curtileno].tp_idx != 0)
683 v = bytestream2_get_byte(&
s->g);
686 s->tile[
s->curtileno].comp[compno].roi_shift = v;
701 x = bytestream2_get_byteu(&
s->g);
711 for (
i = 0;
i < n;
i++)
712 q->
expn[
i] = bytestream2_get_byteu(&
s->g) >> 3;
716 x = bytestream2_get_be16u(&
s->g);
717 q->
expn[0] = x >> 11;
718 q->
mant[0] = x & 0x7ff;
720 int curexpn =
FFMAX(0, q->
expn[0] - (
i - 1) / 3);
721 q->
expn[
i] = curexpn;
729 for (
i = 0;
i < n;
i++) {
730 x = bytestream2_get_be16u(&
s->g);
731 q->
expn[
i] = x >> 11;
732 q->
mant[
i] = x & 0x7ff;
745 memset(&
tmp, 0,
sizeof(
tmp));
749 for (compno = 0; compno <
s->ncomponents; compno++)
750 if (!(properties[compno] &
HAD_QCC))
751 memcpy(q + compno, &
tmp,
sizeof(
tmp));
765 compno = bytestream2_get_byteu(&
s->g);
767 if (compno >=
s->ncomponents) {
769 "Invalid compno %d. There are %d components in the image.\n",
770 compno,
s->ncomponents);
775 return get_qcx(
s, n - 1, q + compno);
781 int elem_size =
s->ncomponents <= 257 ? 7 : 9;
794 tmp.nb_poc = (
size - 2) / elem_size;
800 for (
i = 0;
i<
tmp.nb_poc;
i++) {
802 e->
RSpoc = bytestream2_get_byteu(&
s->g);
803 e->
CSpoc = bytestream2_get_byteu(&
s->g);
804 e->
LYEpoc = bytestream2_get_be16u(&
s->g);
805 e->
REpoc = bytestream2_get_byteu(&
s->g);
806 e->
CEpoc = bytestream2_get_byteu(&
s->g);
807 e->
Ppoc = bytestream2_get_byteu(&
s->g);
810 if (e->
CEpoc >
s->ncomponents)
811 e->
CEpoc =
s->ncomponents;
851 Isot = bytestream2_get_be16u(&
s->g);
852 if (Isot >=
s->numXtiles *
s->numYtiles)
856 Psot = bytestream2_get_be32u(&
s->g);
857 TPsot = bytestream2_get_byteu(&
s->g);
860 bytestream2_get_byteu(&
s->g);
875 s->tile[Isot].tp_idx = TPsot;
876 tp =
s->tile[Isot].tile_part + TPsot;
878 tp->
tp_end =
s->g.buffer + Psot - n - 2;
886 memcpy(&tile->
poc , &
s->poc ,
sizeof(tile->
poc));
895 if (
s->ncomponents*4 != n - 2) {
913 bytestream2_get_byte(&
s->g);
914 Stlm = bytestream2_get_byte(&
s->g);
917 ST = (Stlm >> 4) & 0x03;
923 SP = (Stlm >> 6) & 0x01;
924 tile_tlm = (n - 4) / ((
SP + 1) * 2 + ST);
925 for (
i = 0;
i < tile_tlm;
i++) {
930 bytestream2_get_byte(&
s->g);
933 bytestream2_get_be16(&
s->g);
937 bytestream2_get_be16(&
s->g);
939 bytestream2_get_be32(&
s->g);
956 bytestream2_get_byte(&
s->g);
958 for (
i = 0;
i < n - 3;
i++) {
959 v = bytestream2_get_byte(&
s->g);
975 bytestream2_get_byte(&
s->g);
977 s->packed_headers_size + n - 3);
979 s->packed_headers =
new;
983 memset(&
s->packed_headers_stream, 0,
sizeof(
s->packed_headers_stream));
986 s->packed_headers_size += n - 3;
1000 if (
s->curtileno < 0)
1003 tile = &
s->tile[
s->curtileno];
1006 "PPT marker can occur only on first tile part of a tile.\n");
1011 bytestream2_get_byte(&
s->g);
1020 s->g.buffer, n - 3);
1030 int tilex = tileno %
s->numXtiles;
1031 int tiley = tileno /
s->numXtiles;
1038 tile->
coord[0][1] =
av_clip((tilex + 1) * (
int64_t)
s->tile_width +
s->tile_offset_x,
s->image_offset_x,
s->width);
1039 tile->
coord[1][0] =
av_clip(tiley * (
int64_t)
s->tile_height +
s->tile_offset_y,
s->image_offset_y,
s->height);
1040 tile->
coord[1][1] =
av_clip((tiley + 1) * (
int64_t)
s->tile_height +
s->tile_offset_y,
s->image_offset_y,
s->height);
1042 for (compno = 0; compno <
s->ncomponents; compno++) {
1048 comp->coord_o[0][0] = tile->
coord[0][0];
1049 comp->coord_o[0][1] = tile->
coord[0][1];
1050 comp->coord_o[1][0] = tile->
coord[1][0];
1051 comp->coord_o[1][1] = tile->
coord[1][1];
1063 if (!
comp->roi_shift)
1064 comp->roi_shift =
s->roi_shift[compno];
1068 s->cbps[compno],
s->cdx[compno],
1069 s->cdy[compno],
s->avctx))
1084 return num < 0 ? num : 3 + num;
1086 return num < 0 ? num : 6 + num;
1088 return num < 0 ? num : 37 + num;
1126 av_log(
s->avctx,
AV_LOG_ERROR,
"SOP marker not found. instead %X\n", bytestream2_peek_be32(&
s->g));
1133 int layno,
uint8_t *expn,
int numgbits)
1135 int bandno, cblkno, ret, nb_code_blocks;
1138 if (layno < rlevel->band[0].prec[precno].decoded_layers)
1155 for (bandno = 0; bandno < rlevel->
nbands; bandno++) {
1159 if (band->
coord[0][0] == band->
coord[0][1] ||
1164 for (cblkno = 0; cblkno < nb_code_blocks; cblkno++) {
1166 int incl, newpasses, llen;
1179 int v = expn[bandno] + numgbits - 1 -
1181 if (v < 0 || v > 30) {
1183 "nonzerobits %d invalid or unsupported\n", v);
1199 "Block with length beyond 16 bits");
1218 while (newpasses1 < newpasses) {
1244 newpasses -= newpasses1;
1254 av_log(
s->avctx,
AV_LOG_ERROR,
"EPH marker not found. instead %X\n", bytestream2_peek_be32(&
s->g));
1265 for (bandno = 0; bandno < rlevel->
nbands; bandno++) {
1270 for (cblkno = 0; cblkno < nb_code_blocks; cblkno++) {
1274 for (cwsno = 0; cwsno < cblk->
nb_lengthinc; cwsno ++) {
1287 "Block length %"PRIu16
" or lengthinc %d is too large, left %d\n",
1316 av_log(
s->avctx,
AV_LOG_ERROR,
"EPH marker not found. instead %X\n", bytestream2_peek_be32(&
s->g));
1330 int RSpoc,
int CSpoc,
1331 int LYEpoc,
int REpoc,
int CEpoc,
1332 int Ppoc,
int *tp_index)
1335 int layno, reslevelno, compno, precno, ok_reslevel;
1343 for (reslevelno = RSpoc; ok_reslevel && reslevelno < REpoc; reslevelno++) {
1345 for (layno = 0; layno < LYEpoc; layno++) {
1346 for (compno = CSpoc; compno < CEpoc; compno++) {
1349 if (reslevelno < codsty->nreslevels) {
1357 qntsty->
expn + (reslevelno ? 3 * (reslevelno - 1) + 1 : 0),
1368 for (layno = 0; layno < LYEpoc; layno++) {
1370 for (reslevelno = RSpoc; ok_reslevel && reslevelno < REpoc; reslevelno++) {
1372 for (compno = CSpoc; compno < CEpoc; compno++) {
1375 if (reslevelno < codsty->nreslevels) {
1383 qntsty->
expn + (reslevelno ? 3 * (reslevelno - 1) + 1 : 0),
1394 for (compno = CSpoc; compno < CEpoc; compno++) {
1404 for (reslevelno = RSpoc; reslevelno <
FFMIN(codsty->
nreslevels, REpoc); reslevelno++) {
1410 if (step_x >= 31 || step_y >= 31){
1417 for (y = tile->
coord[1][0]; y < tile->coord[1][1]; y = (y/step_y + 1)*step_y) {
1418 for (x = tile->
coord[0][0]; x < tile->coord[0][1]; x = (x/step_x + 1)*step_x) {
1419 for (reslevelno = RSpoc; reslevelno <
FFMIN(codsty->
nreslevels, REpoc); reslevelno++) {
1420 unsigned prcx, prcy;
1423 int xc = x /
s->cdx[compno];
1424 int yc = y /
s->cdy[compno];
1446 for (layno = 0; layno < LYEpoc; layno++) {
1449 qntsty->
expn + (reslevelno ? 3 * (reslevelno - 1) + 1 : 0),
1462 for (reslevelno = RSpoc; ok_reslevel && reslevelno < REpoc; reslevelno++) {
1466 for (compno = CSpoc; compno < CEpoc; compno++) {
1470 if (reslevelno < codsty->nreslevels) {
1480 for (y = tile->
coord[1][0]; y < tile->coord[1][1]; y = (y/step_y + 1)*step_y) {
1481 for (x = tile->
coord[0][0]; x < tile->coord[0][1]; x = (x/step_x + 1)*step_x) {
1482 for (compno = CSpoc; compno < CEpoc; compno++) {
1488 unsigned prcx, prcy;
1491 if (!
s->cdx[compno] || !
s->cdy[compno])
1500 if (!(y % ((uint64_t)
s->cdy[compno] << (rlevel->
log2_prec_height + reducedresno)) == 0 ||
1504 if (!(x % ((uint64_t)
s->cdx[compno] << (rlevel->
log2_prec_width + reducedresno)) == 0 ||
1523 for (layno = 0; layno < LYEpoc; layno++) {
1527 qntsty->
expn + (reslevelno ? 3 * (reslevelno - 1) + 1 : 0),
1541 for (compno = CSpoc; compno < CEpoc; compno++) {
1545 for (reslevelno = RSpoc; reslevelno <
FFMIN(codsty->
nreslevels, REpoc); reslevelno++) {
1552 if (step_x >= 31 || step_y >= 31){
1559 for (y = tile->
coord[1][0]; y < tile->coord[1][1]; y = (y/step_y + 1)*step_y) {
1560 for (x = tile->
coord[0][0]; x < tile->coord[0][1]; x = (x/step_x + 1)*step_x) {
1561 for (compno = CSpoc; compno < CEpoc; compno++) {
1566 if (!
s->cdx[compno] || !
s->cdy[compno])
1569 for (reslevelno = RSpoc; reslevelno <
FFMIN(codsty->
nreslevels, REpoc); reslevelno++) {
1570 unsigned prcx, prcy;
1578 if (!(y % ((uint64_t)
s->cdy[compno] << (rlevel->
log2_prec_height + reducedresno)) == 0 ||
1582 if (!(x % ((uint64_t)
s->cdx[compno] << (rlevel->
log2_prec_width + reducedresno)) == 0 ||
1600 for (layno = 0; layno < LYEpoc; layno++) {
1603 qntsty->
expn + (reslevelno ? 3 * (reslevelno - 1) + 1 : 0),
1658 int bpno,
int bandno,
1659 int vert_causal_ctx_csty_symbol)
1661 int mask = 3 << (bpno - 1), y0, x, y;
1663 for (y0 = 0; y0 <
height; y0 += 4)
1664 for (x = 0; x <
width; x++)
1665 for (y = y0; y <
height && y < y0 + 4; y++) {
1666 int flags_mask = -1;
1667 if (vert_causal_ctx_csty_symbol && y == y0 + 3)
1680 t1->data[(y) *
t1->stride + x] < 0);
1688 int bpno,
int vert_causal_ctx_csty_symbol)
1693 phalf = 1 << (bpno - 1);
1696 for (y0 = 0; y0 <
height; y0 += 4)
1697 for (x = 0; x <
width; x++)
1698 for (y = y0; y <
height && y < y0 + 4; y++)
1700 int flags_mask = (vert_causal_ctx_csty_symbol && y == y0 + 3) ?
1704 t1->mqc.cx_states + ctxno)
1706 t1->data[(y) *
t1->stride + x] +=
t1->data[(y) *
t1->stride + x] < 0 ? -
r :
r;
1713 int seg_symbols,
int vert_causal_ctx_csty_symbol)
1715 int mask = 3 << (bpno - 1), y0, x, y, runlen, dec;
1717 for (y0 = 0; y0 <
height; y0 += 4) {
1718 for (x = 0; x <
width; x++) {
1719 int flags_mask = -1;
1720 if (vert_causal_ctx_csty_symbol)
1740 for (y = y0 + runlen; y < y0 + 4 && y <
height; y++) {
1741 int flags_mask = -1;
1742 if (vert_causal_ctx_csty_symbol && y == y0 + 3)
1755 t1->mqc.cx_states + ctxno) ^
1773 "Segmentation symbol value incorrect\n");
1790 memset(
t1->data, 0,
t1->stride *
height *
sizeof(*
t1->data));
1796 memset(
t1->flags, 0,
t1->stride * (
height + 2) *
sizeof(*
t1->flags));
1803 if (bpno < 0 || bpno > 29) {
1810 vert_causal_ctx_csty_symbol);
1819 vert_causal_ctx_csty_symbol);
1864 roi_shift =
comp->roi_shift;
1865 val = (quan_parameter < 0)?-quan_parameter:quan_parameter;
1867 if (
val > (1 << roi_shift))
1868 return (quan_parameter < 0)?-(
val >> roi_shift):(
val >> roi_shift);
1869 return quan_parameter;
1885 for (j = 0; j < (cblk->
coord[1][1] - cblk->
coord[1][0]); ++j) {
1886 float *datap = &
comp->f_data[(
comp->coord[0][1] -
comp->coord[0][0]) * (y + j) + x];
1887 int *
src =
t1->data + j*
t1->stride;
1888 for (
i = 0;
i <
w; ++
i)
1900 for (j = 0; j < (cblk->
coord[1][1] - cblk->
coord[1][0]); ++j) {
1902 int *
src =
t1->data + j*
t1->stride;
1904 for (
i = 0;
i <
w; ++
i)
1905 datap[
i] =
src[
i] / 2;
1908 for (
i = 0;
i <
w; ++
i)
1920 for (j = 0; j < (cblk->
coord[1][1] - cblk->
coord[1][0]); ++j) {
1922 int *
src =
t1->data + j*
t1->stride;
1923 for (
i = 0;
i <
w; ++
i)
1933 for (
i = 1;
i < 3;
i++) {
1944 for (
i = 0;
i < 3;
i++)
1950 for (
i = 0;
i < 2;
i++)
1962 for (j = 0; j < (cblk->
coord[1][1] - cblk->
coord[1][0]); ++j) {
1963 int *
src =
t1->data + j*
t1->stride;
1964 for (
i = 0;
i <
w; ++
i)
1973 int compno, reslevelno, bandno;
1976 for (compno = 0; compno <
s->ncomponents; compno++) {
1987 for (bandno = 0; bandno < rlevel->
nbands; bandno++) {
1988 int nb_precincts, precno;
1990 int cblkno = 0, bandpos;
1992 bandpos = bandno + (reslevelno > 0);
1994 if (band->
coord[0][0] == band->
coord[0][1] ||
2000 for (precno = 0; precno < nb_precincts; precno++) {
2012 bandpos,
comp->roi_shift);
2020 if (
comp->roi_shift)
2040 #define WRITE_FRAME(D, PIXEL) \
2041 static inline void write_frame_ ## D(Jpeg2000DecoderContext * s, Jpeg2000Tile * tile, \
2042 AVFrame * picture, int precision) \
2044 const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(s->avctx->pix_fmt); \
2045 int planar = !!(pixdesc->flags & AV_PIX_FMT_FLAG_PLANAR); \
2046 int pixelsize = planar ? 1 : pixdesc->nb_components; \
2051 for (compno = 0; compno < s->ncomponents; compno++) { \
2052 Jpeg2000Component *comp = tile->comp + compno; \
2053 Jpeg2000CodingStyle *codsty = tile->codsty + compno; \
2055 float *datap = comp->f_data; \
2056 int32_t *i_datap = comp->i_data; \
2057 int cbps = s->cbps[compno]; \
2058 int w = tile->comp[compno].coord[0][1] - \
2059 ff_jpeg2000_ceildiv(s->image_offset_x, s->cdx[compno]); \
2060 int h = tile->comp[compno].coord[1][1] - \
2061 ff_jpeg2000_ceildiv(s->image_offset_y, s->cdy[compno]); \
2065 plane = s->cdef[compno] ? s->cdef[compno]-1 : (s->ncomponents-1); \
2067 y = tile->comp[compno].coord[1][0] - \
2068 ff_jpeg2000_ceildiv(s->image_offset_y, s->cdy[compno]); \
2069 line = (PIXEL *)picture->data[plane] + y * (picture->linesize[plane] / sizeof(PIXEL));\
2070 for (; y < h; y++) { \
2073 x = tile->comp[compno].coord[0][0] - \
2074 ff_jpeg2000_ceildiv(s->image_offset_x, s->cdx[compno]); \
2075 dst = line + x * pixelsize + compno*!planar; \
2077 if (codsty->transform == FF_DWT97) { \
2078 for (; x < w; x++) { \
2079 int val = lrintf(*datap) + (1 << (cbps - 1)); \
2081 val = av_clip(val, 0, (1 << cbps) - 1); \
2082 *dst = val << (precision - cbps); \
2087 for (; x < w; x++) { \
2088 int val = *i_datap + (1 << (cbps - 1)); \
2090 val = av_clip(val, 0, (1 << cbps) - 1); \
2091 *dst = val << (precision - cbps); \
2096 line += picture->linesize[plane] / sizeof(PIXEL); \
2108 int jobnr,
int threadnr)
2121 for (x = 0; x <
s->ncomponents; x++) {
2122 if (
s->cdef[x] < 0) {
2123 for (x = 0; x <
s->ncomponents; x++) {
2126 if ((
s->ncomponents & 1) == 0)
2127 s->cdef[
s->ncomponents-1] = 0;
2132 if (
s->precision <= 8) {
2133 write_frame_8(
s, tile, picture, 8);
2140 write_frame_16(
s, tile, picture, precision);
2149 for (tileno = 0; tileno <
s->numXtiles *
s->numYtiles; tileno++) {
2150 if (
s->tile[tileno].comp) {
2151 for (compno = 0; compno <
s->ncomponents; compno++) {
2158 av_freep(&
s->tile[tileno].packed_headers);
2159 s->tile[tileno].packed_headers_size = 0;
2163 s->packed_headers_size = 0;
2164 memset(&
s->packed_headers_stream, 0,
sizeof(
s->packed_headers_stream));
2166 memset(
s->codsty, 0,
sizeof(
s->codsty));
2167 memset(
s->qntsty, 0,
sizeof(
s->qntsty));
2168 memset(
s->properties, 0,
sizeof(
s->properties));
2169 memset(&
s->poc , 0,
sizeof(
s->poc));
2170 s->numXtiles =
s->numYtiles = 0;
2179 uint8_t *properties =
s->properties;
2191 marker = bytestream2_get_be16u(&
s->g);
2193 if (marker >= 0xFF30 && marker <= 0xFF3F)
2203 if (
s->curtileno < 0) {
2208 tile =
s->tile +
s->curtileno;
2210 if (tp->
tp_end <
s->g.buffer) {
2216 uint32_t tp_header_size = bytestream2_get_be32(&
s->packed_headers_stream);
2234 len = bytestream2_get_be16(&
s->g);
2246 if (
s->ncomponents) {
2252 s->numXtiles =
s->numYtiles = 0;
2255 ret =
get_coc(
s, codsty, properties);
2258 ret =
get_cod(
s, codsty, properties);
2273 if (!
s->in_tile_headers) {
2274 s->in_tile_headers = 1;
2281 codsty =
s->tile[
s->curtileno].codsty;
2282 qntsty =
s->tile[
s->curtileno].qntsty;
2283 poc = &
s->tile[
s->curtileno].poc;
2284 properties =
s->tile[
s->curtileno].properties;
2306 if (
s->in_tile_headers) {
2316 "Cannot have both PPT and PPM marker.\n");
2324 "unsupported marker 0x%.4"PRIX16
" at pos 0x%X\n",
2331 "error during processing marker segment %.4"PRIx16
"\n",
2333 return ret ? ret : -1;
2345 for (tileno = 0; tileno <
s->numXtiles *
s->numYtiles; tileno++) {
2360 uint32_t atom_size, atom, atom_end;
2361 int search_range = 10;
2366 atom_size = bytestream2_get_be32u(&
s->g);
2367 atom = bytestream2_get_be32u(&
s->g);
2368 if (atom_size == 1) {
2369 if (bytestream2_get_be32u(&
s->g)) {
2373 atom_size = bytestream2_get_be32u(&
s->g);
2391 uint32_t atom2_size, atom2, atom2_end;
2395 atom2_size = bytestream2_get_be32u(&
s->g);
2396 atom2 = bytestream2_get_be32u(&
s->g);
2398 if (atom2_size < 8 || atom2_end > atom_end || atom2_end < atom2_size)
2403 }
else if (atom2 ==
MKBETAG(
'c',
'o',
'l',
'r') && atom2_size >= 7) {
2404 int method = bytestream2_get_byteu(&
s->g);
2407 s->colour_space = bytestream2_get_be32u(&
s->g);
2409 }
else if (atom2 ==
MKBETAG(
'p',
'c',
'l',
'r') && atom2_size >= 6) {
2410 int i,
size, colour_count, colour_channels, colour_depth[3];
2411 colour_count = bytestream2_get_be16u(&
s->g);
2412 colour_channels = bytestream2_get_byteu(&
s->g);
2414 colour_depth[0] = (bytestream2_get_byteu(&
s->g) & 0x7f) + 1;
2415 colour_depth[1] = (bytestream2_get_byteu(&
s->g) & 0x7f) + 1;
2416 colour_depth[2] = (bytestream2_get_byteu(&
s->g) & 0x7f) + 1;
2417 size = (colour_depth[0] + 7 >> 3) * colour_count +
2418 (colour_depth[1] + 7 >> 3) * colour_count +
2419 (colour_depth[2] + 7 >> 3) * colour_count;
2421 colour_channels != 3 ||
2422 colour_depth[0] > 16 ||
2423 colour_depth[1] > 16 ||
2424 colour_depth[2] > 16 ||
2425 atom2_size <
size) {
2431 for (
i = 0;
i < colour_count;
i++) {
2433 if (colour_depth[0] <= 8) {
2434 r = bytestream2_get_byteu(&
s->g) << 8 - colour_depth[0];
2435 r |=
r >> colour_depth[0];
2437 r = bytestream2_get_be16u(&
s->g) >> colour_depth[0] - 8;
2439 if (colour_depth[1] <= 8) {
2440 g = bytestream2_get_byteu(&
s->g) << 8 - colour_depth[1];
2441 g |=
g >> colour_depth[1];
2443 g = bytestream2_get_be16u(&
s->g) >> colour_depth[1] - 8;
2445 if (colour_depth[2] <= 8) {
2446 b = bytestream2_get_byteu(&
s->g) << 8 - colour_depth[2];
2447 b |=
b >> colour_depth[2];
2449 b = bytestream2_get_be16u(&
s->g) >> colour_depth[2] - 8;
2451 s->palette[
i] = 0xffu << 24 |
r << 16 |
g << 8 |
b;
2453 }
else if (atom2 ==
MKBETAG(
'c',
'd',
'e',
'f') && atom2_size >= 2) {
2454 int n = bytestream2_get_be16u(&
s->g);
2456 int cn = bytestream2_get_be16(&
s->g);
2457 int av_unused typ = bytestream2_get_be16(&
s->g);
2458 int asoc = bytestream2_get_be16(&
s->g);
2459 if (cn < 4 && asoc < 4)
2462 }
else if (atom2 ==
MKBETAG(
'r',
'e',
's',
' ') && atom2_size >= 18) {
2463 int64_t vnum, vden, hnum, hden, vexp, hexp;
2466 resx = bytestream2_get_be32u(&
s->g);
2467 if (resx !=
MKBETAG(
'r',
'e',
's',
'c') && resx !=
MKBETAG(
'r',
'e',
's',
'd')) {
2471 vnum = bytestream2_get_be16u(&
s->g);
2472 vden = bytestream2_get_be16u(&
s->g);
2473 hnum = bytestream2_get_be16u(&
s->g);
2474 hden = bytestream2_get_be16u(&
s->g);
2475 vexp = bytestream2_get_byteu(&
s->g);
2476 hexp = bytestream2_get_byteu(&
s->g);
2477 if (!vnum || !vden || !hnum || !hden) {
2489 if ( INT64_MAX / (hnum * vden) > pow(10, hexp)
2490 && INT64_MAX / (vnum * hden) > pow(10, vexp))
2492 hnum * vden * pow(10, hexp),
2493 vnum * hden * pow(10, vexp),
2497 }
while (atom_end - atom2_end >= 8);
2535 memset(
s->cdef, -1,
sizeof(
s->cdef));
2544 (bytestream2_get_be32u(&
s->g) == 12) &&
2549 "Could not find Jpeg2000 codestream atom.\n");
2584 memcpy(picture->
data[1],
s->palette, 256 *
sizeof(uint32_t));
2585 if (
s->sar.num &&
s->sar.den)
2587 s->sar.num =
s->sar.den = 0;
2596 #define OFFSET(x) offsetof(Jpeg2000DecoderContext, x)
2597 #define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
2600 {
"lowres",
"Lower the decoding resolution by a power of two",
static double val(void *priv, double ch)
Macro definitions for various function/variable attributes.
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Libavcodec external API header.
#define FF_PROFILE_JPEG2000_DCINEMA_2K
#define FF_COMPLIANCE_STRICT
Strictly conform to all the things in the spec no matter what consequences.
#define FF_CODEC_PROPERTY_LOSSLESS
#define FF_PROFILE_JPEG2000_DCINEMA_4K
static av_cold int init(AVCodecContext *avctx)
static av_always_inline unsigned int bytestream_get_buffer(const uint8_t **b, uint8_t *dst, unsigned int size)
static av_always_inline int bytestream2_size(GetByteContext *g)
static av_always_inline void bytestream2_skipu(GetByteContext *g, unsigned int size)
static av_always_inline unsigned int bytestream2_get_bufferu(GetByteContext *g, uint8_t *dst, unsigned int size)
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
static av_always_inline int bytestream2_seek(GetByteContext *g, int offset, int whence)
static av_always_inline int bytestream2_tell(GetByteContext *g)
static uint64_t SP[8][256]
common internal and external API header
#define MKBETAG(a, b, c, d)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
static enum AVPixelFormat pix_fmt
static void comp(unsigned char *dst, ptrdiff_t dst_stride, unsigned char *src, ptrdiff_t src_stride, int add)
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
void * av_realloc(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
Allocate, reallocate, or free an array.
void * av_mallocz_array(size_t nmemb, size_t size)
Allocate a memory block for an array with av_mallocz().
int av_image_check_size2(unsigned int w, unsigned int h, int64_t max_pixels, enum AVPixelFormat pix_fmt, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of a plane of an image with...
@ AV_PICTURE_TYPE_I
Intra.
#define LIBAVUTIL_VERSION_INT
int ff_jpeg2000_init_component(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty, Jpeg2000QuantStyle *qntsty, int cbps, int dx, int dy, AVCodecContext *avctx)
void av_cold ff_jpeg2000_init_tier1_luts(void)
void ff_jpeg2000_cleanup(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty)
void ff_jpeg2000_set_significance(Jpeg2000T1Context *t1, int x, int y, int negative)
JPEG 2000 structures and defines common to encoder and decoder.
#define JPEG2000_T1_SIG_NB
#define JPEG2000_CBLK_VSC
#define JPEG2000_MAX_RESLEVELS
#define JPEG2000_CSTY_SOP
static int ff_jpeg2000_ceildivpow2(int a, int b)
#define JPEG2000_PGOD_PCRL
#define JPEG2000_T1_SGN_S
#define JPEG2000_CBLK_RESET
static int ff_jpeg2000_ceildiv(int a, int64_t b)
#define JPEG2000_CSTY_PREC
#define JPEG2000_CBLK_BYPASS
#define JPEG2000_CSTY_EPH
#define JPEG2000_PGOD_CPRL
#define JPEG2000_SOP_BYTE_LENGTH
#define JPEG2000_SOP_FIXED_BYTES
#define JPEG2000_T1_SIG_SW
#define JPEG2000_PGOD_RPCL
#define JPEG2000_CBLK_SEGSYM
#define JPEG2000_MAX_PASSES
#define JPEG2000_T1_SIG_SE
#define JPEG2000_PGOD_RLCP
#define JPEG2000_T1_SIG_S
static int ff_jpeg2000_getsgnctxno(int flag, int *xorbit)
static int needs_termination(int style, int passno)
static int ff_jpeg2000_getrefctxno(int flag)
static int ff_jpeg2000_getsigctxno(int flag, int bandno)
#define JPEG2000_PGOD_LRCP
#define JPEG2000_MAX_DECLEVELS
static enum AVPixelFormat all_pix_fmts[]
static void mct_decode(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile)
static void roi_scale_cblk(Jpeg2000Cblk *cblk, Jpeg2000Component *comp, Jpeg2000T1Context *t1)
static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile, int *tp_index, Jpeg2000CodingStyle *codsty, Jpeg2000ResLevel *rlevel, int precno, int layno, uint8_t *expn, int numgbits)
#define WRITE_FRAME(D, PIXEL)
static enum AVPixelFormat xyz_pix_fmts[]
static int get_tlm(Jpeg2000DecoderContext *s, int n)
static int get_cox(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c)
static int getlblockinc(Jpeg2000DecoderContext *s)
static void decode_refpass(Jpeg2000T1Context *t1, int width, int height, int bpno, int vert_causal_ctx_csty_symbol)
static const AVOption options[]
#define GRAY_PIXEL_FORMATS
static void dequantization_float(int x, int y, Jpeg2000Cblk *cblk, Jpeg2000Component *comp, Jpeg2000T1Context *t1, Jpeg2000Band *band)
static int pix_fmt_match(enum AVPixelFormat pix_fmt, int components, int bpc, uint32_t log2_chroma_wh, int pal8)
static void select_header(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile, int *tp_index)
static int getnpasses(Jpeg2000DecoderContext *s)
static void jpeg2000_flush(Jpeg2000DecoderContext *s)
static enum AVPixelFormat rgb_pix_fmts[]
static int get_siz(Jpeg2000DecoderContext *s)
static void decode_sigpass(Jpeg2000T1Context *t1, int width, int height, int bpno, int bandno, int vert_causal_ctx_csty_symbol)
static int get_qcc(Jpeg2000DecoderContext *s, int n, Jpeg2000QuantStyle *q, uint8_t *properties)
#define YUV_PIXEL_FORMATS
static void jpeg2000_dec_cleanup(Jpeg2000DecoderContext *s)
static av_cold void jpeg2000_init_static_data(void)
static int get_poc(Jpeg2000DecoderContext *s, int size, Jpeg2000POC *p)
static int jpeg2000_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
static int get_qcx(Jpeg2000DecoderContext *s, int n, Jpeg2000QuantStyle *q)
static int jpeg2000_decode_tile(AVCodecContext *avctx, void *td, int jobnr, int threadnr)
static void decode_clnpass(Jpeg2000DecoderContext *s, Jpeg2000T1Context *t1, int width, int height, int bpno, int bandno, int seg_symbols, int vert_causal_ctx_csty_symbol)
#define RGB_PIXEL_FORMATS
static void tile_codeblocks(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile)
static void dequantization_int(int x, int y, Jpeg2000Cblk *cblk, Jpeg2000Component *comp, Jpeg2000T1Context *t1, Jpeg2000Band *band)
static const AVClass jpeg2000_class
static av_cold int jpeg2000_decode_init(AVCodecContext *avctx)
static void dequantization_int_97(int x, int y, Jpeg2000Cblk *cblk, Jpeg2000Component *comp, Jpeg2000T1Context *t1, Jpeg2000Band *band)
static int jpeg2000_decode_packets_po_iteration(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile, int RSpoc, int CSpoc, int LYEpoc, int REpoc, int CEpoc, int Ppoc, int *tp_index)
static int init_tile(Jpeg2000DecoderContext *s, int tileno)
static void select_stream(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile, int *tp_index, Jpeg2000CodingStyle *codsty)
static int roi_shift_param(Jpeg2000Component *comp, int quan_parameter)
static int get_cod(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c, uint8_t *properties)
static int get_sot(Jpeg2000DecoderContext *s, int n)
static int tag_tree_decode(Jpeg2000DecoderContext *s, Jpeg2000TgtNode *node, int threshold)
static int decode_cblk(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *codsty, Jpeg2000T1Context *t1, Jpeg2000Cblk *cblk, int width, int height, int bandpos, uint8_t roi_shift)
static int jp2_find_codestream(Jpeg2000DecoderContext *s)
static enum AVPixelFormat gray_pix_fmts[]
static int jpeg2000_read_main_headers(Jpeg2000DecoderContext *s)
static int jpeg2000_decode_packets(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile)
#define XYZ_PIXEL_FORMATS
static int get_ppt(Jpeg2000DecoderContext *s, int n)
static int read_crg(Jpeg2000DecoderContext *s, int n)
static int get_ppm(Jpeg2000DecoderContext *s, int n)
static int get_rgn(Jpeg2000DecoderContext *s, int n)
static int get_bits(Jpeg2000DecoderContext *s, int n)
static int jpeg2000_read_bitstream_packets(Jpeg2000DecoderContext *s)
AVCodec ff_jpeg2000_decoder
static enum AVPixelFormat yuv_pix_fmts[]
static int get_plt(Jpeg2000DecoderContext *s, int n)
static int get_coc(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c, uint8_t *properties)
static int get_qcd(Jpeg2000DecoderContext *s, int n, Jpeg2000QuantStyle *q, uint8_t *properties)
int ff_dwt_decode(DWTContext *s, void *t)
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
av_cold void ff_jpeg2000dsp_init(Jpeg2000DSPContext *c)
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#define PTRDIFF_SPECIFIER
static int ff_thread_once(char *control, void(*routine)(void))
static const AVProfile profiles[]
static const uint16_t mask[17]
void av_cold ff_mqc_init_context_tables(void)
MQ-coder Initialize context tables (QE, NLPS, NMPS)
void ff_mqc_init_contexts(MqcState *mqc)
MQ-coder context initialisations.
int ff_mqc_decode(MqcState *mqc, uint8_t *cxstate)
MQ decoder.
void ff_mqc_initdec(MqcState *mqc, uint8_t *bp, int raw, int reset)
Initialize MQ-decoder.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_FLAG_PAL
Pixel format has a palette in data[1], values are indexes in this palette.
#define AV_PIX_FMT_RGBA64
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
@ AV_PIX_FMT_YA8
8 bits gray, 8 bits alpha
#define AV_PIX_FMT_GRAY16
const AVProfile ff_jpeg2000_profiles[]
FF_ENABLE_DEPRECATION_WARNINGS int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
#define FF_ARRAY_ELEMS(a)
Describe the class of an AVClass context structure.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
main external API structure.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel.
int(* execute2)(struct AVCodecContext *c, int(*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count)
The codec may call this to execute several independent things.
const char * name
Name of the codec implementation.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int key_frame
1 -> keyframe, 0-> not
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
enum AVPictureType pict_type
Picture type of the frame.
This structure stores compressed data.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Rational number (pair of numerator and denominator).
Jpeg2000ResLevel * reslevel
GetByteContext packed_headers_stream
Jpeg2000QuantStyle qntsty[4]
Jpeg2000CodingStyle codsty[4]
Jpeg2000POCEntry poc[MAX_POCS]
Jpeg2000TgtNode * zerobits
Jpeg2000TgtNode * cblkincl
uint16_t mant[JPEG2000_MAX_DECLEVELS *3]
uint8_t expn[JPEG2000_MAX_DECLEVELS *3]
struct Jpeg2000TgtNode * parent
GetByteContext header_tpg
Jpeg2000TilePart tile_part[32]
Jpeg2000QuantStyle qntsty[4]
Jpeg2000CodingStyle codsty[4]
GetByteContext packed_headers_stream
#define avpriv_request_sample(...)