[FFmpeg-devel] mpeg2dec: Fix motion vector rounding for chroma components

Submitted by Nekopanda on Feb. 10, 2018, 9:36 a.m.

Details

Message ID 1518255393-34156-2-git-send-email-pianoyayaninth@yahoo.co.jp
State New
Headers show

Commit Message

Nekopanda Feb. 10, 2018, 9:36 a.m.
In 16x8 motion compensation, for lower 16x8 region, the input to mpeg_motion() for motion_y was "motion_y + 16", which causes wrong rounding. For 4:2:0, chroma scaling for y is dividing by two and rounding toward zero. When motion_y < 0 and motion_y + 16 > 0, the rounding direction of "motion_y" and "motion_y + 16" is different and rounding "motion_y + 16" would be incorrect.

We should input "motion_y" as is to round correctly. I add "is_16x8" flag to do that.
---
 libavcodec/mpegvideo_motion.c        |  30 ++++-----
 tests/ref/fate/filter-w3fdif-complex |  60 +++++++++---------
 tests/ref/fate/filter-w3fdif-simple  |  60 +++++++++---------
 tests/ref/fate/filter-yadif-mode0    |  60 +++++++++---------
 tests/ref/fate/filter-yadif-mode1    | 118 +++++++++++++++++------------------
 tests/ref/fate/filter-yadif10        |  60 +++++++++---------
 tests/ref/fate/filter-yadif16        |  60 +++++++++---------
 tests/ref/fate/mpeg2-field-enc       |  60 +++++++++---------
 tests/ref/fate/mpeg2-ticket6677      |  12 ++--
 9 files changed, 261 insertions(+), 259 deletions(-)

Comments

Michael Niedermayer Feb. 11, 2018, 1:33 a.m.
On Sat, Feb 10, 2018 at 06:36:33PM +0900, Nekopanda wrote:
> In 16x8 motion compensation, for lower 16x8 region, the input to mpeg_motion() for motion_y was "motion_y + 16", which causes wrong rounding. For 4:2:0, chroma scaling for y is dividing by two and rounding toward zero. When motion_y < 0 and motion_y + 16 > 0, the rounding direction of "motion_y" and "motion_y + 16" is different and rounding "motion_y + 16" would be incorrect.
> 
> We should input "motion_y" as is to round correctly. I add "is_16x8" flag to do that.
> ---
>  libavcodec/mpegvideo_motion.c        |  30 ++++-----
>  tests/ref/fate/filter-w3fdif-complex |  60 +++++++++---------
>  tests/ref/fate/filter-w3fdif-simple  |  60 +++++++++---------
>  tests/ref/fate/filter-yadif-mode0    |  60 +++++++++---------
>  tests/ref/fate/filter-yadif-mode1    | 118 +++++++++++++++++------------------
>  tests/ref/fate/filter-yadif10        |  60 +++++++++---------
>  tests/ref/fate/filter-yadif16        |  60 +++++++++---------
>  tests/ref/fate/mpeg2-field-enc       |  60 +++++++++---------
>  tests/ref/fate/mpeg2-ticket6677      |  12 ++--
>  9 files changed, 261 insertions(+), 259 deletions(-)

This patch changes 2 fate tests:
make: *** [fate-filter-mcdeint-fast] Error 1
make: *** [fate-filter-mcdeint-medium] Error 1


[...]

Patch hide | download patch | download mbox

