Commit 0ab0ed2b authored by Michael Niedermayer's avatar Michael Niedermayer

j2k: Rename structs to be more similar to jpeg2000dec

This should simplify merging
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 376e89e2
...@@ -64,12 +64,12 @@ static int tag_tree_size(int w, int h) ...@@ -64,12 +64,12 @@ static int tag_tree_size(int w, int h)
return res + 1; return res + 1;
} }
J2kTgtNode *ff_j2k_tag_tree_init(int w, int h) Jpeg2000TgtNode *ff_j2k_tag_tree_init(int w, int h)
{ {
int pw = w, ph = h; int pw = w, ph = h;
J2kTgtNode *res, *t, *t2; Jpeg2000TgtNode *res, *t, *t2;
t = res = av_mallocz(tag_tree_size(w, h)*sizeof(J2kTgtNode)); t = res = av_mallocz(tag_tree_size(w, h)*sizeof(Jpeg2000TgtNode));
if (res == NULL) if (res == NULL)
return NULL; return NULL;
...@@ -93,7 +93,7 @@ J2kTgtNode *ff_j2k_tag_tree_init(int w, int h) ...@@ -93,7 +93,7 @@ J2kTgtNode *ff_j2k_tag_tree_init(int w, int h)
return res; return res;
} }
static void tag_tree_zero(J2kTgtNode *t, int w, int h) static void tag_tree_zero(Jpeg2000TgtNode *t, int w, int h)
{ {
int i, siz = tag_tree_size(w, h); int i, siz = tag_tree_size(w, h);
...@@ -178,7 +178,7 @@ void ff_j2k_init_tier1_luts(void) ...@@ -178,7 +178,7 @@ void ff_j2k_init_tier1_luts(void)
ff_j2k_sgnctxno_lut[i][j] = getsgnctxno(i + (j << 8), &ff_j2k_xorbit_lut[i][j]); ff_j2k_sgnctxno_lut[i][j] = getsgnctxno(i + (j << 8), &ff_j2k_xorbit_lut[i][j]);
} }
void ff_j2k_set_significant(J2kT1Context *t1, int x, int y, int negative) void ff_j2k_set_significant(Jpeg2000T1Context *t1, int x, int y, int negative)
{ {
x++; y++; x++; y++;
t1->flags[y][x] |= J2K_T1_SIG; t1->flags[y][x] |= J2K_T1_SIG;
...@@ -199,7 +199,7 @@ void ff_j2k_set_significant(J2kT1Context *t1, int x, int y, int negative) ...@@ -199,7 +199,7 @@ void ff_j2k_set_significant(J2kT1Context *t1, int x, int y, int negative)
t1->flags[y-1][x-1] |= J2K_T1_SIG_SE; t1->flags[y-1][x-1] |= J2K_T1_SIG_SE;
} }
int ff_j2k_init_component(J2kComponent *comp, J2kCodingStyle *codsty, J2kQuantStyle *qntsty, int cbps, int dx, int dy) int ff_j2k_init_component(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty, Jpeg2000QuantStyle *qntsty, int cbps, int dx, int dy)
{ {
int reslevelno, bandno, gbandno = 0, ret, i, j, csize = 1; int reslevelno, bandno, gbandno = 0, ret, i, j, csize = 1;
...@@ -211,13 +211,13 @@ int ff_j2k_init_component(J2kComponent *comp, J2kCodingStyle *codsty, J2kQuantSt ...@@ -211,13 +211,13 @@ int ff_j2k_init_component(J2kComponent *comp, J2kCodingStyle *codsty, J2kQuantSt
comp->data = av_malloc(csize * sizeof(int)); comp->data = av_malloc(csize * sizeof(int));
if (!comp->data) if (!comp->data)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
comp->reslevel = av_malloc(codsty->nreslevels * sizeof(J2kResLevel)); comp->reslevel = av_malloc(codsty->nreslevels * sizeof(Jpeg2000ResLevel));
if (!comp->reslevel) if (!comp->reslevel)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++){ for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++){
int declvl = codsty->nreslevels - reslevelno; int declvl = codsty->nreslevels - reslevelno;
J2kResLevel *reslevel = comp->reslevel + reslevelno; Jpeg2000ResLevel *reslevel = comp->reslevel + reslevelno;
for (i = 0; i < 2; i++) for (i = 0; i < 2; i++)
for (j = 0; j < 2; j++) for (j = 0; j < 2; j++)
...@@ -241,11 +241,11 @@ int ff_j2k_init_component(J2kComponent *comp, J2kCodingStyle *codsty, J2kQuantSt ...@@ -241,11 +241,11 @@ int ff_j2k_init_component(J2kComponent *comp, J2kCodingStyle *codsty, J2kQuantSt
reslevel->num_precincts_y = ff_j2k_ceildivpow2(reslevel->coord[1][1], codsty->log2_prec_height) reslevel->num_precincts_y = ff_j2k_ceildivpow2(reslevel->coord[1][1], codsty->log2_prec_height)
- (reslevel->coord[1][0] >> codsty->log2_prec_height); - (reslevel->coord[1][0] >> codsty->log2_prec_height);
reslevel->band = av_malloc(reslevel->nbands * sizeof(J2kBand)); reslevel->band = av_malloc(reslevel->nbands * sizeof(Jpeg2000Band));
if (!reslevel->band) if (!reslevel->band)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
for (bandno = 0; bandno < reslevel->nbands; bandno++, gbandno++){ for (bandno = 0; bandno < reslevel->nbands; bandno++, gbandno++){
J2kBand *band = reslevel->band + bandno; Jpeg2000Band *band = reslevel->band + bandno;
int cblkno, precx, precy, precno; int cblkno, precx, precy, precno;
int x0, y0, x1, y1; int x0, y0, x1, y1;
int xi0, yi0, xi1, yi1; int xi0, yi0, xi1, yi1;
...@@ -285,15 +285,15 @@ int ff_j2k_init_component(J2kComponent *comp, J2kCodingStyle *codsty, J2kQuantSt ...@@ -285,15 +285,15 @@ int ff_j2k_init_component(J2kComponent *comp, J2kCodingStyle *codsty, J2kQuantSt
band->cblknx = ff_j2k_ceildiv(band->cblknx, dx); band->cblknx = ff_j2k_ceildiv(band->cblknx, dx);
band->cblkny = ff_j2k_ceildiv(band->cblkny, dy); band->cblkny = ff_j2k_ceildiv(band->cblkny, dy);
band->cblk = av_malloc(sizeof(J2kCblk) * band->cblknx * band->cblkny); band->cblk = av_malloc(sizeof(Jpeg2000Cblk) * band->cblknx * band->cblkny);
if (!band->cblk) if (!band->cblk)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
band->prec = av_malloc(sizeof(J2kCblk) * reslevel->num_precincts_x * reslevel->num_precincts_y); band->prec = av_malloc(sizeof(Jpeg2000Cblk) * reslevel->num_precincts_x * reslevel->num_precincts_y);
if (!band->prec) if (!band->prec)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
for (cblkno = 0; cblkno < band->cblknx * band->cblkny; cblkno++){ for (cblkno = 0; cblkno < band->cblknx * band->cblkny; cblkno++){
J2kCblk *cblk = band->cblk + cblkno; Jpeg2000Cblk *cblk = band->cblk + cblkno;
cblk->zero = 0; cblk->zero = 0;
cblk->lblock = 3; cblk->lblock = 3;
cblk->length = 0; cblk->length = 0;
...@@ -325,7 +325,7 @@ int ff_j2k_init_component(J2kComponent *comp, J2kCodingStyle *codsty, J2kQuantSt ...@@ -325,7 +325,7 @@ int ff_j2k_init_component(J2kComponent *comp, J2kCodingStyle *codsty, J2kQuantSt
cblkperprecw = 1<<(codsty->log2_prec_width - codsty->log2_cblk_width); cblkperprecw = 1<<(codsty->log2_prec_width - codsty->log2_cblk_width);
for (precx = 0, precno = 0; precx < reslevel->num_precincts_x; precx++){ for (precx = 0, precno = 0; precx < reslevel->num_precincts_x; precx++){
for (precy = 0; precy < reslevel->num_precincts_y; precy++, precno = 0){ for (precy = 0; precy < reslevel->num_precincts_y; precy++, precno = 0){
J2kPrec *prec = band->prec + precno; Jpeg2000Prec *prec = band->prec + precno;
prec->xi0 = xi0; prec->xi0 = xi0;
prec->xi1 = xi1; prec->xi1 = xi1;
prec->cblkincl = ff_j2k_tag_tree_init(prec->xi1 - prec->xi0, prec->cblkincl = ff_j2k_tag_tree_init(prec->xi1 - prec->xi0,
...@@ -345,20 +345,20 @@ int ff_j2k_init_component(J2kComponent *comp, J2kCodingStyle *codsty, J2kQuantSt ...@@ -345,20 +345,20 @@ int ff_j2k_init_component(J2kComponent *comp, J2kCodingStyle *codsty, J2kQuantSt
return 0; return 0;
} }
void ff_j2k_reinit(J2kComponent *comp, J2kCodingStyle *codsty) void ff_j2k_reinit(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty)
{ {
int reslevelno, bandno, cblkno, precno; int reslevelno, bandno, cblkno, precno;
for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++){ for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++){
J2kResLevel *rlevel = comp->reslevel + reslevelno; Jpeg2000ResLevel *rlevel = comp->reslevel + reslevelno;
for (bandno = 0; bandno < rlevel->nbands; bandno++){ for (bandno = 0; bandno < rlevel->nbands; bandno++){
J2kBand *band = rlevel->band + bandno; Jpeg2000Band *band = rlevel->band + bandno;
for(precno = 0; precno < rlevel->num_precincts_x * rlevel->num_precincts_y; precno++){ for(precno = 0; precno < rlevel->num_precincts_x * rlevel->num_precincts_y; precno++){
J2kPrec *prec = band->prec + precno; Jpeg2000Prec *prec = band->prec + precno;
tag_tree_zero(prec->zerobits, prec->xi1 - prec->xi0, prec->yi1 - prec->yi0); tag_tree_zero(prec->zerobits, prec->xi1 - prec->xi0, prec->yi1 - prec->yi0);
tag_tree_zero(prec->cblkincl, prec->xi1 - prec->xi0, prec->yi1 - prec->yi0); tag_tree_zero(prec->cblkincl, prec->xi1 - prec->xi0, prec->yi1 - prec->yi0);
} }
for (cblkno = 0; cblkno < band->cblknx * band->cblkny; cblkno++){ for (cblkno = 0; cblkno < band->cblknx * band->cblkny; cblkno++){
J2kCblk *cblk = band->cblk + cblkno; Jpeg2000Cblk *cblk = band->cblk + cblkno;
cblk->length = 0; cblk->length = 0;
cblk->lblock = 3; cblk->lblock = 3;
} }
...@@ -366,16 +366,16 @@ void ff_j2k_reinit(J2kComponent *comp, J2kCodingStyle *codsty) ...@@ -366,16 +366,16 @@ void ff_j2k_reinit(J2kComponent *comp, J2kCodingStyle *codsty)
} }
} }
void ff_j2k_cleanup(J2kComponent *comp, J2kCodingStyle *codsty) void ff_j2k_cleanup(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty)
{ {
int reslevelno, bandno, precno; int reslevelno, bandno, precno;
for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++){ for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++){
J2kResLevel *reslevel = comp->reslevel + reslevelno; Jpeg2000ResLevel *reslevel = comp->reslevel + reslevelno;
for (bandno = 0; bandno < reslevel->nbands ; bandno++){ for (bandno = 0; bandno < reslevel->nbands ; bandno++){
J2kBand *band = reslevel->band + bandno; Jpeg2000Band *band = reslevel->band + bandno;
for (precno = 0; precno < reslevel->num_precincts_x * reslevel->num_precincts_y; precno++){ for (precno = 0; precno < reslevel->num_precincts_x * reslevel->num_precincts_y; precno++){
J2kPrec *prec = band->prec + precno; Jpeg2000Prec *prec = band->prec + precno;
av_freep(&prec->zerobits); av_freep(&prec->zerobits);
av_freep(&prec->cblkincl); av_freep(&prec->cblkincl);
} }
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include "mqc.h" #include "mqc.h"
#include "j2k_dwt.h" #include "j2k_dwt.h"
enum J2kMarkers{ enum Jpeg2000Markers{
J2K_SOC = 0xff4f, ///< start of codestream J2K_SOC = 0xff4f, ///< start of codestream
J2K_SIZ = 0xff51, ///< image and tile size J2K_SIZ = 0xff51, ///< image and tile size
J2K_COD, ///< coding style default J2K_COD, ///< coding style default
...@@ -54,7 +54,7 @@ enum J2kMarkers{ ...@@ -54,7 +54,7 @@ enum J2kMarkers{
J2K_EOC = 0xffd9, ///< end of codestream J2K_EOC = 0xffd9, ///< end of codestream
}; };
enum J2kQuantsty{ ///< quantization style enum Jpeg2000Quantsty{ ///< quantization style
J2K_QSTY_NONE, ///< no quantization J2K_QSTY_NONE, ///< no quantization
J2K_QSTY_SI, ///< scalar derived J2K_QSTY_SI, ///< scalar derived
J2K_QSTY_SE ///< scalar expoounded J2K_QSTY_SE ///< scalar expoounded
...@@ -104,13 +104,13 @@ typedef struct { ...@@ -104,13 +104,13 @@ typedef struct {
int data[J2K_MAX_CBLKW][J2K_MAX_CBLKH]; int data[J2K_MAX_CBLKW][J2K_MAX_CBLKH];
int flags[J2K_MAX_CBLKW+2][J2K_MAX_CBLKH+2]; int flags[J2K_MAX_CBLKW+2][J2K_MAX_CBLKH+2];
MqcState mqc; MqcState mqc;
} J2kT1Context; } Jpeg2000T1Context;
typedef struct J2kTgtNode { typedef struct Jpeg2000TgtNode {
uint8_t val; uint8_t val;
uint8_t vis; uint8_t vis;
struct J2kTgtNode *parent; struct Jpeg2000TgtNode *parent;
} J2kTgtNode; } Jpeg2000TgtNode;
typedef struct { typedef struct {
uint8_t nreslevels; ///< number of resolution levels uint8_t nreslevels; ///< number of resolution levels
...@@ -123,19 +123,19 @@ typedef struct { ...@@ -123,19 +123,19 @@ typedef struct {
uint8_t nlayers; ///< number of layers uint8_t nlayers; ///< number of layers
uint8_t mct; ///< multiple component transformation uint8_t mct; ///< multiple component transformation
uint8_t cblk_style; ///< codeblock coding style uint8_t cblk_style; ///< codeblock coding style
} J2kCodingStyle; } Jpeg2000CodingStyle;
typedef struct { typedef struct {
uint8_t expn[32 * 3]; ///< quantization exponent uint8_t expn[32 * 3]; ///< quantization exponent
uint16_t mant[32 * 3]; ///< quantization mantissa uint16_t mant[32 * 3]; ///< quantization mantissa
uint8_t quantsty; ///< quantization style uint8_t quantsty; ///< quantization style
uint8_t nguardbits; ///< number of guard bits uint8_t nguardbits; ///< number of guard bits
} J2kQuantStyle; } Jpeg2000QuantStyle;
typedef struct { typedef struct {
uint16_t rate; uint16_t rate;
int64_t disto; int64_t disto;
} J2kPass; } Jpeg2000Pass;
typedef struct { typedef struct {
uint8_t npasses; uint8_t npasses;
...@@ -146,38 +146,38 @@ typedef struct { ...@@ -146,38 +146,38 @@ typedef struct {
uint8_t lblock; uint8_t lblock;
uint8_t zero; uint8_t zero;
uint8_t data[8192]; uint8_t data[8192];
J2kPass passes[100]; Jpeg2000Pass passes[100];
} J2kCblk; ///< code block } Jpeg2000Cblk; ///< code block
typedef struct { typedef struct {
uint16_t xi0, xi1, yi0, yi1; ///< codeblock indexes ([xi0, xi1)) uint16_t xi0, xi1, yi0, yi1; ///< codeblock indexes ([xi0, xi1))
J2kTgtNode *zerobits; Jpeg2000TgtNode *zerobits;
J2kTgtNode *cblkincl; Jpeg2000TgtNode *cblkincl;
} J2kPrec; ///< precinct } Jpeg2000Prec; ///< precinct
typedef struct { typedef struct {
uint16_t coord[2][2]; ///< border coordinates {{x0, x1}, {y0, y1}} uint16_t coord[2][2]; ///< border coordinates {{x0, x1}, {y0, y1}}
uint16_t codeblock_width, codeblock_height; uint16_t codeblock_width, codeblock_height;
uint16_t cblknx, cblkny; uint16_t cblknx, cblkny;
uint32_t stepsize; ///< quantization stepsize (* 2^13) uint32_t stepsize; ///< quantization stepsize (* 2^13)
J2kPrec *prec; Jpeg2000Prec *prec;
J2kCblk *cblk; Jpeg2000Cblk *cblk;
} J2kBand; ///< subband } Jpeg2000Band; ///< subband
typedef struct { typedef struct {
uint8_t nbands; uint8_t nbands;
uint16_t coord[2][2]; ///< border coordinates {{x0, x1}, {y0, y1}} uint16_t coord[2][2]; ///< border coordinates {{x0, x1}, {y0, y1}}
uint16_t num_precincts_x, num_precincts_y; ///< number of precincts in x/y direction uint16_t num_precincts_x, num_precincts_y; ///< number of precincts in x/y direction
uint8_t log2_prec_width, log2_prec_height; ///< exponent of precinct size uint8_t log2_prec_width, log2_prec_height; ///< exponent of precinct size
J2kBand *band; Jpeg2000Band *band;
} J2kResLevel; ///< resolution level } Jpeg2000ResLevel; ///< resolution level
typedef struct { typedef struct {
J2kResLevel *reslevel; Jpeg2000ResLevel *reslevel;
DWTContext dwt; DWTContext dwt;
int *data; int *data;
uint16_t coord[2][2]; ///< border coordinates {{x0, x1}, {y0, y1}} uint16_t coord[2][2]; ///< border coordinates {{x0, x1}, {y0, y1}}
} J2kComponent; } Jpeg2000Component;
/* debug routines */ /* debug routines */
#if 0 #if 0
...@@ -199,12 +199,12 @@ static inline int ff_j2k_ceildiv(int a, int b) ...@@ -199,12 +199,12 @@ static inline int ff_j2k_ceildiv(int a, int b)
} }
/* tag tree routines */ /* tag tree routines */
J2kTgtNode *ff_j2k_tag_tree_init(int w, int h); Jpeg2000TgtNode *ff_j2k_tag_tree_init(int w, int h);
/* TIER-1 routines */ /* TIER-1 routines */
void ff_j2k_init_tier1_luts(void); void ff_j2k_init_tier1_luts(void);
void ff_j2k_set_significant(J2kT1Context *t1, int x, int y, int negative); void ff_j2k_set_significant(Jpeg2000T1Context *t1, int x, int y, int negative);
extern uint8_t ff_j2k_nbctxno_lut[256][4]; extern uint8_t ff_j2k_nbctxno_lut[256][4];
...@@ -227,8 +227,8 @@ static inline int ff_j2k_getsgnctxno(int flag, int *xorbit) ...@@ -227,8 +227,8 @@ static inline int ff_j2k_getsgnctxno(int flag, int *xorbit)
return ff_j2k_sgnctxno_lut[flag&15][(flag>>8)&15]; return ff_j2k_sgnctxno_lut[flag&15][(flag>>8)&15];
} }
int ff_j2k_init_component(J2kComponent *comp, J2kCodingStyle *codsty, J2kQuantStyle *qntsty, int cbps, int dx, int dy); int ff_j2k_init_component(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty, Jpeg2000QuantStyle *qntsty, int cbps, int dx, int dy);
void ff_j2k_reinit(J2kComponent *comp, J2kCodingStyle *codsty); void ff_j2k_reinit(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty);
void ff_j2k_cleanup(J2kComponent *comp, J2kCodingStyle *codsty); void ff_j2k_cleanup(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty);
#endif /* AVCODEC_J2K_H */ #endif /* AVCODEC_J2K_H */
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment