From patchwork Mon Dec 30 13:54:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhao Zhili X-Patchwork-Id: 17066 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id EE3E9449AE8 for ; Mon, 30 Dec 2019 15:54:46 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DE9D068ABA6; Mon, 30 Dec 2019 15:54:46 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtpbguseast2.qq.com (smtpbguseast2.qq.com [54.204.34.130]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6608868AB32 for ; Mon, 30 Dec 2019 15:54:37 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1577714072; bh=0qGtv3+Ql9iS3QatZ6dGhj4V+i6wvgerAHnm8fWETnc=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=lnAu3LEdG1YLpOcAMzkL6k/O+xQXDZRSfuKlXimaCLOn1ZZyHptslNcdg03KXkokw WJN5yBijHx4WOuJ4p520zjNy0quKum2WvUovWM2+ADFWpupbYs93lI2183w48eEefY Z3aRjE3UMTtUG88dDe2GqiTDSenxDTpMNgqL4jIw= X-QQ-mid: esmtp3t1577714071tnu8pgiyn Received: from ZHILIZHAO-MB1.tencent.com (unknown [14.17.22.54]) by esmtp4.qq.com (ESMTP) with id ; Mon, 30 Dec 2019 21:54:31 +0800 (CST) X-QQ-SSF: 01000000000000N0WG4000000000002 X-QQ-FEAT: TOsx1yfRfVHWGqGoS9/Stv7tHUB178jN1qAw7oukwqYnZ65lkZi63xsHF9ztq 1QrY4JY+1fCwLhx0Gi+OqqADgkPXjwX9O5iKjKSrT6axnVjop58EkEj1RSoGoMtaAh1zQIW x93Xj19sMqj7ybfGkw1akB77S4t/13/dOmW7GwAdjuvJMXoieuanTy5a/x1vSbxmGhMKEX2 fK2xzkCiZSnoNTJwj443Or+L6jpXT6ieYGm/bt21Raa18PcHFwsqYmfIzf9vqu/4xqgmfLU sK98c2hzcnMAkCBDAd4oGxPlAaLWQw33qibw== X-QQ-GoodBg: 0 From: quinkblack@foxmail.com To: ffmpeg-devel@ffmpeg.org Date: Mon, 30 Dec 2019 21:54:17 +0800 Message-Id: <20191230135419.56529-6-quinkblack@foxmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20191230135419.56529-1-quinkblack@foxmail.com> References: <20191230135419.56529-1-quinkblack@foxmail.com> MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: esmtp:foxmail.com:bgforeign:bgforeign12 X-QQ-Bgrelay: 1 Subject: [FFmpeg-devel] [PATCH 6/8] swscale/tests/swscale: remove access of AV_PIX_FMT_NB X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Zhao Zhili Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Zhao Zhili --- 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;