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

quinkblack at foxmail.com quinkblack at foxmail.com
Mon Dec 30 15:54:17 EET 2019


From: Zhao Zhili <zhilizhao at tencent.com>

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

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;
 
-- 
2.22.0





More information about the ffmpeg-devel mailing list