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 uint8_t x = bytestream2_get_byteu(&
s->g);
351 s->cbps[
i] = (x & 0x7f) + 1;
352 s->precision =
FFMAX(
s->cbps[
i],
s->precision);
353 s->sgnd[
i] = !!(x & 0x80);
354 s->cdx[
i] = bytestream2_get_byteu(&
s->g);
355 s->cdy[
i] = bytestream2_get_byteu(&
s->g);
356 if ( !
s->cdx[
i] ||
s->cdx[
i] == 3 ||
s->cdx[
i] > 4
357 || !
s->cdy[
i] ||
s->cdy[
i] == 3 ||
s->cdy[
i] > 4) {
361 log2_chroma_wh |=
s->cdy[
i] >> 1 <<
i * 4 |
s->cdx[
i] >> 1 <<
i * 4 + 2;
368 if (
s->numXtiles * (uint64_t)
s->numYtiles > INT_MAX/
sizeof(*
s->tile) ||
371 s->numXtiles =
s->numYtiles = 0;
377 s->numXtiles =
s->numYtiles = 0;
381 for (
i = 0;
i <
s->numXtiles *
s->numYtiles;
i++) {
391 s->reduction_factor);
393 s->reduction_factor);
396 for (
i = 1;
i <
s->ncomponents;
i++) {
410 switch (
s->colour_space) {
430 && !
pix_fmt_match(
s->avctx->pix_fmt, ncomponents,
s->precision, log2_chroma_wh,
s->pal8))
433 for (
i = 0;
i < possible_fmts_nb; ++
i) {
434 if (
pix_fmt_match(possible_fmts[
i], ncomponents,
s->precision, log2_chroma_wh,
s->pal8)) {
435 s->avctx->pix_fmt = possible_fmts[
i];
440 if (
i == possible_fmts_nb) {
441 if (ncomponents == 4 &&
442 s->cdy[0] == 1 &&
s->cdx[0] == 1 &&
443 s->cdy[1] == 1 &&
s->cdx[1] == 1 &&
444 s->cdy[2] ==
s->cdy[3] &&
s->cdx[2] ==
s->cdx[3]) {
445 if (
s->precision == 8 &&
s->cdy[2] == 2 &&
s->cdx[2] == 2 && !
s->pal8) {
453 }
else if (ncomponents == 3 &&
s->precision == 8 &&
454 s->cdx[0] ==
s->cdx[1] &&
s->cdx[0] ==
s->cdx[2] &&
455 s->cdy[0] ==
s->cdy[1] &&
s->cdy[0] ==
s->cdy[2]) {
458 }
else if (ncomponents == 2 &&
s->precision == 8 &&
459 s->cdx[0] ==
s->cdx[1] &&
s->cdy[0] ==
s->cdy[1]) {
462 }
else if (ncomponents == 1 &&
s->precision == 8) {
469 if (
i == possible_fmts_nb) {
471 "Unknown pix_fmt, profile: %d, colour_space: %d, "
472 "components: %d, precision: %d\n"
473 "cdx[0]: %d, cdy[0]: %d\n"
474 "cdx[1]: %d, cdy[1]: %d\n"
475 "cdx[2]: %d, cdy[2]: %d\n"
476 "cdx[3]: %d, cdy[3]: %d\n",
477 s->avctx->profile,
s->colour_space, ncomponents,
s->precision,
480 ncomponents > 1 ?
s->cdx[1] : 0,
481 ncomponents > 1 ?
s->cdy[1] : 0,
482 ncomponents > 2 ?
s->cdx[2] : 0,
483 ncomponents > 2 ?
s->cdy[2] : 0,
484 ncomponents > 3 ?
s->cdx[3] : 0,
485 ncomponents > 3 ?
s->cdy[3] : 0);
488 s->avctx->bits_per_raw_sample =
s->precision;
504 c->nreslevels = bytestream2_get_byteu(&
s->g) + 1;
510 if (
c->nreslevels <=
s->reduction_factor) {
515 av_log(
s->avctx,
AV_LOG_ERROR,
"reduction_factor too large for this bitstream, max is %d\n",
c->nreslevels - 1);
516 s->reduction_factor =
c->nreslevels - 1;
521 c->nreslevels2decode =
c->nreslevels -
s->reduction_factor;
523 c->log2_cblk_width = (bytestream2_get_byteu(&
s->g) & 15) + 2;
524 c->log2_cblk_height = (bytestream2_get_byteu(&
s->g) & 15) + 2;
526 if (
c->log2_cblk_width > 10 ||
c->log2_cblk_height > 10 ||
527 c->log2_cblk_width +
c->log2_cblk_height > 12) {
532 c->cblk_style = bytestream2_get_byteu(&
s->g);
533 if (
c->cblk_style != 0) {
538 c->transform = bytestream2_get_byteu(&
s->g);
548 for (
i = 0;
i <
c->nreslevels;
i++) {
549 byte = bytestream2_get_byte(&
s->g);
550 c->log2_prec_widths[
i] =
byte & 0x0F;
551 c->log2_prec_heights[
i] = (
byte >> 4) & 0x0F;
553 if (
c->log2_prec_widths[
i] == 0 ||
c->log2_prec_heights[
i] == 0) {
555 c->log2_prec_widths[
i],
c->log2_prec_heights[
i]);
556 c->log2_prec_widths[
i] =
c->log2_prec_heights[
i] = 1;
561 memset(
c->log2_prec_widths , 15,
sizeof(
c->log2_prec_widths ));
562 memset(
c->log2_prec_heights, 15,
sizeof(
c->log2_prec_heights));
579 tmp.csty = bytestream2_get_byteu(&
s->g);
582 tmp.prog_order = bytestream2_get_byteu(&
s->g);
584 tmp.nlayers = bytestream2_get_be16u(&
s->g);
585 tmp.mct = bytestream2_get_byteu(&
s->g);
587 if (
tmp.mct &&
s->ncomponents < 3) {
589 "MCT %"PRIu8
" with too few components (%d)\n",
590 tmp.mct,
s->ncomponents);
597 for (compno = 0; compno <
s->ncomponents; compno++)
598 if (!(properties[compno] &
HAD_COC))
599 memcpy(
c + compno, &
tmp,
sizeof(
tmp));
616 compno = bytestream2_get_byteu(&
s->g);
618 if (compno >=
s->ncomponents) {
620 "Invalid compno %d. There are %d components in the image.\n",
621 compno,
s->ncomponents);
628 c->csty = bytestream2_get_byteu(&
s->g);
643 compno = (
s->ncomponents < 257)? bytestream2_get_byte(&
s->g):
644 bytestream2_get_be16u(&
s->g);
645 if (bytestream2_get_byte(&
s->g)) {
652 if (compno < s->ncomponents) {
654 if (
s->curtileno == -1) {
655 v = bytestream2_get_byte(&
s->g);
658 s->roi_shift[compno] = v;
660 if (
s->tile[
s->curtileno].tp_idx != 0)
662 v = bytestream2_get_byte(&
s->g);
665 s->tile[
s->curtileno].comp[compno].roi_shift = v;
680 x = bytestream2_get_byteu(&
s->g);
690 for (
i = 0;
i < n;
i++)
691 q->
expn[
i] = bytestream2_get_byteu(&
s->g) >> 3;
695 x = bytestream2_get_be16u(&
s->g);
696 q->
expn[0] = x >> 11;
697 q->
mant[0] = x & 0x7ff;
699 int curexpn =
FFMAX(0, q->
expn[0] - (
i - 1) / 3);
700 q->
expn[
i] = curexpn;
708 for (
i = 0;
i < n;
i++) {
709 x = bytestream2_get_be16u(&
s->g);
710 q->
expn[
i] = x >> 11;
711 q->
mant[
i] = x & 0x7ff;
724 memset(&
tmp, 0,
sizeof(
tmp));
728 for (compno = 0; compno <
s->ncomponents; compno++)
729 if (!(properties[compno] &
HAD_QCC))
730 memcpy(q + compno, &
tmp,
sizeof(
tmp));
744 compno = bytestream2_get_byteu(&
s->g);
746 if (compno >=
s->ncomponents) {
748 "Invalid compno %d. There are %d components in the image.\n",
749 compno,
s->ncomponents);
754 return get_qcx(
s, n - 1, q + compno);
760 int elem_size =
s->ncomponents <= 257 ? 7 : 9;
773 tmp.nb_poc = (
size - 2) / elem_size;
779 for (
i = 0;
i<
tmp.nb_poc;
i++) {
781 e->
RSpoc = bytestream2_get_byteu(&
s->g);
782 e->
CSpoc = bytestream2_get_byteu(&
s->g);
783 e->
LYEpoc = bytestream2_get_be16u(&
s->g);
784 e->
REpoc = bytestream2_get_byteu(&
s->g);
785 e->
CEpoc = bytestream2_get_byteu(&
s->g);
786 e->
Ppoc = bytestream2_get_byteu(&
s->g);
789 if (e->
CEpoc >
s->ncomponents)
790 e->
CEpoc =
s->ncomponents;
830 Isot = bytestream2_get_be16u(&
s->g);
831 if (Isot >=
s->numXtiles *
s->numYtiles)
835 Psot = bytestream2_get_be32u(&
s->g);
836 TPsot = bytestream2_get_byteu(&
s->g);
839 bytestream2_get_byteu(&
s->g);
854 s->tile[Isot].tp_idx = TPsot;
855 tp =
s->tile[Isot].tile_part + TPsot;
857 tp->
tp_end =
s->g.buffer + Psot - n - 2;
865 memcpy(&tile->
poc , &
s->poc ,
sizeof(tile->
poc));
874 if (
s->ncomponents*4 != n - 2) {
892 bytestream2_get_byte(&
s->g);
893 Stlm = bytestream2_get_byte(&
s->g);
896 ST = (Stlm >> 4) & 0x03;
902 SP = (Stlm >> 6) & 0x01;
903 tile_tlm = (n - 4) / ((
SP + 1) * 2 + ST);
904 for (
i = 0;
i < tile_tlm;
i++) {
909 bytestream2_get_byte(&
s->g);
912 bytestream2_get_be16(&
s->g);
916 bytestream2_get_be16(&
s->g);
918 bytestream2_get_be32(&
s->g);
935 bytestream2_get_byte(&
s->g);
937 for (
i = 0;
i < n - 3;
i++) {
938 v = bytestream2_get_byte(&
s->g);
954 bytestream2_get_byte(&
s->g);
956 s->packed_headers_size + n - 3);
958 s->packed_headers =
new;
962 memset(&
s->packed_headers_stream, 0,
sizeof(
s->packed_headers_stream));
965 s->packed_headers_size += n - 3;
979 if (
s->curtileno < 0)
982 tile = &
s->tile[
s->curtileno];
985 "PPT marker can occur only on first tile part of a tile.\n");
990 bytestream2_get_byte(&
s->g);
1009 int tilex = tileno %
s->numXtiles;
1010 int tiley = tileno /
s->numXtiles;
1017 tile->
coord[0][1] =
av_clip((tilex + 1) * (
int64_t)
s->tile_width +
s->tile_offset_x,
s->image_offset_x,
s->width);
1018 tile->
coord[1][0] =
av_clip(tiley * (
int64_t)
s->tile_height +
s->tile_offset_y,
s->image_offset_y,
s->height);
1019 tile->
coord[1][1] =
av_clip((tiley + 1) * (
int64_t)
s->tile_height +
s->tile_offset_y,
s->image_offset_y,
s->height);
1021 for (compno = 0; compno <
s->ncomponents; compno++) {
1027 comp->coord_o[0][0] = tile->
coord[0][0];
1028 comp->coord_o[0][1] = tile->
coord[0][1];
1029 comp->coord_o[1][0] = tile->
coord[1][0];
1030 comp->coord_o[1][1] = tile->
coord[1][1];
1042 if (!
comp->roi_shift)
1043 comp->roi_shift =
s->roi_shift[compno];
1047 s->cbps[compno],
s->cdx[compno],
1048 s->cdy[compno],
s->avctx))
1063 return num < 0 ? num : 3 + num;
1065 return num < 0 ? num : 6 + num;
1067 return num < 0 ? num : 37 + num;
1105 av_log(
s->avctx,
AV_LOG_ERROR,
"SOP marker not found. instead %X\n", bytestream2_peek_be32(&
s->g));
1112 int layno,
uint8_t *expn,
int numgbits)
1114 int bandno, cblkno, ret, nb_code_blocks;
1117 if (layno < rlevel->band[0].prec[precno].decoded_layers)
1134 for (bandno = 0; bandno < rlevel->
nbands; bandno++) {
1138 if (band->
coord[0][0] == band->
coord[0][1] ||
1143 for (cblkno = 0; cblkno < nb_code_blocks; cblkno++) {
1145 int incl, newpasses, llen;
1158 int v = expn[bandno] + numgbits - 1 -
1160 if (v < 0 || v > 30) {
1162 "nonzerobits %d invalid or unsupported\n", v);
1178 "Block with length beyond 16 bits");
1197 while (newpasses1 < newpasses) {
1223 newpasses -= newpasses1;
1233 av_log(
s->avctx,
AV_LOG_ERROR,
"EPH marker not found. instead %X\n", bytestream2_peek_be32(&
s->g));
1244 for (bandno = 0; bandno < rlevel->
nbands; bandno++) {
1249 for (cblkno = 0; cblkno < nb_code_blocks; cblkno++) {
1253 for (cwsno = 0; cwsno < cblk->
nb_lengthinc; cwsno ++) {
1266 "Block length %"PRIu16
" or lengthinc %d is too large, left %d\n",
1294 av_log(
s->avctx,
AV_LOG_ERROR,
"EPH marker not found. instead %X\n", bytestream2_peek_be32(&
s->g));
1308 int RSpoc,
int CSpoc,
1309 int LYEpoc,
int REpoc,
int CEpoc,
1310 int Ppoc,
int *tp_index)
1313 int layno, reslevelno, compno, precno, ok_reslevel;
1321 for (reslevelno = RSpoc; ok_reslevel && reslevelno < REpoc; reslevelno++) {
1323 for (layno = 0; layno < LYEpoc; layno++) {
1324 for (compno = CSpoc; compno < CEpoc; compno++) {
1327 if (reslevelno < codsty->nreslevels) {
1335 qntsty->
expn + (reslevelno ? 3 * (reslevelno - 1) + 1 : 0),
1346 for (layno = 0; layno < LYEpoc; layno++) {
1348 for (reslevelno = RSpoc; ok_reslevel && reslevelno < REpoc; reslevelno++) {
1350 for (compno = CSpoc; compno < CEpoc; compno++) {
1353 if (reslevelno < codsty->nreslevels) {
1361 qntsty->
expn + (reslevelno ? 3 * (reslevelno - 1) + 1 : 0),
1372 for (compno = CSpoc; compno < CEpoc; compno++) {
1382 for (reslevelno = RSpoc; reslevelno <
FFMIN(codsty->
nreslevels, REpoc); reslevelno++) {
1388 if (step_x >= 31 || step_y >= 31){
1395 for (y = tile->
coord[1][0]; y < tile->coord[1][1]; y = (y/step_y + 1)*step_y) {
1396 for (x = tile->
coord[0][0]; x < tile->coord[0][1]; x = (x/step_x + 1)*step_x) {
1397 for (reslevelno = RSpoc; reslevelno <
FFMIN(codsty->
nreslevels, REpoc); reslevelno++) {
1398 unsigned prcx, prcy;
1401 int xc = x /
s->cdx[compno];
1402 int yc = y /
s->cdy[compno];
1424 for (layno = 0; layno < LYEpoc; layno++) {
1427 qntsty->
expn + (reslevelno ? 3 * (reslevelno - 1) + 1 : 0),
1440 for (reslevelno = RSpoc; ok_reslevel && reslevelno < REpoc; reslevelno++) {
1444 for (compno = CSpoc; compno < CEpoc; compno++) {
1448 if (reslevelno < codsty->nreslevels) {
1458 for (y = tile->
coord[1][0]; y < tile->coord[1][1]; y = (y/step_y + 1)*step_y) {
1459 for (x = tile->
coord[0][0]; x < tile->coord[0][1]; x = (x/step_x + 1)*step_x) {
1460 for (compno = CSpoc; compno < CEpoc; compno++) {
1466 unsigned prcx, prcy;
1469 if (!
s->cdx[compno] || !
s->cdy[compno])
1478 if (!(y % ((uint64_t)
s->cdy[compno] << (rlevel->
log2_prec_height + reducedresno)) == 0 ||
1482 if (!(x % ((uint64_t)
s->cdx[compno] << (rlevel->
log2_prec_width + reducedresno)) == 0 ||
1501 for (layno = 0; layno < LYEpoc; layno++) {
1505 qntsty->
expn + (reslevelno ? 3 * (reslevelno - 1) + 1 : 0),
1519 for (compno = CSpoc; compno < CEpoc; compno++) {
1523 for (reslevelno = RSpoc; reslevelno <
FFMIN(codsty->
nreslevels, REpoc); reslevelno++) {
1530 if (step_x >= 31 || step_y >= 31){
1537 for (y = tile->
coord[1][0]; y < tile->coord[1][1]; y = (y/step_y + 1)*step_y) {
1538 for (x = tile->
coord[0][0]; x < tile->coord[0][1]; x = (x/step_x + 1)*step_x) {
1539 for (compno = CSpoc; compno < CEpoc; compno++) {
1544 if (!
s->cdx[compno] || !
s->cdy[compno])
1547 for (reslevelno = RSpoc; reslevelno <
FFMIN(codsty->
nreslevels, REpoc); reslevelno++) {
1548 unsigned prcx, prcy;
1556 if (!(y % ((uint64_t)
s->cdy[compno] << (rlevel->
log2_prec_height + reducedresno)) == 0 ||
1560 if (!(x % ((uint64_t)
s->cdx[compno] << (rlevel->
log2_prec_width + reducedresno)) == 0 ||
1578 for (layno = 0; layno < LYEpoc; layno++) {
1581 qntsty->
expn + (reslevelno ? 3 * (reslevelno - 1) + 1 : 0),
1636 int bpno,
int bandno,
1637 int vert_causal_ctx_csty_symbol)
1639 int mask = 3 << (bpno - 1), y0, x, y;
1641 for (y0 = 0; y0 <
height; y0 += 4)
1642 for (x = 0; x <
width; x++)
1643 for (y = y0; y <
height && y < y0 + 4; y++) {
1644 int flags_mask = -1;
1645 if (vert_causal_ctx_csty_symbol && y == y0 + 3)
1658 t1->data[(y) *
t1->stride + x] < 0);
1666 int bpno,
int vert_causal_ctx_csty_symbol)
1671 phalf = 1 << (bpno - 1);
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++)
1678 int flags_mask = (vert_causal_ctx_csty_symbol && y == y0 + 3) ?
1682 t1->mqc.cx_states + ctxno)
1684 t1->data[(y) *
t1->stride + x] +=
t1->data[(y) *
t1->stride + x] < 0 ? -
r :
r;
1691 int seg_symbols,
int vert_causal_ctx_csty_symbol)
1693 int mask = 3 << (bpno - 1), y0, x, y, runlen, dec;
1695 for (y0 = 0; y0 <
height; y0 += 4) {
1696 for (x = 0; x <
width; x++) {
1697 int flags_mask = -1;
1698 if (vert_causal_ctx_csty_symbol)
1718 for (y = y0 + runlen; y < y0 + 4 && y <
height; y++) {
1719 int flags_mask = -1;
1720 if (vert_causal_ctx_csty_symbol && y == y0 + 3)
1733 t1->mqc.cx_states + ctxno) ^
1751 "Segmentation symbol value incorrect\n");
1768 memset(
t1->data, 0,
t1->stride *
height *
sizeof(*
t1->data));
1774 memset(
t1->flags, 0,
t1->stride * (
height + 2) *
sizeof(*
t1->flags));
1781 if (bpno < 0 || bpno > 29) {
1788 vert_causal_ctx_csty_symbol);
1797 vert_causal_ctx_csty_symbol);
1842 roi_shift =
comp->roi_shift;
1843 val = (quan_parameter < 0)?-quan_parameter:quan_parameter;
1845 if (
val > (1 << roi_shift))
1846 return (quan_parameter < 0)?-(
val >> roi_shift):(
val >> roi_shift);
1847 return quan_parameter;
1863 for (j = 0; j < (cblk->
coord[1][1] - cblk->
coord[1][0]); ++j) {
1864 float *datap = &
comp->f_data[(
comp->coord[0][1] -
comp->coord[0][0]) * (y + j) + x];
1865 int *
src =
t1->data + j*
t1->stride;
1866 for (
i = 0;
i <
w; ++
i)
1878 for (j = 0; j < (cblk->
coord[1][1] - cblk->
coord[1][0]); ++j) {
1880 int *
src =
t1->data + j*
t1->stride;
1882 for (
i = 0;
i <
w; ++
i)
1883 datap[
i] =
src[
i] / 2;
1886 for (
i = 0;
i <
w; ++
i)
1898 for (j = 0; j < (cblk->
coord[1][1] - cblk->
coord[1][0]); ++j) {
1900 int *
src =
t1->data + j*
t1->stride;
1901 for (
i = 0;
i <
w; ++
i)
1911 for (
i = 1;
i < 3;
i++) {
1922 for (
i = 0;
i < 3;
i++)
1928 for (
i = 0;
i < 2;
i++)
1940 for (j = 0; j < (cblk->
coord[1][1] - cblk->
coord[1][0]); ++j) {
1941 int *
src =
t1->data + j*
t1->stride;
1942 for (
i = 0;
i <
w; ++
i)
1951 int compno, reslevelno, bandno;
1954 for (compno = 0; compno <
s->ncomponents; compno++) {
1965 for (bandno = 0; bandno < rlevel->
nbands; bandno++) {
1966 int nb_precincts, precno;
1968 int cblkno = 0, bandpos;
1970 bandpos = bandno + (reslevelno > 0);
1972 if (band->
coord[0][0] == band->
coord[0][1] ||
1978 for (precno = 0; precno < nb_precincts; precno++) {
1990 bandpos,
comp->roi_shift);
1998 if (
comp->roi_shift)
2018 #define WRITE_FRAME(D, PIXEL) \
2019 static inline void write_frame_ ## D(Jpeg2000DecoderContext * s, Jpeg2000Tile * tile, \
2020 AVFrame * picture, int precision) \
2022 const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(s->avctx->pix_fmt); \
2023 int planar = !!(pixdesc->flags & AV_PIX_FMT_FLAG_PLANAR); \
2024 int pixelsize = planar ? 1 : pixdesc->nb_components; \
2029 for (compno = 0; compno < s->ncomponents; compno++) { \
2030 Jpeg2000Component *comp = tile->comp + compno; \
2031 Jpeg2000CodingStyle *codsty = tile->codsty + compno; \
2033 float *datap = comp->f_data; \
2034 int32_t *i_datap = comp->i_data; \
2035 int cbps = s->cbps[compno]; \
2036 int w = tile->comp[compno].coord[0][1] - \
2037 ff_jpeg2000_ceildiv(s->image_offset_x, s->cdx[compno]); \
2038 int h = tile->comp[compno].coord[1][1] - \
2039 ff_jpeg2000_ceildiv(s->image_offset_y, s->cdy[compno]); \
2043 plane = s->cdef[compno] ? s->cdef[compno]-1 : (s->ncomponents-1); \
2045 y = tile->comp[compno].coord[1][0] - \
2046 ff_jpeg2000_ceildiv(s->image_offset_y, s->cdy[compno]); \
2047 line = (PIXEL *)picture->data[plane] + y * (picture->linesize[plane] / sizeof(PIXEL));\
2048 for (; y < h; y++) { \
2051 x = tile->comp[compno].coord[0][0] - \
2052 ff_jpeg2000_ceildiv(s->image_offset_x, s->cdx[compno]); \
2053 dst = line + x * pixelsize + compno*!planar; \
2055 if (codsty->transform == FF_DWT97) { \
2056 for (; x < w; x++) { \
2057 int val = lrintf(*datap) + (1 << (cbps - 1)); \
2059 val = av_clip(val, 0, (1 << cbps) - 1); \
2060 *dst = val << (precision - cbps); \
2065 for (; x < w; x++) { \
2066 int val = *i_datap + (1 << (cbps - 1)); \
2068 val = av_clip(val, 0, (1 << cbps) - 1); \
2069 *dst = val << (precision - cbps); \
2074 line += picture->linesize[plane] / sizeof(PIXEL); \
2086 int jobnr,
int threadnr)
2099 for (x = 0; x <
s->ncomponents; x++) {
2100 if (
s->cdef[x] < 0) {
2101 for (x = 0; x <
s->ncomponents; x++) {
2104 if ((
s->ncomponents & 1) == 0)
2105 s->cdef[
s->ncomponents-1] = 0;
2110 if (
s->precision <= 8) {
2111 write_frame_8(
s, tile, picture, 8);
2118 write_frame_16(
s, tile, picture, precision);
2127 for (tileno = 0; tileno <
s->numXtiles *
s->numYtiles; tileno++) {
2128 if (
s->tile[tileno].comp) {
2129 for (compno = 0; compno <
s->ncomponents; compno++) {
2136 av_freep(&
s->tile[tileno].packed_headers);
2137 s->tile[tileno].packed_headers_size = 0;
2141 s->packed_headers_size = 0;
2142 memset(&
s->packed_headers_stream, 0,
sizeof(
s->packed_headers_stream));
2144 memset(
s->codsty, 0,
sizeof(
s->codsty));
2145 memset(
s->qntsty, 0,
sizeof(
s->qntsty));
2146 memset(
s->properties, 0,
sizeof(
s->properties));
2147 memset(&
s->poc , 0,
sizeof(
s->poc));
2148 s->numXtiles =
s->numYtiles = 0;
2157 uint8_t *properties =
s->properties;
2169 marker = bytestream2_get_be16u(&
s->g);
2171 if (marker >= 0xFF30 && marker <= 0xFF3F)
2181 if (
s->curtileno < 0) {
2186 tile =
s->tile +
s->curtileno;
2188 if (tp->
tp_end <
s->g.buffer) {
2194 uint32_t tp_header_size = bytestream2_get_be32(&
s->packed_headers_stream);
2212 len = bytestream2_get_be16(&
s->g);
2224 if (
s->ncomponents) {
2230 s->numXtiles =
s->numYtiles = 0;
2233 ret =
get_coc(
s, codsty, properties);
2236 ret =
get_cod(
s, codsty, properties);
2251 if (!
s->in_tile_headers) {
2252 s->in_tile_headers = 1;
2259 codsty =
s->tile[
s->curtileno].codsty;
2260 qntsty =
s->tile[
s->curtileno].qntsty;
2261 poc = &
s->tile[
s->curtileno].poc;
2262 properties =
s->tile[
s->curtileno].properties;
2284 if (
s->in_tile_headers) {
2294 "Cannot have both PPT and PPM marker.\n");
2302 "unsupported marker 0x%.4"PRIX16
" at pos 0x%X\n",
2309 "error during processing marker segment %.4"PRIx16
"\n",
2311 return ret ? ret : -1;
2323 for (tileno = 0; tileno <
s->numXtiles *
s->numYtiles; tileno++) {
2338 uint32_t atom_size, atom, atom_end;
2339 int search_range = 10;
2344 atom_size = bytestream2_get_be32u(&
s->g);
2345 atom = bytestream2_get_be32u(&
s->g);
2346 if (atom_size == 1) {
2347 if (bytestream2_get_be32u(&
s->g)) {
2351 atom_size = bytestream2_get_be32u(&
s->g);
2369 uint32_t atom2_size, atom2, atom2_end;
2373 atom2_size = bytestream2_get_be32u(&
s->g);
2374 atom2 = bytestream2_get_be32u(&
s->g);
2376 if (atom2_size < 8 || atom2_end > atom_end || atom2_end < atom2_size)
2381 }
else if (atom2 ==
MKBETAG(
'c',
'o',
'l',
'r') && atom2_size >= 7) {
2382 int method = bytestream2_get_byteu(&
s->g);
2385 s->colour_space = bytestream2_get_be32u(&
s->g);
2387 }
else if (atom2 ==
MKBETAG(
'p',
'c',
'l',
'r') && atom2_size >= 6) {
2388 int i,
size, colour_count, colour_channels, colour_depth[3];
2389 colour_count = bytestream2_get_be16u(&
s->g);
2390 colour_channels = bytestream2_get_byteu(&
s->g);
2392 colour_depth[0] = (bytestream2_get_byteu(&
s->g) & 0x7f) + 1;
2393 colour_depth[1] = (bytestream2_get_byteu(&
s->g) & 0x7f) + 1;
2394 colour_depth[2] = (bytestream2_get_byteu(&
s->g) & 0x7f) + 1;
2395 size = (colour_depth[0] + 7 >> 3) * colour_count +
2396 (colour_depth[1] + 7 >> 3) * colour_count +
2397 (colour_depth[2] + 7 >> 3) * colour_count;
2399 colour_channels != 3 ||
2400 colour_depth[0] > 16 ||
2401 colour_depth[1] > 16 ||
2402 colour_depth[2] > 16 ||
2403 atom2_size <
size) {
2409 for (
i = 0;
i < colour_count;
i++) {
2411 if (colour_depth[0] <= 8) {
2412 r = bytestream2_get_byteu(&
s->g) << 8 - colour_depth[0];
2413 r |=
r >> colour_depth[0];
2415 r = bytestream2_get_be16u(&
s->g) >> colour_depth[0] - 8;
2417 if (colour_depth[1] <= 8) {
2418 g = bytestream2_get_byteu(&
s->g) << 8 - colour_depth[1];
2419 g |=
g >> colour_depth[1];
2421 g = bytestream2_get_be16u(&
s->g) >> colour_depth[1] - 8;
2423 if (colour_depth[2] <= 8) {
2424 b = bytestream2_get_byteu(&
s->g) << 8 - colour_depth[2];
2425 b |=
b >> colour_depth[2];
2427 b = bytestream2_get_be16u(&
s->g) >> colour_depth[2] - 8;
2429 s->palette[
i] = 0xffu << 24 |
r << 16 |
g << 8 |
b;
2431 }
else if (atom2 ==
MKBETAG(
'c',
'd',
'e',
'f') && atom2_size >= 2) {
2432 int n = bytestream2_get_be16u(&
s->g);
2434 int cn = bytestream2_get_be16(&
s->g);
2435 int av_unused typ = bytestream2_get_be16(&
s->g);
2436 int asoc = bytestream2_get_be16(&
s->g);
2437 if (cn < 4 && asoc < 4)
2440 }
else if (atom2 ==
MKBETAG(
'r',
'e',
's',
' ') && atom2_size >= 18) {
2441 int64_t vnum, vden, hnum, hden, vexp, hexp;
2444 resx = bytestream2_get_be32u(&
s->g);
2445 if (resx !=
MKBETAG(
'r',
'e',
's',
'c') && resx !=
MKBETAG(
'r',
'e',
's',
'd')) {
2449 vnum = bytestream2_get_be16u(&
s->g);
2450 vden = bytestream2_get_be16u(&
s->g);
2451 hnum = bytestream2_get_be16u(&
s->g);
2452 hden = bytestream2_get_be16u(&
s->g);
2453 vexp = bytestream2_get_byteu(&
s->g);
2454 hexp = bytestream2_get_byteu(&
s->g);
2455 if (!vnum || !vden || !hnum || !hden) {
2467 if ( INT64_MAX / (hnum * vden) > pow(10, hexp)
2468 && INT64_MAX / (vnum * hden) > pow(10, vexp))
2470 hnum * vden * pow(10, hexp),
2471 vnum * hden * pow(10, vexp),
2475 }
while (atom_end - atom2_end >= 8);
2513 memset(
s->cdef, -1,
sizeof(
s->cdef));
2522 (bytestream2_get_be32u(&
s->g) == 12) &&
2527 "Could not find Jpeg2000 codestream atom.\n");
2562 memcpy(picture->
data[1],
s->palette, 256 *
sizeof(uint32_t));
2563 if (
s->sar.num &&
s->sar.den)
2565 s->sar.num =
s->sar.den = 0;
2574 #define OFFSET(x) offsetof(Jpeg2000DecoderContext, x)
2575 #define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
2578 {
"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(...)