This source file includes following definitions.
- ff_jpeg2000_ceildivpow2
- ff_jpeg2000_ceildiv
- ff_jpeg2000_getsigctxno
- ff_jpeg2000_getrefctxno
- ff_jpeg2000_getsgnctxno
#ifndef AVCODEC_JPEG2000_H
#define AVCODEC_JPEG2000_H
#include <stdint.h>
#include "avcodec.h"
#include "mqc.h"
#include "jpeg2000dwt.h"
enum Jpeg2000Markers {
JPEG2000_SOC = 0xff4f,
JPEG2000_SIZ = 0xff51,
JPEG2000_COD,
JPEG2000_COC,
JPEG2000_TLM = 0xff55,
JPEG2000_PLM = 0xff57,
JPEG2000_PLT,
JPEG2000_QCD = 0xff5c,
JPEG2000_QCC,
JPEG2000_RGN,
JPEG2000_POC,
JPEG2000_PPM,
JPEG2000_PPT,
JPEG2000_CRG = 0xff63,
JPEG2000_COM,
JPEG2000_SOT = 0xff90,
JPEG2000_SOP,
JPEG2000_EPH,
JPEG2000_SOD,
JPEG2000_EOC = 0xffd9,
};
enum Jpeg2000Quantsty {
JPEG2000_QSTY_NONE,
JPEG2000_QSTY_SI,
JPEG2000_QSTY_SE
};
#define JPEG2000_MAX_CBLKW 64
#define JPEG2000_MAX_CBLKH 64
#define JPEG2000_MAX_DECLEVELS 32
#define JPEG2000_MAX_RESLEVELS (JPEG2000_MAX_DECLEVELS + 1)
#define JPEG2000_T1_SIG_N 0x0001
#define JPEG2000_T1_SIG_E 0x0002
#define JPEG2000_T1_SIG_W 0x0004
#define JPEG2000_T1_SIG_S 0x0008
#define JPEG2000_T1_SIG_NE 0x0010
#define JPEG2000_T1_SIG_NW 0x0020
#define JPEG2000_T1_SIG_SE 0x0040
#define JPEG2000_T1_SIG_SW 0x0080
#define JPEG2000_T1_SIG_NB (JPEG2000_T1_SIG_N | JPEG2000_T1_SIG_E | \
JPEG2000_T1_SIG_S | JPEG2000_T1_SIG_W | \
JPEG2000_T1_SIG_NE | JPEG2000_T1_SIG_NW | \
JPEG2000_T1_SIG_SE | JPEG2000_T1_SIG_SW)
#define JPEG2000_T1_SGN_N 0x0100
#define JPEG2000_T1_SGN_S 0x0200
#define JPEG2000_T1_SGN_W 0x0400
#define JPEG2000_T1_SGN_E 0x0800
#define JPEG2000_T1_VIS 0x1000
#define JPEG2000_T1_SIG 0x2000
#define JPEG2000_T1_REF 0x4000
#define JPEG2000_T1_SGN 0x8000
#define JPEG2000_CBLK_BYPASS 0x01
#define JPEG2000_CBLK_RESET 0x02
#define JPEG2000_CBLK_TERMALL 0x04
#define JPEG2000_CBLK_VSC 0x08
#define JPEG2000_CBLK_PREDTERM 0x10
#define JPEG2000_CBLK_SEGSYM 0x20
#define JPEG2000_CSTY_PREC 0x01
#define JPEG2000_CSTY_SOP 0x02
#define JPEG2000_CSTY_EPH 0x04
#define JPEG2000_PGOD_LRCP 0x00
#define JPEG2000_PGOD_RLCP 0x01
#define JPEG2000_PGOD_RPCL 0x02
#define JPEG2000_PGOD_PCRL 0x03
#define JPEG2000_PGOD_CPRL 0x04
typedef struct Jpeg2000T1Context {
int data[JPEG2000_MAX_CBLKW][JPEG2000_MAX_CBLKH];
int flags[JPEG2000_MAX_CBLKW + 2][JPEG2000_MAX_CBLKH + 2];
MqcState mqc;
} Jpeg2000T1Context;
typedef struct Jpeg2000TgtNode {
uint8_t val;
uint8_t vis;
struct Jpeg2000TgtNode *parent;
} Jpeg2000TgtNode;
typedef struct Jpeg2000CodingStyle {
int nreslevels;
int nreslevels2decode;
uint8_t log2_cblk_width,
log2_cblk_height;
uint8_t transform;
uint8_t csty;
uint8_t nlayers;
uint8_t mct;
uint8_t cblk_style;
uint8_t prog_order;
uint8_t log2_prec_widths[JPEG2000_MAX_RESLEVELS];
uint8_t log2_prec_heights[JPEG2000_MAX_RESLEVELS];
} Jpeg2000CodingStyle;
typedef struct Jpeg2000QuantStyle {
uint8_t expn[JPEG2000_MAX_DECLEVELS * 3];
uint16_t mant[JPEG2000_MAX_DECLEVELS * 3];
uint8_t quantsty;
uint8_t nguardbits;
} Jpeg2000QuantStyle;
typedef struct Jpeg2000Pass {
uint16_t rate;
int64_t disto;
} Jpeg2000Pass;
typedef struct Jpeg2000Cblk {
uint8_t npasses;
uint8_t ninclpasses;
uint8_t nonzerobits;
uint16_t length;
uint16_t lengthinc;
uint8_t lblock;
uint8_t zero;
uint8_t data[8192];
Jpeg2000Pass passes[100];
uint16_t coord[2][2];
} Jpeg2000Cblk;
typedef struct Jpeg2000Prec {
uint16_t nb_codeblocks_width;
uint16_t nb_codeblocks_height;
Jpeg2000TgtNode *zerobits;
Jpeg2000TgtNode *cblkincl;
Jpeg2000Cblk *cblk;
uint16_t coord[2][2];
} Jpeg2000Prec;
typedef struct Jpeg2000Band {
uint16_t coord[2][2];
uint16_t log2_cblk_width, log2_cblk_height;
int i_stepsize;
float f_stepsize;
Jpeg2000Prec *prec;
} Jpeg2000Band;
typedef struct Jpeg2000ResLevel {
uint8_t nbands;
uint16_t coord[2][2];
uint16_t num_precincts_x, num_precincts_y;
uint8_t log2_prec_width, log2_prec_height;
Jpeg2000Band *band;
} Jpeg2000ResLevel;
typedef struct Jpeg2000Component {
Jpeg2000ResLevel *reslevel;
DWTContext dwt;
float *f_data;
int *i_data;
uint16_t coord[2][2];
uint16_t coord_o[2][2];
} Jpeg2000Component;
static inline int ff_jpeg2000_ceildivpow2(int a, int b)
{
return (a + (1 << b) - 1) >> b;
}
static inline int ff_jpeg2000_ceildiv(int a, int b)
{
return (a + b - 1) / b;
}
void ff_jpeg2000_init_tier1_luts(void);
void ff_jpeg2000_set_significance(Jpeg2000T1Context *t1,
int x, int y, int negative);
extern uint8_t ff_jpeg2000_sigctxno_lut[256][4];
static inline int ff_jpeg2000_getsigctxno(int flag, int bandno)
{
return ff_jpeg2000_sigctxno_lut[flag & 255][bandno];
}
static const uint8_t refctxno_lut[2][2] = { { 14, 15 }, { 16, 16 } };
static inline int ff_jpeg2000_getrefctxno(int flag)
{
return refctxno_lut[(flag >> 14) & 1][(flag & 255) != 0];
}
extern uint8_t ff_jpeg2000_sgnctxno_lut[16][16];
extern uint8_t ff_jpeg2000_xorbit_lut[16][16];
static inline int ff_jpeg2000_getsgnctxno(int flag, int *xorbit)
{
*xorbit = ff_jpeg2000_xorbit_lut[flag & 15][(flag >> 8) & 15];
return ff_jpeg2000_sgnctxno_lut[flag & 15][(flag >> 8) & 15];
}
int ff_jpeg2000_init_component(Jpeg2000Component *comp,
Jpeg2000CodingStyle *codsty,
Jpeg2000QuantStyle *qntsty,
int cbps, int dx, int dy,
AVCodecContext *ctx);
void ff_jpeg2000_reinit(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty);
void ff_jpeg2000_cleanup(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty);
#endif