Resetting it on codec init would incorrectly clear the values if av_find_stream_info was already run before, in particular breaking ffplay. This fixes trac tickets #213 and #262.
Unified · Split
| @@ -570,9 +570,6 @@ static av_cold int aac_decode_init(AVCodecContext *avctx) · 569 unmodified lines | |||
| 570 | ac->m4ac.sample_rate = avctx->sample_rate; | 570 | ac->m4ac.sample_rate = avctx->sample_rate; |
| 571 | 571 | ||
| 572 | if (avctx->extradata_size > 0) { | 572 | if (avctx->extradata_size > 0) { |
| 573 | avctx->channels = 0; | ||
| 574 | avctx->frame_size = 0; | ||
| 575 | avctx->sample_rate = 0; | ||
| 576 | if (decode_audio_specific_config(ac, ac->avctx, &ac->m4ac, | 573 | if (decode_audio_specific_config(ac, ac->avctx, &ac->m4ac, |
| 577 | avctx->extradata, | 574 | avctx->extradata, |
| 578 | avctx->extradata_size) < 0) | 575 | avctx->extradata_size) < 0) |
| @@ -2261,6 +2261,15 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) · 2260 unmodified lines | |||
| 2261 | for(i=0;i<ic->nb_streams;i++) { | 2261 | for(i=0;i<ic->nb_streams;i++) { |
| 2262 | AVCodec *codec; | 2262 | AVCodec *codec; |
| 2263 | st = ic->streams[i]; | 2263 | st = ic->streams[i]; |
| 2264 | if (st->codec->codec_id == CODEC_ID_AAC && st->codec->extradata_size) { | ||
| 2265 | // We need to discard these since they can be plain wrong for | ||
| 2266 | // backwards compatible HE-AAC signaling. | ||
| 2267 | // But when we have no extradata we need to keep them or we can't | ||
| 2268 | // play anything at all. | ||
| 2269 | st->codec->sample_rate = 0; | ||
| 2270 | st->codec->frame_size = 0; | ||
| 2271 | st->codec->channels = 0; | ||
| 2272 | } | ||
| 2264 | 2273 | ||
| 2265 | if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO || | 2274 | if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO || |
| 2266 | st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) { | 2275 | st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) { |