diff options
author | Gautam Ramakrishnan <gautamramk@gmail.com> | 2020-08-28 00:15:36 +0530 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2020-08-30 16:18:37 +0200 |
commit | 341064d68a134e2fb3dd35f8f5b50c6df8506c10 (patch) | |
tree | 767b9687e77cf50e243c16ce6be016b9a88e5b95 /libavcodec | |
parent | f0e33119e4fa1cf1705c16affa5daa6f0b487b48 (diff) |
libavcodec/jpeg2000: fix tag tree reset
The implementation of the tag tree did not
set the correct reset value for the encoder.
This lead to inefficent tag tree being encoded.
This patch fixes the implementation of the
ff_tag_tree_zero() function.
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/j2kenc.c | 4 | ||||
-rw-r--r-- | libavcodec/jpeg2000.c | 8 | ||||
-rw-r--r-- | libavcodec/jpeg2000.h | 2 |
3 files changed, 7 insertions, 7 deletions
diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c index 8b9f6464af..4cefe6d7fb 100644 --- a/libavcodec/j2kenc.c +++ b/libavcodec/j2kenc.c @@ -802,8 +802,8 @@ static int encode_packet(Jpeg2000EncoderContext *s, Jpeg2000ResLevel *rlevel, in Jpeg2000Prec *prec = band->prec + precno; int nb_cblks = prec->nb_codeblocks_height * prec->nb_codeblocks_width; int pos; - 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, 99); + ff_tag_tree_zero(prec->cblkincl, prec->nb_codeblocks_width, prec->nb_codeblocks_height, 99); for (pos = 0; pos < nb_cblks; pos++) { Jpeg2000Cblk *cblk = &prec->cblk[pos]; prec->zerobits[pos].val = expn[bandno] + numgbits - 1 - cblk->nonzerobits; diff --git a/libavcodec/jpeg2000.c b/libavcodec/jpeg2000.c index 6501de0d04..56d98c8a89 100644 --- a/libavcodec/jpeg2000.c +++ b/libavcodec/jpeg2000.c @@ -82,12 +82,12 @@ static Jpeg2000TgtNode *ff_jpeg2000_tag_tree_init(int w, int h) 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; } @@ -575,8 +575,8 @@ void ff_jpeg2000_reinit(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty) 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; diff --git a/libavcodec/jpeg2000.h b/libavcodec/jpeg2000.h index a7ba8aa7f3..612832c872 100644 --- a/libavcodec/jpeg2000.h +++ b/libavcodec/jpeg2000.h @@ -302,6 +302,6 @@ static inline int needs_termination(int style, int passno) { } int32_t ff_tag_tree_size(int w, int h); -void ff_tag_tree_zero(Jpeg2000TgtNode *t, int w, int h); +void ff_tag_tree_zero(Jpeg2000TgtNode *t, int w, int h, int val); #endif /* AVCODEC_JPEG2000_H */ |