diff --git a/libavcodec/mpegvideo_motion.c b/libavcodec/mpegvideo_motion.c
index c913504..5624c10 100644
--- a/libavcodec/mpegvideo_motion.c
+++ b/libavcodec/mpegvideo_motion.c
@@ -239,20 +239,22 @@  void mpeg_motion_internal(MpegEncContext *s,
                           int motion_y,
                           int h,
                           int is_mpeg12,
+                          int is_16x8,
                           int mb_y)
 {
     uint8_t *ptr_y, *ptr_cb, *ptr_cr;
     int dxy, uvdxy, mx, my, src_x, src_y,
-        uvsrc_x, uvsrc_y, v_edge_pos;
+        uvsrc_x, uvsrc_y, v_edge_pos, block_y_half;
     ptrdiff_t uvlinesize, linesize;
 
     v_edge_pos = s->v_edge_pos >> field_based;
     linesize   = s->current_picture.f->linesize[0] << field_based;
     uvlinesize = s->current_picture.f->linesize[1] << field_based;
+    block_y_half = (field_based | is_16x8);
 
     dxy   = ((motion_y & 1) << 1) | (motion_x & 1);
     src_x = s->mb_x * 16 + (motion_x >> 1);
-    src_y = (mb_y << (4 - field_based)) + (motion_y >> 1);
+    src_y = (mb_y << (4 - block_y_half)) + (motion_y >> 1);
 
     if (!is_mpeg12 && s->out_format == FMT_H263) {
         if ((s->workaround_bugs & FF_BUG_HPEL_CHROMA) && field_based) {
@@ -260,7 +262,7 @@  void mpeg_motion_internal(MpegEncContext *s,
             my      = motion_y >> 1;
             uvdxy   = ((my & 1) << 1) | (mx & 1);
             uvsrc_x = s->mb_x * 8 + (mx >> 1);
-            uvsrc_y = (mb_y << (3 - field_based)) + (my >> 1);
+            uvsrc_y = (mb_y << (3 - block_y_half)) + (my >> 1);
         } else {
             uvdxy   = dxy | (motion_y & 2) | ((motion_x & 2) >> 1);
             uvsrc_x = src_x >> 1;
@@ -279,7 +281,7 @@  void mpeg_motion_internal(MpegEncContext *s,
             my      = motion_y / 2;
             uvdxy   = ((my & 1) << 1) | (mx & 1);
             uvsrc_x = s->mb_x * 8 + (mx >> 1);
-            uvsrc_y = (mb_y << (3 - field_based)) + (my >> 1);
+            uvsrc_y = (mb_y << (3 - block_y_half)) + (my >> 1);
         } else {
             if (s->chroma_x_shift) {
                 // Chroma422
@@ -370,18 +372,18 @@  static void mpeg_motion(MpegEncContext *s,
                         uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
                         int field_select, uint8_t **ref_picture,
                         op_pixels_func (*pix_op)[4],
-                        int motion_x, int motion_y, int h, int mb_y)
+                        int motion_x, int motion_y, int h, int is_16x8, int mb_y)
 {
 #if !CONFIG_SMALL
     if (s->out_format == FMT_MPEG1)
         mpeg_motion_internal(s, dest_y, dest_cb, dest_cr, 0, 0,
                              field_select, ref_picture, pix_op,
-                             motion_x, motion_y, h, 1, mb_y);
+                             motion_x, motion_y, h, 1, is_16x8, mb_y);
     else
 #endif
         mpeg_motion_internal(s, dest_y, dest_cb, dest_cr, 0, 0,
                              field_select, ref_picture, pix_op,
-                             motion_x, motion_y, h, 0, mb_y);
+                             motion_x, motion_y, h, 0, is_16x8, mb_y);
 }
 
 static void mpeg_motion_field(MpegEncContext *s, uint8_t *dest_y,
@@ -395,12 +397,12 @@  static void mpeg_motion_field(MpegEncContext *s, uint8_t *dest_y,
     if (s->out_format == FMT_MPEG1)
         mpeg_motion_internal(s, dest_y, dest_cb, dest_cr, 1,
                              bottom_field, field_select, ref_picture, pix_op,
-                             motion_x, motion_y, h, 1, mb_y);
+                             motion_x, motion_y, h, 1, 0, mb_y);
     else
 #endif
         mpeg_motion_internal(s, dest_y, dest_cb, dest_cr, 1,
                              bottom_field, field_select, ref_picture, pix_op,
-                             motion_x, motion_y, h, 0, mb_y);
+                             motion_x, motion_y, h, 0, 0, mb_y);
 }
 
 // FIXME: SIMDify, avg variant, 16x16 version
@@ -870,7 +872,7 @@  static av_always_inline void mpv_motion_internal(MpegEncContext *s,
         } else {
             mpeg_motion(s, dest_y, dest_cb, dest_cr, 0,
                         ref_picture, pix_op,
-                        s->mv[dir][0][0], s->mv[dir][0][1], 16, mb_y);
+                        s->mv[dir][0][0], s->mv[dir][0][1], 16, 0, mb_y);
         }
         break;
     case MV_TYPE_8X8:
@@ -907,7 +909,7 @@  static av_always_inline void mpv_motion_internal(MpegEncContext *s,
             mpeg_motion(s, dest_y, dest_cb, dest_cr,
                         s->field_select[dir][0],
                         ref_picture, pix_op,
-                        s->mv[dir][0][0], s->mv[dir][0][1], 16, mb_y >> 1);
+                        s->mv[dir][0][0], s->mv[dir][0][1], 16, 0, mb_y >> 1);
         }
         break;
     case MV_TYPE_16X8:
@@ -924,8 +926,8 @@  static av_always_inline void mpv_motion_internal(MpegEncContext *s,
             mpeg_motion(s, dest_y, dest_cb, dest_cr,
                         s->field_select[dir][i],
                         ref2picture, pix_op,
-                        s->mv[dir][i][0], s->mv[dir][i][1] + 16 * i,
-                        8, mb_y >> 1);
+                        s->mv[dir][i][0], s->mv[dir][i][1],
+                        8, 1, (mb_y & ~1) + i);
 
             dest_y  += 16 * s->linesize;
             dest_cb += (16 >> s->chroma_y_shift) * s->uvlinesize;
@@ -952,7 +954,7 @@  static av_always_inline void mpv_motion_internal(MpegEncContext *s,
                             s->picture_structure != i + 1,
                             ref_picture, pix_op,
                             s->mv[dir][2 * i][0], s->mv[dir][2 * i][1],
-                            16, mb_y >> 1);
+                            16, 0, mb_y >> 1);
 
                 // after put we make avg of the same block
                 pix_op = s->hdsp.avg_pixels_tab;
diff --git a/tests/ref/fate/filter-w3fdif-complex b/tests/ref/fate/filter-w3fdif-complex
index 4b334da..cbd8f06 100644
--- a/tests/ref/fate/filter-w3fdif-complex
+++ b/tests/ref/fate/filter-w3fdif-complex
@@ -3,33 +3,33 @@ 
 #codec_id 0: rawvideo
 #dimensions 0: 720x576
 #sar 0: 16/15
