[FFmpeg-devel] [PATCH] avcodec/vda_h264_dec: add format check

Xidorn Quan quanxunzhen at gmail.com
Thu Dec 26 14:43:22 CET 2013


Fix crash when using this decoder for unsupported format on some version
of OS X.
---
 libavcodec/vda_h264_dec.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/libavcodec/vda_h264_dec.c b/libavcodec/vda_h264_dec.c
index e5fa807..d2ef5dc 100644
--- a/libavcodec/vda_h264_dec.c
+++ b/libavcodec/vda_h264_dec.c
@@ -235,6 +235,16 @@ static av_cold int vdadec_init(AVCodecContext *avctx)
     }
     ctx->h264_initialized = 1;
 
+    for (int i = 0; i < MAX_SPS_COUNT; i++) {
+        SPS *sps = ctx->h264ctx.sps_buffers[i];
+        if (sps && (sps->bit_depth_luma != 8 ||
+                sps->chroma_format_idc == 2 ||
+                sps->chroma_format_idc == 3)) {
+            av_log(avctx, AV_LOG_ERROR, "Format is not supported.\n");
+            goto failed;
+        }
+    }
+
     return 0;
 
 failed:
-- 
1.8.5.1



More information about the ffmpeg-devel mailing list