42 #define JP2_SIG_TYPE 0x6A502020
43 #define JP2_SIG_VALUE 0x0D0A870A
44 #define JP2_CODESTREAM 0x6A703263
45 #define JP2_HEADER 0x6A703268
134 s->
bit_index = 7 + (bytestream2_get_byte(&s->
g) != 0xFF
u);
137 res |= (bytestream2_peek_byte(&s->
g) >> s->
bit_index) & 1;
144 if (bytestream2_get_byte(&s->
g) == 0xff)
154 int sp = -1, curval = 0;
161 while (node && !node->
vis) {
169 curval = stack[
sp]->
val;
171 while (curval < threshold && sp >= 0) {
172 if (curval < stack[sp]->
val)
173 curval = stack[
sp]->
val;
174 while (curval < threshold) {
184 stack[
sp]->
val = curval;
191 int bpc, uint32_t log2_chroma_wh,
int pal8)
202 switch (components) {
205 (log2_chroma_wh >> 14 & 3) == 0 &&
206 (log2_chroma_wh >> 12 & 3) == 0;
218 (log2_chroma_wh >> 2 & 3) == 0 &&
219 (log2_chroma_wh & 3) == 0 &&
227 #define RGB_PIXEL_FORMATS AV_PIX_FMT_PAL8,AV_PIX_FMT_RGB24,AV_PIX_FMT_RGBA,AV_PIX_FMT_RGB48,AV_PIX_FMT_RGBA64
228 #define GRAY_PIXEL_FORMATS AV_PIX_FMT_GRAY8,AV_PIX_FMT_GRAY8A,AV_PIX_FMT_GRAY16,AV_PIX_FMT_YA16
229 #define YUV_PIXEL_FORMATS AV_PIX_FMT_YUV410P,AV_PIX_FMT_YUV411P,AV_PIX_FMT_YUVA420P, \
230 AV_PIX_FMT_YUV420P,AV_PIX_FMT_YUV422P,AV_PIX_FMT_YUVA422P, \
231 AV_PIX_FMT_YUV440P,AV_PIX_FMT_YUV444P,AV_PIX_FMT_YUVA444P, \
232 AV_PIX_FMT_YUV420P9,AV_PIX_FMT_YUV422P9,AV_PIX_FMT_YUV444P9, \
233 AV_PIX_FMT_YUVA420P9,AV_PIX_FMT_YUVA422P9,AV_PIX_FMT_YUVA444P9, \
234 AV_PIX_FMT_YUV420P10,AV_PIX_FMT_YUV422P10,AV_PIX_FMT_YUV444P10, \
235 AV_PIX_FMT_YUVA420P10,AV_PIX_FMT_YUVA422P10,AV_PIX_FMT_YUVA444P10, \
236 AV_PIX_FMT_YUV420P12,AV_PIX_FMT_YUV422P12,AV_PIX_FMT_YUV444P12, \
237 AV_PIX_FMT_YUV420P14,AV_PIX_FMT_YUV422P14,AV_PIX_FMT_YUV444P14, \
238 AV_PIX_FMT_YUV420P16,AV_PIX_FMT_YUV422P16,AV_PIX_FMT_YUV444P16, \
239 AV_PIX_FMT_YUVA420P16,AV_PIX_FMT_YUVA422P16,AV_PIX_FMT_YUVA444P16
240 #define XYZ_PIXEL_FORMATS AV_PIX_FMT_XYZ12
258 uint32_t log2_chroma_wh = 0;
260 int possible_fmts_nb = 0;
268 s->
width = bytestream2_get_be32u(&s->
g);
269 s->
height = bytestream2_get_be32u(&s->
g);
276 ncomponents = bytestream2_get_be16u(&s->
g);
283 if (ncomponents <= 0) {
289 if (ncomponents > 4) {
309 uint8_t x = bytestream2_get_byteu(&s->
g);
310 s->
cbps[i] = (x & 0x7f) + 1;
312 s->
sgnd[i] = !!(x & 0x80);
313 s->
cdx[i] = bytestream2_get_byteu(&s->
g);
314 s->
cdy[i] = bytestream2_get_byteu(&s->
g);
315 if ( !s->
cdx[i] || s->
cdx[i] == 3 || s->
cdx[i] > 4
316 || !s->
cdy[i] || s->
cdy[i] == 3 || s->
cdy[i] > 4) {
320 log2_chroma_wh |= s->
cdy[i] >> 1 << i * 4 | s->
cdx[i] >> 1 << i * 4 + 2;
375 for (i = 0; i < possible_fmts_nb; ++i) {
382 if (i == possible_fmts_nb) {
383 if (ncomponents == 4 &&
384 s->
cdy[0] == 1 && s->
cdx[0] == 1 &&
385 s->
cdy[1] == 1 && s->
cdx[1] == 1 &&
399 if (i == possible_fmts_nb) {
401 "Unknown pix_fmt, profile: %d, colour_space: %d, "
402 "components: %d, precision: %d\n"
403 "cdx[0]: %d, cdy[0]: %d\n"
404 "cdx[1]: %d, cdy[1]: %d\n"
405 "cdx[2]: %d, cdy[2]: %d\n"
406 "cdx[3]: %d, cdy[3]: %d\n",
410 ncomponents > 1 ? s->
cdx[1] : 0,
411 ncomponents > 1 ? s->
cdy[1] : 0,
412 ncomponents > 2 ? s->
cdx[2] : 0,
413 ncomponents > 2 ? s->
cdy[2] : 0,
414 ncomponents > 3 ? s->
cdx[3] : 0,
415 ncomponents > 3 ? s->
cdy[3] : 0);
479 byte = bytestream2_get_byte(&s->
g);
509 tmp.
csty = bytestream2_get_byteu(&s->
g);
514 tmp.
nlayers = bytestream2_get_be16u(&s->
g);
515 tmp.
mct = bytestream2_get_byteu(&s->
g);
519 "MCT %"PRIu8
" with too few components (%d)\n",
524 if ((ret =
get_cox(s, &tmp)) < 0)
527 for (compno = 0; compno < s->
ncomponents; compno++)
528 if (!(properties[compno] &
HAD_COC))
529 memcpy(c + compno, &tmp,
sizeof(tmp));
545 compno = bytestream2_get_byteu(&s->
g);
549 "Invalid compno %d. There are %d components in the image.\n",
555 c->
csty = bytestream2_get_byteu(&s->
g);
572 x = bytestream2_get_byteu(&s->
g);
582 for (i = 0; i <
n; i++)
583 q->
expn[i] = bytestream2_get_byteu(&s->
g) >> 3;
587 x = bytestream2_get_be16u(&s->
g);
588 q->
expn[0] = x >> 11;
589 q->
mant[0] = x & 0x7ff;
591 int curexpn =
FFMAX(0, q->
expn[0] - (i - 1) / 3);
592 q->
expn[i] = curexpn;
600 for (i = 0; i <
n; i++) {
601 x = bytestream2_get_be16u(&s->
g);
602 q->
expn[i] = x >> 11;
603 q->
mant[i] = x & 0x7ff;
616 memset(&tmp, 0,
sizeof(tmp));
618 if ((ret =
get_qcx(s, n, &tmp)) < 0)
620 for (compno = 0; compno < s->
ncomponents; compno++)
621 if (!(properties[compno] &
HAD_QCC))
622 memcpy(q + compno, &tmp,
sizeof(tmp));
636 compno = bytestream2_get_byteu(&s->
g);
640 "Invalid compno %d. There are %d components in the image.\n",
646 return get_qcx(s, n - 1, q + compno);
665 tmp.
nb_poc = (size - 2) / elem_size;
671 for (i = 0; i<tmp.
nb_poc; i++) {
673 e->
RSpoc = bytestream2_get_byteu(&s->
g);
674 e->
CSpoc = bytestream2_get_byteu(&s->
g);
675 e->
LYEpoc = bytestream2_get_be16u(&s->
g);
676 e->
REpoc = bytestream2_get_byteu(&s->
g);
677 e->
CEpoc = bytestream2_get_byteu(&s->
g);
678 e->
Ppoc = bytestream2_get_byteu(&s->
g);
722 Isot = bytestream2_get_be16u(&s->
g);
727 Psot = bytestream2_get_be32u(&s->
g);
728 TPsot = bytestream2_get_byteu(&s->
g);
731 bytestream2_get_byteu(&s->
g);
754 memcpy(&tile->
poc , &s->
poc ,
sizeof(tile->
poc));
772 bytestream2_get_byte(&s->
g);
773 Stlm = bytestream2_get_byte(&s->
g);
776 ST = (Stlm >> 4) & 0x03;
778 SP = (Stlm >> 6) & 0x01;
779 tile_tlm = (n - 4) / ((SP + 1) * 2 + ST);
780 for (i = 0; i < tile_tlm; i++) {
785 bytestream2_get_byte(&s->
g);
788 bytestream2_get_be16(&s->
g);
791 bytestream2_get_be32(&s->
g);
795 bytestream2_get_be16(&s->
g);
797 bytestream2_get_be32(&s->
g);
810 bytestream2_get_byte(&s->
g);
812 for (i = 0; i < n - 3; i++) {
813 bytestream2_get_byte(&s->
g);
834 for (compno = 0; compno < s->
ncomponents; compno++) {
857 s->
cbps[compno], s->
cdx[compno],
873 return num < 0 ? num : 3 + num;
875 return num < 0 ? num : 6 + num;
877 return num < 0 ? num : 37 + num;
894 int layno,
uint8_t *expn,
int numgbits)
896 int bandno, cblkno, ret, nb_code_blocks;
899 if (layno < rlevel->
band[0].prec[precno].decoded_layers)
918 for (bandno = 0; bandno < rlevel->
nbands; bandno++) {
927 for (cblkno = 0; cblkno < nb_code_blocks; cblkno++) {
929 int incl, newpasses, llen;
941 int v = expn[bandno] + numgbits - 1 -
945 "nonzerobits %d invalid\n", v);
961 "Block with length beyond 16 bits");
972 while (newpasses1 < newpasses) {
982 if (ret >
sizeof(cblk->
data)) {
990 newpasses -= newpasses1;
1003 for (bandno = 0; bandno < rlevel->
nbands; bandno++) {
1008 for (cblkno = 0; cblkno < nb_code_blocks; cblkno++) {
1010 for (cwsno = 0; cwsno < cblk->
nb_lengthinc; cwsno ++) {
1015 "Block length %"PRIu16
" or lengthinc %d is too large, left %d\n",
1037 int RSpoc,
int CSpoc,
1038 int LYEpoc,
int REpoc,
int CEpoc,
1039 int Ppoc,
int *tp_index)
1042 int layno, reslevelno, compno, precno, ok_reslevel;
1050 for (reslevelno = RSpoc; ok_reslevel && reslevelno < REpoc; reslevelno++) {
1052 for (layno = 0; layno < LYEpoc; layno++) {
1053 for (compno = CSpoc; compno < CEpoc; compno++) {
1056 if (reslevelno < codsty->nreslevels) {
1064 qntsty->
expn + (reslevelno ? 3 * (reslevelno - 1) + 1 : 0),
1075 for (layno = 0; layno < LYEpoc; layno++) {
1077 for (reslevelno = RSpoc; ok_reslevel && reslevelno < REpoc; reslevelno++) {
1079 for (compno = CSpoc; compno < CEpoc; compno++) {
1082 if (reslevelno < codsty->nreslevels) {
1090 qntsty->
expn + (reslevelno ? 3 * (reslevelno - 1) + 1 : 0),
1101 for (compno = CSpoc; compno < CEpoc; compno++) {
1108 for (reslevelno = RSpoc; reslevelno <
FFMIN(codsty->
nreslevels, REpoc); reslevelno++) {
1118 for (y = tile->
coord[1][0]; y < tile->coord[1][1]; y = (y/step_y + 1)*step_y) {
1119 for (x = tile->
coord[0][0]; x < tile->coord[0][1]; x = (x/step_x + 1)*step_x) {
1120 for (reslevelno = RSpoc; reslevelno <
FFMIN(codsty->
nreslevels, REpoc); reslevelno++) {
1121 unsigned prcx, prcy;
1124 int xc = x / s->
cdx[compno];
1125 int yc = y / s->
cdy[compno];
1147 for (layno = 0; layno < LYEpoc; layno++) {
1150 qntsty->
expn + (reslevelno ? 3 * (reslevelno - 1) + 1 : 0),
1163 for (reslevelno = RSpoc; ok_reslevel && reslevelno < REpoc; reslevelno++) {
1167 for (compno = CSpoc; compno < CEpoc; compno++) {
1171 if (reslevelno < codsty->nreslevels) {
1181 for (y = tile->
coord[1][0]; y < tile->coord[1][1]; y = (y/step_y + 1)*step_y) {
1182 for (x = tile->
coord[0][0]; x < tile->coord[0][1]; x = (x/step_x + 1)*step_x) {
1183 for (compno = CSpoc; compno < CEpoc; compno++) {
1189 unsigned prcx, prcy;
1191 int xc = x / s->
cdx[compno];
1192 int yc = y / s->
cdy[compno];
1218 for (layno = 0; layno < LYEpoc; layno++) {
1222 qntsty->
expn + (reslevelno ? 3 * (reslevelno - 1) + 1 : 0),
1236 for (compno = CSpoc; compno < CEpoc; compno++) {
1240 for (reslevelno = RSpoc; reslevelno <
FFMIN(codsty->
nreslevels, REpoc); reslevelno++) {
1250 for (y = tile->
coord[1][0]; y < tile->coord[1][1]; y = (y/step_y + 1)*step_y) {
1251 for (x = tile->
coord[0][0]; x < tile->coord[0][1]; x = (x/step_x + 1)*step_x) {
1252 for (compno = CSpoc; compno < CEpoc; compno++) {
1256 int xc = x / s->
cdx[compno];
1257 int yc = y / s->
cdy[compno];
1259 for (reslevelno = RSpoc; reslevelno <
FFMIN(codsty->
nreslevels, REpoc); reslevelno++) {
1260 unsigned prcx, prcy;
1284 for (layno = 0; layno < LYEpoc; layno++) {
1287 qntsty->
expn + (reslevelno ? 3 * (reslevelno - 1) + 1 : 0),
1342 int bpno,
int bandno,
1343 int vert_causal_ctx_csty_symbol)
1345 int mask = 3 << (bpno - 1), y0, x,
y;
1347 for (y0 = 0; y0 <
height; y0 += 4)
1348 for (x = 0; x <
width; x++)
1349 for (
y = y0;
y < height &&
y < y0 + 4;
y++) {
1350 int flags_mask = -1;
1351 if (vert_causal_ctx_csty_symbol &&
y == y0 + 3)
1372 int bpno,
int vert_causal_ctx_csty_symbol)
1377 phalf = 1 << (bpno - 1);
1380 for (y0 = 0; y0 <
height; y0 += 4)
1381 for (x = 0; x <
width; x++)
1382 for (y = y0; y < height && y < y0 + 4; y++)
1384 int flags_mask = (vert_causal_ctx_csty_symbol && y == y0 + 3) ?
1397 int seg_symbols,
int vert_causal_ctx_csty_symbol)
1399 int mask = 3 << (bpno - 1), y0, x,
y, runlen, dec;
1401 for (y0 = 0; y0 <
height; y0 += 4) {
1402 for (x = 0; x <
width; x++) {
1403 int flags_mask = -1;
1404 if (vert_causal_ctx_csty_symbol)
1406 if (y0 + 3 < height &&
1424 for (
y = y0 + runlen;
y < y0 + 4 &&
y <
height;
y++) {
1425 int flags_mask = -1;
1426 if (vert_causal_ctx_csty_symbol &&
y == y0 + 3)
1457 "Segmentation symbol value incorrect\n");
1490 vert_causal_ctx_csty_symbol);
1493 decode_refpass(t1, width, height, bpno + 1, vert_causal_ctx_csty_symbol);
1499 vert_causal_ctx_csty_symbol);
1527 if (cblk->
data + cblk->
length - 2*(term_cnt < cblk->nb_terminations) != t1->
mqc.
bp) {
1529 cblk->
data + cblk->
length - 2*(term_cnt < cblk->nb_terminations) - t1->
mqc.
bp);
1547 int w = cblk->
coord[0][1] - cblk->
coord[0][0];
1548 for (j = 0; j < (cblk->
coord[1][1] - cblk->
coord[1][0]); ++j) {
1549 float *datap = &comp->
f_data[(comp->
coord[0][1] - comp->
coord[0][0]) * (y + j) + x];
1551 for (i = 0; i < w; ++i)
1562 int w = cblk->
coord[0][1] - cblk->
coord[0][0];
1563 for (j = 0; j < (cblk->
coord[1][1] - cblk->
coord[1][0]); ++j) {
1567 for (i = 0; i < w; ++i)
1568 datap[i] = src[i] / 2;
1571 for (i = 0; i < w; ++i)
1572 datap[i] = (src[i] * (int64_t)band->
i_stepsize) / 65536;
1582 int w = cblk->
coord[0][1] - cblk->
coord[0][0];
1583 for (j = 0; j < (cblk->
coord[1][1] - cblk->
coord[1][0]); ++j) {
1586 for (i = 0; i < w; ++i)
1587 datap[i] = (src[i] * (int64_t)band->
i_stepsize + (1<<15)) >> 16;
1596 for (i = 1; i < 3; i++) {
1607 for (i = 0; i < 3; i++)
1613 for (i = 0; i < 2; i++)
1623 int compno, reslevelno, bandno;
1632 for (compno = 0; compno < s->
ncomponents; compno++) {
1642 for (bandno = 0; bandno < rlevel->
nbands; bandno++) {
1643 int nb_precincts, precno;
1645 int cblkno = 0, bandpos;
1647 bandpos = bandno + (reslevelno > 0);
1649 if (band->
coord[0][0] == band->
coord[0][1] ||
1655 for (precno = 0; precno < nb_precincts; precno++) {
1689 if (s->
cdef[0] < 0) {
1697 for (compno = 0; compno < s->
ncomponents; compno++) {
1700 float *datap = comp->
f_data;
1702 int cbps = s->
cbps[compno];
1716 dst = line + x * pixelsize + compno*!planar;
1719 for (; x < w; x ++) {
1720 int val =
lrintf(*datap) + (1 << (cbps - 1));
1722 val = av_clip(val, 0, (1 << cbps) - 1);
1723 *dst = val << (8 - cbps);
1728 for (; x < w; x ++) {
1729 int val = *i_datap + (1 << (cbps - 1));
1731 val = av_clip(val, 0, (1 << cbps) - 1);
1732 *dst = val << (8 - cbps);
1746 for (compno = 0; compno < s->
ncomponents; compno++) {
1749 float *datap = comp->
f_data;
1752 int cbps = s->
cbps[compno];
1760 linel = (uint16_t *)picture->
data[plane] + y * (picture->
linesize[plane] >> 1);
1765 dst = linel + (x * pixelsize + compno*!planar);
1767 for (; x < w; x ++) {
1768 int val =
lrintf(*datap) + (1 << (cbps - 1));
1770 val = av_clip(val, 0, (1 << cbps) - 1);
1772 *dst = val << (precision - cbps);
1777 for (; x < w; x ++) {
1778 int val = *i_datap + (1 << (cbps - 1));
1780 val = av_clip(val, 0, (1 << cbps) - 1);
1782 *dst = val << (precision - cbps);
1800 for (compno = 0; compno < s->
ncomponents; compno++) {
1812 memset(&s->
poc , 0,
sizeof(s->
poc));
1833 marker = bytestream2_get_be16u(&s->
g);
1863 len = bytestream2_get_be16(&s->
g);
1876 ret =
get_coc(s, codsty, properties);
1879 ret =
get_cod(s, codsty, properties);
1882 ret =
get_qcc(s, len, qntsty, properties);
1885 ret =
get_qcd(s, len, qntsty, properties);
1891 if (!(ret =
get_sot(s, len))) {
1913 "unsupported marker 0x%.4"PRIX16
" at pos 0x%X\n",
1920 "error during processing marker segment %.4"PRIx16
"\n",
1922 return ret ? ret : -1;
1950 uint32_t atom_size, atom, atom_end;
1951 int search_range = 10;
1956 atom_size = bytestream2_get_be32u(&s->
g);
1957 atom = bytestream2_get_be32u(&s->
g);
1968 uint32_t atom2_size, atom2, atom2_end;
1970 atom2_size = bytestream2_get_be32u(&s->
g);
1971 atom2 = bytestream2_get_be32u(&s->
g);
1973 if (atom2_size < 8 || atom2_end > atom_end || atom2_end < atom2_size)
1977 }
else if (atom2 ==
MKBETAG(
'c',
'o',
'l',
'r') && atom2_size >= 7) {
1978 int method = bytestream2_get_byteu(&s->
g);
1983 }
else if (atom2 ==
MKBETAG(
'p',
'c',
'l',
'r') && atom2_size >= 6) {
1984 int i,
size, colour_count, colour_channels, colour_depth[3];
1986 colour_count = bytestream2_get_be16u(&s->
g);
1987 colour_channels = bytestream2_get_byteu(&s->
g);
1989 colour_depth[0] = (bytestream2_get_byteu(&s->
g) & 0x7f) + 1;
1990 colour_depth[1] = (bytestream2_get_byteu(&s->
g) & 0x7f) + 1;
1991 colour_depth[2] = (bytestream2_get_byteu(&s->
g) & 0x7f) + 1;
1992 size = (colour_depth[0] + 7 >> 3) * colour_count +
1993 (colour_depth[1] + 7 >> 3) * colour_count +
1994 (colour_depth[2] + 7 >> 3) * colour_count;
1995 if (colour_count > 256 ||
1996 colour_channels != 3 ||
1997 colour_depth[0] > 16 ||
1998 colour_depth[1] > 16 ||
1999 colour_depth[2] > 16 ||
2000 atom2_size < size) {
2006 for (i = 0; i < colour_count; i++) {
2007 if (colour_depth[0] <= 8) {
2008 r = bytestream2_get_byteu(&s->
g) << 8 - colour_depth[0];
2009 r |= r >> colour_depth[0];
2011 r = bytestream2_get_be16u(&s->
g) >> colour_depth[0] - 8;
2013 if (colour_depth[1] <= 8) {
2014 g = bytestream2_get_byteu(&s->
g) << 8 - colour_depth[1];
2015 r |= r >> colour_depth[1];
2017 g = bytestream2_get_be16u(&s->
g) >> colour_depth[1] - 8;
2019 if (colour_depth[2] <= 8) {
2020 b = bytestream2_get_byteu(&s->
g) << 8 - colour_depth[2];
2021 r |= r >> colour_depth[2];
2023 b = bytestream2_get_be16u(&s->
g) >> colour_depth[2] - 8;
2025 s->
palette[i] = 0xff
u << 24 | r << 16 | g << 8 |
b;
2027 }
else if (atom2 ==
MKBETAG(
'c',
'd',
'e',
'f') && atom2_size >= 2) {
2028 int n = bytestream2_get_be16u(&s->
g);
2030 int cn = bytestream2_get_be16(&s->
g);
2031 int av_unused typ = bytestream2_get_be16(&s->
g);
2032 int asoc = bytestream2_get_be16(&s->
g);
2033 if (cn < 4 && asoc < 4)
2038 }
while (atom_end - atom2_end >= 8);
2068 memset(s->
cdef, -1,
sizeof(s->
cdef));
2077 (bytestream2_get_be32u(&s->
g) == 12) &&
2082 "Could not find Jpeg2000 codestream atom.\n");
2119 memcpy(picture->
data[1], s->
palette, 256 *
sizeof(uint32_t));
2134 #define OFFSET(x) offsetof(Jpeg2000DecoderContext, x)
2135 #define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
2138 {
"lowres",
"Lower the decoding resolution by a power of two",
2169 .priv_class = &jpeg2000_class,
#define AV_PIX_FMT_FLAG_PAL
Pixel format has a palette in data[1], values are indexes in this palette.
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)
void ff_mqc_initdec(MqcState *mqc, uint8_t *bp, int raw, int reset)
Initialize MQ-decoder.
#define JPEG2000_CBLK_VSC
const char const char void * val
void(* mct_decode[FF_DWT_NB])(void *src0, void *src1, void *src2, int csize)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
void av_cold ff_jpeg2000_init_tier1_luts(void)
static enum AVPixelFormat pix_fmt
void ff_jpeg2000_cleanup(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
This structure describes decoded (raw) audio or video data.
static int jpeg2000_read_main_headers(Jpeg2000DecoderContext *s)
ptrdiff_t const GLvoid * data
Jpeg2000TgtNode * cblkincl
static enum AVPixelFormat xyz_pix_fmts[]
static int jpeg2000_decode_tile(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile, AVFrame *picture)
#define JPEG2000_T1_SIG_NB
#define FF_PROFILE_JPEG2000_CSTREAM_NO_RESTRICTION
#define AV_LOG_WARNING
Something somehow does not look correct.
#define LIBAVUTIL_VERSION_INT
#define RGB_PIXEL_FORMATS
#define JPEG2000_PGOD_PCRL
static enum AVPixelFormat all_pix_fmts[]
static av_cold int init(AVCodecContext *avctx)
static uint64_t SP[8][256]
#define AV_PIX_FMT_RGBA64
static void decode_refpass(Jpeg2000T1Context *t1, int width, int height, int bpno, int vert_causal_ctx_csty_symbol)
#define JPEG2000_PGOD_RLCP
static void jpeg2000_flush(Jpeg2000DecoderContext *s)
static int get_qcc(Jpeg2000DecoderContext *s, int n, Jpeg2000QuantStyle *q, uint8_t *properties)
Jpeg2000QuantStyle qntsty[4]
static void mct_decode(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile)
void ff_mqc_init_contexts(MqcState *mqc)
MQ-coder context initialisations.
#define FF_CODEC_PROPERTY_LOSSLESS
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
uint16_t mant[JPEG2000_MAX_DECLEVELS *3]
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
av_cold void ff_jpeg2000dsp_init(Jpeg2000DSPContext *c)
static av_cold int jpeg2000_decode_init(AVCodecContext *avctx)
static int get_qcd(Jpeg2000DecoderContext *s, int n, Jpeg2000QuantStyle *q, uint8_t *properties)
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
static int init_tile(Jpeg2000DecoderContext *s, int tileno)
Jpeg2000CodingStyle codsty[4]
uint16_t nb_codeblocks_height
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
static void dequantization_int(int x, int y, Jpeg2000Cblk *cblk, Jpeg2000Component *comp, Jpeg2000T1Context *t1, Jpeg2000Band *band)
static int get_cod(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c, uint8_t *properties)
static av_always_inline unsigned int bytestream2_get_bufferu(GetByteContext *g, uint8_t *dst, unsigned int size)
Macro definitions for various function/variable attributes.
static int jpeg2000_read_bitstream_packets(Jpeg2000DecoderContext *s)
static enum AVPixelFormat rgb_pix_fmts[]
#define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_1
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
static void dequantization_float(int x, int y, Jpeg2000Cblk *cblk, Jpeg2000Component *comp, Jpeg2000T1Context *t1, Jpeg2000Band *band)
static int jpeg2000_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
8 bit with AV_PIX_FMT_RGB32 palette
static av_cold int end(AVCodecContext *avctx)
Multithreading support functions.
Jpeg2000TgtNode * zerobits
#define FF_PROFILE_UNKNOWN
static int tag_tree_decode(Jpeg2000DecoderContext *s, Jpeg2000TgtNode *node, int threshold)
static av_cold void init_static_data(void)
static av_always_inline void bytestream2_skipu(GetByteContext *g, unsigned int size)
Jpeg2000POCEntry poc[MAX_POCS]
#define JPEG2000_T1_SIG_SE
static uint8_t get_tlm(Jpeg2000DecoderContext *s, int n)
#define JPEG2000_CBLK_SEGSYM
uint8_t log2_prec_widths[JPEG2000_MAX_RESLEVELS]
static int get_poc(Jpeg2000DecoderContext *s, int size, Jpeg2000POC *p)
#define JPEG2000_CSTY_EPH
uint16_t depth_minus1
Number of bits in the component minus 1.
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 AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int getnpasses(Jpeg2000DecoderContext *s)
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
static const uint16_t mask[17]
#define PTRDIFF_SPECIFIER
#define YUV_PIXEL_FORMATS
void ff_jpeg2000_set_significance(Jpeg2000T1Context *t1, int x, int y, int negative)
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
static enum AVPixelFormat gray_pix_fmts[]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
#define JPEG2000_PGOD_CPRL
static int get_coc(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c, uint8_t *properties)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
uint8_t log2_prec_heights[JPEG2000_MAX_RESLEVELS]
static av_always_inline unsigned int bytestream2_get_bytes_left(GetByteContext *g)
int flags
AV_CODEC_FLAG_*.
#define JPEG2000_MAX_PASSES
simple assert() macros that are a bit more flexible than ISO C assert().
const char * name
Name of the codec implementation.
#define JPEG2000_CBLK_RESET
static uint8_t get_plt(Jpeg2000DecoderContext *s, int n)
Libavcodec external API header.
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
#define JPEG2000_SOP_FIXED_BYTES
static int get_cox(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c)
static const AVClass jpeg2000_class
uint8_t nb_components
The number of components each pixel has, (1-4)
enum AVPictureType pict_type
Picture type of the frame.
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
#define AV_PIX_FMT_GRAY16
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
struct Jpeg2000TgtNode * parent
#define JPEG2000_T1_SGN_S
int width
picture width / height.
JPEG 2000 structures and defines common to encoder and decoder.
#define JPEG2000_MAX_RESLEVELS
static int needs_termination(int style, int passno)
#define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_0
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
static av_cold void jpeg2000_init_static_data(AVCodec *codec)
static int ff_jpeg2000_getsigctxno(int flag, int bandno)
#define JPEG2000_MAX_DECLEVELS
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)
Jpeg2000TilePart tile_part[256]
static int get_siz(Jpeg2000DecoderContext *s)
static const AVProfile profiles[]
#define FF_ARRAY_ELEMS(a)
uint16_t lengthinc[JPEG2000_MAX_PASSES]
#define JPEG2000_PGOD_RPCL
static int ff_jpeg2000_ceildivpow2(int a, int b)
#define FF_PROFILE_JPEG2000_DCINEMA_4K
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
static av_always_inline int bytestream2_tell(GetByteContext *g)
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
int data_start[JPEG2000_MAX_PASSES]
static enum AVPixelFormat yuv_pix_fmts[]
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_WB16 unsigned int_TMPL byte
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
int ff_mqc_decode(MqcState *mqc, uint8_t *cxstate)
MQ decoder.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
main external API structure.
AVCodec ff_jpeg2000_decoder
static int pix_fmt_match(enum AVPixelFormat pix_fmt, int components, int bpc, uint32_t log2_chroma_wh, int pal8)
void av_cold ff_mqc_init_context_tables(void)
MQ-coder Initialize context tables (QE, NLPS, NMPS)
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
BYTE int const BYTE int int int height
static int getlblockinc(Jpeg2000DecoderContext *s)
Describe the class of an AVClass context structure.
uint16_t nb_codeblocks_width
#define JPEG2000_SOP_BYTE_LENGTH
static const AVOption options[]
#define JPEG2000_T1_SIG_S
Jpeg2000ResLevel * reslevel
static int ff_jpeg2000_ceildiv(int a, int b)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
uint8_t expn[JPEG2000_MAX_DECLEVELS *3]
static int jpeg2000_decode_packets(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile)
#define FF_PROFILE_JPEG2000_DCINEMA_2K
static int get_sot(Jpeg2000DecoderContext *s, int n)
static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avpkt)
static int jp2_find_codestream(Jpeg2000DecoderContext *s)
static void jpeg2000_dec_cleanup(Jpeg2000DecoderContext *s)
static void decode_sigpass(Jpeg2000T1Context *t1, int width, int height, int bpno, int bandno, int vert_causal_ctx_csty_symbol)
static void dequantization_int_97(int x, int y, Jpeg2000Cblk *cblk, Jpeg2000Component *comp, Jpeg2000T1Context *t1, Jpeg2000Band *band)
common internal api header.
common internal and external API header
Jpeg2000QuantStyle qntsty[4]
int ff_dwt_decode(DWTContext *s, void *t)
#define XYZ_PIXEL_FORMATS
#define GRAY_PIXEL_FORMATS
#define MKBETAG(a, b, c, d)
#define JPEG2000_CBLK_BYPASS
int ff_jpeg2000_init_component(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty, Jpeg2000QuantStyle *qntsty, int cbps, int dx, int dy, AVCodecContext *avctx)
#define JPEG2000_T1_SIG_SW
#define JPEG2000_PGOD_LRCP
static int get_bits(Jpeg2000DecoderContext *s, int n)
int key_frame
1 -> keyframe, 0-> not
static av_always_inline int bytestream2_seek(GetByteContext *g, int offset, int whence)
static void * av_mallocz_array(size_t nmemb, size_t size)
static void comp(unsigned char *dst, int dst_stride, unsigned char *src, int src_stride, int add)
static int ff_jpeg2000_getrefctxno(int flag)
#define JPEG2000_CSTY_PREC
AVPixelFormat
Pixel format.
This structure stores compressed data.
static int get_qcx(Jpeg2000DecoderContext *s, int n, Jpeg2000QuantStyle *q)
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Jpeg2000CodingStyle codsty[4]
static int decode_cblk(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *codsty, Jpeg2000T1Context *t1, Jpeg2000Cblk *cblk, int width, int height, int bandpos)
static int ff_jpeg2000_getsgnctxno(int flag, int *xorbit)