From 504dfc78085163d588b3f06d9e62c4d85ceebb17 Mon Sep 17 00:00:00 2001
From: Stanislav Dolganov <dolganov@qst.hk>
Date: Thu, 24 Mar 2016 13:53:43 +0300
Subject: [PATCH] simple P frame support

---
 libavcodec/ffv1.c                          | 13 ++++-
 libavcodec/ffv1.h                          |  4 +-
 libavcodec/ffv1dec.c                       | 76 ++++++++++++++++++++++++++
 libavcodec/ffv1enc.c                       | 87 ++++++++++++++++++++++++++++++
 tests/ref/vsynth/vsynth1-ffv1              |  4 +-
 tests/ref/vsynth/vsynth1-ffv1-v0           |  4 +-
 tests/ref/vsynth/vsynth1-ffv1-v3-bgr0      |  4 +-
 tests/ref/vsynth/vsynth1-ffv1-v3-yuv420p   |  4 +-
 tests/ref/vsynth/vsynth1-ffv1-v3-yuv422p10 |  4 +-
 tests/ref/vsynth/vsynth1-ffv1-v3-yuv444p16 |  4 +-
 tests/ref/vsynth/vsynth2-ffv1              |  4 +-
 tests/ref/vsynth/vsynth2-ffv1-v0           |  4 +-
 tests/ref/vsynth/vsynth2-ffv1-v3-bgr0      |  4 +-
 tests/ref/vsynth/vsynth2-ffv1-v3-yuv420p   |  4 +-
 tests/ref/vsynth/vsynth2-ffv1-v3-yuv422p10 |  4 +-
 tests/ref/vsynth/vsynth2-ffv1-v3-yuv444p16 |  4 +-
 tests/ref/vsynth/vsynth3-ffv1              |  4 +-
 tests/ref/vsynth/vsynth3-ffv1-v0           |  4 +-
 tests/ref/vsynth/vsynth3-ffv1-v3-bgr0      |  4 +-
 tests/ref/vsynth/vsynth3-ffv1-v3-yuv420p   |  4 +-
 tests/ref/vsynth/vsynth3-ffv1-v3-yuv422p10 |  4 +-
 tests/ref/vsynth/vsynth3-ffv1-v3-yuv444p16 |  4 +-
 22 files changed, 214 insertions(+), 38 deletions(-)

diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c
index 537409e..428bc8d 100644
--- a/libavcodec/ffv1.c
+++ b/libavcodec/ffv1.c
@@ -51,12 +51,16 @@ av_cold int ff_ffv1_common_init(AVCodecContext *avctx)
 
     s->picture.f = av_frame_alloc();
     s->last_picture.f = av_frame_alloc();
-    if (!s->picture.f || !s->last_picture.f)
+    s->residual.f = av_frame_alloc();
+    if (!s->picture.f || !s->last_picture.f || !s->residual.f)
         return AVERROR(ENOMEM);
 
     s->width  = avctx->width;
     s->height = avctx->height;
 
+    s->c_image_line_buf = av_mallocz_array(sizeof(*s->c_image_line_buf), s->width);
+    s->p_image_line_buf = av_mallocz_array(sizeof(*s->p_image_line_buf), s->width);
+
     // defaults
     s->num_h_slices = 1;
     s->num_v_slices = 1;
@@ -215,6 +219,10 @@ av_cold int ff_ffv1_close(AVCodecContext *avctx)
         ff_thread_release_buffer(avctx, &s->last_picture);
     av_frame_free(&s->last_picture.f);
 