-0,         18,         18,        1,   622080, 0x21d21485
-0,         19,         19,        1,   622080, 0x600a5468
-0,         20,         20,        1,   622080, 0x9526f7b8
-0,         21,         21,        1,   622080, 0x8b3e661f
-0,         22,         22,        1,   622080, 0xff5cb5a9
-0,         23,         23,        1,   622080, 0x7e5e730c
-0,         24,         24,        1,   622080, 0x85219ac6
-0,         25,         25,        1,   622080, 0x2f3465a0
-0,         26,         26,        1,   622080, 0xddbf4da0
-0,         27,         27,        1,   622080, 0xc115d4ee
-0,         28,         28,        1,   622080, 0x7a8a8d72
-0,         29,         29,        1,   622080, 0xbafcd973
-0,         30,         30,        1,   622080, 0xd2c15603
-0,         31,         31,        1,   622080, 0xd7217855
-0,         32,         32,        1,   622080, 0x9a584eca
-0,         33,         33,        1,   622080, 0x9f3e1c40
-0,         34,         34,        1,   622080, 0x6d01efb7
-0,         35,         35,        1,   622080, 0x9ecfcce0
-0,         36,         36,        1,   622080, 0xb355fd7e
-0,         37,         37,        1,   622080, 0xc7784021
-0,         38,         38,        1,   622080, 0x13fe4187
-0,         39,         39,        1,   622080, 0xfa03b613
-0,         40,         40,        1,   622080, 0x2c9ccfcd
-0,         41,         41,        1,   622080, 0xcae6e6c6
-0,         42,         42,        1,   622080, 0x177968f9
-0,         43,         43,        1,   622080, 0xf708de36
-0,         44,         44,        1,   622080, 0x4491870a
-0,         45,         45,        1,   622080, 0x37709f98
-0,         46,         46,        1,   622080, 0x23e8d22f
-0,         47,         47,        1,   622080, 0x25cba876
+0,         18,         18,        1,   622080, 0xe1b21462
+0,         19,         19,        1,   622080, 0x1362538d
+0,         20,         20,        1,   622080, 0x0f55f79b
+0,         21,         21,        1,   622080, 0xfdb265f6
+0,         22,         22,        1,   622080, 0x2f8eb534
+0,         23,         23,        1,   622080, 0x0de472b1
+0,         24,         24,        1,   622080, 0x3e699a78
+0,         25,         25,        1,   622080, 0x66396524
+0,         26,         26,        1,   622080, 0x17244d40
+0,         27,         27,        1,   622080, 0x04a5d554
+0,         28,         28,        1,   622080, 0x0e278cd9
+0,         29,         29,        1,   622080, 0x7b53d8de
+0,         30,         30,        1,   622080, 0xe51a558e
+0,         31,         31,        1,   622080, 0xd58177e4
+0,         32,         32,        1,   622080, 0x270b4e1f
+0,         33,         33,        1,   622080, 0x3fbf1bdf
+0,         34,         34,        1,   622080, 0xbfebee9d
+0,         35,         35,        1,   622080, 0x2c6fcccf
+0,         36,         36,        1,   622080, 0x4a57fcc2
+0,         37,         37,        1,   622080, 0x33b53f5d
+0,         38,         38,        1,   622080, 0x93ba405d
+0,         39,         39,        1,   622080, 0xf4dbb54b
+0,         40,         40,        1,   622080, 0xf205ce68
+0,         41,         41,        1,   622080, 0x383fe5bc
+0,         42,         42,        1,   622080, 0x4dd06905
+0,         43,         43,        1,   622080, 0xc925de57
+0,         44,         44,        1,   622080, 0x7c8786e8
+0,         45,         45,        1,   622080, 0x550b9f60
+0,         46,         46,        1,   622080, 0x4162d1e9
+0,         47,         47,        1,   622080, 0xf609a847
diff --git a/tests/ref/fate/filter-w3fdif-simple b/tests/ref/fate/filter-w3fdif-simple
index 62efaae..09c0d7c 100644
--- a/tests/ref/fate/filter-w3fdif-simple
+++ b/tests/ref/fate/filter-w3fdif-simple
@@ -3,33 +3,33 @@ 
 #codec_id 0: rawvideo
 #dimensions 0: 720x576
 #sar 0: 16/15
