From 344d6db978af251e32b886f4c54e993771004fc0 Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Fri, 27 Dec 2013 00:05:36 +1100 Subject: [PATCH] avcodec/vda_h264_dec: add format check 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 e5fa8071b3..d2ef5dc9a6 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: