diff mbox series

[FFmpeg-devel,03/12] avcodec/proresenc_anatoliy: Mark impossible case as unreachable

Message ID AS8P250MB0744D8BD22E2E1727D97AB068FF52@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM
State New
Headers show
Series [FFmpeg-devel,01/12] avutil/avassert: Add av_unreachable and av_assume() macros | 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

Andreas Rheinhardt May 24, 2024, 10:04 p.m. UTC
Should fix Coverity issue 1440385.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
Alternative to https://ffmpeg.org/pipermail/ffmpeg-devel/2024-May/327293.html

 libavcodec/proresenc_anatoliy.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index 2fb96e9cf5..7b7618af9b 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -845,18 +845,25 @@  static av_cold int prores_encode_init(AVCodecContext *avctx)
     }
 
     if (avctx->profile == AV_PROFILE_UNKNOWN) {
-        if (avctx->pix_fmt == AV_PIX_FMT_YUV422P10) {
+        switch (avctx->pix_fmt) {
+        case AV_PIX_FMT_YUV422P10:
             avctx->profile = AV_PROFILE_PRORES_STANDARD;
             av_log(avctx, AV_LOG_INFO,
                 "encoding with ProRes standard (apcn) profile\n");
-        } else if (avctx->pix_fmt == AV_PIX_FMT_YUV444P10) {
+            break;
+        case AV_PIX_FMT_YUV444P10:
             avctx->profile = AV_PROFILE_PRORES_4444;
             av_log(avctx, AV_LOG_INFO,
                    "encoding with ProRes 4444 (ap4h) profile\n");
-        } else if (avctx->pix_fmt == AV_PIX_FMT_YUVA444P10) {
+            break;
+        case AV_PIX_FMT_YUVA444P10:
             avctx->profile = AV_PROFILE_PRORES_4444;
             av_log(avctx, AV_LOG_INFO,
                    "encoding with ProRes 4444+ (ap4h) profile\n");
+            break;
+        default:
+            /* Already checked via AVCodec.pix_fmts. */
+            av_unreachable;
         }
     } else if (avctx->profile < AV_PROFILE_PRORES_PROXY
             || avctx->profile > AV_PROFILE_PRORES_XQ) {