Commit 46246567 authored by Michael Niedermayer's avatar Michael Niedermayer

avcodec/j2kenc: Properly flush the end of the truncated AC stream

Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent e6190045
...@@ -612,7 +612,7 @@ static void encode_cblk(Jpeg2000EncoderContext *s, Jpeg2000T1Context *t1, Jpeg20 ...@@ -612,7 +612,7 @@ static void encode_cblk(Jpeg2000EncoderContext *s, Jpeg2000T1Context *t1, Jpeg20
break; break;
} }
cblk->passes[passno].rate = 3 + ff_mqc_length(&t1->mqc); cblk->passes[passno].rate = ff_mqc_flush_to(&t1->mqc, cblk->passes[passno].flushed, &cblk->passes[passno].flushed_len);
wmsedec += (int64_t)nmsedec << (2*bpno); wmsedec += (int64_t)nmsedec << (2*bpno);
cblk->passes[passno].disto = wmsedec; cblk->passes[passno].disto = wmsedec;
...@@ -624,8 +624,7 @@ static void encode_cblk(Jpeg2000EncoderContext *s, Jpeg2000T1Context *t1, Jpeg20 ...@@ -624,8 +624,7 @@ static void encode_cblk(Jpeg2000EncoderContext *s, Jpeg2000T1Context *t1, Jpeg20
cblk->npasses = passno; cblk->npasses = passno;
cblk->ninclpasses = passno; cblk->ninclpasses = passno;
// TODO: optional flush on each pass cblk->passes[passno-1].rate = ff_mqc_flush_to(&t1->mqc, cblk->passes[passno-1].flushed, &cblk->passes[passno-1].flushed_len);
cblk->passes[passno-1].rate = ff_mqc_flush(&t1->mqc);
} }
/* tier-2 routines: */ /* tier-2 routines: */
...@@ -732,7 +731,10 @@ static int encode_packet(Jpeg2000EncoderContext *s, Jpeg2000ResLevel *rlevel, in ...@@ -732,7 +731,10 @@ static int encode_packet(Jpeg2000EncoderContext *s, Jpeg2000ResLevel *rlevel, in
if (cblk->ninclpasses){ if (cblk->ninclpasses){
if (s->buf_end - s->buf < cblk->passes[cblk->ninclpasses-1].rate) if (s->buf_end - s->buf < cblk->passes[cblk->ninclpasses-1].rate)
return -1; return -1;
bytestream_put_buffer(&s->buf, cblk->data, cblk->passes[cblk->ninclpasses-1].rate); bytestream_put_buffer(&s->buf, cblk->data, cblk->passes[cblk->ninclpasses-1].rate
- cblk->passes[cblk->ninclpasses-1].flushed_len);
bytestream_put_buffer(&s->buf, cblk->passes[cblk->ninclpasses-1].flushed,
cblk->passes[cblk->ninclpasses-1].flushed_len);
} }
} }
} }
......
...@@ -159,6 +159,8 @@ typedef struct Jpeg2000QuantStyle { ...@@ -159,6 +159,8 @@ typedef struct Jpeg2000QuantStyle {
typedef struct Jpeg2000Pass { typedef struct Jpeg2000Pass {
uint16_t rate; uint16_t rate;
int64_t disto; int64_t disto;
uint8_t flushed[4];
int flushed_len;
} Jpeg2000Pass; } Jpeg2000Pass;
typedef struct Jpeg2000Cblk { typedef struct Jpeg2000Cblk {
......
ed9c45dc090a03c2eb9c35cf76e4d914 *tests/data/fate/vsynth1-jpeg2000.avi 445742f01d5ace759fef5c6bdcfda473 *tests/data/fate/vsynth1-jpeg2000.avi
2306906 tests/data/fate/vsynth1-jpeg2000.avi 2257170 tests/data/fate/vsynth1-jpeg2000.avi
64166a8fbb730a7a132c50ee89592672 *tests/data/fate/vsynth1-jpeg2000.out.rawvideo 5cdeb5efd2343994b949718e278819f2 *tests/data/fate/vsynth1-jpeg2000.out.rawvideo
stddev: 5.41 PSNR: 33.46 MAXDIFF: 63 bytes: 7603200/ 7603200 stddev: 5.37 PSNR: 33.53 MAXDIFF: 60 bytes: 7603200/ 7603200
95a06cbed5f085f5081653ec55a4dfe3 *tests/data/fate/vsynth1-jpeg2000-97.avi a6d84f1c576f3eb7d4ea37d0e4a3b84b *tests/data/fate/vsynth1-jpeg2000-97.avi
2243132 tests/data/fate/vsynth1-jpeg2000-97.avi 2195974 tests/data/fate/vsynth1-jpeg2000-97.avi
cc52cfa56b1bbd0fb011af37a2b94170 *tests/data/fate/vsynth1-jpeg2000-97.out.rawvideo 99f8f9436e6d9d42a71e3d2a90de61d0 *tests/data/fate/vsynth1-jpeg2000-97.out.rawvideo
stddev: 6.23 PSNR: 32.23 MAXDIFF: 75 bytes: 7603200/ 7603200 stddev: 6.21 PSNR: 32.27 MAXDIFF: 60 bytes: 7603200/ 7603200
b918de21dec4310f87af3788ed458462 *tests/data/fate/vsynth2-jpeg2000.avi 5e6963f14c74c374158bca007f9fd704 *tests/data/fate/vsynth2-jpeg2000.avi
1513144 tests/data/fate/vsynth2-jpeg2000.avi 1491518 tests/data/fate/vsynth2-jpeg2000.avi
d30f637670a60de6cc8d177047f32a59 *tests/data/fate/vsynth2-jpeg2000.out.rawvideo 025b1592f31bc71bb249af7e1124b50b *tests/data/fate/vsynth2-jpeg2000.out.rawvideo
stddev: 5.04 PSNR: 34.07 MAXDIFF: 71 bytes: 7603200/ 7603200 stddev: 5.00 PSNR: 34.14 MAXDIFF: 59 bytes: 7603200/ 7603200
156d67def9f0c1818a3e338bf85059c6 *tests/data/fate/vsynth2-jpeg2000-97.avi 228d4e9f4fde3cd5ef78c65506a1f85b *tests/data/fate/vsynth2-jpeg2000-97.avi
1467526 tests/data/fate/vsynth2-jpeg2000-97.avi 1447470 tests/data/fate/vsynth2-jpeg2000-97.avi
f9bd95734ebc92843cfd66b418bbdb96 *tests/data/fate/vsynth2-jpeg2000-97.out.rawvideo 3351e4a11b4da2971194be7f571f2655 *tests/data/fate/vsynth2-jpeg2000-97.out.rawvideo
stddev: 5.44 PSNR: 33.42 MAXDIFF: 57 bytes: 7603200/ 7603200 stddev: 5.40 PSNR: 33.47 MAXDIFF: 58 bytes: 7603200/ 7603200
7ea4e3901817f06a3de59ee70836f5d9 *tests/data/fate/vsynth3-jpeg2000.avi 9840f4a4fac08b00762fd377d6586772 *tests/data/fate/vsynth3-jpeg2000.avi
63772 tests/data/fate/vsynth3-jpeg2000.avi 61294 tests/data/fate/vsynth3-jpeg2000.avi
ddfc0e8e033aeecf334c1450148dab44 *tests/data/fate/vsynth3-jpeg2000.out.rawvideo 861d660c6618202cbbc70b71d5eae25b *tests/data/fate/vsynth3-jpeg2000.out.rawvideo
stddev: 5.52 PSNR: 33.28 MAXDIFF: 48 bytes: 86700/ 86700 stddev: 5.49 PSNR: 33.32 MAXDIFF: 47 bytes: 86700/ 86700
3e2f1e7d009d05e2bb9e8c3b10fab134 *tests/data/fate/vsynth3-jpeg2000-97.avi 65bf9803b13ae90b71e0e3caaa68719b *tests/data/fate/vsynth3-jpeg2000-97.avi
65364 tests/data/fate/vsynth3-jpeg2000-97.avi 62672 tests/data/fate/vsynth3-jpeg2000-97.avi
f9dad7a31175e400ca35de60aec826fd *tests/data/fate/vsynth3-jpeg2000-97.out.rawvideo 38058e324177a0ff064b48497ac2af4b *tests/data/fate/vsynth3-jpeg2000-97.out.rawvideo
stddev: 6.27 PSNR: 32.17 MAXDIFF: 52 bytes: 86700/ 86700 stddev: 6.26 PSNR: 32.19 MAXDIFF: 54 bytes: 86700/ 86700
9283c83bc8dc830bd48ad66f71ae42e8 *tests/data/fate/vsynth_lena-jpeg2000.avi b312f1eddda3aed23030495029d55888 *tests/data/fate/vsynth_lena-jpeg2000.avi
1151148 tests/data/fate/vsynth_lena-jpeg2000.avi 1133188 tests/data/fate/vsynth_lena-jpeg2000.avi
71a9ee7ad7c3dad60aa6641712c1f9e4 *tests/data/fate/vsynth_lena-jpeg2000.out.rawvideo 7630a7f2ae57be5827b4ade8323717e5 *tests/data/fate/vsynth_lena-jpeg2000.out.rawvideo
stddev: 4.44 PSNR: 35.17 MAXDIFF: 61 bytes: 7603200/ 7603200 stddev: 4.41 PSNR: 35.24 MAXDIFF: 58 bytes: 7603200/ 7603200
52771e812599277d65585b5849836bda *tests/data/fate/vsynth_lena-jpeg2000-97.avi 8e34a7e90f1363994fc2ce071b9bfc0f *tests/data/fate/vsynth_lena-jpeg2000-97.avi
1118958 tests/data/fate/vsynth_lena-jpeg2000-97.avi 1102144 tests/data/fate/vsynth_lena-jpeg2000-97.avi
1e53a235d1378010e14859d4d0d740f7 *tests/data/fate/vsynth_lena-jpeg2000-97.out.rawvideo 44f4d7a4cb6b0de932e2538fa75e983c *tests/data/fate/vsynth_lena-jpeg2000-97.out.rawvideo
stddev: 4.94 PSNR: 34.24 MAXDIFF: 60 bytes: 7603200/ 7603200 stddev: 4.91 PSNR: 34.30 MAXDIFF: 54 bytes: 7603200/ 7603200
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