-0,         18,         18,        1,   622080, 0xc73774f5
-0,         19,         19,        1,   622080, 0x4ea3a400
-0,         20,         20,        1,   622080, 0x95153cda
-0,         21,         21,        1,   622080, 0xec39bf0b
-0,         22,         22,        1,   622080, 0x94b6f836
-0,         23,         23,        1,   622080, 0xc145c3ee
-0,         24,         24,        1,   622080, 0x4d4cdee2
-0,         25,         25,        1,   622080, 0x193ebc7c
-0,         26,         26,        1,   622080, 0xbd728fd8
-0,         27,         27,        1,   622080, 0xf0f3252f
-0,         28,         28,        1,   622080, 0xc012d20a
-0,         29,         29,        1,   622080, 0x7b5831b2
-0,         30,         30,        1,   622080, 0x464e9622
-0,         31,         31,        1,   622080, 0x46e3c6c0
-0,         32,         32,        1,   622080, 0xa6ec908b
-0,         33,         33,        1,   622080, 0x6a257595
-0,         34,         34,        1,   622080, 0xa6552ecc
-0,         35,         35,        1,   622080, 0xdecd1a91
-0,         36,         36,        1,   622080, 0xfaa53e71
-0,         37,         37,        1,   622080, 0xc94a9707
-0,         38,         38,        1,   622080, 0xb5727fd4
-0,         39,         39,        1,   622080, 0x143c018c
-0,         40,         40,        1,   622080, 0x92d110c9
-0,         41,         41,        1,   622080, 0x4f762fc0
-0,         42,         42,        1,   622080, 0x3dd2a7d2
-0,         43,         43,        1,   622080, 0xa5d02dc0
-0,         44,         44,        1,   622080, 0x2223ce3d
-0,         45,         45,        1,   622080, 0xe4a5fc36
-0,         46,         46,        1,   622080, 0x8384159e
-0,         47,         47,        1,   622080, 0x995efa57
+0,         18,         18,        1,   622080, 0x338874e8
+0,         19,         19,        1,   622080, 0x1a9da32b
+0,         20,         20,        1,   622080, 0x2ecc3cd9
+0,         21,         21,        1,   622080, 0x0441beec
+0,         22,         22,        1,   622080, 0x4de3f7ba
+0,         23,         23,        1,   622080, 0x59a4c388
+0,         24,         24,        1,   622080, 0x833ade92
+0,         25,         25,        1,   622080, 0x4c79bbf3
+0,         26,         26,        1,   622080, 0xe1998f77
+0,         27,         27,        1,   622080, 0xd00e2586
+0,         28,         28,        1,   622080, 0xe716d185
+0,         29,         29,        1,   622080, 0x24763136
+0,         30,         30,        1,   622080, 0xaeaa95a2
+0,         31,         31,        1,   622080, 0x92eec65a
+0,         32,         32,        1,   622080, 0x7cde9000
+0,         33,         33,        1,   622080, 0x98e2752c
+0,         34,         34,        1,   622080, 0x5ffe2db6
+0,         35,         35,        1,   622080, 0x1e911a65
+0,         36,         36,        1,   622080, 0x302d3dc2
+0,         37,         37,        1,   622080, 0xc1399647
+0,         38,         38,        1,   622080, 0xc4477ebf
+0,         39,         39,        1,   622080, 0x50e900ca
+0,         40,         40,        1,   622080, 0x867e0f7a
+0,         41,         41,        1,   622080, 0xa2412ebe
+0,         42,         42,        1,   622080, 0xc7a5a7e6
+0,         43,         43,        1,   622080, 0xaa5d2de7
+0,         44,         44,        1,   622080, 0x9bf0ce31
+0,         45,         45,        1,   622080, 0xfb88fbf9
+0,         46,         46,        1,   622080, 0xe6321572
+0,         47,         47,        1,   622080, 0x5541fa37
diff --git a/tests/ref/fate/filter-yadif-mode0 b/tests/ref/fate/filter-yadif-mode0
index 2c6346b..be807f9 100644
--- a/tests/ref/fate/filter-yadif-mode0
+++ b/tests/ref/fate/filter-yadif-mode0
@@ -3,33 +3,33 @@ 
 #codec_id 0: rawvideo
 #dimensions 0: 720x576
 #sar 0: 16/15
-0,          9,          9,        1,   622080, 0x6331caee
-0,         10,         10,        1,   622080, 0xa459e690
-0,         11,         11,        1,   622080, 0x6429c648
-0,         12,         12,        1,   622080, 0xa49891ca
-0,         13,         13,        1,   622080, 0x2a887404
-0,         14,         14,        1,   622080, 0xe8d49705
-0,         15,         15,        1,   622080, 0x1b627835
-0,         16,         16,        1,   622080, 0x686858fd
-0,         17,         17,        1,   622080, 0x2675174f
-0,         18,         18,        1,   622080, 0x78470e7f
-0,         19,         19,        1,   622080, 0xffb366ec
-0,         20,         20,        1,   622080, 0xd575da72
-0,         21,         21,        1,   622080, 0x5fb297f7
-0,         22,         22,        1,   622080, 0xbac77ca0
-0,         23,         23,        1,   622080, 0x3276ed72
-0,         24,         24,        1,   622080, 0x264092b2
-0,         25,         25,        1,   622080, 0x20ba1094
-0,         26,         26,        1,   622080, 0x76cc3139
-0,         27,         27,        1,   622080, 0x469a4902
-0,         28,         28,        1,   622080, 0x0ed7b8f5
-0,         29,         29,        1,   622080, 0xdc51aeac
-0,         30,         30,        1,   622080, 0xee06aa36
-0,         31,         31,        1,   622080, 0x7372405f
-0,         32,         32,        1,   622080, 0x9e0ee776
-0,         33,         33,        1,   622080, 0x39e6d8c9
-0,         34,         34,        1,   622080, 0x51d9ac9a
-0,         35,         35,        1,   622080, 0x2b63441d
-0,         36,         36,        1,   622080, 0x58afbd5e
-0,         37,         37,        1,   622080, 0xb972f716
-0,         38,         38,        1,   622080, 0x6a6df129
+0,          9,          9,        1,   622080, 0x77c0ca92
+0,         10,         10,        1,   622080, 0xbe7fe646
+0,         11,         11,        1,   622080, 0x4384c5da
+0,         12,         12,        1,   622080, 0x296b9168
+0,         13,         13,        1,   622080, 0x96d5738e
+0,         14,         14,        1,   622080, 0x769b9681
+0,         15,         15,        1,   622080, 0x461d778d
+0,         16,         16,        1,   622080, 0xb88c584b
+0,         17,         17,        1,   622080, 0x7d7b1635
+0,         18,         18,        1,   622080, 0x49c60dc0
+0,         19,         19,        1,   622080, 0x498765a4
+0,         20,         20,        1,   622080, 0x0caed8f9
+0,         21,         21,        1,   622080, 0x41d897d3
+0,         22,         22,        1,   622080, 0x7aeb7c93
+0,         23,         23,        1,   622080, 0xa8bced40
+0,         24,         24,        1,   622080, 0x11de928c
+0,         25,         25,        1,   622080, 0x64741075
+0,         26,         26,        1,   622080, 0x160f310e
+0,         27,         27,        1,   622080, 0x702d489c
+0,         28,         28,        1,   622080, 0xaf2fb8aa
+0,         29,         29,        1,   622080, 0x575bae0f
+0,         30,         30,        1,   622080, 0xfd68a990
+0,         31,         31,        1,   622080, 0x8b513f66
+0,         32,         32,        1,   622080, 0x0e6ae6c3
+0,         33,         33,        1,   622080, 0x3d12d8ab
+0,         34,         34,        1,   622080, 0x45d0ac80
+0,         35,         35,        1,   622080, 0xb18d4421
+0,         36,         36,        1,   622080, 0x2e81bd32
+0,         37,         37,        1,   622080, 0x852cf6cf
+0,         38,         38,        1,   622080, 0xb055f0e5
diff --git a/tests/ref/fate/filter-yadif-mode1 b/tests/ref/fate/filter-yadif-mode1
index e2d14d5..53741b0 100644
--- a/tests/ref/fate/filter-yadif-mode1
+++ b/tests/ref/fate/filter-yadif-mode1
@@ -3,62 +3,62 @@ 
 #codec_id 0: rawvideo
 #dimensions 0: 720x576
 #sar 0: 16/15
