[FFmpeg-devel] [PATCH 2/4] tests/sw_scale: Add test cases for input sizes 16

Hubert Mazur hum at semihalf.com
Mon Oct 17 16:07:13 EEST 2022


Previously test cases handled only input sizes equal to 8.
Add support for input size 16 which is used by scaling
routines hscale16To15 and hscale16To19. Pass SwsContext
pointer to each function as some of them make use of it.

Signed-off-by: Hubert Mazur <hum at semihalf.com>
---
 tests/checkasm/sw_scale.c | 35 ++++++++++++++++++++++++++---------
 1 file changed, 26 insertions(+), 9 deletions(-)

diff --git a/tests/checkasm/sw_scale.c b/tests/checkasm/sw_scale.c
index 3b8dd310ec..2e4b698f88 100644
--- a/tests/checkasm/sw_scale.c
+++ b/tests/checkasm/sw_scale.c
@@ -262,23 +262,31 @@ static void check_hscale(void)
 #define FILTER_SIZES 6
     static const int filter_sizes[FILTER_SIZES] = { 4, 8, 12, 16, 32, 40 };
 
-#define HSCALE_PAIRS 2
+#define HSCALE_PAIRS 4
     static const int hscale_pairs[HSCALE_PAIRS][2] = {
         { 8, 14 },
         { 8, 18 },
+        { 16, 14 },
+        { 16, 18 }
     };
 
+#define DST_WIDTH(x) ( (x) == (14) ? sizeof(int16_t) : sizeof(int32_t))
 #define LARGEST_INPUT_SIZE 512
 #define INPUT_SIZES 6
     static const int input_sizes[INPUT_SIZES] = {8, 24, 128, 144, 256, 512};
 
     int i, j, fsi, hpi, width, dstWi;
     struct SwsContext *ctx;
+    void *(*_dst)[2];
+    void *_src;
 
     // padded
     LOCAL_ALIGNED_32(uint8_t, src, [FFALIGN(SRC_PIXELS + MAX_FILTER_WIDTH - 1, 4)]);
-    LOCAL_ALIGNED_32(uint32_t, dst0, [SRC_PIXELS]);
-    LOCAL_ALIGNED_32(uint32_t, dst1, [SRC_PIXELS]);
+    LOCAL_ALIGNED_32(uint16_t, src1, [FFALIGN(SRC_PIXELS + MAX_FILTER_WIDTH - 1, 4)]);
+    LOCAL_ALIGNED_32(int16_t, dst_ref_16, [SRC_PIXELS]);
+    LOCAL_ALIGNED_32(int16_t, dst_new_16, [SRC_PIXELS]);
+    LOCAL_ALIGNED_32(int32_t, dst_ref_32, [SRC_PIXELS]);
+    LOCAL_ALIGNED_32(int32_t, dst_new_32, [SRC_PIXELS]);
 
     // padded
     LOCAL_ALIGNED_32(int16_t, filter, [SRC_PIXELS * MAX_FILTER_WIDTH + MAX_FILTER_WIDTH]);
@@ -286,6 +294,9 @@ static void check_hscale(void)
     LOCAL_ALIGNED_32(int16_t, filterAvx2, [SRC_PIXELS * MAX_FILTER_WIDTH + MAX_FILTER_WIDTH]);
     LOCAL_ALIGNED_32(int32_t, filterPosAvx, [SRC_PIXELS]);
 
+    void *_dst_16[2] = {dst_ref_16, dst_new_16};
+    void *_dst_32[2] = {dst_ref_32, dst_new_32};
+
     // The dst parameter here is either int16_t or int32_t but we use void* to
     // just cover both cases.
     declare_func_emms(AV_CPU_FLAG_MMX, void, void *c, void *dst, int dstW,
@@ -297,6 +308,7 @@ static void check_hscale(void)
         fail();
 
     randomize_buffers(src, SRC_PIXELS + MAX_FILTER_WIDTH - 1);
+    randomize_buffers(src1, SRC_PIXELS + MAX_FILTER_WIDTH - 1);
 
     for (hpi = 0; hpi < HSCALE_PAIRS; hpi++) {
         for (fsi = 0; fsi < FILTER_SIZES; fsi++) {
@@ -306,6 +318,8 @@ static void check_hscale(void)
                 ctx->srcBpc = hscale_pairs[hpi][0];
                 ctx->dstBpc = hscale_pairs[hpi][1];
                 ctx->hLumFilterSize = ctx->hChrFilterSize = width;
+                _src = ctx->srcBpc == 8 ? (void *)src : (void *)src1;
+                _dst = ctx->dstBpc == 14 ? (void*)_dst_16 : (void*)_dst_32;
 
                 for (i = 0; i < SRC_PIXELS; i++) {
                     filterPos[i] = i;
@@ -343,14 +357,15 @@ static void check_hscale(void)
                 ff_shuffle_filter_coefficients(ctx, filterPosAvx, width, filterAvx2, ctx->dstW);
 
                 if (check_func(ctx->hcScale, "hscale_%d_to_%d__fs_%d_dstW_%d", ctx->srcBpc, ctx->dstBpc + 1, width, ctx->dstW)) {
-                    memset(dst0, 0, SRC_PIXELS * sizeof(dst0[0]));
-                    memset(dst1, 0, SRC_PIXELS * sizeof(dst1[0]));
+                    memset((*_dst)[0], 0, SRC_PIXELS * DST_WIDTH(ctx->dstBpc));
+                    memset((*_dst)[1], 0, SRC_PIXELS * DST_WIDTH(ctx->dstBpc));
+
+                    call_ref(ctx, (*_dst)[0], ctx->dstW, src, filter, filterPos, width);
+                    call_new(ctx, (*_dst)[1], ctx->dstW, src, filterAvx2, filterPosAvx, width);
 
-                    call_ref(NULL, dst0, ctx->dstW, src, filter, filterPos, width);
-                    call_new(NULL, dst1, ctx->dstW, src, filterAvx2, filterPosAvx, width);
-                    if (memcmp(dst0, dst1, ctx->dstW * sizeof(dst0[0])))
+                    if (memcmp((*_dst)[0], (*_dst)[1], ctx->dstW * DST_WIDTH(ctx->dstBpc)))
                         fail();
-                    bench_new(NULL, dst0, ctx->dstW, src, filter, filterPosAvx, width);
+                    bench_new(ctx, (*_dst)[1], ctx->dstW, _src, filter, filterPosAvx, width);
                 }
             }
         }
@@ -358,6 +373,8 @@ static void check_hscale(void)
     sws_freeContext(ctx);
 }
 
+#undef DST_WIDTH
+
 void checkasm_check_sw_scale(void)
 {
     check_hscale();
-- 
2.37.1



More information about the ffmpeg-devel mailing list