38#define SHL(a, n) ((n) >= 0 ? (a) << (n) : (a) >> -(n))
45 while (
w > 1 ||
h > 1) {
67 while (
w > 1 ||
h > 1) {
76 for (
i = 0;
i <
ph;
i++)
77 for (j = 0; j < pw; j++)
78 t[
i * pw + j].parent = &t2[(
i >> 1) *
w + (j >> 1)];
90 for (
i = 0;
i < siz;
i++) {
115 if (
h == 2)
return 8;
117 if (v >= 1)
return 7;
118 if (d >= 1)
return 6;
121 if (v == 2)
return 4;
122 if (v == 1)
return 3;
123 if (d >= 2)
return 2;
124 if (d == 1)
return 1;
126 if (d >= 3)
return 8;
128 if (
h+v >= 1)
return 7;
132 if (
h+v >= 2)
return 5;
133 if (
h+v == 1)
return 4;
136 if (
h+v >= 2)
return 2;
137 if (
h+v == 1)
return 1;
144static const int contribtab[3][3] = { { 0, -1, 1 }, { -1, -1, 0 }, { 1, 0, 1 } };
145static const int ctxlbltab[3][3] = { { 13, 12, 11 }, { 10, 9, 10 }, { 11, 12, 13 } };
146static const int xorbittab[3][3] = { { 1, 1, 1 }, { 1, 0, 0 }, { 0, 0, 0 } };
150 int vcontrib, hcontrib;
164 for (
i = 0;
i < 256;
i++)
165 for (j = 0; j < 4; j++)
167 for (
i = 0;
i < 16;
i++)
168 for (j = 0; j < 16; j++)
219 int bandno,
int gbandno,
int reslevelno,
254 switch (bandno + (reslevelno > 0)) {
280 int precno,
int bandno,
int reslevelno,
281 int log2_band_prec_width,
282 int log2_band_prec_height)
285 int nb_codeblocks, cblkno;
294 (1 << log2_band_prec_width);
298 (1 << log2_band_prec_height);
302 (1 << log2_band_prec_width);
308 (1 << log2_band_prec_height);
343 for (cblkno = 0; cblkno < nb_codeblocks; cblkno++) {
366 if ((bandno + !!reslevelno) & 1) {
367 cblk->
coord[0][0] +=
comp->reslevel[reslevelno-1].coord[0][1] -
368 comp->reslevel[reslevelno-1].coord[0][0];
369 cblk->
coord[0][1] +=
comp->reslevel[reslevelno-1].coord[0][1] -
370 comp->reslevel[reslevelno-1].coord[0][0];
372 if ((bandno + !!reslevelno) & 2) {
373 cblk->
coord[1][0] +=
comp->reslevel[reslevelno-1].coord[1][1] -
374 comp->reslevel[reslevelno-1].coord[1][0];
375 cblk->
coord[1][1] +=
comp->reslevel[reslevelno-1].coord[1][1] -
376 comp->reslevel[reslevelno-1].coord[1][0];
397 int bandno,
int gbandno,
int reslevelno,
398 const int cbps,
int dx,
int dy)
401 uint8_t log2_band_prec_width, log2_band_prec_height;
413 if (reslevelno == 0) {
415 for (
i = 0;
i < 2;
i++)
416 for (j = 0; j < 2; j++)
430 for (
i = 0;
i < 2;
i++)
431 for (j = 0; j < 2; j++)
435 (((bandno + 1 >>
i) & 1LL) << declvl - 1),
459 for (precno = 0; precno < nb_precincts; precno++) {
461 precno, bandno, reslevelno,
462 log2_band_prec_width, log2_band_prec_height);
473 const int cbps,
int dx,
int dy,
476 int reslevelno, bandno, gbandno = 0, ret,
i, j;
490 comp->coord[1][1] -
comp->coord[1][0], 0, avctx))
492 csize = (
comp->coord[0][1] -
comp->coord[0][0]) *
493 (
comp->coord[1][1] -
comp->coord[1][0]);
494 if (
comp->coord[0][1] -
comp->coord[0][0] > 32768 ||
495 comp->coord[1][1] -
comp->coord[1][0] > 32768) {
517 for (reslevelno = 0; reslevelno < codsty->
nreslevels; reslevelno++) {
524 for (
i = 0;
i < 2;
i++)
525 for (j = 0; j < 2; j++)
545 if (reslevel->
coord[0][1] == reslevel->
coord[0][0])
553 if (reslevel->
coord[1][1] == reslevel->
coord[1][0])
568 for (bandno = 0; bandno < reslevel->
nbands; bandno++, gbandno++) {
570 comp, codsty, qntsty,
571 bandno, gbandno, reslevelno,
582 int reslevelno, bandno, cblkno, precno;
583 for (reslevelno = 0; reslevelno < codsty->
nreslevels; reslevelno++) {
585 for (bandno = 0; bandno < rlevel->
nbands; bandno++) {
603 int reslevelno, bandno, precno;
612 reslevel =
comp->reslevel + reslevelno;
613 for (bandno = 0; bandno < reslevel->
nbands; bandno++) {
619 band = reslevel->
band + bandno;
629 for (cblkno = 0; cblkno < nb_code_blocks; cblkno ++) {
static double val(void *priv, double ch)
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_assert0(cond)
assert() equivalent, that is always enabled.
Libavcodec external API header.
#define i(width, name, range_min, range_max)
static int FUNC ph(CodedBitstreamContext *ctx, RWContext *rw, H266RawPH *current)
common internal and external API header
static __device__ float floorf(float a)
static void comp(unsigned char *dst, ptrdiff_t dst_stride, unsigned char *src, ptrdiff_t src_stride, int add)
int av_codec_is_encoder(const AVCodec *codec)
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
static av_always_inline float av_int2float(uint32_t i)
Reinterpret a 32-bit integer as a float.
static void init_band_stepsize(AVCodecContext *avctx, Jpeg2000Band *band, Jpeg2000CodingStyle *codsty, Jpeg2000QuantStyle *qntsty, int bandno, int gbandno, int reslevelno, int cbps)
static void av_cold jpeg2000_init_tier1_luts(void)
static const int ctxlbltab[3][3]
static const int contribtab[3][3]
static int getsigctxno(int flag, int bandno)
static Jpeg2000TgtNode * ff_jpeg2000_tag_tree_init(int w, int h)
uint8_t ff_jpeg2000_sgnctxno_lut[16][16]
void ff_tag_tree_zero(Jpeg2000TgtNode *t, int w, int h, int val)
uint8_t ff_jpeg2000_xorbit_lut[16][16]
void av_cold ff_jpeg2000_init_tier1_luts(void)
void ff_jpeg2000_reinit(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty)
static const int xorbittab[3][3]
static int init_band(AVCodecContext *avctx, Jpeg2000ResLevel *reslevel, Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty, Jpeg2000QuantStyle *qntsty, int bandno, int gbandno, int reslevelno, const int cbps, int dx, int dy)
static av_always_inline float exp2fi(int x)
2^(x) for integer x in the range -126..128.
static int32_t tag_tree_size(int w, int h)
static int init_prec(AVCodecContext *avctx, Jpeg2000Band *band, Jpeg2000ResLevel *reslevel, Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty, int precno, int bandno, int reslevelno, int log2_band_prec_width, int log2_band_prec_height)
uint8_t ff_jpeg2000_sigctxno_lut[256][4]
void ff_jpeg2000_cleanup(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty)
int ff_jpeg2000_init_component(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty, Jpeg2000QuantStyle *qntsty, const int cbps, int dx, int dy, AVCodecContext *avctx)
void ff_jpeg2000_set_significance(Jpeg2000T1Context *t1, int x, int y, int negative)
static int getsgnctxno(int flag, uint8_t *xorbit)
JPEG 2000 structures and defines common to encoder and decoder.
static int ff_jpeg2000_ceildivpow2(int a, int b)
#define JPEG2000_T1_SGN_S
#define JPEG2000_T1_SIG_NW
#define JPEG2000_T1_SIG_E
#define JPEG2000_T1_SGN_E
#define JPEG2000_T1_SGN_N
#define JPEG2000_T1_SGN_W
#define JPEG2000_T1_SIG_NE
#define JPEG2000_T1_SIG_SW
#define JPEG2000_T1_SIG_SE
#define JPEG2000_T1_SIG_W
#define JPEG2000_T1_SIG_S
#define JPEG2000_T1_SIG_N
void ff_dwt_destroy(DWTContext *s)
int ff_jpeg2000_dwt_init(DWTContext *s, int border[2][2], int decomp_levels, int type)
Initialize DWT.
Macro definitions for various function/variable attributes.
static int ff_thread_once(char *control, void(*routine)(void))
#define FFSWAP(type, a, b)
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
main external API structure.
int64_t max_pixels
The number of pixels per image to maximally accept.
const struct AVCodec * codec
uint16_t log2_cblk_height
uint8_t log2_prec_widths[JPEG2000_MAX_RESLEVELS]
uint8_t log2_prec_heights[JPEG2000_MAX_RESLEVELS]
Jpeg2000TgtNode * zerobits
Jpeg2000TgtNode * cblkincl
uint16_t mant[JPEG2000_MAX_DECLEVELS *3]
uint8_t expn[JPEG2000_MAX_DECLEVELS *3]
struct Jpeg2000TgtNode * parent