[FFmpeg-devel] [PATCH 2/2] libswscale/tests/swscale: Use slices randomly

Michael Niedermayer michael at niedermayer.cc
Thu Apr 2 23:56:33 EEST 2020


Output is identical

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
 libswscale/tests/swscale.c | 41 ++++++++++++++++++++++++++++++++------
 1 file changed, 35 insertions(+), 6 deletions(-)

diff --git a/libswscale/tests/swscale.c b/libswscale/tests/swscale.c
index 19878a7877..82eb135824 100644
--- a/libswscale/tests/swscale.c
+++ b/libswscale/tests/swscale.c
@@ -55,6 +55,35 @@
      (x) == AV_PIX_FMT_RGB32_1 ||         \
      (x) == AV_PIX_FMT_YUVA420P)
 
+static int sws_scale_test(struct SwsContext *c,
+                                  const uint8_t * const srcSlice[],
+                                  const int srcStride[], int srcSliceY,
+                                  int srcSliceH, uint8_t *const dst[],
+                                  const int dstStride[], int vsub1)
+{
+    int h = srcSliceH;
+    int y, i;
+    static int t = 0;
+    const uint8_t * src[4];
+    t ++;
+    y = FFALIGN(t, 4) % FFALIGN(h, 4);
+
+    if (y && !srcSliceY && h == srcSliceH) {
+        int ret = sws_scale(c, srcSlice, srcStride, 0, y, dst, dstStride);
+        if (ret < 0)
+            return ret;
+        srcSliceY = y;
+        srcSliceH -= y;
+
+        for (i=0; i<4; i++) {
+            int vsub= ((i+1)&2) ? vsub1 : 0;
+            src[i] = srcSlice[i] + (y>>vsub) * srcStride[i];
+        }
+        srcSlice = src;
+    }
+    return sws_scale(c, srcSlice, srcStride, srcSliceY, srcSliceH, dst, dstStride);
+}
+
 static uint64_t getSSD(const uint8_t *src1, const uint8_t *src2,
                        int stride1, int stride2, int w, int h)
 {
@@ -132,8 +161,8 @@ static int doTest(const uint8_t * const ref[4], int refStride[4], int w, int h,
             res = -1;
             goto end;
         }
-        sws_scale(srcContext, ref, refStride, 0, h,
-                  (uint8_t * const *) src, srcStride);
+        sws_scale_test(srcContext, ref, refStride, 0, h,
+                  (uint8_t * const *) src, srcStride, 1);
         sws_freeContext(srcContext);
 
         cur_srcFormat = srcFormat;
@@ -180,7 +209,7 @@ static int doTest(const uint8_t * const ref[4], int refStride[4], int w, int h,
            flags);
     fflush(stdout);
 
-    sws_scale(dstContext, (const uint8_t * const*)src, srcStride, 0, srcH, dst, dstStride);
+    sws_scale_test(dstContext, (const uint8_t * const*)src, srcStride, 0, srcH, dst, dstStride, desc_src->log2_chroma_h);
 
     for (i = 0; i < 4 && dstStride[i]; i++)
         crc = av_crc(av_crc_get_table(AV_CRC_32_IEEE), crc, dst[i],
@@ -212,8 +241,8 @@ static int doTest(const uint8_t * const ref[4], int refStride[4], int w, int h,
             res = -1;
             goto end;
         }
-        sws_scale(outContext, (const uint8_t * const *) dst, dstStride, 0, dstH,
-                  out, refStride);
+        sws_scale_test(outContext, (const uint8_t * const *) dst, dstStride, 0, dstH,
+                  out, refStride, desc_dst->log2_chroma_h);
 
         ssdY = getSSD(ref[0], out[0], refStride[0], refStride[0], w, h);
         if (hasChroma(srcFormat) && hasChroma(dstFormat)) {
@@ -422,7 +451,7 @@ bad_option:
     for (y = 0; y < H; y++)
         for (x = 0; x < W * 4; x++)
             rgb_data[ x + y * 4 * W] = av_lfg_get(&rand);
-    sws_scale(sws, rgb_src, rgb_stride, 0, H / 12, (uint8_t * const *) src, stride);
+    sws_scale_test(sws, rgb_src, rgb_stride, 0, H / 12, (uint8_t * const *) src, stride, 0);
     sws_freeContext(sws);
     av_free(rgb_data);
 
-- 
2.17.1



More information about the ffmpeg-devel mailing list