-0,         18,         18,        1,   622080, 0x6331caee
-0,         19,         19,        1,   622080, 0x625da883
-0,         20,         20,        1,   622080, 0xa459e690
-0,         21,         21,        1,   622080, 0xce5d891e
-0,         22,         22,        1,   622080, 0x6429c648
-0,         23,         23,        1,   622080, 0x608cc0ba
-0,         24,         24,        1,   622080, 0xa49891ca
-0,         25,         25,        1,   622080, 0x9721987f
-0,         26,         26,        1,   622080, 0x2a887404
-0,         27,         27,        1,   622080, 0x60d71d47
-0,         28,         28,        1,   622080, 0xe8d49705
-0,         29,         29,        1,   622080, 0x821e13cb
-0,         30,         30,        1,   622080, 0x1b627835
-0,         31,         31,        1,   622080, 0x1806c5f4
-0,         32,         32,        1,   622080, 0x686858fd
-0,         33,         33,        1,   622080, 0xab865773
-0,         34,         34,        1,   622080, 0x2675174f
-0,         35,         35,        1,   622080, 0x43a61a14
-0,         36,         36,        1,   622080, 0x78470e7f
-0,         37,         37,        1,   622080, 0xeb877bc6
-0,         38,         38,        1,   622080, 0xffb366ec
-0,         39,         39,        1,   622080, 0xda0906e7
-0,         40,         40,        1,   622080, 0xd575da72
-0,         41,         41,        1,   622080, 0x23ae25a4
-0,         42,         42,        1,   622080, 0x5fb297f7
-0,         43,         43,        1,   622080, 0x99b32978
-0,         44,         44,        1,   622080, 0xbac77ca0
-0,         45,         45,        1,   622080, 0xc1cdcbf9
-0,         46,         46,        1,   622080, 0x3276ed72
-0,         47,         47,        1,   622080, 0x4061f5ab
-0,         48,         48,        1,   622080, 0x264092b2
-0,         49,         49,        1,   622080, 0xa4e2039e
-0,         50,         50,        1,   622080, 0x20ba1094
-0,         51,         51,        1,   622080, 0x984e906e
-0,         52,         52,        1,   622080, 0x76cc3139
-0,         53,         53,        1,   622080, 0xf70e2cf6
-0,         54,         54,        1,   622080, 0x469a4902
-0,         55,         55,        1,   622080, 0x235312e6
-0,         56,         56,        1,   622080, 0x0ed7b8f5
-0,         57,         57,        1,   622080, 0xd0269cc3
-0,         58,         58,        1,   622080, 0xdc51aeac
-0,         59,         59,        1,   622080, 0x1aa5f76e
-0,         60,         60,        1,   622080, 0xee06aa36
-0,         61,         61,        1,   622080, 0xa7103230
-0,         62,         62,        1,   622080, 0x7372405f
-0,         63,         63,        1,   622080, 0x8d7a44b5
-0,         64,         64,        1,   622080, 0x9e0ee776
-0,         65,         65,        1,   622080, 0xd41e8560
-0,         66,         66,        1,   622080, 0x39e6d8c9
-0,         67,         67,        1,   622080, 0x7a23d70c
-0,         68,         68,        1,   622080, 0x51d9ac9a
-0,         69,         69,        1,   622080, 0x8eacf7f2
-0,         70,         70,        1,   622080, 0x2b63441d
-0,         71,         71,        1,   622080, 0x9f71b742
-0,         72,         72,        1,   622080, 0x58afbd5e
-0,         73,         73,        1,   622080, 0x4d645292
-0,         74,         74,        1,   622080, 0xb972f716
-0,         75,         75,        1,   622080, 0xbb5d01a2
-0,         76,         76,        1,   622080, 0x6a6df129
+0,         18,         18,        1,   622080, 0x77c0ca92
+0,         19,         19,        1,   622080, 0x06d3a822
+0,         20,         20,        1,   622080, 0xbe7fe646
+0,         21,         21,        1,   622080, 0x542e891a
+0,         22,         22,        1,   622080, 0x4384c5da
+0,         23,         23,        1,   622080, 0xddd4c056
+0,         24,         24,        1,   622080, 0x296b9168
+0,         25,         25,        1,   622080, 0xf8e09812
+0,         26,         26,        1,   622080, 0x96d5738e
+0,         27,         27,        1,   622080, 0xac341d9b
+0,         28,         28,        1,   622080, 0x769b9681
+0,         29,         29,        1,   622080, 0xb5da1354
+0,         30,         30,        1,   622080, 0x461d778d
+0,         31,         31,        1,   622080, 0xd9dcc5a8
+0,         32,         32,        1,   622080, 0xb88c584b
+0,         33,         33,        1,   622080, 0x581b5727
+0,         34,         34,        1,   622080, 0x7d7b1635
+0,         35,         35,        1,   622080, 0xfc1b1a12
+0,         36,         36,        1,   622080, 0x49c60dc0
+0,         37,         37,        1,   622080, 0x1d537b22
+0,         38,         38,        1,   622080, 0x498765a4
+0,         39,         39,        1,   622080, 0xdd2e063a
+0,         40,         40,        1,   622080, 0x0caed8f9
+0,         41,         41,        1,   622080, 0xfb4a24aa
+0,         42,         42,        1,   622080, 0x41d897d3
+0,         43,         43,        1,   622080, 0xdd3f29ae
+0,         44,         44,        1,   622080, 0x7aeb7c93
+0,         45,         45,        1,   622080, 0x2410cbe2
+0,         46,         46,        1,   622080, 0xa8bced40
+0,         47,         47,        1,   622080, 0x5534f5ca
+0,         48,         48,        1,   622080, 0x11de928c
+0,         49,         49,        1,   622080, 0x82180322
+0,         50,         50,        1,   622080, 0x64741075
+0,         51,         51,        1,   622080, 0x5e048fc8
+0,         52,         52,        1,   622080, 0x160f310e
+0,         53,         53,        1,   622080, 0x4f6d2ce7
+0,         54,         54,        1,   622080, 0x702d489c
+0,         55,         55,        1,   622080, 0xa4b41315
+0,         56,         56,        1,   622080, 0xaf2fb8aa
+0,         57,         57,        1,   622080, 0x5ec09c25
+0,         58,         58,        1,   622080, 0x575bae0f
+0,         59,         59,        1,   622080, 0x94ecf775
+0,         60,         60,        1,   622080, 0xfd68a990
+0,         61,         61,        1,   622080, 0x15a7315c
+0,         62,         62,        1,   622080, 0x8b513f66
+0,         63,         63,        1,   622080, 0xeba9440a
+0,         64,         64,        1,   622080, 0x0e6ae6c3
+0,         65,         65,        1,   622080, 0x751484a6
+0,         66,         66,        1,   622080, 0x3d12d8ab
+0,         67,         67,        1,   622080, 0xdff3d681
+0,         68,         68,        1,   622080, 0x45d0ac80
+0,         69,         69,        1,   622080, 0xbe2df7f7
+0,         70,         70,        1,   622080, 0xb18d4421
+0,         71,         71,        1,   622080, 0xa49cb6de
+0,         72,         72,        1,   622080, 0x2e81bd32
+0,         73,         73,        1,   622080, 0xa47a5272
+0,         74,         74,        1,   622080, 0x852cf6cf
+0,         75,         75,        1,   622080, 0x892a014e
+0,         76,         76,        1,   622080, 0xb055f0e5
diff --git a/tests/ref/fate/filter-yadif10 b/tests/ref/fate/filter-yadif10
index 09ab745..28e799f 100644
--- a/tests/ref/fate/filter-yadif10
+++ b/tests/ref/fate/filter-yadif10
@@ -3,33 +3,33 @@ 
 #codec_id 0: rawvideo
 #dimensions 0: 720x576
 #sar 0: 16/15
