[FFmpeg-cvslog] swscale/tests/swscale: Allow comparing a subset of cases to a reference file

Michael Niedermayer git at videolan.org
Fri Feb 16 00:09:02 EET 2024


ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Wed Feb 14 22:14:14 2024 +0100| [f7770ec9a4c9f3db3dcc198a390edc8780e1bb89] | committer: Michael Niedermayer

swscale/tests/swscale: Allow comparing a subset of cases to a reference file

Testing all cases exhaustively is slow

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f7770ec9a4c9f3db3dcc198a390edc8780e1bb89
---

 libswscale/tests/swscale.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/libswscale/tests/swscale.c b/libswscale/tests/swscale.c
index 07d0af4377..68434fb7ba 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);
 



More information about the ffmpeg-cvslog mailing list