diff mbox series

[FFmpeg-devel,5/7] swscale/tests/swscale: Allow comparing a subset of cases to a reference file

Message ID 20240214220631.9641-5-michael@niedermayer.cc
State Accepted
Commit f7770ec9a4c9f3db3dcc198a390edc8780e1bb89
Headers show
Series [FFmpeg-devel,1/7] swscale/tests/swscale: Implement isALPHA() using AVPixFmtDescriptor | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Michael Niedermayer Feb. 14, 2024, 10:06 p.m. UTC
Testing all cases exhaustively is slow

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libswscale/tests/swscale.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
diff mbox series

Patch

diff --git a/libswscale/tests/swscale.c b/libswscale/tests/swscale.c
index 07d0af4377e..68434fb7baf 100644
--- a/libswscale/tests/swscale.c
+++ b/libswscale/tests/swscale.c
@@ -33,6 +33,7 @@ 
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/lfg.h"
+#include "libavutil/sfc64.h"
 
 #include "libswscale/swscale.h"
 
@@ -56,6 +57,9 @@  static av_always_inline int isALPHA(enum AVPixelFormat pix_fmt)
     return desc->flags & AV_PIX_FMT_FLAG_ALPHA;
 }
 
+static double prob = 1;
+FFSFC64 prng_state;
+
 static uint64_t getSSD(const uint8_t *src1, const uint8_t *src2,
                        int stride1, int stride2, int w, int h)
 {
@@ -117,6 +121,9 @@  static int doTest(const uint8_t * const ref[4], int refStride[4], int w, int h,
     uint32_t crc = 0;
     int res      = 0;
 
+    if (ff_sfc64_get(&prng_state) > UINT64_MAX * prob)
+        return 0;
+
     if (cur_srcFormat != srcFormat || cur_srcW != srcW || cur_srcH != srcH) {
         struct SwsContext *srcContext = NULL;
         int p;
@@ -449,6 +456,8 @@  int main(int argc, char **argv)
                 fprintf(stderr, "invalid pixel format %s\n", argv[i + 1]);
                 return -1;
             }
+        } else if (!strcmp(argv[i], "-p")) {
+            prob = atof(argv[i + 1]);
         } else {
 bad_option:
             fprintf(stderr, "bad option or argument missing (%s)\n", argv[i]);
@@ -456,6 +465,8 @@  bad_option:
         }
     }
 
+    ff_sfc64_init(&prng_state, 0, 0, 0, 12);
+
     sws = sws_getContext(W / 12, H / 12, AV_PIX_FMT_RGB32, W, H,
                          AV_PIX_FMT_YUVA420P, SWS_BILINEAR, NULL, NULL, NULL);