-0,          9,          9,        1,  1244160, 0x5b49e0c0
-0,         10,         10,        1,  1244160, 0x76ba6bab
-0,         11,         11,        1,  1244160, 0x0298cb8d
-0,         12,         12,        1,  1244160, 0x9c81759a
-0,         13,         13,        1,  1244160, 0xa239d1ae
-0,         14,         14,        1,  1244160, 0x3e95ada9
-0,         15,         15,        1,  1244160, 0x8b87e8f8
-0,         16,         16,        1,  1244160, 0x64f89653
-0,         17,         17,        1,  1244160, 0x58e5d12e
-0,         18,         18,        1,  1244160, 0x38b4003a
-0,         19,         19,        1,  1244160, 0xc005c29c
-0,         20,         20,        1,  1244160, 0x10c0c60d
-0,         21,         21,        1,  1244160, 0x1b550998
-0,         22,         22,        1,  1244160, 0x7aacf6ab
-0,         23,         23,        1,  1244160, 0xeb205d98
-0,         24,         24,        1,  1244160, 0x6ad2134c
-0,         25,         25,        1,  1244160, 0x8aea4e56
-0,         26,         26,        1,  1244160, 0x0d910a6b
-0,         27,         27,        1,  1244160, 0x749ae307
-0,         28,         28,        1,  1244160, 0x8ff7af3c
-0,         29,         29,        1,  1244160, 0x9ba51b91
-0,         30,         30,        1,  1244160, 0xad476514
-0,         31,         31,        1,  1244160, 0x674481d6
-0,         32,         32,        1,  1244160, 0x0937e677
-0,         33,         33,        1,  1244160, 0x6c2c53ee
-0,         34,         34,        1,  1244160, 0x524a164e
-0,         35,         35,        1,  1244160, 0x77a405ab
-0,         36,         36,        1,  1244160, 0xaa6b47c4
-0,         37,         37,        1,  1244160, 0x0b5ab556
-0,         38,         38,        1,  1244160, 0xbe1edab9
+0,          9,          9,        1,  1244160, 0xe0c2231b
+0,         10,         10,        1,  1244160, 0xdc7caa43
+0,         11,         11,        1,  1244160, 0x52c4dfbf
+0,         12,         12,        1,  1244160, 0x7c577f07
+0,         13,         13,        1,  1244160, 0x5b6ad7ce
+0,         14,         14,        1,  1244160, 0x6f15ce76
+0,         15,         15,        1,  1244160, 0xf120034a
+0,         16,         16,        1,  1244160, 0x9c65ba64
+0,         17,         17,        1,  1244160, 0x883b237e
+0,         18,         18,        1,  1244160, 0xb8292e0d
+0,         19,         19,        1,  1244160, 0xbc392721
+0,         20,         20,        1,  1244160, 0x7cd82ec9
+0,         21,         21,        1,  1244160, 0x167325eb
+0,         22,         22,        1,  1244160, 0x49bafa73
+0,         23,         23,        1,  1244160, 0xe1ff6dbf
+0,         24,         24,        1,  1244160, 0x85f710b6
+0,         25,         25,        1,  1244160, 0xd1fd4cdb
+0,         26,         26,        1,  1244160, 0xafee03c5
+0,         27,         27,        1,  1244160, 0x566be070
+0,         28,         28,        1,  1244160, 0xb6abbd01
+0,         29,         29,        1,  1244160, 0xa98f38fd
+0,         30,         30,        1,  1244160, 0x00f4736b
+0,         31,         31,        1,  1244160, 0x6b0f9dd2
+0,         32,         32,        1,  1244160, 0x15810b92
+0,         33,         33,        1,  1244160, 0x0b516465
+0,         34,         34,        1,  1244160, 0x927d15e6
+0,         35,         35,        1,  1244160, 0xd102f2bf
+0,         36,         36,        1,  1244160, 0xdd8b3b20
+0,         37,         37,        1,  1244160, 0x229ac529
+0,         38,         38,        1,  1244160, 0xf844e0a2
diff --git a/tests/ref/fate/filter-yadif16 b/tests/ref/fate/filter-yadif16
index 3386b02..0c856ab 100644
--- a/tests/ref/fate/filter-yadif16
+++ b/tests/ref/fate/filter-yadif16
@@ -3,33 +3,33 @@ 
 #codec_id 0: rawvideo
 #dimensions 0: 720x576
 #sar 0: 16/15
