diff mbox

[FFmpeg-devel,6/8] swscale/tests/swscale: remove access of AV_PIX_FMT_NB

Message ID 20191230135419.56529-6-quinkblack@foxmail.com
State New
Headers show

Commit Message

Zhao Zhili Dec. 30, 2019, 1:54 p.m. UTC
From: Zhao Zhili <zhilizhao@tencent.com>

---
 libswscale/tests/swscale.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/libswscale/tests/swscale.c b/libswscale/tests/swscale.c
index 19878a7877..784195f468 100644
--- a/libswscale/tests/swscale.c
+++ b/libswscale/tests/swscale.c
@@ -251,6 +251,18 @@  end:
     return res;
 }
 
+static int getMaxFmt()
+{
+    const AVPixFmtDescriptor *desc = NULL;
+    int fmt_max = AV_PIX_FMT_NONE;
+
+    while ((desc = av_pix_fmt_desc_next(desc))) {
+        int fmt = av_pix_fmt_desc_get_id(desc);
+        fmt_max = FFMAX(fmt, fmt_max);
+    }
+    return fmt_max;
+}
+
 static void selfTest(const uint8_t * const ref[4], int refStride[4],
                      int w, int h,
                      enum AVPixelFormat srcFormat_in,
@@ -264,9 +276,10 @@  static void selfTest(const uint8_t * const ref[4], int refStride[4],
     const int dstH[] = { srcH - srcH / 3, srcH, srcH + srcH / 3, 0 };
     enum AVPixelFormat srcFormat, dstFormat;
     const AVPixFmtDescriptor *desc_src, *desc_dst;
+    const int fmt_max = getMaxFmt();
 
     for (srcFormat = srcFormat_in != AV_PIX_FMT_NONE ? srcFormat_in : 0;
-         srcFormat < AV_PIX_FMT_NB; srcFormat++) {
+         srcFormat <= fmt_max; srcFormat++) {
         if (!sws_isSupportedInput(srcFormat) ||
             !sws_isSupportedOutput(srcFormat))
             continue;
@@ -274,7 +287,7 @@  static void selfTest(const uint8_t * const ref[4], int refStride[4],
         desc_src = av_pix_fmt_desc_get(srcFormat);
 
         for (dstFormat = dstFormat_in != AV_PIX_FMT_NONE ? dstFormat_in : 0;
-             dstFormat < AV_PIX_FMT_NB; dstFormat++) {
+             dstFormat <= fmt_max; dstFormat++) {
             int i, j, k;
             int res = 0;