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>
This commit is contained in:
Gautam Ramakrishnan 2020-08-28 00:15:36 +05:30 committed by Michael Niedermayer
parent f0e33119e4
commit 341064d68a
11 changed files with 23 additions and 23 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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 */

View File

@ -1,4 +1,4 @@
dd66b25f2ebc965eae4c29cfacdd960f *tests/data/fate/vsynth1-jpeg2000.avi
2274950 tests/data/fate/vsynth1-jpeg2000.avi
95add005faf68fcf8f16e86eab079ca2 *tests/data/fate/vsynth1-jpeg2000.avi
2263192 tests/data/fate/vsynth1-jpeg2000.avi
b7f48a8965f78011c76483277befc6fc *tests/data/fate/vsynth1-jpeg2000.out.rawvideo
stddev: 5.35 PSNR: 33.56 MAXDIFF: 59 bytes: 7603200/ 7603200

View File

@ -1,4 +1,4 @@
f22ad99de77f8f4382c6cf10d5af42b5 *tests/data/fate/vsynth1-jpeg2000-97.avi
3661422 tests/data/fate/vsynth1-jpeg2000-97.avi
e4d03b2e3c03e56c7f831b1e662c4031 *tests/data/fate/vsynth1-jpeg2000-97.avi
3643928 tests/data/fate/vsynth1-jpeg2000-97.avi
a2262f1da2f49bc196b780a6b47ec4e8 *tests/data/fate/vsynth1-jpeg2000-97.out.rawvideo
stddev: 4.23 PSNR: 35.59 MAXDIFF: 53 bytes: 7603200/ 7603200

View File

@ -1,4 +1,4 @@
49df1372d20dae57b4ff28ac4d81bb78 *tests/data/fate/vsynth2-jpeg2000.avi
1551520 tests/data/fate/vsynth2-jpeg2000.avi
8c8a68ca748190c71b3ea43e5ab7f502 *tests/data/fate/vsynth2-jpeg2000.avi
1538736 tests/data/fate/vsynth2-jpeg2000.avi
64fadc87447268cf90503cb294db7f61 *tests/data/fate/vsynth2-jpeg2000.out.rawvideo
stddev: 4.91 PSNR: 34.29 MAXDIFF: 55 bytes: 7603200/ 7603200

View File

@ -1,4 +1,4 @@
8443e3ae43675212be9a8274cfe5d5be *tests/data/fate/vsynth2-jpeg2000-97.avi
2484530 tests/data/fate/vsynth2-jpeg2000-97.avi
c8f76055f59804ca72dbd66eb4db83a2 *tests/data/fate/vsynth2-jpeg2000-97.avi
2464138 tests/data/fate/vsynth2-jpeg2000-97.avi
1f63c8b065e847e4c63d57ce23442ea8 *tests/data/fate/vsynth2-jpeg2000-97.out.rawvideo
stddev: 3.21 PSNR: 37.99 MAXDIFF: 26 bytes: 7603200/ 7603200

View File

@ -1,4 +1,4 @@
548df443acb32593455bbcd8f531c00b *tests/data/fate/vsynth3-jpeg2000.avi
67658 tests/data/fate/vsynth3-jpeg2000.avi
776bf3234cbf25002f129b89baab42ea *tests/data/fate/vsynth3-jpeg2000.avi
67400 tests/data/fate/vsynth3-jpeg2000.avi
098f5980667e1fcd50452b1dc1a74f61 *tests/data/fate/vsynth3-jpeg2000.out.rawvideo
stddev: 5.47 PSNR: 33.36 MAXDIFF: 48 bytes: 86700/ 86700

View File

@ -1,4 +1,4 @@
494464d224d5aa2726bc6a8630a390aa *tests/data/fate/vsynth3-jpeg2000-97.avi
86016 tests/data/fate/vsynth3-jpeg2000-97.avi
cd023db503f03ef72dd83e4617a90c7b *tests/data/fate/vsynth3-jpeg2000-97.avi
85606 tests/data/fate/vsynth3-jpeg2000-97.avi
8def36ad1413ab3a5c2af2e1af4603f9 *tests/data/fate/vsynth3-jpeg2000-97.out.rawvideo
stddev: 4.51 PSNR: 35.04 MAXDIFF: 47 bytes: 86700/ 86700

View File

@ -1,4 +1,4 @@
e4cf380b198e6bcb00ec338914f6ebb3 *tests/data/fate/vsynth_lena-jpeg2000.avi
1202516 tests/data/fate/vsynth_lena-jpeg2000.avi
b8aaa45236f77a2a626791d462fd8ac1 *tests/data/fate/vsynth_lena-jpeg2000.avi
1188886 tests/data/fate/vsynth_lena-jpeg2000.avi
39a2c5b61cd0cf2821c6fb4cceba2fa8 *tests/data/fate/vsynth_lena-jpeg2000.out.rawvideo
stddev: 4.30 PSNR: 35.45 MAXDIFF: 45 bytes: 7603200/ 7603200

View File

@ -1,4 +1,4 @@
29dd43765363e17179c2de4167b32399 *tests/data/fate/vsynth_lena-jpeg2000-97.avi
1958334 tests/data/fate/vsynth_lena-jpeg2000-97.avi
b2d9525433c6300674f504922d762437 *tests/data/fate/vsynth_lena-jpeg2000-97.avi
1937232 tests/data/fate/vsynth_lena-jpeg2000-97.avi
1b97333a8dc115a5ba609b0070d89d4d *tests/data/fate/vsynth_lena-jpeg2000-97.out.rawvideo
stddev: 2.82 PSNR: 39.10 MAXDIFF: 24 bytes: 7603200/ 7603200