-0,          9,          9,        1,  1244160, 0xfb65caee
-0,         10,         10,        1,  1244160, 0x6222e690
-0,         11,         11,        1,  1244160, 0x020ac648
-0,         12,         12,        1,  1244160, 0xb76691ca
-0,         13,         13,        1,  1244160, 0xe0fd7404
-0,         14,         14,        1,  1244160, 0x3ab29705
-0,         15,         15,        1,  1244160, 0xbe807835
-0,         16,         16,        1,  1244160, 0x77d358fd
-0,         17,         17,        1,  1244160, 0x359b174f
-0,         18,         18,        1,  1244160, 0xe20f0e7f
-0,         19,         19,        1,  1244160, 0x988966ec
-0,         20,         20,        1,  1244160, 0xd078da72
-0,         21,         21,        1,  1244160, 0x276d97f7
-0,         22,         22,        1,  1244160, 0xf8ee7ca0
-0,         23,         23,        1,  1244160, 0x776bed72
-0,         24,         24,        1,  1244160, 0xb9bf92b2
-0,         25,         25,        1,  1244160, 0x30e01094
-0,         26,         26,        1,  1244160, 0xbc5f3139
-0,         27,         27,        1,  1244160, 0x44324902
-0,         28,         28,        1,  1244160, 0x64aab8f5
-0,         29,         29,        1,  1244160, 0x0a05aeac
-0,         30,         30,        1,  1244160, 0x31e5aa36
-0,         31,         31,        1,  1244160, 0xa685405f
-0,         32,         32,        1,  1244160, 0x54a6e776
-0,         33,         33,        1,  1244160, 0x9af4d8c9
-0,         34,         34,        1,  1244160, 0xf709ac9a
-0,         35,         35,        1,  1244160, 0x12a9441d
-0,         36,         36,        1,  1244160, 0xf3f1bd5e
-0,         37,         37,        1,  1244160, 0x7bcef716
-0,         38,         38,        1,  1244160, 0xe3a2f129
+0,          9,          9,        1,  1244160, 0x24eeca92
+0,         10,         10,        1,  1244160, 0x96b8e646
+0,         11,         11,        1,  1244160, 0xc11fc5da
+0,         12,         12,        1,  1244160, 0xc15f9168
+0,         13,         13,        1,  1244160, 0xba1c738e
+0,         14,         14,        1,  1244160, 0x56b59681
+0,         15,         15,        1,  1244160, 0x14ad778d
+0,         16,         16,        1,  1244160, 0x18dc584b
+0,         17,         17,        1,  1244160, 0xe4c11635
+0,         18,         18,        1,  1244160, 0x85cc0dc0
+0,         19,         19,        1,  1244160, 0x2d6a65a4
+0,         20,         20,        1,  1244160, 0x4054d8f9
+0,         21,         21,        1,  1244160, 0xebce97d3
+0,         22,         22,        1,  1244160, 0x79437c93
+0,         23,         23,        1,  1244160, 0x6438ed40
+0,         24,         24,        1,  1244160, 0x9121928c
+0,         25,         25,        1,  1244160, 0xb8731075
+0,         26,         26,        1,  1244160, 0xfb01310e
+0,         27,         27,        1,  1244160, 0x97be489c
+0,         28,         28,        1,  1244160, 0xa5b4b8aa
+0,         29,         29,        1,  1244160, 0x00a7ae0f
+0,         30,         30,        1,  1244160, 0x514fa990
+0,         31,         31,        1,  1244160, 0xd73c3f66
+0,         32,         32,        1,  1244160, 0x3602e6c3
+0,         33,         33,        1,  1244160, 0xa16ad8ab
+0,         34,         34,        1,  1244160, 0xdf11ac80
+0,         35,         35,        1,  1244160, 0x1f084421
+0,         36,         36,        1,  1244160, 0x9fc1bd32
+0,         37,         37,        1,  1244160, 0x1389f6cf
+0,         38,         38,        1,  1244160, 0x6fc5f0e5
diff --git a/tests/ref/fate/mpeg2-field-enc b/tests/ref/fate/mpeg2-field-enc
index 4c288a8..8062b82 100644
--- a/tests/ref/fate/mpeg2-field-enc
+++ b/tests/ref/fate/mpeg2-field-enc
@@ -3,33 +3,33 @@ 
 #codec_id 0: rawvideo
 #dimensions 0: 720x576
 #sar 0: 16/15
