flashsv2enc: only encode diff blocks when needed
authorDaniel Verkamp <daniel@drv.nu>
Sat, 8 Sep 2012 02:43:56 +0000 (19:43 -0700)
committerMichael Niedermayer <michaelni@gmx.at>
Sat, 8 Sep 2012 03:36:34 +0000 (05:36 +0200)
A flashsv2 block may have a "diff block" to indicate which scan lines of
the block are actually encoded.  However, this diff block need not be
used when the entire block is coded.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/flashsv2enc.c
tests/ref/fate/vsynth1-flashsv2
tests/ref/fate/vsynth2-flashsv2

index 9725f29..a33c9bb 100644 (file)
@@ -634,18 +634,17 @@ static int encode_all_blocks(FlashSV2Context * s, int keyframe)
         for (col = 0; col < s->cols; col++) {
             b = s->frame_blocks + (row * s->cols + col);
             prev = s->key_blocks + (row * s->cols + col);
+            b->flags = s->use15_7 ? COLORSPACE_15_7 : 0;
             if (keyframe) {
                 b->start = 0;
                 b->len = b->height;
-                b->flags = s->use15_7 ? COLORSPACE_15_7 : 0;
             } else if (!b->dirty) {
                 b->start = 0;
                 b->len = 0;
                 b->data_size = 0;
-                b->flags = s->use15_7 ? COLORSPACE_15_7 : 0;
                 continue;
-            } else {
-                b->flags = s->use15_7 ? COLORSPACE_15_7 | HAS_DIFF_BLOCKS : HAS_DIFF_BLOCKS;
+            } else if (b->start != 0 || b->len != b->height) {
+                b->flags |= HAS_DIFF_BLOCKS;
             }
             data = s->current_frame + s->image_width * 3 * s->block_height * row + s->block_width * col * 3;
             res = encode_block(s, &s->palette, b, prev, data, s->image_width * 3, s->comp, s->dist, keyframe);
index f8c2ed1..a01ccbe 100644 (file)
@@ -1,4 +1,4 @@
-e3403ea852029daf589a7a4dfd8f6cae *tests/data/fate/vsynth1-flashsv2.flv
-9371095 tests/data/fate/vsynth1-flashsv2.flv
+adbbdd25c1ed2f87ea589d2314307cdf *tests/data/fate/vsynth1-flashsv2.flv
+9368395 tests/data/fate/vsynth1-flashsv2.flv
 efa88d09115a2e947eff00ee435ba3f3 *tests/data/fate/vsynth1-flashsv2.out.rawvideo
 stddev:    3.47 PSNR: 37.31 MAXDIFF:   49 bytes:  7603200/  7603200
index 580ad97..d207a8b 100644 (file)
@@ -1,4 +1,4 @@
-4baf149705dbbd8084879d692e6acc8a *tests/data/fate/vsynth2-flashsv2.flv
-9293862 tests/data/fate/vsynth2-flashsv2.flv
+01e0aa4da9ccc8e12fd03df63625eea4 *tests/data/fate/vsynth2-flashsv2.flv
+9291162 tests/data/fate/vsynth2-flashsv2.flv
 8f63e24049ba1789a7f8353c695a3d99 *tests/data/fate/vsynth2-flashsv2.out.rawvideo
 stddev:    2.39 PSNR: 40.55 MAXDIFF:   21 bytes:  7603200/  7603200