Mercurial > libavcodec.hg
comparison aac_ac3_parser.c @ 11356:9056fd765255 libavcodec
AAC parser: Don't write channels, sample rate, and frame size each frame.
Thanks to backwards compatible HE-AAC signalling these values are unreliable.
author | alexc |
---|---|
date | Thu, 04 Mar 2010 02:30:51 +0000 |
parents | 4d13e2e2503a |
children | 3b06c3d9e72d |
comparison
equal
deleted
inserted
replaced
11355:3f7b7e3695c0 | 11356:9056fd765255 |
---|---|
69 | 69 |
70 *poutbuf = buf; | 70 *poutbuf = buf; |
71 *poutbuf_size = buf_size; | 71 *poutbuf_size = buf_size; |
72 | 72 |
73 /* update codec info */ | 73 /* update codec info */ |
74 avctx->sample_rate = s->sample_rate; | |
75 if(s->codec_id) | 74 if(s->codec_id) |
76 avctx->codec_id = s->codec_id; | 75 avctx->codec_id = s->codec_id; |
76 | |
77 /* Due to backwards compatible HE-AAC the sample rate, channel count, | |
78 and total number of samples found in an AAC ADTS header are not | |
79 reliable. Bit rate is still accurate because the total frame duration in | |
80 seconds is still correct (as is the number of bits in the frame). */ | |
81 if (avctx->codec_id != CODEC_ID_AAC) { | |
82 avctx->sample_rate = s->sample_rate; | |
77 | 83 |
78 /* allow downmixing to stereo (or mono for AC-3) */ | 84 /* allow downmixing to stereo (or mono for AC-3) */ |
79 if(avctx->request_channels > 0 && | 85 if(avctx->request_channels > 0 && |
80 avctx->request_channels < s->channels && | 86 avctx->request_channels < s->channels && |
81 (avctx->request_channels <= 2 || | 87 (avctx->request_channels <= 2 || |
82 (avctx->request_channels == 1 && | 88 (avctx->request_channels == 1 && |
83 (avctx->codec_id == CODEC_ID_AC3 || | 89 (avctx->codec_id == CODEC_ID_AC3 || |
84 avctx->codec_id == CODEC_ID_EAC3)))) { | 90 avctx->codec_id == CODEC_ID_EAC3)))) { |
85 avctx->channels = avctx->request_channels; | 91 avctx->channels = avctx->request_channels; |
86 } else if (avctx->codec_id != CODEC_ID_AAC || s->channels) { | 92 } else { |
87 avctx->channels = s->channels; | 93 avctx->channels = s->channels; |
88 avctx->channel_layout = s->channel_layout; | 94 avctx->channel_layout = s->channel_layout; |
89 } | 95 } |
96 avctx->frame_size = s->samples; | |
97 } | |
98 | |
90 avctx->bit_rate = s->bit_rate; | 99 avctx->bit_rate = s->bit_rate; |
91 avctx->frame_size = s->samples; | |
92 | 100 |
93 return i; | 101 return i; |
94 } | 102 } |