+    if (s->residual.f)
+        ff_thread_release_buffer(avctx, &s->residual);
+    av_frame_free(&s->residual.f);
+
     for (j = 0; j < s->max_slice_count; j++) {
         FFV1Context *fs = s->slice_context[j];
         for (i = 0; i < s->plane_count; i++) {
@@ -226,6 +234,9 @@ av_cold int ff_ffv1_close(AVCodecContext *avctx)
         av_freep(&fs->sample_buffer);
     }
 
+    av_freep(&s->c_image_line_buf);
+    av_freep(&s->p_image_line_buf);
+
     av_freep(&avctx->stats_out);
     for (j = 0; j < s->quant_table_count; j++) {
         av_freep(&s->initial_states[j]);
diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h
index d9398e5..8d1f74a 100644
--- a/libavcodec/ffv1.h
+++ b/libavcodec/ffv1.h
@@ -93,7 +93,7 @@ typedef struct FFV1Context {
     int flags;
     int picture_number;
     int key_frame;
-    ThreadFrame picture, last_picture;
+    ThreadFrame picture, last_picture, residual;
     struct FFV1Context *fsrc;
 
     AVFrame *cur;
@@ -110,6 +110,8 @@ typedef struct FFV1Context {
     int colorspace;
     int16_t *sample_buffer;
 
+    uint16_t *p_image_line_buf, *c_image_line_buf;
+
     int ec;
     int intra;
     int slice_damaged;
diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c
index d2bf3a8..32e8d9b 100644
--- a/libavcodec/ffv1dec.c
+++ b/libavcodec/ffv1dec.c
@@ -39,6 +39,74 @@
 #include "mathops.h"
 #include "ffv1.h"
 
+static int ff_predict_frame(AVCodecContext *c, FFV1Context *f)
+{
+    int ret, i, x, y;
+    AVFrame *curr     = f->picture.f;
+    AVFrame *prev     = f->last_picture.f;
+    AVFrame *residual = f->residual.f;
+    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(prev->format);
+    int width  = f->width;
+    int height = f->height;
+    int has_plane[4] = { 0 };
+    const int cw = AV_CEIL_RSHIFT(width, desc->log2_chroma_w);
+    const int ch = AV_CEIL_RSHIFT(height, desc->log2_chroma_h);
+
+    if (f->residual.f)
+        av_frame_unref(f->residual.f);
+    if ((ret = av_frame_ref(f->residual.f, f->picture.f)) < 0)
+        return ret;
+    if ((ret = av_frame_make_writable(f->residual.f)) < 0) {
+        av_frame_unref(f->residual.f);
+        return ret;
+    }
+
+    for (i = 0; i < desc->nb_components; i++)
+        has_plane[desc->comp[i].plane] = 1;
+
+    for (i = 0; i < desc->nb_components && has_plane[i]; i++)
+        memset(residual->buf[i]->data, 0, residual->buf[i]->size * sizeof(*residual->buf[i]->data));
+
+    for (i = 0; i < desc->nb_components; i++) {
+        const int w1 = (i == 1 || i == 2) ? cw : width;
+        const int h1 = (i == 1 || i == 2) ? ch : height;
+
+        for (y = 0; y < h1; y++) {
+            memset(f->p_image_line_buf, 0, width * sizeof(*f->p_image_line_buf));
+            memset(f->c_image_line_buf, 0, width * sizeof(*f->c_image_line_buf));
+            av_read_image_line(f->c_image_line_buf,
+                               (void *)curr->data,
+                               curr->linesize,
+                               desc,
+                               0, y, i, w1, 0);
+            av_read_image_line(f->p_image_line_buf,
+                              (void *)prev->data,
+                              prev->linesize,
+                              desc,
+                              0, y, i, w1, 0);
+            for (x = 0; x < w1; ++x)
+                f->c_image_line_buf[x] ^= f->p_image_line_buf[x];
+            av_write_image_line(f->c_image_line_buf,
+                                residual->data,
+                                residual->linesize,
+                                desc,
+                                0, y, i, w1);
+            memset(f->p_image_line_buf, 0, width * sizeof(*f->p_image_line_buf));
+            av_read_image_line(f->p_image_line_buf,
+                               (void *)residual->data,
+                               residual->linesize,
+                               desc,
+                               0, y, i, w1, 0);
+            av_assert0(!memcmp(f->p_image_line_buf, f->c_image_line_buf, width * sizeof(*f->c_image_line_buf)));
+        }
+    }
+
+    if ((ret = av_frame_ref(f->picture.f, f->residual.f)) < 0)
+        return ret;
+
+    return 0;
+}
+
 static inline av_flatten int get_symbol_inline(RangeCoder *c, uint8_t *state,
                                                int is_signed)
 {
@@ -935,6 +1003,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
         p->key_frame = 0;
     }
 
+    p->pict_type = p->key_frame ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
+
     if ((ret = ff_thread_get_buffer(avctx, &f->picture, AV_GET_BUFFER_FLAG_REF)) < 0)
         return ret;
 
@@ -1022,9 +1092,15 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
 
     f->picture_number++;
 
+    if (!p->key_frame) {
+        if ((ret = ff_predict_frame(avctx, f)) < 0)
+            return ret;
+    }
+
     if (f->last_picture.f)
         ff_thread_release_buffer(avctx, &f->last_picture);
     f->cur = NULL;
+
     if ((ret = av_frame_ref(data, f->picture.f)) < 0)
         return ret;
 
diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index 9ee9921..6627234 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -135,6 +135,76 @@ static const uint8_t ver2_state[256] = {
     241, 243, 242, 244, 245, 246, 247, 248, 249, 250, 251, 252, 252, 253, 254, 255,
 };
 
+static int ff_frame_diff(FFV1Context *f, const AVFrame *pict)
+{
+    int ret, i, x, y;
+    AVFrame *curr     = f->picture.f;
+    AVFrame *prev     = f->last_picture.f;
+    AVFrame *residual = f->residual.f;
+    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(prev->format);
+    int width  = f->width;
+    int height = f->height;
+    int has_plane[4] = { 0 };
+    const int cw = AV_CEIL_RSHIFT(width, desc->log2_chroma_w);
+    const int ch = AV_CEIL_RSHIFT(height, desc->log2_chroma_h);
+
+    if (f->picture.f)
+        av_frame_unref(f->picture.f);
+    if (f->residual.f)
+        av_frame_unref(f->residual.f);
+    if ((ret = av_frame_ref(f->residual.f, pict)) < 0)
+        return ret;
+    if ((ret = av_frame_make_writable(f->residual.f)) < 0) {
+        av_frame_unref(f->residual.f);
+        return ret;
+    }
+
+    for (i = 0; i < desc->nb_components; i++)
+        has_plane[desc->comp[i].plane] = 1;
+
+    for (i = 0; i < desc->nb_components && has_plane[i]; i++)
+        memset(residual->buf[i]->data, 0, residual->buf[i]->size * sizeof(*residual->buf[i]->data));
+
+    for (i = 0; i < desc->nb_components; i++) {
+        const int w1 = (i == 1 || i == 2) ? cw : width;
+        const int h1 = (i == 1 || i == 2) ? ch : height;
+
+        for (y = 0; y < h1; y++) {
+            memset(f->p_image_line_buf, 0, width * sizeof(*f->p_image_line_buf));
+            memset(f->c_image_line_buf, 0, width * sizeof(*f->c_image_line_buf));
+            av_read_image_line(f->c_image_line_buf,
+                               (void *)pict->data,
+                               pict->linesize,
+                               desc,
+                               0, y, i, w1, 0);
+            av_read_image_line(f->p_image_line_buf,
+                              (void *)prev->data,
+                              prev->linesize,
+                              desc,
+                              0, y, i, w1, 0);
+            for (x = 0; x < w1; ++x)
+                f->c_image_line_buf[x] ^= f->p_image_line_buf[x];
+            av_write_image_line(f->c_image_line_buf,
+                                residual->data,
+                                residual->linesize,
+                                desc,
+                                0, y, i, w1);
+            memset(f->p_image_line_buf, 0, width * sizeof(*f->p_image_line_buf));
+            av_read_image_line(f->p_image_line_buf,
+                              (void *)residual->data,
+                              residual->linesize,
+                              desc,
+                              0, y, i, w1, 0);
+            av_assert0(!memcmp(f->p_image_line_buf, f->c_image_line_buf, width * sizeof(*f->c_image_line_buf)));
+        }
+    }
+
+    if ((ret = av_frame_ref(f->picture.f, f->residual.f)) < 0)
+        return ret;
+
+    return 0;
+}
+
 static void find_best_state(uint8_t best_state[256][256],
                             const uint8_t one_state[256])
 {
@@ -1222,6 +1292,9 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
                         const AVFrame *pict, int *got_packet)
 {
     FFV1Context *f      = avctx->priv_data;
+    if (f->last_picture.f)
+        av_frame_unref(f->last_picture.f);
+    FFSWAP(ThreadFrame, f->picture, f->last_picture);
     RangeCoder *const c = &f->slice_context[0]->c;
     AVFrame *const p    = f->picture.f;
     int used_count      = 0;
@@ -1301,6 +1374,13 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
         f->key_frame = 0;
     }
 
+    avctx->coded_frame->pict_type = f->key_frame ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
+    if (!f->key_frame) {
+        if ((ret = ff_frame_diff(f, pict)) < 0) {
+            return ret;
+        }
+    }
+
     if (f->ac == AC_RANGE_CUSTOM_TAB) {
         int i;
         for (i = 1; i < 256; i++) {
@@ -1364,6 +1444,13 @@ FF_ENABLE_DEPRECATION_WARNINGS
     pkt->flags |= AV_PKT_FLAG_KEY * f->key_frame;
     *got_packet = 1;
 
+    if (f->picture.f)
+        av_frame_unref(f->picture.f);
+    if ((ret = av_frame_ref(f->picture.f, pict)) < 0)
+        return ret;
+    if (f->last_picture.f)
+        av_frame_unref(f->last_picture.f);
+
     return 0;
 }
 
diff --git a/tests/ref/vsynth/vsynth1-ffv1 b/tests/ref/vsynth/vsynth1-ffv1
index 001f10a..477462b 100644
--- a/tests/ref/vsynth/vsynth1-ffv1
+++ b/tests/ref/vsynth/vsynth1-ffv1
@@ -1,4 +1,4 @@
-26b1296a0ef80a3b5c8b63cc57c52bc2 *tests/data/fate/vsynth1-ffv1.avi
-2691268 tests/data/fate/vsynth1-ffv1.avi
+32caa587f6dc41f5f9c0fdf858b202d6 *tests/data/fate/vsynth1-ffv1.avi
+5877448 tests/data/fate/vsynth1-ffv1.avi
 c5ccac874dbf808e9088bc3107860042 *tests/data/fate/vsynth1-ffv1.out.rawvideo
 stddev:    0.00 PSNR:999.99 MAXDIFF:    0 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth1-ffv1-v0 b/tests/ref/vsynth/vsynth1-ffv1-v0
index 8c722e4..0a5c3bb 100644
--- a/tests/ref/vsynth/vsynth1-ffv1-v0
+++ b/tests/ref/vsynth/vsynth1-ffv1-v0
@@ -1,4 +1,4 @@
-36011c9a2b288fb04bf6c520371646d4 *tests/data/fate/vsynth1-ffv1-v0.avi
-2655368 tests/data/fate/vsynth1-ffv1-v0.avi
+db9cee61d80d114d4c20dc2999b65feb *tests/data/fate/vsynth1-ffv1-v0.avi
+5784902 tests/data/fate/vsynth1-ffv1-v0.avi
 c5ccac874dbf808e9088bc3107860042 *tests/data/fate/vsynth1-ffv1-v0.out.rawvideo
 stddev:    0.00 PSNR:999.99 MAXDIFF:    0 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth1-ffv1-v3-bgr0 b/tests/ref/vsynth/vsynth1-ffv1-v3-bgr0
index 3808f49..f24001e 100644
--- a/tests/ref/vsynth/vsynth1-ffv1-v3-bgr0
+++ b/tests/ref/vsynth/vsynth1-ffv1-v3-bgr0
@@ -1,4 +1,4 @@
-3c68357b239479fc26656f6dd76b0b58 *tests/data/fate/vsynth1-ffv1-v3-bgr0.avi
-6883176 tests/data/fate/vsynth1-ffv1-v3-bgr0.avi
+3becb49d5a46e53e27332095bb48c14c *tests/data/fate/vsynth1-ffv1-v3-bgr0.avi
+14332302 tests/data/fate/vsynth1-ffv1-v3-bgr0.avi
 49c03ab1b73b7cd3cabc3c77a9479c9e *tests/data/fate/vsynth1-ffv1-v3-bgr0.out.rawvideo
 stddev:    3.16 PSNR: 38.12 MAXDIFF:   50 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth1-ffv1-v3-yuv420p b/tests/ref/vsynth/vsynth1-ffv1-v3-yuv420p
index a4af95b..6d7dbf3 100644
--- a/tests/ref/vsynth/vsynth1-ffv1-v3-yuv420p
+++ b/tests/ref/vsynth/vsynth1-ffv1-v3-yuv420p
@@ -1,4 +1,4 @@
-26b1296a0ef80a3b5c8b63cc57c52bc2 *tests/data/fate/vsynth1-ffv1-v3-yuv420p.avi
-2691268 tests/data/fate/vsynth1-ffv1-v3-yuv420p.avi
+32caa587f6dc41f5f9c0fdf858b202d6 *tests/data/fate/vsynth1-ffv1-v3-yuv420p.avi
+5877448 tests/data/fate/vsynth1-ffv1-v3-yuv420p.avi
 c5ccac874dbf808e9088bc3107860042 *tests/data/fate/vsynth1-ffv1-v3-yuv420p.out.rawvideo
 stddev:    0.00 PSNR:999.99 MAXDIFF:    0 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth1-ffv1-v3-yuv422p10 b/tests/ref/vsynth/vsynth1-ffv1-v3-yuv422p10
index d56cf27..d76a70a 100644
--- a/tests/ref/vsynth/vsynth1-ffv1-v3-yuv422p10
+++ b/tests/ref/vsynth/vsynth1-ffv1-v3-yuv422p10
@@ -1,4 +1,4 @@
-aa8c5630213381c7b2afdec4a91405ed *tests/data/fate/vsynth1-ffv1-v3-yuv422p10.avi
-2845574 tests/data/fate/vsynth1-ffv1-v3-yuv422p10.avi
+ab7b36e05d2de2e00996414b3ad9f064 *tests/data/fate/vsynth1-ffv1-v3-yuv422p10.avi
+5726318 tests/data/fate/vsynth1-ffv1-v3-yuv422p10.avi
 c5ccac874dbf808e9088bc3107860042 *tests/data/fate/vsynth1-ffv1-v3-yuv422p10.out.rawvideo
 stddev:    0.00 PSNR:999.99 MAXDIFF:    0 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth1-ffv1-v3-yuv444p16 b/tests/ref/vsynth/vsynth1-ffv1-v3-yuv444p16
index 5d919ea..5e77750 100644
--- a/tests/ref/vsynth/vsynth1-ffv1-v3-yuv444p16
+++ b/tests/ref/vsynth/vsynth1-ffv1-v3-yuv444p16
@@ -1,4 +1,4 @@
-f6b6943455d8b2c3010ff898df5dc9db *tests/data/fate/vsynth1-ffv1-v3-yuv444p16.avi
-5357816 tests/data/fate/vsynth1-ffv1-v3-yuv444p16.avi
+a15d66221e9949a851742144f483d332 *tests/data/fate/vsynth1-ffv1-v3-yuv444p16.avi
+7675980 tests/data/fate/vsynth1-ffv1-v3-yuv444p16.avi
 c5ccac874dbf808e9088bc3107860042 *tests/data/fate/vsynth1-ffv1-v3-yuv444p16.out.rawvideo
 stddev:    0.00 PSNR:999.99 MAXDIFF:    0 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth2-ffv1 b/tests/ref/vsynth/vsynth2-ffv1
index b38bb38..56a25e8 100644
--- a/tests/ref/vsynth/vsynth2-ffv1
+++ b/tests/ref/vsynth/vsynth2-ffv1
@@ -1,4 +1,4 @@
-6d7b6352f49e21153bb891df411e60ec *tests/data/fate/vsynth2-ffv1.avi
-3718026 tests/data/fate/vsynth2-ffv1.avi
+b694fcc3db64acf3e361f9b43b3a72ad *tests/data/fate/vsynth2-ffv1.avi
+5635324 tests/data/fate/vsynth2-ffv1.avi
 36d7ca943916e1743cefa609eba0205c *tests/data/fate/vsynth2-ffv1.out.rawvideo
 stddev:    0.00 PSNR:999.99 MAXDIFF:    0 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth2-ffv1-v0 b/tests/ref/vsynth/vsynth2-ffv1-v0
index e1e71f1..42cdd11 100644
--- a/tests/ref/vsynth/vsynth2-ffv1-v0
+++ b/tests/ref/vsynth/vsynth2-ffv1-v0
@@ -1,4 +1,4 @@
-9647e906f0739ed84303bd03d1cb8105 *tests/data/fate/vsynth2-ffv1-v0.avi
-3692542 tests/data/fate/vsynth2-ffv1-v0.avi
+de2f14ea38bf8542bfb1408737a6f77f *tests/data/fate/vsynth2-ffv1-v0.avi
+5611322 tests/data/fate/vsynth2-ffv1-v0.avi
 36d7ca943916e1743cefa609eba0205c *tests/data/fate/vsynth2-ffv1-v0.out.rawvideo
 stddev:    0.00 PSNR:999.99 MAXDIFF:    0 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth2-ffv1-v3-bgr0 b/tests/ref/vsynth/vsynth2-ffv1-v3-bgr0
index 11f516b..735444b 100644
--- a/tests/ref/vsynth/vsynth2-ffv1-v3-bgr0
+++ b/tests/ref/vsynth/vsynth2-ffv1-v3-bgr0
@@ -1,4 +1,4 @@
-4e8ea4c31ddb7703638989c6251e37fe *tests/data/fate/vsynth2-ffv1-v3-bgr0.avi
-6386312 tests/data/fate/vsynth2-ffv1-v3-bgr0.avi
+5f7e1306350f98e2b4c8d09253b3fb54 *tests/data/fate/vsynth2-ffv1-v3-bgr0.avi
+12610264 tests/data/fate/vsynth2-ffv1-v3-bgr0.avi
 835a86f8dff88917c3e5f2776954c5b7 *tests/data/fate/vsynth2-ffv1-v3-bgr0.out.rawvideo
 stddev:    1.57 PSNR: 44.18 MAXDIFF:   20 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth2-ffv1-v3-yuv420p b/tests/ref/vsynth/vsynth2-ffv1-v3-yuv420p
index 5d85ffc..73e5999 100644
--- a/tests/ref/vsynth/vsynth2-ffv1-v3-yuv420p
+++ b/tests/ref/vsynth/vsynth2-ffv1-v3-yuv420p
@@ -1,4 +1,4 @@
-6d7b6352f49e21153bb891df411e60ec *tests/data/fate/vsynth2-ffv1-v3-yuv420p.avi
-3718026 tests/data/fate/vsynth2-ffv1-v3-yuv420p.avi
+b694fcc3db64acf3e361f9b43b3a72ad *tests/data/fate/vsynth2-ffv1-v3-yuv420p.avi
+5635324 tests/data/fate/vsynth2-ffv1-v3-yuv420p.avi
 36d7ca943916e1743cefa609eba0205c *tests/data/fate/vsynth2-ffv1-v3-yuv420p.out.rawvideo
 stddev:    0.00 PSNR:999.99 MAXDIFF:    0 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth2-ffv1-v3-yuv422p10 b/tests/ref/vsynth/vsynth2-ffv1-v3-yuv422p10
index b1a6c19..2f3f9fb 100644
--- a/tests/ref/vsynth/vsynth2-ffv1-v3-yuv422p10
+++ b/tests/ref/vsynth/vsynth2-ffv1-v3-yuv422p10
@@ -1,4 +1,4 @@
-b43b20163948e44a6c806714e69ac3bf *tests/data/fate/vsynth2-ffv1-v3-yuv422p10.avi
-4069370 tests/data/fate/vsynth2-ffv1-v3-yuv422p10.avi
+bf3c90b9bc53fd4ffd71f2cfd3772d5e *tests/data/fate/vsynth2-ffv1-v3-yuv422p10.avi
+5733518 tests/data/fate/vsynth2-ffv1-v3-yuv422p10.avi
 36d7ca943916e1743cefa609eba0205c *tests/data/fate/vsynth2-ffv1-v3-yuv422p10.out.rawvideo
 stddev:    0.00 PSNR:999.99 MAXDIFF:    0 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth2-ffv1-v3-yuv444p16 b/tests/ref/vsynth/vsynth2-ffv1-v3-yuv444p16
index 4d0a0c2..d4bf4ff 100644
--- a/tests/ref/vsynth/vsynth2-ffv1-v3-yuv444p16
+++ b/tests/ref/vsynth/vsynth2-ffv1-v3-yuv444p16
@@ -1,4 +1,4 @@
-ae0bad7ece3ceacc9554f342ab489a4d *tests/data/fate/vsynth2-ffv1-v3-yuv444p16.avi
-5086918 tests/data/fate/vsynth2-ffv1-v3-yuv444p16.avi
+ffe94d29e2ac53d94b743f23c20682fc *tests/data/fate/vsynth2-ffv1-v3-yuv444p16.avi
+6877576 tests/data/fate/vsynth2-ffv1-v3-yuv444p16.avi
 36d7ca943916e1743cefa609eba0205c *tests/data/fate/vsynth2-ffv1-v3-yuv444p16.out.rawvideo
 stddev:    0.00 PSNR:999.99 MAXDIFF:    0 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth3-ffv1 b/tests/ref/vsynth/vsynth3-ffv1
index 8ffdd3f..6311cae 100644
--- a/tests/ref/vsynth/vsynth3-ffv1
+++ b/tests/ref/vsynth/vsynth3-ffv1
@@ -1,4 +1,4 @@
-f969ca8542c8384c27233f362b661f8a *tests/data/fate/vsynth3-ffv1.avi
-62194 tests/data/fate/vsynth3-ffv1.avi
+3fc9afe788960bc7cda9c23a8bb97bc7 *tests/data/fate/vsynth3-ffv1.avi
+98168 tests/data/fate/vsynth3-ffv1.avi
 a038ad7c3c09f776304ef7accdea9c74 *tests/data/fate/vsynth3-ffv1.out.rawvideo
 stddev:    0.00 PSNR:999.99 MAXDIFF:    0 bytes:    86700/    86700
diff --git a/tests/ref/vsynth/vsynth3-ffv1-v0 b/tests/ref/vsynth/vsynth3-ffv1-v0
index 967a022..dff4db9 100644
--- a/tests/ref/vsynth/vsynth3-ffv1-v0
+++ b/tests/ref/vsynth/vsynth3-ffv1-v0
@@ -1,4 +1,4 @@
-91ddf7723476e2b084253ffca69f382e *tests/data/fate/vsynth3-ffv1-v0.avi
-52256 tests/data/fate/vsynth3-ffv1-v0.avi
+e7449d7cbcd59a5526e530fe1e645c8c *tests/data/fate/vsynth3-ffv1-v0.avi
+85114 tests/data/fate/vsynth3-ffv1-v0.avi
 a038ad7c3c09f776304ef7accdea9c74 *tests/data/fate/vsynth3-ffv1-v0.out.rawvideo
 stddev:    0.00 PSNR:999.99 MAXDIFF:    0 bytes:    86700/    86700
diff --git a/tests/ref/vsynth/vsynth3-ffv1-v3-bgr0 b/tests/ref/vsynth/vsynth3-ffv1-v3-bgr0
index 2adffed..e89efe8 100644
--- a/tests/ref/vsynth/vsynth3-ffv1-v3-bgr0
+++ b/tests/ref/vsynth/vsynth3-ffv1-v3-bgr0
@@ -1,4 +1,4 @@
-bdb5f694222e91bb7cb7264d2d5d419b *tests/data/fate/vsynth3-ffv1-v3-bgr0.avi
-112780 tests/data/fate/vsynth3-ffv1-v3-bgr0.avi
+e802f4a285cc1ce498151a5ad9888900 *tests/data/fate/vsynth3-ffv1-v3-bgr0.avi
+195832 tests/data/fate/vsynth3-ffv1-v3-bgr0.avi
 5d031d2e891b13593b8cd79e63d083b4 *tests/data/fate/vsynth3-ffv1-v3-bgr0.out.rawvideo
 stddev:    3.23 PSNR: 37.92 MAXDIFF:   50 bytes:    86700/    86700
diff --git a/tests/ref/vsynth/vsynth3-ffv1-v3-yuv420p b/tests/ref/vsynth/vsynth3-ffv1-v3-yuv420p
index 38fb24a..2964628 100644
--- a/tests/ref/vsynth/vsynth3-ffv1-v3-yuv420p
+++ b/tests/ref/vsynth/vsynth3-ffv1-v3-yuv420p
@@ -1,4 +1,4 @@
-f969ca8542c8384c27233f362b661f8a *tests/data/fate/vsynth3-ffv1-v3-yuv420p.avi
-62194 tests/data/fate/vsynth3-ffv1-v3-yuv420p.avi
+3fc9afe788960bc7cda9c23a8bb97bc7 *tests/data/fate/vsynth3-ffv1-v3-yuv420p.avi
+98168 tests/data/fate/vsynth3-ffv1-v3-yuv420p.avi
 a038ad7c3c09f776304ef7accdea9c74 *tests/data/fate/vsynth3-ffv1-v3-yuv420p.out.rawvideo
 stddev:    0.00 PSNR:999.99 MAXDIFF:    0 bytes:    86700/    86700
diff --git a/tests/ref/vsynth/vsynth3-ffv1-v3-yuv422p10 b/tests/ref/vsynth/vsynth3-ffv1-v3-yuv422p10
index d86c9c9..4eb1cb8 100644
--- a/tests/ref/vsynth/vsynth3-ffv1-v3-yuv422p10
+++ b/tests/ref/vsynth/vsynth3-ffv1-v3-yuv422p10
@@ -1,4 +1,4 @@
-4fc113caac00ada68e19639ae6f7bc47 *tests/data/fate/vsynth3-ffv1-v3-yuv422p10.avi
-63840 tests/data/fate/vsynth3-ffv1-v3-yuv422p10.avi
+c30329d9efb8f3aedd51899df89830d0 *tests/data/fate/vsynth3-ffv1-v3-yuv422p10.avi
+107410 tests/data/fate/vsynth3-ffv1-v3-yuv422p10.avi
 a038ad7c3c09f776304ef7accdea9c74 *tests/data/fate/vsynth3-ffv1-v3-yuv422p10.out.rawvideo
 stddev:    0.00 PSNR:999.99 MAXDIFF:    0 bytes:    86700/    86700
diff --git a/tests/ref/vsynth/vsynth3-ffv1-v3-yuv444p16 b/tests/ref/vsynth/vsynth3-ffv1-v3-yuv444p16
index 5d61f11..0f320cb 100644
--- a/tests/ref/vsynth/vsynth3-ffv1-v3-yuv444p16
+++ b/tests/ref/vsynth/vsynth3-ffv1-v3-yuv444p16
@@ -1,4 +1,4 @@
-1e8981cec92407938b25cd82381d1c64 *tests/data/fate/vsynth3-ffv1-v3-yuv444p16.avi
-82908 tests/data/fate/vsynth3-ffv1-v3-yuv444p16.avi
+4ac7c1149c41adadca2a91804c671c97 *tests/data/fate/vsynth3-ffv1-v3-yuv444p16.avi
+107964 tests/data/fate/vsynth3-ffv1-v3-yuv444p16.avi
 a038ad7c3c09f776304ef7accdea9c74 *tests/data/fate/vsynth3-ffv1-v3-yuv444p16.out.rawvideo
 stddev:    0.00 PSNR:999.99 MAXDIFF:    0 bytes:    86700/    86700
-- 
2.6.4 (Apple Git-63)

