28 #include "libavutil/avassert.h"
29 #include "libavutil/common.h"
30 #include "libavutil/opt.h"
31 #include "libavutil/pixdesc.h"
38 #define JP2_SIG_TYPE 0x6A502020
39 #define JP2_SIG_VALUE 0x0D0A870A
40 #define JP2_CODESTREAM 0x6A703263
41 #define JP2_HEADER 0x6A703268
109 s->
bit_index = 7 + (bytestream2_get_byte(&s->
g) != 0xFF
u);
112 res |= (bytestream2_peek_byte(&s->
g) >> s->
bit_index) & 1;
119 if (bytestream2_get_byte(&s->
g) == 0xff)
129 int sp = -1, curval = 0;
134 while (node && !node->
vis) {
142 curval = stack[
sp]->
val;
144 while (curval < threshold && sp >= 0) {
145 if (curval < stack[sp]->
val)
146 curval = stack[
sp]->
val;
147 while (curval < threshold) {
157 stack[
sp]->
val = curval;
164 int bpc, uint32_t log2_chroma_wh,
int pal8)
173 switch (components) {
176 (log2_chroma_wh >> 14 & 3) == 0 &&
177 (log2_chroma_wh >> 12 & 3) == 0;
189 (log2_chroma_wh >> 2 & 3) == 0 &&
190 (log2_chroma_wh & 3) == 0 &&
198 #define RGB_PIXEL_FORMATS AV_PIX_FMT_PAL8,AV_PIX_FMT_RGB24,AV_PIX_FMT_RGBA,AV_PIX_FMT_RGB48,AV_PIX_FMT_RGBA64
199 #define GRAY_PIXEL_FORMATS AV_PIX_FMT_GRAY8,AV_PIX_FMT_GRAY8A,AV_PIX_FMT_GRAY16
200 #define YUV_PIXEL_FORMATS AV_PIX_FMT_YUV410P,AV_PIX_FMT_YUV411P,AV_PIX_FMT_YUVA420P, \
201 AV_PIX_FMT_YUV420P,AV_PIX_FMT_YUV422P,AV_PIX_FMT_YUVA422P, \
202 AV_PIX_FMT_YUV440P,AV_PIX_FMT_YUV444P,AV_PIX_FMT_YUVA444P, \
203 AV_PIX_FMT_YUV420P9,AV_PIX_FMT_YUV422P9,AV_PIX_FMT_YUV444P9, \
204 AV_PIX_FMT_YUVA420P9,AV_PIX_FMT_YUVA422P9,AV_PIX_FMT_YUVA444P9, \
205 AV_PIX_FMT_YUV420P10,AV_PIX_FMT_YUV422P10,AV_PIX_FMT_YUV444P10, \
206 AV_PIX_FMT_YUVA420P10,AV_PIX_FMT_YUVA422P10,AV_PIX_FMT_YUVA444P10, \
207 AV_PIX_FMT_YUV420P12,AV_PIX_FMT_YUV422P12,AV_PIX_FMT_YUV444P12, \
208 AV_PIX_FMT_YUV420P14,AV_PIX_FMT_YUV422P14,AV_PIX_FMT_YUV444P14, \
209 AV_PIX_FMT_YUV420P16,AV_PIX_FMT_YUV422P16,AV_PIX_FMT_YUV444P16, \
210 AV_PIX_FMT_YUVA420P16,AV_PIX_FMT_YUVA422P16,AV_PIX_FMT_YUVA444P16
211 #define XYZ_PIXEL_FORMATS AV_PIX_FMT_XYZ12
228 uint32_t log2_chroma_wh = 0;
230 int possible_fmts_nb = 0;
236 s->
width = bytestream2_get_be32u(&s->
g);
237 s->
height = bytestream2_get_be32u(&s->
g);
244 ncomponents = bytestream2_get_be16u(&s->
g);
251 if (ncomponents <= 0) {
257 if (ncomponents > 4) {
275 uint8_t x = bytestream2_get_byteu(&s->
g);
276 s->
cbps[i] = (x & 0x7f) + 1;
278 s->
sgnd[i] = !!(x & 0x80);
279 s->
cdx[i] = bytestream2_get_byteu(&s->
g);
280 s->
cdy[i] = bytestream2_get_byteu(&s->
g);
281 if ( !s->
cdx[i] || s->
cdx[i] == 3 || s->
cdx[i] > 4
282 || !s->
cdy[i] || s->
cdy[i] == 3 || s->
cdy[i] > 4) {
286 log2_chroma_wh |= s->
cdy[i] >> 1 << i * 4 | s->
cdx[i] >> 1 << i * 4 + 2;
341 for (i = 0; i < possible_fmts_nb; ++i) {
349 "Unknown pix_fmt, profile: %d, colour_space: %d, "
350 "components: %d, precision: %d, "
351 "cdx[1]: %d, cdy[1]: %d, cdx[2]: %d, cdy[2]: %d\n",
353 ncomponents > 2 ? s->
cdx[1] : 0,
354 ncomponents > 2 ? s->
cdy[1] : 0,
355 ncomponents > 2 ? s->
cdx[2] : 0,
356 ncomponents > 2 ? s->
cdy[2] : 0);
417 byte = bytestream2_get_byte(&s->
g);
438 tmp.
csty = bytestream2_get_byteu(&s->
g);
443 tmp.
nlayers = bytestream2_get_be16u(&s->
g);
444 tmp.
mct = bytestream2_get_byteu(&s->
g);
448 "MCT %d with too few components (%d)\n",
453 if ((ret =
get_cox(s, &tmp)) < 0)
456 for (compno = 0; compno < s->
ncomponents; compno++)
457 if (!(properties[compno] &
HAD_COC))
458 memcpy(c + compno, &tmp,
sizeof(tmp));
472 compno = bytestream2_get_byteu(&s->
g);
476 "Invalid compno %d. There are %d components in the image.\n",
482 c->
csty = bytestream2_get_byteu(&s->
g);
499 x = bytestream2_get_byteu(&s->
g);
509 for (i = 0; i <
n; i++)
510 q->
expn[i] = bytestream2_get_byteu(&s->
g) >> 3;
514 x = bytestream2_get_be16u(&s->
g);
515 q->
expn[0] = x >> 11;
516 q->
mant[0] = x & 0x7ff;
518 int curexpn =
FFMAX(0, q->
expn[0] - (i - 1) / 3);
519 q->
expn[i] = curexpn;
527 for (i = 0; i <
n; i++) {
528 x = bytestream2_get_be16u(&s->
g);
529 q->
expn[i] = x >> 11;
530 q->
mant[i] = x & 0x7ff;
543 if ((ret =
get_qcx(s, n, &tmp)) < 0)
545 for (compno = 0; compno < s->
ncomponents; compno++)
546 if (!(properties[compno] &
HAD_QCC))
547 memcpy(q + compno, &tmp,
sizeof(tmp));
561 compno = bytestream2_get_byteu(&s->
g);
565 "Invalid compno %d. There are %d components in the image.\n",
571 return get_qcx(s, n - 1, q + compno);
586 Isot = bytestream2_get_be16u(&s->
g);
591 Psot = bytestream2_get_be32u(&s->
g);
592 TPsot = bytestream2_get_byteu(&s->
g);
595 bytestream2_get_byteu(&s->
g);
633 uint8_t Stlm, ST, SP, tile_tlm, i;
634 bytestream2_get_byte(&s->
g);
635 Stlm = bytestream2_get_byte(&s->
g);
638 ST = (Stlm >> 4) & 0x03;
640 SP = (Stlm >> 6) & 0x01;
641 tile_tlm = (n - 4) / ((SP + 1) * 2 + ST);
642 for (i = 0; i < tile_tlm; i++) {
647 bytestream2_get_byte(&s->
g);
650 bytestream2_get_be16(&s->
g);
653 bytestream2_get_be32(&s->
g);
657 bytestream2_get_be16(&s->
g);
659 bytestream2_get_be32(&s->
g);
675 for (compno = 0; compno < s->
ncomponents; compno++) {
692 s->
cbps[compno], s->
cdx[compno],
708 return num < 0 ? num : 3 + num;
710 return num < 0 ? num : 6 + num;
712 return num < 0 ? num : 37 + num;
729 int layno,
uint8_t *expn,
int numgbits)
731 int bandno, cblkno,
ret, nb_code_blocks;
739 for (bandno = 0; bandno < rlevel->
nbands; bandno++) {
748 for (cblkno = 0; cblkno < nb_code_blocks; cblkno++) {
750 int incl, newpasses, llen;
762 int v = expn[bandno] + numgbits - 1 -
766 "nonzerobits %d invalid\n", v);
778 if (ret >
sizeof(cblk->
data)) {
780 "Block with lengthinc greater than %zu",
797 for (bandno = 0; bandno < rlevel->
nbands; bandno++) {
802 for (cblkno = 0; cblkno < nb_code_blocks; cblkno++) {
808 "Block length %d or lengthinc %d is too large\n",
824 int layno, reslevelno, compno, precno, ok_reslevel;
835 for (reslevelno = 0; ok_reslevel; reslevelno++) {
837 for (compno = 0; compno < s->
ncomponents; compno++) {
840 if (reslevelno < codsty->nreslevels) {
848 qntsty->
expn + (reslevelno ? 3 * (reslevelno - 1) + 1 : 0),
858 for (compno = 0; compno < s->
ncomponents; compno++) {
870 for (y = 0; y < s->
height; y += 256) {
874 for (x = 0; x < s->
width; x += 256) {
875 for (reslevelno = 0; reslevelno < codsty->
nreslevels; reslevelno++) {
895 qntsty->
expn + (reslevelno ? 3 * (reslevelno - 1) + 1 : 0),
927 int bpno,
int bandno,
int bpass_csty_symbol,
928 int vert_causal_ctx_csty_symbol)
930 int mask = 3 << (bpno - 1), y0, x,
y;
932 for (y0 = 0; y0 <
height; y0 += 4)
933 for (x = 0; x <
width; x++)
934 for (
y = y0;
y < height &&
y < y0 + 4;
y++) {
938 if (vert_causal_ctx_csty_symbol &&
y == y0 + 3)
942 if (bpass_csty_symbol)
962 phalf = 1 << (bpno - 1);
965 for (y0 = 0; y0 <
height; y0 += 4)
966 for (x = 0; x <
width; x++)
967 for (y = y0; y < height && y < y0 + 4; y++)
980 int seg_symbols,
int vert_causal_ctx_csty_symbol)
982 int mask = 3 << (bpno - 1), y0, x,
y, runlen, dec;
984 for (y0 = 0; y0 <
height; y0 += 4) {
985 for (x = 0; x <
width; x++) {
986 if (y0 + 3 < height &&
1004 for (
y = y0 + runlen;
y < y0 + 4 &&
y <
height;
y++) {
1007 int flags_mask = -1;
1008 if (vert_causal_ctx_csty_symbol &&
y == y0 + 3)
1037 "Segmentation symbol value incorrect\n");
1046 int clnpass_cnt = 0;
1054 memset(t1->
data[
y], 0, width *
sizeof(**t1->
data));
1060 for (
y = 0;
y < height + 2;
y++)
1061 memset(t1->
flags[
y], 0, (width + 2) *
sizeof(**t1->
flags));
1071 bpass_csty_symbol && (clnpass_cnt >= 4),
1072 vert_causal_ctx_csty_symbol);
1076 if (bpass_csty_symbol && clnpass_cnt >= 4)
1082 vert_causal_ctx_csty_symbol);
1083 clnpass_cnt = clnpass_cnt + 1;
1084 if (bpass_csty_symbol && clnpass_cnt >= 4)
1110 int w = cblk->
coord[0][1] - cblk->
coord[0][0];
1111 for (j = 0; j < (cblk->
coord[1][1] - cblk->
coord[1][0]); ++j) {
1112 float *datap = &comp->
f_data[(comp->
coord[0][1] - comp->
coord[0][0]) * (y + j) + x];
1114 for (i = 0; i < w; ++i)
1125 int w = cblk->
coord[0][1] - cblk->
coord[0][0];
1126 for (j = 0; j < (cblk->
coord[1][1] - cblk->
coord[1][0]); ++j) {
1129 for (i = 0; i < w; ++i)
1130 datap[i] = (src[i] * band->
i_stepsize + (1 << 14)) >> 15;
1153 float *srcf[3], i0f, i1f,
i2f;
1155 for (i = 1; i < 3; i++)
1161 for (i = 0; i < 3; i++)
1167 for (i = 0; i < 2; i++)
1172 for (i = 0; i < csize; i++) {
1183 for (i = 0; i < csize; i++) {
1184 i0 = *src[0] + (((
i_ict_params[0] * *src[2]) + (1 << 15)) >> 16);
1185 i1 = *src[0] - (((
i_ict_params[1] * *src[1]) + (1 << 15)) >> 16)
1187 i2 = *src[0] + (((
i_ict_params[3] * *src[1]) + (1 << 15)) >> 16);
1194 for (i = 0; i < csize; i++) {
1195 i1 = *src[0] - (*src[2] + *src[1] >> 2);
1209 int compno, reslevelno, bandno;
1216 for (compno = 0; compno < s->
ncomponents; compno++) {
1224 for (bandno = 0; bandno < rlevel->
nbands; bandno++) {
1225 int nb_precincts, precno;
1227 int cblkno = 0, bandpos;
1229 bandpos = bandno + (reslevelno > 0);
1231 if (band->
coord[0][0] == band->
coord[0][1] ||
1237 for (precno = 0; precno < nb_precincts; precno++) {
1249 x = cblk->
coord[0][0];
1250 y = cblk->
coord[1][0];
1269 if (s->
cdef[0] < 0) {
1277 for (compno = 0; compno < s->
ncomponents; compno++) {
1280 float *datap = comp->
f_data;
1282 int cbps = s->
cbps[compno];
1284 int planar = !!picture->
data[2];
1293 line = picture->
data[plane] + y / s->
cdy[compno] * picture->
linesize[plane];
1298 dst = line + x / s->
cdx[compno] * pixelsize + compno*!planar;
1301 for (; x < w; x += s->
cdx[compno]) {
1302 int val =
lrintf(*datap) + (1 << (cbps - 1));
1304 val = av_clip(val, 0, (1 << cbps) - 1);
1305 *dst = val << (8 - cbps);
1310 for (; x < w; x += s->
cdx[compno]) {
1311 int val = *i_datap + (1 << (cbps - 1));
1313 val = av_clip(val, 0, (1 << cbps) - 1);
1314 *dst = val << (8 - cbps);
1323 for (compno = 0; compno < s->
ncomponents; compno++) {
1326 float *datap = comp->
f_data;
1329 int cbps = s->
cbps[compno];
1331 int planar = !!picture->
data[2];
1339 linel = (uint16_t *)picture->
data[plane] + y / s->
cdy[compno] * (picture->
linesize[plane] >> 1);
1344 dst = linel + (x / s->
cdx[compno] * pixelsize + compno*!planar);
1346 for (; x < w; x += s-> cdx[compno]) {
1347 int val =
lrintf(*datap) + (1 << (cbps - 1));
1349 val = av_clip(val, 0, (1 << cbps) - 1);
1351 *dst = val << (16 - cbps);
1356 for (; x < w; x += s-> cdx[compno]) {
1357 int val = *i_datap + (1 << (cbps - 1));
1359 val = av_clip(val, 0, (1 << cbps) - 1);
1361 *dst = val << (16 - cbps);
1366 linel += picture->
linesize[plane] >> 1;
1379 for (compno = 0; compno < s->
ncomponents; compno++) {
1410 marker = bytestream2_get_be16u(&s->
g);
1440 len = bytestream2_get_be16(&s->
g);
1451 ret =
get_coc(s, codsty, properties);
1454 ret =
get_cod(s, codsty, properties);
1457 ret =
get_qcc(s, len, qntsty, properties);
1460 ret =
get_qcd(s, len, qntsty, properties);
1463 if (!(ret =
get_sot(s, len))) {
1480 "unsupported marker 0x%.4X at pos 0x%X\n",
1487 "error during processing marker segment %.4x\n", marker);
1488 return ret ? ret : -1;
1516 uint32_t atom_size, atom, atom_end;
1517 int search_range = 10;
1522 atom_size = bytestream2_get_be32u(&s->
g);
1523 atom = bytestream2_get_be32u(&s->
g);
1534 uint32_t atom2_size, atom2, atom2_end;
1536 atom2_size = bytestream2_get_be32u(&s->
g);
1537 atom2 = bytestream2_get_be32u(&s->
g);
1539 if (atom2_size < 8 || atom2_end > atom_end || atom2_end < atom2_size)
1543 }
else if (atom2 ==
MKBETAG(
'c',
'o',
'l',
'r') && atom2_size >= 7) {
1544 int method = bytestream2_get_byteu(&s->
g);
1549 }
else if (atom2 ==
MKBETAG(
'p',
'c',
'l',
'r') && atom2_size >= 6) {
1550 int i,
size, colour_count, colour_channels, colour_depth[3];
1552 colour_count = bytestream2_get_be16u(&s->
g);
1553 colour_channels = bytestream2_get_byteu(&s->
g);
1555 colour_depth[0] = (bytestream2_get_byteu(&s->
g) & 0x7f) + 1;
1556 colour_depth[1] = (bytestream2_get_byteu(&s->
g) & 0x7f) + 1;
1557 colour_depth[2] = (bytestream2_get_byteu(&s->
g) & 0x7f) + 1;
1558 size = (colour_depth[0] + 7 >> 3) * colour_count +
1559 (colour_depth[1] + 7 >> 3) * colour_count +
1560 (colour_depth[2] + 7 >> 3) * colour_count;
1561 if (colour_count > 256 ||
1562 colour_channels != 3 ||
1563 colour_depth[0] > 16 ||
1564 colour_depth[1] > 16 ||
1565 colour_depth[2] > 16 ||
1566 atom2_size < size) {
1572 for (i = 0; i < colour_count; i++) {
1573 if (colour_depth[0] <= 8) {
1574 r = bytestream2_get_byteu(&s->
g) << 8 - colour_depth[0];
1575 r |= r >> colour_depth[0];
1577 r = bytestream2_get_be16u(&s->
g) >> colour_depth[0] - 8;
1579 if (colour_depth[1] <= 8) {
1580 g = bytestream2_get_byteu(&s->
g) << 8 - colour_depth[1];
1581 r |= r >> colour_depth[1];
1583 g = bytestream2_get_be16u(&s->
g) >> colour_depth[1] - 8;
1585 if (colour_depth[2] <= 8) {
1586 b = bytestream2_get_byteu(&s->
g) << 8 - colour_depth[2];
1587 r |= r >> colour_depth[2];
1589 b = bytestream2_get_be16u(&s->
g) >> colour_depth[2] - 8;
1591 s->
palette[i] = 0xff
u << 24 | r << 16 | g << 8 |
b;
1593 }
else if (atom2 ==
MKBETAG(
'c',
'd',
'e',
'f') && atom2_size >= 2) {
1594 int n = bytestream2_get_be16u(&s->
g);
1596 int cn = bytestream2_get_be16(&s->
g);
1597 int av_unused typ = bytestream2_get_be16(&s->
g);
1598 int asoc = bytestream2_get_be16(&s->
g);
1599 if (cn < 4 || asoc < 4)
1604 }
while (atom_end - atom2_end >= 8);
1625 memset(s->
cdef, -1,
sizeof(s->
cdef));
1634 (bytestream2_get_be32u(&s->
g) == 12) &&
1639 "Could not find Jpeg2000 codestream atom.\n");
1676 memcpy(picture->
data[1], s->
palette, 256 *
sizeof(uint32_t));
1691 #define OFFSET(x) offsetof(Jpeg2000DecoderContext, x)
1692 #define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
1695 {
"lowres",
"Lower the decoding resolution by a power of two",
1725 .priv_class = &jpeg2000_class,
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
#define AVERROR_PATCHWELCOME
int flags[JPEG2000_MAX_CBLKW+2][JPEG2000_MAX_CBLKH+2]
void ff_jpeg2000_cleanup(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty)
This structure describes decoded (raw) audio or video data.
static int jpeg2000_read_main_headers(Jpeg2000DecoderContext *s)
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 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[]
#define FF_PROFILE_JPEG2000_DCINEMA_4K
#define JPEG2000_PGOD_RLCP
static void jpeg2000_flush(Jpeg2000DecoderContext *s)
static Float11 * i2f(int i, Float11 *f)
static int get_qcc(Jpeg2000DecoderContext *s, int n, Jpeg2000QuantStyle *q, uint8_t *properties)
Jpeg2000QuantStyle qntsty[4]
static void mct_decode(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile)
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
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)
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)
static int jpeg2000_read_bitstream_packets(Jpeg2000DecoderContext *s)
static enum AVPixelFormat rgb_pix_fmts[]
void av_freep(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
if((e=av_dict_get(options,"", NULL, AV_DICT_IGNORE_SUFFIX)))
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)
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
const char * av_default_item_name(void *ctx)
Return the context name.
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 av_cold int end(AVCodecContext *avctx)
Multithreading support functions.
Jpeg2000TgtNode * zerobits
const char * name
Name of the codec implementation.
#define AV_PIX_FMT_FLAG_PAL
Pixel format has a palette in data[1], values are indexes in this palette.
static int tag_tree_decode(Jpeg2000DecoderContext *s, Jpeg2000TgtNode *node, int threshold)
static av_always_inline void bytestream2_skipu(GetByteContext *g, unsigned int size)
enum AVPixelFormat pix_fmt
#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)
const OptionDef options[]
#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 void jpeg2000_init_static_data(AVCodec *codec)
static av_always_inline unsigned int bytestream2_get_bytes_left(GetByteContext *g)
Libavcodec external API header.
AVPixelFormat
Pixel format.
#define av_unused
Disable warnings about deprecated features This is useful for sections of code kept for backward comp...
static int get_cox(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c)
static const AVClass jpeg2000_class
#define FF_ARRAY_ELEMS(a)
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.
struct Jpeg2000TgtNode * parent
void ff_jpeg2000_init_tier1_luts(void)
int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
int width
picture width / height.
JPEG 2000 structures and defines common to encoder and decoder.
#define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_0
#define JPEG2000_MAX_RESLEVELS
static int ff_jpeg2000_getsigctxno(int flag, int bandno)
#define JPEG2000_MAX_DECLEVELS
#define FF_PROFILE_UNKNOWN
static int get_siz(Jpeg2000DecoderContext *s)
static const AVProfile profiles[]
static const float f_ict_params[4]
#define JPEG2000_PGOD_RPCL
static int ff_jpeg2000_ceildivpow2(int a, int b)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
static av_always_inline int bytestream2_tell(GetByteContext *g)
void ff_mqc_init_context_tables(void)
MQ-coder Initialize context tables (QE, NLPS, NMPS)
static enum AVPixelFormat yuv_pix_fmts[]
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...
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)
#define FF_PROFILE_JPEG2000_CSTREAM_NO_RESTRICTION
BYTE int const BYTE int int int height
static int getlblockinc(Jpeg2000DecoderContext *s)
Describe the class of an AVClass context structure.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
#define FF_PROFILE_JPEG2000_DCINEMA_2K
uint16_t nb_codeblocks_width
#define MKBETAG(a, b, c, d)
#define JPEG2000_T1_SIG_S
Jpeg2000ResLevel * reslevel
static int ff_jpeg2000_ceildiv(int a, int b)
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
uint8_t expn[JPEG2000_MAX_DECLEVELS *3]
static int jpeg2000_decode_packets(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile)
static int get_sot(Jpeg2000DecoderContext *s, int n)
static int jp2_find_codestream(Jpeg2000DecoderContext *s)
static void jpeg2000_dec_cleanup(Jpeg2000DecoderContext *s)
common internal 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 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
#define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_1
static int get_bits(Jpeg2000DecoderContext *s, int n)
static const int i_ict_params[4]
#define AVERROR_INVALIDDATA
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)
static int decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
#define JPEG2000_CSTY_PREC
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define JPEG2000_MAX_CBLKW
8 bit with PIX_FMT_RGB32 palette
static void decode_refpass(Jpeg2000T1Context *t1, int width, int height, int bpno)
This structure stores compressed data.
static int get_qcx(Jpeg2000DecoderContext *s, int n, Jpeg2000QuantStyle *q)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Jpeg2000CodingStyle codsty[4]
static int decode_cblk(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *codsty, Jpeg2000T1Context *t1, Jpeg2000Cblk *cblk, int width, int height, int bandpos)
void * av_mallocz(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
static int ff_jpeg2000_getsgnctxno(int flag, int *xorbit)