[FFmpeg-cvslog] avcodec/j2kenc: Properly flush the end of the truncated AC stream

Michael Niedermayer git at videolan.org
Wed Jun 17 20:50:57 CEST 2015


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Wed Jun 17 20:13:05 2015 +0200| [4624656797b667eb6405186682eb04e74dfd90fd] | committer: Michael Niedermayer

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

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4624656797b667eb6405186682eb04e74dfd90fd
---

 libavcodec/j2kenc.c                      |   10 ++++++----
 libavcodec/jpeg2000.h                    |    2 ++
 tests/ref/vsynth/vsynth1-jpeg2000        |    8 ++++----
 tests/ref/vsynth/vsynth1-jpeg2000-97     |    8 ++++----
 tests/ref/vsynth/vsynth2-jpeg2000        |    8 ++++----
 tests/ref/vsynth/vsynth2-jpeg2000-97     |    8 ++++----
 tests/ref/vsynth/vsynth3-jpeg2000        |    8 ++++----
 tests/ref/vsynth/vsynth3-jpeg2000-97     |    8 ++++----
 tests/ref/vsynth/vsynth_lena-jpeg2000    |    8 ++++----
 tests/ref/vsynth/vsynth_lena-jpeg2000-97 |    8 ++++----
 10 files changed, 40 insertions(+), 36 deletions(-)

diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c
index 593ceb4..68905cc 100644
--- a/libavcodec/j2kenc.c
+++ b/libavcodec/j2kenc.c
@@ -612,7 +612,7 @@ static void encode_cblk(Jpeg2000EncoderContext *s, Jpeg2000T1Context *t1, Jpeg20
                     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);
         cblk->passes[passno].disto = wmsedec;
 
@@ -624,8 +624,7 @@ static void encode_cblk(Jpeg2000EncoderContext *s, Jpeg2000T1Context *t1, Jpeg20
     cblk->npasses = passno;
     cblk->ninclpasses = passno;
 
-    // TODO: optional flush on each pass
-    cblk->passes[passno-1].rate = ff_mqc_flush(&t1->mqc);
+    cblk->passes[passno-1].rate = ff_mqc_flush_to(&t1->mqc, cblk->passes[passno-1].flushed, &cblk->passes[passno-1].flushed_len);
 }
 
 /* tier-2 routines: */
@@ -732,7 +731,10 @@ static int encode_packet(Jpeg2000EncoderContext *s, Jpeg2000ResLevel *rlevel, in
                 if (cblk->ninclpasses){
                     if (s->buf_end - s->buf < cblk->passes[cblk->ninclpasses-1].rate)
                         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);
                 }
             }
         }