-0,          9,          9,        1,   622080, 0xb3b66c5c
-0,         10,         10,        1,   622080, 0x088ec02b
-0,         11,         11,        1,   622080, 0x7a36db21
-0,         12,         12,        1,   622080, 0x541b286f
-0,         13,         13,        1,   622080, 0xb6c3e590
-0,         14,         14,        1,   622080, 0x39dbed51
-0,         15,         15,        1,   622080, 0x973dc728
-0,         16,         16,        1,   622080, 0xd7a4f804
-0,         17,         17,        1,   622080, 0xa2484762
-0,         18,         18,        1,   622080, 0x0cd268d1
-0,         19,         19,        1,   622080, 0x72eb663d
-0,         20,         20,        1,   622080, 0x8fdbac59
-0,         21,         21,        1,   622080, 0xa6f4feb9
-0,         22,         22,        1,   622080, 0xadb828c6
-0,         23,         23,        1,   622080, 0xea630a63
-0,         24,         24,        1,   622080, 0xa901d925
-0,         25,         25,        1,   622080, 0xac5e7087
-0,         26,         26,        1,   622080, 0x10274a2b
-0,         27,         27,        1,   622080, 0x143d541c
-0,         28,         28,        1,   622080, 0xee94c93a
-0,         29,         29,        1,   622080, 0xca030208
-0,         30,         30,        1,   622080, 0x26f30ead
-0,         31,         31,        1,   622080, 0xfc22f32c
-0,         32,         32,        1,   622080, 0x940a5ff8
-0,         33,         33,        1,   622080, 0x2164f805
-0,         34,         34,        1,   622080, 0xa76f5aba
-0,         35,         35,        1,   622080, 0x8c311471
-0,         36,         36,        1,   622080, 0xa45e1d95
-0,         37,         37,        1,   622080, 0x6cc61d6c
-0,         38,         38,        1,   622080, 0x6983b417
+0,          9,          9,        1,   622080, 0xff496bf5
+0,         10,         10,        1,   622080, 0x9bf6c014
+0,         11,         11,        1,   622080, 0x870edac7
+0,         12,         12,        1,   622080, 0x9dec280c
+0,         13,         13,        1,   622080, 0x0f02e57a
+0,         14,         14,        1,   622080, 0x161beccb
+0,         15,         15,        1,   622080, 0x2234c6b0
+0,         16,         16,        1,   622080, 0x143ef78a
+0,         17,         17,        1,   622080, 0x0d6e46cf
+0,         18,         18,        1,   622080, 0xb41667fd
+0,         19,         19,        1,   622080, 0xcc476539
+0,         20,         20,        1,   622080, 0x85d8ab16
+0,         21,         21,        1,   622080, 0xcd6afec1
+0,         22,         22,        1,   622080, 0x187a28ac
+0,         23,         23,        1,   622080, 0x06100a4b
+0,         24,         24,        1,   622080, 0x1b4ed8e9
+0,         25,         25,        1,   622080, 0xde33702c
+0,         26,         26,        1,   622080, 0x11974a0c
+0,         27,         27,        1,   622080, 0x1a0553e8
+0,         28,         28,        1,   622080, 0x98e1c8da
+0,         29,         29,        1,   622080, 0x003801ce
+0,         30,         30,        1,   622080, 0x6f300e00
+0,         31,         31,        1,   622080, 0xb232f27d
+0,         32,         32,        1,   622080, 0x07c65f57
+0,         33,         33,        1,   622080, 0x6363f7ce
+0,         34,         34,        1,   622080, 0x69ba5ac3
+0,         35,         35,        1,   622080, 0x8561143e
+0,         36,         36,        1,   622080, 0xf45e1d76
+0,         37,         37,        1,   622080, 0x69f81d2f
+0,         38,         38,        1,   622080, 0x8653b3ed
diff --git a/tests/ref/fate/mpeg2-ticket6677 b/tests/ref/fate/mpeg2-ticket6677
index 5fc7cb2..e963e32 100644
--- a/tests/ref/fate/mpeg2-ticket6677
+++ b/tests/ref/fate/mpeg2-ticket6677
@@ -3,10 +3,10 @@ 
 #codec_id 0: rawvideo
 #dimensions 0: 720x480
 #sar 0: 8/9
-0,          0,          0,        1,   518400, 0x354b6fc3
-0,          1,          1,        1,   518400, 0xd86f281b
-0,          2,          2,        1,   518400, 0xdd2e2b38
-0,          3,          3,        1,   518400, 0x589535d4
-0,          4,          4,        1,   518400, 0x3f8f02b6
-0,          5,          5,        1,   518400, 0xa81b246a
+0,          0,          0,        1,   518400, 0xc1866f5f
+0,          1,          1,        1,   518400, 0x9ba32764
+0,          2,          2,        1,   518400, 0xa9031bb8
+0,          3,          3,        1,   518400, 0x5e2c3502
+0,          4,          4,        1,   518400, 0xe860027a
+0,          5,          5,        1,   518400, 0xa9152430
 0,          6,          6,        1,   518400, 0xb98dd9f7