[FFmpeg-devel] [PATCH] flashsv2enc: only encode diff blocks when needed

Daniel Verkamp daniel at drv.nu
Sat Sep 8 04:43:56 CEST 2012


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.
---
 libavcodec/flashsv2enc.c        |    7 +++----
 tests/ref/fate/vsynth1-flashsv2 |    4 ++--
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/libavcodec/flashsv2enc.c b/libavcodec/flashsv2enc.c
index 9725f29..a33c9bb 100644
--- a/libavcodec/flashsv2enc.c
+++ b/libavcodec/flashsv2enc.c
@@ -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);
diff --git a/tests/ref/fate/vsynth1-flashsv2 b/tests/ref/fate/vsynth1-flashsv2
index f8c2ed1..a01ccbe 100644
--- a/tests/ref/fate/vsynth1-flashsv2
+++ b/tests/ref/fate/vsynth1-flashsv2
@@ -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
-- 
1.7.8.6



More information about the ffmpeg-devel mailing list