diff --git a/libavcodec/jpeg2000.h b/libavcodec/jpeg2000.h
index 1054fe6..f963cbe 100644
--- a/libavcodec/jpeg2000.h
+++ b/libavcodec/jpeg2000.h
@@ -159,6 +159,8 @@ typedef struct Jpeg2000QuantStyle {
 typedef struct Jpeg2000Pass {
     uint16_t rate;
     int64_t disto;
+    uint8_t flushed[4];
+    int flushed_len;
 } Jpeg2000Pass;
 
 typedef struct Jpeg2000Cblk {
diff --git a/tests/ref/vsynth/vsynth1-jpeg2000 b/tests/ref/vsynth/vsynth1-jpeg2000
index fb110b2..fec4c2e 100644
--- a/tests/ref/vsynth/vsynth1-jpeg2000
+++ b/tests/ref/vsynth/vsynth1-jpeg2000
@@ -1,4 +1,4 @@
-ed9c45dc090a03c2eb9c35cf76e4d914 *tests/data/fate/vsynth1-jpeg2000.avi
-2306906 tests/data/fate/vsynth1-jpeg2000.avi
-64166a8fbb730a7a132c50ee89592672 *tests/data/fate/vsynth1-jpeg2000.out.rawvideo
-stddev:    5.41 PSNR: 33.46 MAXDIFF:   63 bytes:  7603200/  7603200
+445742f01d5ace759fef5c6bdcfda473 *tests/data/fate/vsynth1-jpeg2000.avi
+2257170 tests/data/fate/vsynth1-jpeg2000.avi
+5cdeb5efd2343994b949718e278819f2 *tests/data/fate/vsynth1-jpeg2000.out.rawvideo
+stddev:    5.37 PSNR: 33.53 MAXDIFF:   60 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth1-jpeg2000-97 b/tests/ref/vsynth/vsynth1-jpeg2000-97
index 7235245..13b0050 100644
--- a/tests/ref/vsynth/vsynth1-jpeg2000-97
+++ b/tests/ref/vsynth/vsynth1-jpeg2000-97
@@ -1,4 +1,4 @@
-95a06cbed5f085f5081653ec55a4dfe3 *tests/data/fate/vsynth1-jpeg2000-97.avi
-2243132 tests/data/fate/vsynth1-jpeg2000-97.avi
-cc52cfa56b1bbd0fb011af37a2b94170 *tests/data/fate/vsynth1-jpeg2000-97.out.rawvideo
-stddev:    6.23 PSNR: 32.23 MAXDIFF:   75 bytes:  7603200/  7603200
+a6d84f1c576f3eb7d4ea37d0e4a3b84b *tests/data/fate/vsynth1-jpeg2000-97.avi
+2195974 tests/data/fate/vsynth1-jpeg2000-97.avi
+99f8f9436e6d9d42a71e3d2a90de61d0 *tests/data/fate/vsynth1-jpeg2000-97.out.rawvideo
+stddev:    6.21 PSNR: 32.27 MAXDIFF:   60 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth2-jpeg2000 b/tests/ref/vsynth/vsynth2-jpeg2000
index 2100042..e06a5af 100644
--- a/tests/ref/vsynth/vsynth2-jpeg2000
+++ b/tests/ref/vsynth/vsynth2-jpeg2000
@@ -1,4 +1,4 @@
-b918de21dec4310f87af3788ed458462 *tests/data/fate/vsynth2-jpeg2000.avi
-1513144 tests/data/fate/vsynth2-jpeg2000.avi
-d30f637670a60de6cc8d177047f32a59 *tests/data/fate/vsynth2-jpeg2000.out.rawvideo
-stddev:    5.04 PSNR: 34.07 MAXDIFF:   71 bytes:  7603200/  7603200
+5e6963f14c74c374158bca007f9fd704 *tests/data/fate/vsynth2-jpeg2000.avi
+1491518 tests/data/fate/vsynth2-jpeg2000.avi
+025b1592f31bc71bb249af7e1124b50b *tests/data/fate/vsynth2-jpeg2000.out.rawvideo
+stddev:    5.00 PSNR: 34.14 MAXDIFF:   59 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth2-jpeg2000-97 b/tests/ref/vsynth/vsynth2-jpeg2000-97
index 5de0222..87dac4f 100644
--- a/tests/ref/vsynth/vsynth2-jpeg2000-97
+++ b/tests/ref/vsynth/vsynth2-jpeg2000-97
@@ -1,4 +1,4 @@
-156d67def9f0c1818a3e338bf85059c6 *tests/data/fate/vsynth2-jpeg2000-97.avi
-1467526 tests/data/fate/vsynth2-jpeg2000-97.avi
-f9bd95734ebc92843cfd66b418bbdb96 *tests/data/fate/vsynth2-jpeg2000-97.out.rawvideo
-stddev:    5.44 PSNR: 33.42 MAXDIFF:   57 bytes:  7603200/  7603200
+228d4e9f4fde3cd5ef78c65506a1f85b *tests/data/fate/vsynth2-jpeg2000-97.avi
+1447470 tests/data/fate/vsynth2-jpeg2000-97.avi
+3351e4a11b4da2971194be7f571f2655 *tests/data/fate/vsynth2-jpeg2000-97.out.rawvideo
+stddev:    5.40 PSNR: 33.47 MAXDIFF:   58 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth3-jpeg2000 b/tests/ref/vsynth/vsynth3-jpeg2000
index 0d086cf..4bbb2d8 100644
--- a/tests/ref/vsynth/vsynth3-jpeg2000
+++ b/tests/ref/vsynth/vsynth3-jpeg2000
@@ -1,4 +1,4 @@
-7ea4e3901817f06a3de59ee70836f5d9 *tests/data/fate/vsynth3-jpeg2000.avi
-63772 tests/data/fate/vsynth3-jpeg2000.avi
-ddfc0e8e033aeecf334c1450148dab44 *tests/data/fate/vsynth3-jpeg2000.out.rawvideo
-stddev:    5.52 PSNR: 33.28 MAXDIFF:   48 bytes:    86700/    86700
+9840f4a4fac08b00762fd377d6586772 *tests/data/fate/vsynth3-jpeg2000.avi
+61294 tests/data/fate/vsynth3-jpeg2000.avi
+861d660c6618202cbbc70b71d5eae25b *tests/data/fate/vsynth3-jpeg2000.out.rawvideo
+stddev:    5.49 PSNR: 33.32 MAXDIFF:   47 bytes:    86700/    86700
diff --git a/tests/ref/vsynth/vsynth3-jpeg2000-97 b/tests/ref/vsynth/vsynth3-jpeg2000-97
index d1695de..67b70df 100644
--- a/tests/ref/vsynth/vsynth3-jpeg2000-97
+++ b/tests/ref/vsynth/vsynth3-jpeg2000-97
@@ -1,4 +1,4 @@
-3e2f1e7d009d05e2bb9e8c3b10fab134 *tests/data/fate/vsynth3-jpeg2000-97.avi
-65364 tests/data/fate/vsynth3-jpeg2000-97.avi
-f9dad7a31175e400ca35de60aec826fd *tests/data/fate/vsynth3-jpeg2000-97.out.rawvideo
-stddev:    6.27 PSNR: 32.17 MAXDIFF:   52 bytes:    86700/    86700
+65bf9803b13ae90b71e0e3caaa68719b *tests/data/fate/vsynth3-jpeg2000-97.avi
+62672 tests/data/fate/vsynth3-jpeg2000-97.avi
+38058e324177a0ff064b48497ac2af4b *tests/data/fate/vsynth3-jpeg2000-97.out.rawvideo
+stddev:    6.26 PSNR: 32.19 MAXDIFF:   54 bytes:    86700/    86700
diff --git a/tests/ref/vsynth/vsynth_lena-jpeg2000 b/tests/ref/vsynth/vsynth_lena-jpeg2000
index 6605f62..04c4560 100644
--- a/tests/ref/vsynth/vsynth_lena-jpeg2000
+++ b/tests/ref/vsynth/vsynth_lena-jpeg2000
@@ -1,4 +1,4 @@
-9283c83bc8dc830bd48ad66f71ae42e8 *tests/data/fate/vsynth_lena-jpeg2000.avi
-1151148 tests/data/fate/vsynth_lena-jpeg2000.avi
-71a9ee7ad7c3dad60aa6641712c1f9e4 *tests/data/fate/vsynth_lena-jpeg2000.out.rawvideo
-stddev:    4.44 PSNR: 35.17 MAXDIFF:   61 bytes:  7603200/  7603200
+b312f1eddda3aed23030495029d55888 *tests/data/fate/vsynth_lena-jpeg2000.avi
+1133188 tests/data/fate/vsynth_lena-jpeg2000.avi
+7630a7f2ae57be5827b4ade8323717e5 *tests/data/fate/vsynth_lena-jpeg2000.out.rawvideo
+stddev:    4.41 PSNR: 35.24 MAXDIFF:   58 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth_lena-jpeg2000-97 b/tests/ref/vsynth/vsynth_lena-jpeg2000-97
index ea30c0d..a82c9d6 100644
--- a/tests/ref/vsynth/vsynth_lena-jpeg2000-97
+++ b/tests/ref/vsynth/vsynth_lena-jpeg2000-97
@@ -1,4 +1,4 @@
-52771e812599277d65585b5849836bda *tests/data/fate/vsynth_lena-jpeg2000-97.avi
-1118958 tests/data/fate/vsynth_lena-jpeg2000-97.avi
-1e53a235d1378010e14859d4d0d740f7 *tests/data/fate/vsynth_lena-jpeg2000-97.out.rawvideo
-stddev:    4.94 PSNR: 34.24 MAXDIFF:   60 bytes:  7603200/  7603200
+8e34a7e90f1363994fc2ce071b9bfc0f *tests/data/fate/vsynth_lena-jpeg2000-97.avi
+1102144 tests/data/fate/vsynth_lena-jpeg2000-97.avi
+44f4d7a4cb6b0de932e2538fa75e983c *tests/data/fate/vsynth_lena-jpeg2000-97.out.rawvideo
+stddev:    4.91 PSNR: 34.30 MAXDIFF:   54 bytes:  7603200/  7603200



More information about the ffmpeg-cvslog mailing list