34 #define SHL(a, n) ((n) >= 0 ? (a) << (n) : (a) >> -(n)) 42 while (w > 1 || h > 1) {
44 if (res + 1 >= INT32_MAX)
66 while (w > 1 || h > 1) {
75 for (i = 0; i < ph; i++)
76 for (j = 0; j < pw; j++)
77 t[i * pw + j].parent = &t2[(i >> 1) * w + (j >> 1)];
144 static const int contribtab[3][3] = { { 0, -1, 1 }, { -1, -1, 0 }, { 1, 0, 1 } };
145 static const int ctxlbltab[3][3] = { { 13, 12, 11 }, { 10, 9, 10 }, { 11, 12, 13 } };
146 static 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++)
202 int bandno,
int gbandno,
int reslevelno,
219 2 + numbps - qntsty->
expn[gbandno]);
250 int precno,
int bandno,
int reslevelno,
251 int log2_band_prec_width,
252 int log2_band_prec_height)
255 int nb_codeblocks, cblkno;
262 (1 << log2_band_prec_width);
267 (1 << log2_band_prec_height);
272 (1 << log2_band_prec_width);
277 (1 << log2_band_prec_height);
306 for (cblkno = 0; cblkno < nb_codeblocks; cblkno++) {
329 if ((bandno + !!reslevelno) & 1) {
335 if ((bandno + !!reslevelno) & 2) {
357 int bandno,
int gbandno,
int reslevelno,
358 int cbps,
int dx,
int dy)
361 uint8_t log2_band_prec_width, log2_band_prec_height;
374 if (reslevelno == 0) {
376 for (i = 0; i < 2; i++)
377 for (j = 0; j < 2; j++)
391 for (i = 0; i < 2; i++)
392 for (j = 0; j < 2; j++)
396 (((bandno + 1 >> i) & 1) << declvl - 1),
411 for (j = 0; j < 2; j++)
413 for (j = 0; j < 2; j++)
421 for (precno = 0; precno < nb_precincts; precno++) {
423 precno, bandno, reslevelno,
424 log2_band_prec_width, log2_band_prec_height);
435 int cbps,
int dx,
int dy,
438 int reslevelno, bandno, gbandno = 0, ret, i, j;
451 csize = (comp->
coord[0][1] - comp->
coord[0][0]) *
469 for (reslevelno = 0; reslevelno < codsty->
nreslevels; reslevelno++) {
476 for (i = 0; i < 2; i++)
477 for (j = 0; j < 2; j++)
478 reslevel->
coord[i][j] =
497 if (reslevel->
coord[0][1] == reslevel->
coord[0][0])
505 if (reslevel->
coord[1][1] == reslevel->
coord[1][0])
517 for (bandno = 0; bandno < reslevel->
nbands; bandno++, gbandno++) {
519 comp, codsty, qntsty,
520 bandno, gbandno, reslevelno,
531 int reslevelno, bandno, precno;
540 reslevel = comp->
reslevel + reslevelno;
541 for (bandno = 0; bandno < reslevel->
nbands; bandno++) {
547 band = reslevel->
band + bandno;
554 prec = band->
prec + precno;
uint8_t ff_jpeg2000_sgnctxno_lut[16][16]
const struct AVCodec * codec
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
void av_cold ff_jpeg2000_init_tier1_luts(void)
int flags[JPEG2000_MAX_CBLKW+2][JPEG2000_MAX_CBLKH+2]
void ff_jpeg2000_cleanup(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty)
Jpeg2000TgtNode * cblkincl
static int init_prec(Jpeg2000Band *band, Jpeg2000ResLevel *reslevel, Jpeg2000Component *comp, int precno, int bandno, int reslevelno, int log2_band_prec_width, int log2_band_prec_height)
memory handling functions
av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (%s)\, len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic ? ac->func_descr_generic :ac->func_descr)
static const int contribtab[3][3]
static const int xorbittab[3][3]
uint16_t nb_codeblocks_height
static Jpeg2000TgtNode * ff_jpeg2000_tag_tree_init(int w, int h)
Macro definitions for various function/variable attributes.
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
int av_codec_is_encoder(const AVCodec *codec)
#define JPEG2000_T1_SIG_W
static const uint8_t lut_gain[2][4]
Jpeg2000TgtNode * zerobits
int ff_jpeg2000_dwt_init(DWTContext *s, uint16_t border[2][2], int decomp_levels, int type)
Initialize DWT.
#define JPEG2000_T1_SIG_NE
#define JPEG2000_T1_SIG_SE
static const int ctxlbltab[3][3]
uint8_t log2_prec_widths[JPEG2000_MAX_RESLEVELS]
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int init_band(AVCodecContext *avctx, Jpeg2000ResLevel *reslevel, Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty, Jpeg2000QuantStyle *qntsty, int bandno, int gbandno, int reslevelno, int cbps, int dx, int dy)
void ff_jpeg2000_set_significance(Jpeg2000T1Context *t1, int x, int y, int negative)
uint8_t log2_prec_heights[JPEG2000_MAX_RESLEVELS]
static void init_band_stepsize(AVCodecContext *avctx, Jpeg2000Band *band, Jpeg2000CodingStyle *codsty, Jpeg2000QuantStyle *qntsty, int bandno, int gbandno, int reslevelno, int cbps)
struct Jpeg2000TgtNode * parent
#define JPEG2000_T1_SGN_S
JPEG 2000 structures and defines common to encoder and decoder.
void ff_dwt_destroy(DWTContext *s)
#define JPEG2000_T1_SIG_N
static int ff_jpeg2000_ceildivpow2(int a, int b)
Libavcodec external API header.
uint8_t nreslevels2decode
main external API structure.
uint16_t nb_codeblocks_width
#define JPEG2000_T1_SIG_S
Jpeg2000ResLevel * reslevel
static int ff_jpeg2000_ceildiv(int a, int b)
#define JPEG2000_T1_SGN_E
static void * av_malloc_array(size_t nmemb, size_t size)
uint8_t expn[JPEG2000_MAX_DECLEVELS *3]
common internal and external API header
uint16_t log2_cblk_height
static int32_t tag_tree_size(uint16_t w, uint16_t h)
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_T1_SGN_N
static int getsgnctxno(int flag, uint8_t *xorbit)
#define JPEG2000_T1_SIG_E
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 getsigctxno(int flag, int bandno)
#define FFSWAP(type, a, b)
uint8_t ff_jpeg2000_sigctxno_lut[256][4]
uint32_t mant[JPEG2000_MAX_DECLEVELS *3]
#define JPEG2000_T1_SIG_NW
#define JPEG2000_T1_SGN_W
uint8_t ff_jpeg2000_xorbit_lut[16][16]