42 #define JP2_SIG_TYPE 0x6A502020
43 #define JP2_SIG_VALUE 0x0D0A870A
44 #define JP2_CODESTREAM 0x6A703263
45 #define JP2_HEADER 0x6A703268
114 s->
bit_index = 7 + (bytestream2_get_byte(&s->
g) != 0xFF
u);
117 res |= (bytestream2_peek_byte(&s->
g) >> s->
bit_index) & 1;
124 if (bytestream2_get_byte(&s->
g) == 0xff)
134 int sp = -1, curval = 0;
139 while (node && !node->
vis) {
147 curval = stack[
sp]->
val;
149 while (curval < threshold && sp >= 0) {
150 if (curval < stack[sp]->
val)
151 curval = stack[
sp]->
val;
152 while (curval < threshold) {
162 stack[
sp]->
val = curval;
169 int bpc, uint32_t log2_chroma_wh,
int pal8)
178 switch (components) {
181 (log2_chroma_wh >> 14 & 3) == 0 &&
182 (log2_chroma_wh >> 12 & 3) == 0;
194 (log2_chroma_wh >> 2 & 3) == 0 &&
195 (log2_chroma_wh & 3) == 0 &&
203 #define RGB_PIXEL_FORMATS AV_PIX_FMT_PAL8,AV_PIX_FMT_RGB24,AV_PIX_FMT_RGBA,AV_PIX_FMT_RGB48,AV_PIX_FMT_RGBA64
204 #define GRAY_PIXEL_FORMATS AV_PIX_FMT_GRAY8,AV_PIX_FMT_GRAY8A,AV_PIX_FMT_GRAY16,AV_PIX_FMT_YA16
205 #define YUV_PIXEL_FORMATS AV_PIX_FMT_YUV410P,AV_PIX_FMT_YUV411P,AV_PIX_FMT_YUVA420P, \
206 AV_PIX_FMT_YUV420P,AV_PIX_FMT_YUV422P,AV_PIX_FMT_YUVA422P, \
207 AV_PIX_FMT_YUV440P,AV_PIX_FMT_YUV444P,AV_PIX_FMT_YUVA444P, \
208 AV_PIX_FMT_YUV420P9,AV_PIX_FMT_YUV422P9,AV_PIX_FMT_YUV444P9, \
209 AV_PIX_FMT_YUVA420P9,AV_PIX_FMT_YUVA422P9,AV_PIX_FMT_YUVA444P9, \
210 AV_PIX_FMT_YUV420P10,AV_PIX_FMT_YUV422P10,AV_PIX_FMT_YUV444P10, \
211 AV_PIX_FMT_YUVA420P10,AV_PIX_FMT_YUVA422P10,AV_PIX_FMT_YUVA444P10, \
212 AV_PIX_FMT_YUV420P12,AV_PIX_FMT_YUV422P12,AV_PIX_FMT_YUV444P12, \
213 AV_PIX_FMT_YUV420P14,AV_PIX_FMT_YUV422P14,AV_PIX_FMT_YUV444P14, \
214 AV_PIX_FMT_YUV420P16,AV_PIX_FMT_YUV422P16,AV_PIX_FMT_YUV444P16, \
215 AV_PIX_FMT_YUVA420P16,AV_PIX_FMT_YUVA422P16,AV_PIX_FMT_YUVA444P16
216 #define XYZ_PIXEL_FORMATS AV_PIX_FMT_XYZ12
233 uint32_t log2_chroma_wh = 0;
235 int possible_fmts_nb = 0;
241 s->
width = bytestream2_get_be32u(&s->
g);
242 s->
height = bytestream2_get_be32u(&s->
g);
249 ncomponents = bytestream2_get_be16u(&s->
g);
256 if (ncomponents <= 0) {
262 if (ncomponents > 4) {
280 uint8_t x = bytestream2_get_byteu(&s->
g);
281 s->
cbps[i] = (x & 0x7f) + 1;
283 s->
sgnd[i] = !!(x & 0x80);
284 s->
cdx[i] = bytestream2_get_byteu(&s->
g);
285 s->
cdy[i] = bytestream2_get_byteu(&s->
g);
286 if ( !s->
cdx[i] || s->
cdx[i] == 3 || s->
cdx[i] > 4
287 || !s->
cdy[i] || s->
cdy[i] == 3 || s->
cdy[i] > 4) {
291 log2_chroma_wh |= s->
cdy[i] >> 1 << i * 4 | s->
cdx[i] >> 1 << i * 4 + 2;
346 for (i = 0; i < possible_fmts_nb; ++i) {
352 if (i == possible_fmts_nb) {
354 "Unknown pix_fmt, profile: %d, colour_space: %d, "
355 "components: %d, precision: %d, "
356 "cdx[1]: %d, cdy[1]: %d, cdx[2]: %d, cdy[2]: %d\n",
358 ncomponents > 2 ? s->
cdx[1] : 0,
359 ncomponents > 2 ? s->
cdy[1] : 0,
360 ncomponents > 2 ? s->
cdx[2] : 0,
361 ncomponents > 2 ? s->
cdy[2] : 0);
423 byte = bytestream2_get_byte(&s->
g);
444 tmp.
csty = bytestream2_get_byteu(&s->
g);
449 tmp.
nlayers = bytestream2_get_be16u(&s->
g);
450 tmp.
mct = bytestream2_get_byteu(&s->
g);
454 "MCT %"PRIu8
" with too few components (%d)\n",
459 if ((ret =
get_cox(s, &tmp)) < 0)
462 for (compno = 0; compno < s->
ncomponents; compno++)
463 if (!(properties[compno] &
HAD_COC))
464 memcpy(c + compno, &tmp,
sizeof(tmp));
478 compno = bytestream2_get_byteu(&s->
g);
482 "Invalid compno %d. There are %d components in the image.\n",
488 c->
csty = bytestream2_get_byteu(&s->
g);
505 x = bytestream2_get_byteu(&s->
g);
515 for (i = 0; i <
n; i++)
516 q->
expn[i] = bytestream2_get_byteu(&s->
g) >> 3;
520 x = bytestream2_get_be16u(&s->
g);
521 q->
expn[0] = x >> 11;
522 q->
mant[0] = x & 0x7ff;
524 int curexpn =
FFMAX(0, q->
expn[0] - (i - 1) / 3);
525 q->
expn[i] = curexpn;
533 for (i = 0; i <
n; i++) {
534 x = bytestream2_get_be16u(&s->
g);
535 q->
expn[i] = x >> 11;
536 q->
mant[i] = x & 0x7ff;
549 memset(&tmp, 0,
sizeof(tmp));
551 if ((ret =
get_qcx(s, n, &tmp)) < 0)
553 for (compno = 0; compno < s->
ncomponents; compno++)
554 if (!(properties[compno] &
HAD_QCC))
555 memcpy(q + compno, &tmp,
sizeof(tmp));
569 compno = bytestream2_get_byteu(&s->
g);
573 "Invalid compno %d. There are %d components in the image.\n",
579 return get_qcx(s, n - 1, q + compno);
594 Isot = bytestream2_get_be16u(&s->
g);
599 Psot = bytestream2_get_be32u(&s->
g);
600 TPsot = bytestream2_get_byteu(&s->
g);
603 bytestream2_get_byteu(&s->
g);
645 bytestream2_get_byte(&s->
g);
646 Stlm = bytestream2_get_byte(&s->
g);
649 ST = (Stlm >> 4) & 0x03;
651 SP = (Stlm >> 6) & 0x01;
652 tile_tlm = (n - 4) / ((SP + 1) * 2 + ST);
653 for (i = 0; i < tile_tlm; i++) {
658 bytestream2_get_byte(&s->
g);
661 bytestream2_get_be16(&s->
g);
664 bytestream2_get_be32(&s->
g);
668 bytestream2_get_be16(&s->
g);
670 bytestream2_get_be32(&s->
g);
683 bytestream2_get_byte(&s->
g);
685 for (i = 0; i < n - 3; i++) {
686 bytestream2_get_byte(&s->
g);
702 for (compno = 0; compno < s->
ncomponents; compno++) {
725 s->
cbps[compno], s->
cdx[compno],
741 return num < 0 ? num : 3 + num;
743 return num < 0 ? num : 6 + num;
745 return num < 0 ? num : 37 + num;
762 int layno,
uint8_t *expn,
int numgbits)
764 int bandno, cblkno,
ret, nb_code_blocks;
772 for (bandno = 0; bandno < rlevel->
nbands; bandno++) {
781 for (cblkno = 0; cblkno < nb_code_blocks; cblkno++) {
783 int incl, newpasses, llen;
795 int v = expn[bandno] + numgbits - 1 -
799 "nonzerobits %d invalid\n", v);
811 if (ret >
sizeof(cblk->
data)) {
830 for (bandno = 0; bandno < rlevel->
nbands; bandno++) {
835 for (cblkno = 0; cblkno < nb_code_blocks; cblkno++) {
841 "Block length %"PRIu16
" or lengthinc %d is too large\n",
857 int layno, reslevelno, compno, precno, ok_reslevel;
868 for (reslevelno = 0; ok_reslevel; reslevelno++) {
870 for (compno = 0; compno < s->
ncomponents; compno++) {
873 if (reslevelno < codsty->nreslevels) {
881 qntsty->
expn + (reslevelno ? 3 * (reslevelno - 1) + 1 : 0),
891 for (compno = 0; compno < s->
ncomponents; compno++) {
903 for (y = 0; y < s->
height; y += 256) {
907 for (x = 0; x < s->
width; x += 256) {
908 for (reslevelno = 0; reslevelno < codsty->
nreslevels; reslevelno++) {
932 qntsty->
expn + (reslevelno ? 3 * (reslevelno - 1) + 1 : 0),
964 int bpno,
int bandno,
int bpass_csty_symbol,
965 int vert_causal_ctx_csty_symbol)
967 int mask = 3 << (bpno - 1), y0, x,
y;
969 for (y0 = 0; y0 <
height; y0 += 4)
970 for (x = 0; x <
width; x++)
971 for (
y = y0;
y < height &&
y < y0 + 4;
y++) {
975 if (vert_causal_ctx_csty_symbol &&
y == y0 + 3)
979 if (bpass_csty_symbol)
999 phalf = 1 << (bpno - 1);
1002 for (y0 = 0; y0 <
height; y0 += 4)
1003 for (x = 0; x <
width; x++)
1004 for (y = y0; y < height && y < y0 + 4; y++)
1017 int seg_symbols,
int vert_causal_ctx_csty_symbol)
1019 int mask = 3 << (bpno - 1), y0, x,
y, runlen, dec;
1021 for (y0 = 0; y0 <
height; y0 += 4) {
1022 for (x = 0; x <
width; x++) {
1023 if (y0 + 3 < height &&
1041 for (
y = y0 + runlen;
y < y0 + 4 &&
y <
height;
y++) {
1044 int flags_mask = -1;
1045 if (vert_causal_ctx_csty_symbol &&
y == y0 + 3)
1074 "Segmentation symbol value incorrect\n");
1083 int clnpass_cnt = 0;
1091 memset(t1->
data[
y], 0, width *
sizeof(**t1->
data));
1097 for (
y = 0;
y < height + 2;
y++)
1098 memset(t1->
flags[
y], 0, (width + 2) *
sizeof(**t1->
flags));
1108 bpass_csty_symbol && (clnpass_cnt >= 4),
1109 vert_causal_ctx_csty_symbol);
1113 if (bpass_csty_symbol && clnpass_cnt >= 4)
1119 vert_causal_ctx_csty_symbol);
1120 clnpass_cnt = clnpass_cnt + 1;
1121 if (bpass_csty_symbol && clnpass_cnt >= 4)
1147 int w = cblk->
coord[0][1] - cblk->
coord[0][0];
1148 for (j = 0; j < (cblk->
coord[1][1] - cblk->
coord[1][0]); ++j) {
1149 float *datap = &comp->
f_data[(comp->
coord[0][1] - comp->
coord[0][0]) * (y + j) + x];
1151 for (i = 0; i < w; ++i)
1162 int w = cblk->
coord[0][1] - cblk->
coord[0][0];
1163 for (j = 0; j < (cblk->
coord[1][1] - cblk->
coord[1][0]); ++j) {
1166 for (i = 0; i < w; ++i)
1167 datap[i] = (src[i] * band->
i_stepsize) / 32768;
1176 int w = cblk->
coord[0][1] - cblk->
coord[0][0];
1177 for (j = 0; j < (cblk->
coord[1][1] - cblk->
coord[1][0]); ++j) {
1180 for (i = 0; i < w; ++i)
1181 datap[i] = (src[i] * band->
i_stepsize + (1<<14)) >> 15;
1190 for (i = 1; i < 3; i++) {
1201 for (i = 0; i < 3; i++)
1207 for (i = 0; i < 2; i++)
1217 int compno, reslevelno, bandno;
1226 for (compno = 0; compno < s->
ncomponents; compno++) {
1234 for (bandno = 0; bandno < rlevel->
nbands; bandno++) {
1235 int nb_precincts, precno;
1237 int cblkno = 0, bandpos;
1239 bandpos = bandno + (reslevelno > 0);
1241 if (band->
coord[0][0] == band->
coord[0][1] ||
1247 for (precno = 0; precno < nb_precincts; precno++) {
1259 x = cblk->
coord[0][0];
1260 y = cblk->
coord[1][0];
1281 if (s->
cdef[0] < 0) {
1289 for (compno = 0; compno < s->
ncomponents; compno++) {
1292 float *datap = comp->
f_data;
1294 int cbps = s->
cbps[compno];
1308 dst = line + x / s->
cdx[compno] * pixelsize + compno*!planar;
1311 for (; x < w; x ++) {
1312 int val =
lrintf(*datap) + (1 << (cbps - 1));
1314 val = av_clip(val, 0, (1 << cbps) - 1);
1315 *dst = val << (8 - cbps);
1320 for (; x < w; x ++) {
1321 int val = *i_datap + (1 << (cbps - 1));
1323 val = av_clip(val, 0, (1 << cbps) - 1);
1324 *dst = val << (8 - cbps);
1336 for (compno = 0; compno < s->
ncomponents; compno++) {
1339 float *datap = comp->
f_data;
1342 int cbps = s->
cbps[compno];
1350 linel = (uint16_t *)picture->
data[plane] + y / s->
cdy[compno] * (picture->
linesize[plane] >> 1);
1355 dst = linel + (x / s->
cdx[compno] * pixelsize + compno*!planar);
1357 for (; x < w; x ++) {
1358 int val =
lrintf(*datap) + (1 << (cbps - 1));
1360 val = av_clip(val, 0, (1 << cbps) - 1);
1362 *dst = val << (precision - cbps);
1367 for (; x < w; x ++) {
1368 int val = *i_datap + (1 << (cbps - 1));
1370 val = av_clip(val, 0, (1 << cbps) - 1);
1372 *dst = val << (precision - cbps);
1390 for (compno = 0; compno < s->
ncomponents; compno++) {
1421 marker = bytestream2_get_be16u(&s->
g);
1451 len = bytestream2_get_be16(&s->
g);
1462 ret =
get_coc(s, codsty, properties);
1465 ret =
get_cod(s, codsty, properties);
1468 ret =
get_qcc(s, len, qntsty, properties);
1471 ret =
get_qcd(s, len, qntsty, properties);
1474 if (!(ret =
get_sot(s, len))) {
1495 "unsupported marker 0x%.4"PRIX16
" at pos 0x%X\n",
1502 "error during processing marker segment %.4"PRIx16
"\n",
1504 return ret ? ret : -1;
1532 uint32_t atom_size, atom, atom_end;
1533 int search_range = 10;
1538 atom_size = bytestream2_get_be32u(&s->
g);
1539 atom = bytestream2_get_be32u(&s->
g);
1550 uint32_t atom2_size, atom2, atom2_end;
1552 atom2_size = bytestream2_get_be32u(&s->
g);
1553 atom2 = bytestream2_get_be32u(&s->
g);
1555 if (atom2_size < 8 || atom2_end > atom_end || atom2_end < atom2_size)
1559 }
else if (atom2 ==
MKBETAG(
'c',
'o',
'l',
'r') && atom2_size >= 7) {
1560 int method = bytestream2_get_byteu(&s->
g);
1565 }
else if (atom2 ==
MKBETAG(
'p',
'c',
'l',
'r') && atom2_size >= 6) {
1566 int i,
size, colour_count, colour_channels, colour_depth[3];
1568 colour_count = bytestream2_get_be16u(&s->
g);
1569 colour_channels = bytestream2_get_byteu(&s->
g);
1571 colour_depth[0] = (bytestream2_get_byteu(&s->
g) & 0x7f) + 1;
1572 colour_depth[1] = (bytestream2_get_byteu(&s->
g) & 0x7f) + 1;
1573 colour_depth[2] = (bytestream2_get_byteu(&s->
g) & 0x7f) + 1;
1574 size = (colour_depth[0] + 7 >> 3) * colour_count +
1575 (colour_depth[1] + 7 >> 3) * colour_count +
1576 (colour_depth[2] + 7 >> 3) * colour_count;
1577 if (colour_count > 256 ||
1578 colour_channels != 3 ||
1579 colour_depth[0] > 16 ||
1580 colour_depth[1] > 16 ||
1581 colour_depth[2] > 16 ||
1582 atom2_size < size) {
1588 for (i = 0; i < colour_count; i++) {
1589 if (colour_depth[0] <= 8) {
1590 r = bytestream2_get_byteu(&s->
g) << 8 - colour_depth[0];
1591 r |= r >> colour_depth[0];
1593 r = bytestream2_get_be16u(&s->
g) >> colour_depth[0] - 8;
1595 if (colour_depth[1] <= 8) {
1596 g = bytestream2_get_byteu(&s->
g) << 8 - colour_depth[1];
1597 r |= r >> colour_depth[1];
1599 g = bytestream2_get_be16u(&s->
g) >> colour_depth[1] - 8;
1601 if (colour_depth[2] <= 8) {
1602 b = bytestream2_get_byteu(&s->
g) << 8 - colour_depth[2];
1603 r |= r >> colour_depth[2];
1605 b = bytestream2_get_be16u(&s->
g) >> colour_depth[2] - 8;
1607 s->
palette[i] = 0xff
u << 24 | r << 16 | g << 8 |
b;
1609 }
else if (atom2 ==
MKBETAG(
'c',
'd',
'e',
'f') && atom2_size >= 2) {
1610 int n = bytestream2_get_be16u(&s->
g);
1612 int cn = bytestream2_get_be16(&s->
g);
1613 int av_unused typ = bytestream2_get_be16(&s->
g);
1614 int asoc = bytestream2_get_be16(&s->
g);
1615 if (cn < 4 && asoc < 4)
1620 }
while (atom_end - atom2_end >= 8);
1650 memset(s->
cdef, -1,
sizeof(s->
cdef));
1659 (bytestream2_get_be32u(&s->
g) == 12) &&
1664 "Could not find Jpeg2000 codestream atom.\n");
1701 memcpy(picture->
data[1], s->
palette, 256 *
sizeof(uint32_t));
1716 #define OFFSET(x) offsetof(Jpeg2000DecoderContext, x)
1717 #define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
1720 {
"lowres",
"Lower the decoding resolution by a power of two",
1751 .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)
#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
int flags[JPEG2000_MAX_CBLKW+2][JPEG2000_MAX_CBLKH+2]
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
#define JPEG2000_MAX_CBLKH
static enum AVPixelFormat all_pix_fmts[]
static av_cold int init(AVCodecContext *avctx)
static uint64_t SP[8][256]
#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)
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)
#define FF_ARRAY_ELEMS(a)
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.
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
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)
#define CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
#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]
#define JPEG2000_CSTY_EPH
uint16_t depth_minus1
Number of bits in the component minus 1.
#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 void decode_sigpass(Jpeg2000T1Context *t1, int width, int height, int bpno, int bandno, int bpass_csty_symbol, int vert_causal_ctx_csty_symbol)
static const uint16_t mask[17]
#define YUV_PIXEL_FORMATS
void ff_jpeg2000_set_significance(Jpeg2000T1Context *t1, int x, int y, int negative)
int data[JPEG2000_MAX_CBLKW][JPEG2000_MAX_CBLKH]
void ff_mqc_initdec(MqcState *mqc, uint8_t *bp)
Initialize MQ-decoder.
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)
uint8_t log2_prec_heights[JPEG2000_MAX_RESLEVELS]
static av_always_inline unsigned int bytestream2_get_bytes_left(GetByteContext *g)
simple assert() macros that are a bit more flexible than ISO C assert().
const char * name
Name of the codec implementation.
static uint8_t get_plt(Jpeg2000DecoderContext *s, int n)
Libavcodec external API header.
static int get_cox(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c)
static const AVClass jpeg2000_class
Jpeg2000TilePart tile_part[4]
uint8_t nb_components
The number of components each pixel has, (1-4)
enum AVPictureType pict_type
Picture type of the frame.
#define AV_PIX_FMT_GRAY16
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
struct Jpeg2000TgtNode * parent
int width
picture width / height.
JPEG 2000 structures and defines common to encoder and decoder.
#define JPEG2000_MAX_RESLEVELS
#define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_0
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 get_siz(Jpeg2000DecoderContext *s)
static const AVProfile profiles[]
#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...
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)
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
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 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
#define CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
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)
static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *codsty, Jpeg2000ResLevel *rlevel, int precno, int layno, uint8_t *expn, int numgbits)
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
#define JPEG2000_MAX_CBLKW
static void decode_refpass(Jpeg2000T1Context *t1, int width, int height, int bpno)
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 ...
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)