diff options
author | Rodger Combs <rodger.combs@gmail.com> | 2016-04-07 20:27:03 -0500 |
---|---|---|
committer | Rodger Combs <rodger.combs@gmail.com> | 2016-04-13 03:27:29 -0500 |
commit | c11157c09a11ad3f80ace4dc6832eef7067db72a (patch) | |
tree | c24c3079f03f2fce7497a4d0828899ee4e1c0d46 | |
parent | acd5910e39be56ea0486b71148626881bf7056a8 (diff) | |
download | ffmpeg-c11157c09a11ad3f80ace4dc6832eef7067db72a.tar.gz |
lavf/audiotoolboxdec: only send extradata for formats that use it
Fixes initialization errors for some AVI files
-rw-r--r-- | libavcodec/audiotoolboxdec.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/libavcodec/audiotoolboxdec.c b/libavcodec/audiotoolboxdec.c index 2740648486..80b1f33922 100644 --- a/libavcodec/audiotoolboxdec.c +++ b/libavcodec/audiotoolboxdec.c @@ -261,10 +261,17 @@ static uint8_t* ffat_get_magic_cookie(AVCodecContext *avctx, UInt32 *cookie_size } } +static av_cold int ffat_usable_extradata(AVCodecContext *avctx) +{ + return avctx->extradata_size && + (avctx->codec_id == AV_CODEC_ID_ALAC || + avctx->codec_id == AV_CODEC_ID_AAC); +} + static int ffat_set_extradata(AVCodecContext *avctx) { ATDecodeContext *at = avctx->priv_data; - if (avctx->extradata_size) { + if (ffat_usable_extradata(avctx)) { OSStatus status; UInt32 cookie_size; uint8_t *cookie = ffat_get_magic_cookie(avctx, &cookie_size); @@ -305,7 +312,7 @@ static av_cold int ffat_create_decoder(AVCodecContext *avctx, AVPacket *pkt) avctx->sample_fmt = sample_fmt; - if (avctx->extradata) { + if (ffat_usable_extradata(avctx)) { UInt32 format_size = sizeof(in_format); UInt32 cookie_size; uint8_t *cookie = ffat_get_magic_cookie(avctx, &cookie_size); @@ -384,7 +391,7 @@ static av_cold int ffat_create_decoder(AVCodecContext *avctx, AVPacket *pkt) static av_cold int ffat_init_decoder(AVCodecContext *avctx) { - if ((avctx->channels && avctx->sample_rate) || avctx->extradata_size) + if ((avctx->channels && avctx->sample_rate) || ffat_usable_extradata(avctx)) return ffat_create_decoder(avctx, NULL); else return 0; |