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 if (
s->cdef[
i] < 0) {
370 for (
i = 0;
i <
s->ncomponents;
i++) {
373 if ((
s->ncomponents & 1) == 0)
374 s->cdef[
s->ncomponents-1] = 0;
379 for (
i = 0;
i <
s->ncomponents;
i++) {
380 uint8_t x = bytestream2_get_byteu(&
s->g);
381 s->cbps[
i] = (x & 0x7f) + 1;
382 s->precision =
FFMAX(
s->cbps[
i],
s->precision);
383 s->sgnd[
i] = !!(x & 0x80);
384 s->cdx[
i] = bytestream2_get_byteu(&
s->g);
385 s->cdy[
i] = bytestream2_get_byteu(&
s->g);
386 if ( !
s->cdx[
i] ||
s->cdx[
i] == 3 ||
s->cdx[
i] > 4
387 || !
s->cdy[
i] ||
s->cdy[
i] == 3 ||
s->cdy[
i] > 4) {
391 int i_remapped =
s->cdef[
i] ?
s->cdef[
i]-1 : (
s->ncomponents-1);
393 log2_chroma_wh |=
s->cdy[
i] >> 1 << i_remapped * 4 |
s->cdx[
i] >> 1 << i_remapped * 4 + 2;
400 if (
s->numXtiles * (uint64_t)
s->numYtiles > INT_MAX/
sizeof(*
s->tile) ||
403 s->numXtiles =
s->numYtiles = 0;
409 s->numXtiles =
s->numYtiles = 0;
413 for (
i = 0;
i <
s->numXtiles *
s->numYtiles;
i++) {
423 s->reduction_factor);
425 s->reduction_factor);
428 for (
i = 1;
i <
s->ncomponents;
i++) {
442 switch (
s->colour_space) {
462 && !
pix_fmt_match(
s->avctx->pix_fmt, ncomponents,
s->precision, log2_chroma_wh,
s->pal8))
465 for (
i = 0;
i < possible_fmts_nb; ++
i) {
466 if (
pix_fmt_match(possible_fmts[
i], ncomponents,
s->precision, log2_chroma_wh,
s->pal8)) {
467 s->avctx->pix_fmt = possible_fmts[
i];
472 if (
i == possible_fmts_nb) {
473 if (ncomponents == 4 &&
474 s->cdy[0] == 1 &&
s->cdx[0] == 1 &&
475 s->cdy[1] == 1 &&
s->cdx[1] == 1 &&
476 s->cdy[2] ==
s->cdy[3] &&
s->cdx[2] ==
s->cdx[3]) {
477 if (
s->precision == 8 &&
s->cdy[2] == 2 &&
s->cdx[2] == 2 && !
s->pal8) {
485 }
else if (ncomponents == 3 &&
s->precision == 8 &&
486 s->cdx[0] ==
s->cdx[1] &&
s->cdx[0] ==
s->cdx[2] &&
487 s->cdy[0] ==
s->cdy[1] &&
s->cdy[0] ==
s->cdy[2]) {
490 }
else if (ncomponents == 2 &&
s->precision == 8 &&
491 s->cdx[0] ==
s->cdx[1] &&
s->cdy[0] ==
s->cdy[1]) {
494 }
else if (ncomponents == 1 &&
s->precision == 8) {
501 if (
i == possible_fmts_nb) {
503 "Unknown pix_fmt, profile: %d, colour_space: %d, "
504 "components: %d, precision: %d\n"
505 "cdx[0]: %d, cdy[0]: %d\n"
506 "cdx[1]: %d, cdy[1]: %d\n"
507 "cdx[2]: %d, cdy[2]: %d\n"
508 "cdx[3]: %d, cdy[3]: %d\n",
509 s->avctx->profile,
s->colour_space, ncomponents,
s->precision,
512 ncomponents > 1 ?
s->cdx[1] : 0,
513 ncomponents > 1 ?
s->cdy[1] : 0,
514 ncomponents > 2 ?
s->cdx[2] : 0,
515 ncomponents > 2 ?
s->cdy[2] : 0,
516 ncomponents > 3 ?
s->cdx[3] : 0,
517 ncomponents > 3 ?
s->cdy[3] : 0);
520 s->avctx->bits_per_raw_sample =
s->precision;
536 c->nreslevels = bytestream2_get_byteu(&
s->g) + 1;
542 if (
c->nreslevels <=
s->reduction_factor) {
547 av_log(
s->avctx,
AV_LOG_ERROR,
"reduction_factor too large for this bitstream, max is %d\n",
c->nreslevels - 1);
548 s->reduction_factor =
c->nreslevels - 1;
553 c->nreslevels2decode =
c->nreslevels -
s->reduction_factor;
555 c->log2_cblk_width = (bytestream2_get_byteu(&
s->g) & 15) + 2;
556 c->log2_cblk_height = (bytestream2_get_byteu(&
s->g) & 15) + 2;
558 if (
c->log2_cblk_width > 10 ||
c->log2_cblk_height > 10 ||
559 c->log2_cblk_width +
c->log2_cblk_height > 12) {
564 c->cblk_style = bytestream2_get_byteu(&
s->g);
565 if (
c->cblk_style != 0) {
570 c->transform = bytestream2_get_byteu(&
s->g);
580 for (
i = 0;
i <
c->nreslevels;
i++) {
581 byte = bytestream2_get_byte(&
s->g);
582 c->log2_prec_widths[
i] =
byte & 0x0F;
583 c->log2_prec_heights[
i] = (
byte >> 4) & 0x0F;
585 if (
c->log2_prec_widths[
i] == 0 ||
c->log2_prec_heights[
i] == 0) {
587 c->log2_prec_widths[
i],
c->log2_prec_heights[
i]);
588 c->log2_prec_widths[
i] =
c->log2_prec_heights[
i] = 1;
593 memset(
c->log2_prec_widths , 15,
sizeof(
c->log2_prec_widths ));
594 memset(
c->log2_prec_heights, 15,
sizeof(
c->log2_prec_heights));
611 tmp.csty = bytestream2_get_byteu(&
s->g);
614 tmp.prog_order = bytestream2_get_byteu(&
s->g);
616 tmp.nlayers = bytestream2_get_be16u(&
s->g);
617 tmp.mct = bytestream2_get_byteu(&
s->g);
619 if (
tmp.mct &&
s->ncomponents < 3) {
621 "MCT %"PRIu8
" with too few components (%d)\n",
622 tmp.mct,
s->ncomponents);
629 for (compno = 0; compno <
s->ncomponents; compno++)
630 if (!(properties[compno] &
HAD_COC))
631 memcpy(
c + compno, &
tmp,
sizeof(
tmp));
648 compno = bytestream2_get_byteu(&
s->g);
650 if (compno >=
s->ncomponents) {
652 "Invalid compno %d. There are %d components in the image.\n",
653 compno,
s->ncomponents);
660 c->csty = bytestream2_get_byteu(&
s->g);
675 compno = (
s->ncomponents < 257)? bytestream2_get_byte(&
s->g):
676 bytestream2_get_be16u(&
s->g);
677 if (bytestream2_get_byte(&
s->g)) {
684 if (compno < s->ncomponents) {
686 if (
s->curtileno == -1) {
687 v = bytestream2_get_byte(&
s->g);
690 s->roi_shift[compno] = v;
692 if (
s->tile[
s->curtileno].tp_idx != 0)
694 v = bytestream2_get_byte(&
s->g);
697 s->tile[
s->curtileno].comp[compno].roi_shift = v;
712 x = bytestream2_get_byteu(&
s->g);
722 for (
i = 0;
i < n;
i++)
723 q->
expn[
i] = bytestream2_get_byteu(&
s->g) >> 3;
727 x = bytestream2_get_be16u(&
s->g);
728 q->
expn[0] = x >> 11;
729 q->
mant[0] = x & 0x7ff;
731 int curexpn =
FFMAX(0, q->
expn[0] - (
i - 1) / 3);
732 q->
expn[
i] = curexpn;
740 for (
i = 0;
i < n;
i++) {
741 x = bytestream2_get_be16u(&
s->g);
742 q->
expn[
i] = x >> 11;
743 q->
mant[
i] = x & 0x7ff;
756 memset(&
tmp, 0,
sizeof(
tmp));
760 for (compno = 0; compno <
s->ncomponents; compno++)
761 if (!(properties[compno] &
HAD_QCC))
762 memcpy(q + compno, &
tmp,
sizeof(
tmp));
776 compno = bytestream2_get_byteu(&
s->g);
778 if (compno >=
s->ncomponents) {
780 "Invalid compno %d. There are %d components in the image.\n",
781 compno,
s->ncomponents);
786 return get_qcx(
s, n - 1, q + compno);
792 int elem_size =
s->ncomponents <= 257 ? 7 : 9;
805 tmp.nb_poc = (
size - 2) / elem_size;
811 for (
i = 0;
i<
tmp.nb_poc;
i++) {
813 e->
RSpoc = bytestream2_get_byteu(&
s->g);
814 e->
CSpoc = bytestream2_get_byteu(&
s->g);
815 e->
LYEpoc = bytestream2_get_be16u(&
s->g);
816 e->
REpoc = bytestream2_get_byteu(&
s->g);
817 e->
CEpoc = bytestream2_get_byteu(&
s->g);
818 e->
Ppoc = bytestream2_get_byteu(&
s->g);
821 if (e->
CEpoc >
s->ncomponents)
822 e->
CEpoc =
s->ncomponents;
862 Isot = bytestream2_get_be16u(&
s->g);
863 if (Isot >=
s->numXtiles *
s->numYtiles)
867 Psot = bytestream2_get_be32u(&
s->g);
868 TPsot = bytestream2_get_byteu(&
s->g);
871 bytestream2_get_byteu(&
s->g);
886 s->tile[Isot].tp_idx = TPsot;
887 tp =
s->tile[Isot].tile_part + TPsot;
889 tp->
tp_end =
s->g.buffer + Psot - n - 2;
897 memcpy(&tile->
poc , &
s->poc ,
sizeof(tile->
poc));
906 if (
s->ncomponents*4 != n - 2) {
924 bytestream2_get_byte(&
s->g);
925 Stlm = bytestream2_get_byte(&
s->g);
928 ST = (Stlm >> 4) & 0x03;
934 SP = (Stlm >> 6) & 0x01;
935 tile_tlm = (n - 4) / ((
SP + 1) * 2 + ST);
936 for (
i = 0;
i < tile_tlm;
i++) {
941 bytestream2_get_byte(&
s->g);
944 bytestream2_get_be16(&
s->g);
948 bytestream2_get_be16(&
s->g);
950 bytestream2_get_be32(&
s->g);
967 bytestream2_get_byte(&
s->g);
969 for (
i = 0;
i < n - 3;
i++) {
970 v = bytestream2_get_byte(&
s->g);
986 bytestream2_get_byte(&
s->g);
988 s->packed_headers_size + n - 3);
990 s->packed_headers =
new;
994 memset(&
s->packed_headers_stream, 0,
sizeof(
s->packed_headers_stream));
997 s->packed_headers_size += n - 3;
1011 if (
s->curtileno < 0)
1014 tile = &
s->tile[
s->curtileno];
1017 "PPT marker can occur only on first tile part of a tile.\n");
1022 bytestream2_get_byte(&
s->g);
1031 s->g.buffer, n - 3);
1041 int tilex = tileno %
s->numXtiles;
1042 int tiley = tileno /
s->numXtiles;
1049 tile->
coord[0][1] =
av_clip((tilex + 1) * (
int64_t)
s->tile_width +
s->tile_offset_x,
s->image_offset_x,
s->width);
1050 tile->
coord[1][0] =
av_clip(tiley * (
int64_t)
s->tile_height +
s->tile_offset_y,
s->image_offset_y,
s->height);
1051 tile->
coord[1][1] =
av_clip((tiley + 1) * (
int64_t)
s->tile_height +
s->tile_offset_y,
s->image_offset_y,
s->height);
1053 for (compno = 0; compno <
s->ncomponents; compno++) {
1059 comp->coord_o[0][0] = tile->
coord[0][0];
1060 comp->coord_o[0][1] = tile->
coord[0][1];
1061 comp->coord_o[1][0] = tile->
coord[1][0];
1062 comp->coord_o[1][1] = tile->
coord[1][1];
1074 if (!
comp->roi_shift)
1075 comp->roi_shift =
s->roi_shift[compno];
1079 s->cbps[compno],
s->cdx[compno],
1080 s->cdy[compno],
s->avctx))
1095 return num < 0 ? num : 3 + num;
1097 return num < 0 ? num : 6 + num;
1099 return num < 0 ? num : 37 + num;
1137 av_log(
s->avctx,
AV_LOG_ERROR,
"SOP marker not found. instead %X\n", bytestream2_peek_be32(&
s->g));
1144 int layno,
uint8_t *expn,
int numgbits)
1146 int bandno, cblkno, ret, nb_code_blocks;
1149 if (layno < rlevel->band[0].prec[precno].decoded_layers)
1166 for (bandno = 0; bandno < rlevel->
nbands; bandno++) {
1170 if (band->
coord[0][0] == band->
coord[0][1] ||
1175 for (cblkno = 0; cblkno < nb_code_blocks; cblkno++) {
1177 int incl, newpasses, llen;
1190 int v = expn[bandno] + numgbits - 1 -
1192 if (v < 0 || v > 30) {
1194 "nonzerobits %d invalid or unsupported\n", v);
1210 "Block with length beyond 16 bits");
1229 while (newpasses1 < newpasses) {
1255 newpasses -= newpasses1;
1265 av_log(
s->avctx,
AV_LOG_ERROR,
"EPH marker not found. instead %X\n", bytestream2_peek_be32(&
s->g));
1276 for (bandno = 0; bandno < rlevel->
nbands; bandno++) {
1281 for (cblkno = 0; cblkno < nb_code_blocks; cblkno++) {
1285 for (cwsno = 0; cwsno < cblk->
nb_lengthinc; cwsno ++) {
1298 "Block length %"PRIu16
" or lengthinc %d is too large, left %d\n",
1327 av_log(
s->avctx,
AV_LOG_ERROR,
"EPH marker not found. instead %X\n", bytestream2_peek_be32(&
s->g));
1341 int RSpoc,
int CSpoc,
1342 int LYEpoc,
int REpoc,
int CEpoc,
1343 int Ppoc,
int *tp_index)
1346 int layno, reslevelno, compno, precno, ok_reslevel;
1354 for (reslevelno = RSpoc; ok_reslevel && reslevelno < REpoc; reslevelno++) {
1356 for (layno = 0; layno < LYEpoc; layno++) {
1357 for (compno = CSpoc; compno < CEpoc; compno++) {
1360 if (reslevelno < codsty->nreslevels) {
1368 qntsty->
expn + (reslevelno ? 3 * (reslevelno - 1) + 1 : 0),
1379 for (layno = 0; layno < LYEpoc; layno++) {
1381 for (reslevelno = RSpoc; ok_reslevel && reslevelno < REpoc; reslevelno++) {
1383 for (compno = CSpoc; compno < CEpoc; compno++) {
1386 if (reslevelno < codsty->nreslevels) {
1394 qntsty->
expn + (reslevelno ? 3 * (reslevelno - 1) + 1 : 0),
1405 for (compno = CSpoc; compno < CEpoc; compno++) {
1415 for (reslevelno = RSpoc; reslevelno <
FFMIN(codsty->
nreslevels, REpoc); reslevelno++) {
1421 if (step_x >= 31 || step_y >= 31){
1428 for (y = tile->
coord[1][0]; y < tile->coord[1][1]; y = (y/step_y + 1)*step_y) {
1429 for (x = tile->
coord[0][0]; x < tile->coord[0][1]; x = (x/step_x + 1)*step_x) {
1430 for (reslevelno = RSpoc; reslevelno <
FFMIN(codsty->
nreslevels, REpoc); reslevelno++) {
1431 unsigned prcx, prcy;
1434 int xc = x /
s->cdx[compno];
1435 int yc = y /
s->cdy[compno];
1457 for (layno = 0; layno < LYEpoc; layno++) {
1460 qntsty->
expn + (reslevelno ? 3 * (reslevelno - 1) + 1 : 0),
1473 for (reslevelno = RSpoc; ok_reslevel && reslevelno < REpoc; reslevelno++) {
1477 for (compno = CSpoc; compno < CEpoc; compno++) {
1481 if (reslevelno < codsty->nreslevels) {
1491 for (y = tile->
coord[1][0]; y < tile->coord[1][1]; y = (y/step_y + 1)*step_y) {
1492 for (x = tile->
coord[0][0]; x < tile->coord[0][1]; x = (x/step_x + 1)*step_x) {
1493 for (compno = CSpoc; compno < CEpoc; compno++) {
1499 unsigned prcx, prcy;
1502 if (!
s->cdx[compno] || !
s->cdy[compno])
1511 if (!(y % ((uint64_t)
s->cdy[compno] << (rlevel->
log2_prec_height + reducedresno)) == 0 ||
1515 if (!(x % ((uint64_t)
s->cdx[compno] << (rlevel->
log2_prec_width + reducedresno)) == 0 ||
1534 for (layno = 0; layno < LYEpoc; layno++) {
1538 qntsty->
expn + (reslevelno ? 3 * (reslevelno - 1) + 1 : 0),
1552 for (compno = CSpoc; compno < CEpoc; compno++) {
1556 for (reslevelno = RSpoc; reslevelno <
FFMIN(codsty->
nreslevels, REpoc); reslevelno++) {
1563 if (step_x >= 31 || step_y >= 31){
1570 for (y = tile->
coord[1][0]; y < tile->coord[1][1]; y = (y/step_y + 1)*step_y) {
1571 for (x = tile->
coord[0][0]; x < tile->coord[0][1]; x = (x/step_x + 1)*step_x) {
1572 for (compno = CSpoc; compno < CEpoc; compno++) {
1577 if (!
s->cdx[compno] || !
s->cdy[compno])
1580 for (reslevelno = RSpoc; reslevelno <
FFMIN(codsty->
nreslevels, REpoc); reslevelno++) {
1581 unsigned prcx, prcy;
1589 if (!(y % ((uint64_t)
s->cdy[compno] << (rlevel->
log2_prec_height + reducedresno)) == 0 ||
1593 if (!(x % ((uint64_t)
s->cdx[compno] << (rlevel->
log2_prec_width + reducedresno)) == 0 ||
1611 for (layno = 0; layno < LYEpoc; layno++) {
1614 qntsty->
expn + (reslevelno ? 3 * (reslevelno - 1) + 1 : 0),
1669 int bpno,
int bandno,
1670 int vert_causal_ctx_csty_symbol)
1672 int mask = 3 << (bpno - 1), y0, x, y;
1674 for (y0 = 0; y0 <
height; y0 += 4)
1675 for (x = 0; x <
width; x++)
1676 for (y = y0; y <
height && y < y0 + 4; y++) {
1677 int flags_mask = -1;
1678 if (vert_causal_ctx_csty_symbol && y == y0 + 3)
1691 t1->data[(y) *
t1->stride + x] < 0);
1699 int bpno,
int vert_causal_ctx_csty_symbol)
1704 phalf = 1 << (bpno - 1);
1707 for (y0 = 0; y0 <
height; y0 += 4)
1708 for (x = 0; x <
width; x++)
1709 for (y = y0; y <
height && y < y0 + 4; y++)
1711 int flags_mask = (vert_causal_ctx_csty_symbol && y == y0 + 3) ?
1715 t1->mqc.cx_states + ctxno)
1717 t1->data[(y) *
t1->stride + x] +=
t1->data[(y) *
t1->stride + x] < 0 ? -
r :
r;
1724 int seg_symbols,
int vert_causal_ctx_csty_symbol)
1726 int mask = 3 << (bpno - 1), y0, x, y, runlen, dec;
1728 for (y0 = 0; y0 <
height; y0 += 4) {
1729 for (x = 0; x <
width; x++) {
1730 int flags_mask = -1;
1731 if (vert_causal_ctx_csty_symbol)
1751 for (y = y0 + runlen; y < y0 + 4 && y <
height; y++) {
1752 int flags_mask = -1;
1753 if (vert_causal_ctx_csty_symbol && y == y0 + 3)
1766 t1->mqc.cx_states + ctxno) ^
1784 "Segmentation symbol value incorrect\n");
1801 memset(
t1->data, 0,
t1->stride *
height *
sizeof(*
t1->data));
1807 memset(
t1->flags, 0,
t1->stride * (
height + 2) *
sizeof(*
t1->flags));
1814 if (bpno < 0 || bpno > 29) {
1821 vert_causal_ctx_csty_symbol);
1830 vert_causal_ctx_csty_symbol);
1875 roi_shift =
comp->roi_shift;
1876 val = (quan_parameter < 0)?-quan_parameter:quan_parameter;
1878 if (
val > (1 << roi_shift))
1879 return (quan_parameter < 0)?-(
val >> roi_shift):(
val >> roi_shift);
1880 return quan_parameter;
1896 for (j = 0; j < (cblk->
coord[1][1] - cblk->
coord[1][0]); ++j) {
1897 float *datap = &
comp->f_data[(
comp->coord[0][1] -
comp->coord[0][0]) * (y + j) + x];
1898 int *
src =
t1->data + j*
t1->stride;
1899 for (
i = 0;
i <
w; ++
i)
1911 for (j = 0; j < (cblk->
coord[1][1] - cblk->
coord[1][0]); ++j) {
1913 int *
src =
t1->data + j*
t1->stride;
1915 for (
i = 0;
i <
w; ++
i)
1916 datap[
i] =
src[
i] / 2;
1919 for (
i = 0;
i <
w; ++
i)
1931 for (j = 0; j < (cblk->
coord[1][1] - cblk->
coord[1][0]); ++j) {
1933 int *
src =
t1->data + j*
t1->stride;
1934 for (
i = 0;
i <
w; ++
i)
1944 for (
i = 1;
i < 3;
i++) {
1955 for (
i = 0;
i < 3;
i++)
1961 for (
i = 0;
i < 2;
i++)
1973 for (j = 0; j < (cblk->
coord[1][1] - cblk->
coord[1][0]); ++j) {
1974 int *
src =
t1->data + j*
t1->stride;
1975 for (
i = 0;
i <
w; ++
i)
1984 int compno, reslevelno, bandno;
1987 for (compno = 0; compno <
s->ncomponents; compno++) {
1998 for (bandno = 0; bandno < rlevel->
nbands; bandno++) {
1999 int nb_precincts, precno;
2001 int cblkno = 0, bandpos;
2003 bandpos = bandno + (reslevelno > 0);
2005 if (band->
coord[0][0] == band->
coord[0][1] ||
2011 for (precno = 0; precno < nb_precincts; precno++) {
2023 bandpos,
comp->roi_shift);
2031 if (
comp->roi_shift)
2051 #define WRITE_FRAME(D, PIXEL) \
2052 static inline void write_frame_ ## D(Jpeg2000DecoderContext * s, Jpeg2000Tile * tile, \
2053 AVFrame * picture, int precision) \
2055 const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(s->avctx->pix_fmt); \
2056 int planar = !!(pixdesc->flags & AV_PIX_FMT_FLAG_PLANAR); \
2057 int pixelsize = planar ? 1 : pixdesc->nb_components; \
2062 for (compno = 0; compno < s->ncomponents; compno++) { \
2063 Jpeg2000Component *comp = tile->comp + compno; \
2064 Jpeg2000CodingStyle *codsty = tile->codsty + compno; \
2066 float *datap = comp->f_data; \
2067 int32_t *i_datap = comp->i_data; \
2068 int cbps = s->cbps[compno]; \
2069 int w = tile->comp[compno].coord[0][1] - \
2070 ff_jpeg2000_ceildiv(s->image_offset_x, s->cdx[compno]); \
2071 int h = tile->comp[compno].coord[1][1] - \
2072 ff_jpeg2000_ceildiv(s->image_offset_y, s->cdy[compno]); \
2074 ptrdiff_t dstoffset = 0; \
2077 plane = s->cdef[compno] ? s->cdef[compno]-1 : (s->ncomponents-1); \
2079 dstoffset = s->cdef[compno] ? s->cdef[compno] - 1 : compno; \
2081 y = tile->comp[compno].coord[1][0] - \
2082 ff_jpeg2000_ceildiv(s->image_offset_y, s->cdy[compno]); \
2083 line = (PIXEL *)picture->data[plane] + y * (picture->linesize[plane] / sizeof(PIXEL));\
2084 for (; y < h; y++) { \
2087 x = tile->comp[compno].coord[0][0] - \
2088 ff_jpeg2000_ceildiv(s->image_offset_x, s->cdx[compno]); \
2089 dst = line + x * pixelsize + dstoffset; \
2091 if (codsty->transform == FF_DWT97) { \
2092 for (; x < w; x++) { \
2093 int val = lrintf(*datap) + (1 << (cbps - 1)); \
2095 val = av_clip(val, 0, (1 << cbps) - 1); \
2096 *dst = val << (precision - cbps); \
2101 for (; x < w; x++) { \
2102 int val = *i_datap + (1 << (cbps - 1)); \
2104 val = av_clip(val, 0, (1 << cbps) - 1); \
2105 *dst = val << (precision - cbps); \
2110 line += picture->linesize[plane] / sizeof(PIXEL); \
2122 int jobnr,
int threadnr)
2135 for (x = 0; x <
s->ncomponents; x++) {
2136 if (
s->cdef[x] < 0) {
2137 for (x = 0; x <
s->ncomponents; x++) {
2140 if ((
s->ncomponents & 1) == 0)
2141 s->cdef[
s->ncomponents-1] = 0;
2146 if (
s->precision <= 8) {
2147 write_frame_8(
s, tile, picture, 8);
2154 write_frame_16(
s, tile, picture, precision);
2163 for (tileno = 0; tileno <
s->numXtiles *
s->numYtiles; tileno++) {
2164 if (
s->tile[tileno].comp) {
2165 for (compno = 0; compno <
s->ncomponents; compno++) {
2172 av_freep(&
s->tile[tileno].packed_headers);
2173 s->tile[tileno].packed_headers_size = 0;
2177 s->packed_headers_size = 0;
2178 memset(&
s->packed_headers_stream, 0,
sizeof(
s->packed_headers_stream));
2180 memset(
s->codsty, 0,
sizeof(
s->codsty));
2181 memset(
s->qntsty, 0,
sizeof(
s->qntsty));
2182 memset(
s->properties, 0,
sizeof(
s->properties));
2183 memset(&
s->poc , 0,
sizeof(
s->poc));
2184 s->numXtiles =
s->numYtiles = 0;
2193 uint8_t *properties =
s->properties;
2205 marker = bytestream2_get_be16u(&
s->g);
2207 if (marker >= 0xFF30 && marker <= 0xFF3F)
2217 if (
s->curtileno < 0) {
2222 tile =
s->tile +
s->curtileno;
2224 if (tp->
tp_end <
s->g.buffer) {
2230 uint32_t tp_header_size = bytestream2_get_be32(&
s->packed_headers_stream);
2248 len = bytestream2_get_be16(&
s->g);
2260 if (
s->ncomponents) {
2266 s->numXtiles =
s->numYtiles = 0;
2269 ret =
get_coc(
s, codsty, properties);
2272 ret =
get_cod(
s, codsty, properties);
2287 if (!
s->in_tile_headers) {
2288 s->in_tile_headers = 1;
2295 codsty =
s->tile[
s->curtileno].codsty;
2296 qntsty =
s->tile[
s->curtileno].qntsty;
2297 poc = &
s->tile[
s->curtileno].poc;
2298 properties =
s->tile[
s->curtileno].properties;
2320 if (
s->in_tile_headers) {
2330 "Cannot have both PPT and PPM marker.\n");
2338 "unsupported marker 0x%.4"PRIX16
" at pos 0x%X\n",
2345 "error during processing marker segment %.4"PRIx16
"\n",
2347 return ret ? ret : -1;
2359 for (tileno = 0; tileno <
s->numXtiles *
s->numYtiles; tileno++) {
2374 uint32_t atom_size, atom, atom_end;
2375 int search_range = 10;
2380 atom_size = bytestream2_get_be32u(&
s->g);
2381 atom = bytestream2_get_be32u(&
s->g);
2382 if (atom_size == 1) {
2383 if (bytestream2_get_be32u(&
s->g)) {
2387 atom_size = bytestream2_get_be32u(&
s->g);
2405 uint32_t atom2_size, atom2, atom2_end;
2409 atom2_size = bytestream2_get_be32u(&
s->g);
2410 atom2 = bytestream2_get_be32u(&
s->g);
2412 if (atom2_size < 8 || atom2_end > atom_end || atom2_end < atom2_size)
2417 }
else if (atom2 ==
MKBETAG(
'c',
'o',
'l',
'r') && atom2_size >= 7) {
2418 int method = bytestream2_get_byteu(&
s->g);
2421 s->colour_space = bytestream2_get_be32u(&
s->g);
2423 }
else if (atom2 ==
MKBETAG(
'p',
'c',
'l',
'r') && atom2_size >= 6) {
2424 int i,
size, colour_count, colour_channels, colour_depth[3];
2425 colour_count = bytestream2_get_be16u(&
s->g);
2426 colour_channels = bytestream2_get_byteu(&
s->g);
2428 colour_depth[0] = (bytestream2_get_byteu(&
s->g) & 0x7f) + 1;
2429 colour_depth[1] = (bytestream2_get_byteu(&
s->g) & 0x7f) + 1;
2430 colour_depth[2] = (bytestream2_get_byteu(&
s->g) & 0x7f) + 1;
2431 size = (colour_depth[0] + 7 >> 3) * colour_count +
2432 (colour_depth[1] + 7 >> 3) * colour_count +
2433 (colour_depth[2] + 7 >> 3) * colour_count;
2435 colour_channels != 3 ||
2436 colour_depth[0] > 16 ||
2437 colour_depth[1] > 16 ||
2438 colour_depth[2] > 16 ||
2439 atom2_size <
size) {
2445 for (
i = 0;
i < colour_count;
i++) {
2447 if (colour_depth[0] <= 8) {
2448 r = bytestream2_get_byteu(&
s->g) << 8 - colour_depth[0];
2449 r |=
r >> colour_depth[0];
2451 r = bytestream2_get_be16u(&
s->g) >> colour_depth[0] - 8;
2453 if (colour_depth[1] <= 8) {
2454 g = bytestream2_get_byteu(&
s->g) << 8 - colour_depth[1];
2455 g |=
g >> colour_depth[1];
2457 g = bytestream2_get_be16u(&
s->g) >> colour_depth[1] - 8;
2459 if (colour_depth[2] <= 8) {
2460 b = bytestream2_get_byteu(&
s->g) << 8 - colour_depth[2];
2461 b |=
b >> colour_depth[2];
2463 b = bytestream2_get_be16u(&
s->g) >> colour_depth[2] - 8;
2465 s->palette[
i] = 0xffu << 24 |
r << 16 |
g << 8 |
b;
2467 }
else if (atom2 ==
MKBETAG(
'c',
'd',
'e',
'f') && atom2_size >= 2) {
2468 int n = bytestream2_get_be16u(&
s->g);
2470 int cn = bytestream2_get_be16(&
s->g);
2471 int av_unused typ = bytestream2_get_be16(&
s->g);
2472 int asoc = bytestream2_get_be16(&
s->g);
2473 if (cn < 4 && asoc < 4)
2476 }
else if (atom2 ==
MKBETAG(
'r',
'e',
's',
' ') && atom2_size >= 18) {
2477 int64_t vnum, vden, hnum, hden, vexp, hexp;
2480 resx = bytestream2_get_be32u(&
s->g);
2481 if (resx !=
MKBETAG(
'r',
'e',
's',
'c') && resx !=
MKBETAG(
'r',
'e',
's',
'd')) {
2485 vnum = bytestream2_get_be16u(&
s->g);
2486 vden = bytestream2_get_be16u(&
s->g);
2487 hnum = bytestream2_get_be16u(&
s->g);
2488 hden = bytestream2_get_be16u(&
s->g);
2489 vexp = bytestream2_get_byteu(&
s->g);
2490 hexp = bytestream2_get_byteu(&
s->g);
2491 if (!vnum || !vden || !hnum || !hden) {
2503 if ( INT64_MAX / (hnum * vden) > pow(10, hexp)
2504 && INT64_MAX / (vnum * hden) > pow(10, vexp))
2506 hnum * vden * pow(10, hexp),
2507 vnum * hden * pow(10, vexp),
2511 }
while (atom_end - atom2_end >= 8);
2549 memset(
s->cdef, -1,
sizeof(
s->cdef));
2558 (bytestream2_get_be32u(&
s->g) == 12) &&
2563 "Could not find Jpeg2000 codestream atom.\n");
2598 memcpy(picture->
data[1],
s->palette, 256 *
sizeof(uint32_t));
2599 if (
s->sar.num &&
s->sar.den)
2601 s->sar.num =
s->sar.den = 0;
2610 #define OFFSET(x) offsetof(Jpeg2000DecoderContext, x)
2611 #define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
2614 {
"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(...)