summaryrefslogtreecommitdiff
path: root/libavcodec/jpeg2000.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-05-30 14:40:58 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-05-30 14:57:58 +0200
commit62d00aa22f28532edc192bd9bf92e815ff78304e (patch)
treef09d4de8f715642c7fe2d7f27830bd89618fa1af /libavcodec/jpeg2000.c
parentc2ac389bba2481d18b59055c0a929e57b241c055 (diff)
jpeg2000/j2k: merge j2k/jpeg2000.c/h
Now only j2kdec / jpeg2000dec.c remain Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/jpeg2000.c')
-rw-r--r--libavcodec/jpeg2000.c41
1 files changed, 38 insertions, 3 deletions
diff --git a/libavcodec/jpeg2000.c b/libavcodec/jpeg2000.c
index 9339523e88..d41ec74dac 100644
--- a/libavcodec/jpeg2000.c
+++ b/libavcodec/jpeg2000.c
@@ -79,6 +79,16 @@ static Jpeg2000TgtNode *ff_jpeg2000_tag_tree_init(int w, int h)
return res;
}
+static void tag_tree_zero(Jpeg2000TgtNode *t, int w, int h)
+{
+ int i, siz = tag_tree_size(w, h);
+
+ for (i = 0; i < siz; i++) {
+ t[i].val = 0;
+ t[i].vis = 0;
+ }
+}
+
uint8_t ff_jpeg2000_sigctxno_lut[256][4];
static int getsigctxno(int flag, int bandno)
@@ -316,9 +326,8 @@ int ff_jpeg2000_init_component(Jpeg2000Component *comp,
for (i = 0; i < 2; i++)
for (j = 0; j < 2; j++)
band->coord[i][j] =
- ff_jpeg2000_ceildivpow2(comp->coord_o[i][j],
+ ff_jpeg2000_ceildivpow2(comp->coord_o[i][j] - comp->coord_o[i][0],
declvl - 1);
-
log2_band_prec_width = reslevel->log2_prec_width;
log2_band_prec_height = reslevel->log2_prec_height;
/* see ISO/IEC 15444-1:2002 eq. B-17 and eq. B-15 */
@@ -333,7 +342,7 @@ int ff_jpeg2000_init_component(Jpeg2000Component *comp,
for (j = 0; j < 2; j++)
/* Formula example for tbx_0 = ceildiv((tcx_0 - 2 ^ (declvl - 1) * x0_b) / declvl) */
band->coord[i][j] =
- ff_jpeg2000_ceildivpow2(comp->coord_o[i][j] -
+ ff_jpeg2000_ceildivpow2(comp->coord_o[i][j] - comp->coord_o[i][0] -
(((bandno + 1 >> i) & 1) << declvl - 1),
declvl);
/* TODO: Manage case of 3 band offsets here or
@@ -349,6 +358,11 @@ int ff_jpeg2000_init_component(Jpeg2000Component *comp,
log2_band_prec_height = reslevel->log2_prec_height - 1;
}
+ for (j = 0; j < 2; j++)
+ band->coord[0][j] = ff_jpeg2000_ceildiv(band->coord[0][j], dx);
+ for (j = 0; j < 2; j++)
+ band->coord[1][j] = ff_jpeg2000_ceildiv(band->coord[1][j], dy);
+
band->prec = av_malloc_array(reslevel->num_precincts_x *
reslevel->num_precincts_y,
sizeof(*band->prec));
@@ -454,6 +468,27 @@ int ff_jpeg2000_init_component(Jpeg2000Component *comp,
return 0;
}
+void ff_jpeg2000_reinit(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty)
+{
+ int reslevelno, bandno, cblkno, precno;
+ for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++) {
+ Jpeg2000ResLevel *rlevel = comp->reslevel + reslevelno;
+ for (bandno = 0; bandno < rlevel->nbands; bandno++) {
+ Jpeg2000Band *band = rlevel->band + bandno;
+ for(precno = 0; precno < rlevel->num_precincts_x * rlevel->num_precincts_y; precno++) {
+ Jpeg2000Prec *prec = band->prec + precno;
+ tag_tree_zero(prec->zerobits, prec->nb_codeblocks_width, prec->nb_codeblocks_height);
+ tag_tree_zero(prec->cblkincl, prec->nb_codeblocks_width, prec->nb_codeblocks_height);
+ for (cblkno = 0; cblkno < prec->nb_codeblocks_width * prec->nb_codeblocks_height; cblkno++) {
+ Jpeg2000Cblk *cblk = prec->cblk + cblkno;
+ cblk->length = 0;
+ cblk->lblock = 3;
+ }
+ }
+ }
+ }
+}
+
void ff_jpeg2000_cleanup(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty)
{
int reslevelno, bandno, precno;