From 8203aa9eb65e616df0c7ad3926a83484bec930d5 Mon Sep 17 00:00:00 2001
From: Martin Vignali <martin.vignali@gmail.com>
Date: Fri, 8 Mar 2019 00:06:01 +0100
Subject: [PATCH] avcodec/proresenc_aw : fix interlace encoding for unsafe
 height

fix the call of the unsafe version of slice encoding in interlace mode
fix padding line count in sub image with fill in interlace mode
---
 libavcodec/proresenc_anatoliy.c         | 4 ++--
 tests/ref/vsynth/vsynth3-prores_444_int | 8 ++++----
 tests/ref/vsynth/vsynth3-prores_int     | 8 ++++----
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index 5914445b52..0fc79fc1de 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -485,7 +485,7 @@ static inline void subimage_with_fill_template(uint16_t *src, unsigned x, unsign
     } else {
         src_stride = stride; /* 2 lines stride */
         src += y * src_stride + x;
-        box_height = FFMIN(height - y * 2, dst_height);
+        box_height = FFMIN(height/2 - y, dst_height);
         if (!is_top_field)
             src += stride >> 1;
     }
@@ -671,7 +671,7 @@ static int prores_encode_picture(AVCodecContext *avctx, const AVFrame *pic,
             picture_height = avctx->height / 2;
         }
         mb_height = (picture_height + 15) >> 4;
-        unsafe_mb_height_limit = mb_height * 2;
+        unsafe_mb_height_limit = mb_height;
     }
 
     for (i = av_log2(DEFAULT_SLICE_MB_WIDTH); i >= 0; --i) {
diff --git a/tests/ref/vsynth/vsynth3-prores_444_int b/tests/ref/vsynth/vsynth3-prores_444_int
index ec9dda8965..36760adf9a 100644
--- a/tests/ref/vsynth/vsynth3-prores_444_int
+++ b/tests/ref/vsynth/vsynth3-prores_444_int
@@ -1,4 +1,4 @@
-4928501bad7c46a277eab54440f2a794 *tests/data/fate/vsynth3-prores_444_int.mov
-230539 tests/data/fate/vsynth3-prores_444_int.mov
-7acff20947af998d5a6e6f85ff24a6d2 *tests/data/fate/vsynth3-prores_444_int.out.rawvideo
-stddev:    3.27 PSNR: 37.82 MAXDIFF:   42 bytes:    86700/    86700
+270045a731d4cb6ba253880021c87a63 *tests/data/fate/vsynth3-prores_444_int.mov
+184397 tests/data/fate/vsynth3-prores_444_int.mov
+a8852aa2841c2ce5f2aa86176ceda4ef *tests/data/fate/vsynth3-prores_444_int.out.rawvideo
+stddev:    3.24 PSNR: 37.91 MAXDIFF:   41 bytes:    86700/    86700
diff --git a/tests/ref/vsynth/vsynth3-prores_int b/tests/ref/vsynth/vsynth3-prores_int
index 0208a2d15a..53dcfbd14d 100644
--- a/tests/ref/vsynth/vsynth3-prores_int
+++ b/tests/ref/vsynth/vsynth3-prores_int
@@ -1,4 +1,4 @@
-8bd60c3d149977dd25e21adcf57d76fa *tests/data/fate/vsynth3-prores_int.mov
-148325 tests/data/fate/vsynth3-prores_int.mov
-628a667a0de678239f05a6e5497c4601 *tests/data/fate/vsynth3-prores_int.out.rawvideo
-stddev:    3.06 PSNR: 38.40 MAXDIFF:   29 bytes:    86700/    86700
+ee1f14b23eb9dee4d59b021d4ec041bf *tests/data/fate/vsynth3-prores_int.mov
+120484 tests/data/fate/vsynth3-prores_int.mov
+e5859ba47a99f9e53c1ddcaa68a8f8f8 *tests/data/fate/vsynth3-prores_int.out.rawvideo
+stddev:    2.92 PSNR: 38.81 MAXDIFF:   29 bytes:    86700/    86700
-- 
2.17.2 (Apple Git-113)

