return res;
}
-void ff_tag_tree_zero(Jpeg2000TgtNode *t, int w, int h)
+void ff_tag_tree_zero(Jpeg2000TgtNode *t, int w, int h, int val)
{
int i, siz = ff_tag_tree_size(w, h);
for (i = 0; i < siz; i++) {
- t[i].val = 0;
+ t[i].val = val;
+ t[i].temp_val = 0;
t[i].vis = 0;
}
}
band->f_stepsize *= 0.5;
}
-static int init_prec(Jpeg2000Band *band,
+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)
cblk->lblock = 3;
cblk->length = 0;
cblk->npasses = 0;
+ if (av_codec_is_encoder(avctx->codec)) {
+ cblk->layers = av_mallocz_array(codsty->nlayers, sizeof(*cblk->layers));
+ if (!cblk->layers)
+ return AVERROR(ENOMEM);
+ }
}
return 0;
return AVERROR(ENOMEM);
for (precno = 0; precno < nb_precincts; precno++) {
- ret = init_prec(band, reslevel, comp,
+ ret = init_prec(avctx, band, reslevel, comp, codsty,
precno, bandno, reslevelno,
log2_band_prec_width, log2_band_prec_height);
if (ret < 0)
Jpeg2000Band *band = rlevel->band + bandno;
for(precno = 0; precno < rlevel->num_precincts_x * rlevel->num_precincts_y; precno++) {
Jpeg2000Prec *prec = band->prec + precno;
- ff_tag_tree_zero(prec->zerobits, prec->nb_codeblocks_width, prec->nb_codeblocks_height);
- ff_tag_tree_zero(prec->cblkincl, prec->nb_codeblocks_width, prec->nb_codeblocks_height);
+ ff_tag_tree_zero(prec->zerobits, prec->nb_codeblocks_width, prec->nb_codeblocks_height, 0);
+ ff_tag_tree_zero(prec->cblkincl, prec->nb_codeblocks_width, prec->nb_codeblocks_height, 0);
for (cblkno = 0; cblkno < prec->nb_codeblocks_width * prec->nb_codeblocks_height; cblkno++) {
Jpeg2000Cblk *cblk = prec->cblk + cblkno;
cblk->length = 0;
av_freep(&cblk->passes);
av_freep(&cblk->lengthinc);
av_freep(&cblk->data_start);
+ av_freep(&cblk->layers);
}
av_freep(&prec->cblk);
}