Thanks to backwards compatible HE-AAC signalling these values are unreliable.
Originally committed as revision 22194 to svn://svn.ffmpeg.org/ffmpeg/trunk
| ... | ... |
@@ -71,10 +71,16 @@ get_next: |
| 71 | 71 |
*poutbuf_size = buf_size; |
| 72 | 72 |
|
| 73 | 73 |
/* update codec info */ |
| 74 |
- avctx->sample_rate = s->sample_rate; |
|
| 75 | 74 |
if(s->codec_id) |
| 76 | 75 |
avctx->codec_id = s->codec_id; |
| 77 | 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; |
|
| 83 |
+ |
|
| 78 | 84 |
/* allow downmixing to stereo (or mono for AC-3) */ |
| 79 | 85 |
if(avctx->request_channels > 0 && |
| 80 | 86 |
avctx->request_channels < s->channels && |
| ... | ... |
@@ -83,12 +89,14 @@ get_next: |
| 83 | 83 |
(avctx->codec_id == CODEC_ID_AC3 || |
| 84 | 84 |
avctx->codec_id == CODEC_ID_EAC3)))) {
|
| 85 | 85 |
avctx->channels = avctx->request_channels; |
| 86 |
- } else if (avctx->codec_id != CODEC_ID_AAC || s->channels) {
|
|
| 86 |
+ } else {
|
|
| 87 | 87 |
avctx->channels = s->channels; |
| 88 | 88 |
avctx->channel_layout = s->channel_layout; |
| 89 | 89 |
} |
| 90 |
- avctx->bit_rate = s->bit_rate; |
|
| 91 | 90 |
avctx->frame_size = s->samples; |
| 91 |
+ } |
|
| 92 |
+ |
|
| 93 |
+ avctx->bit_rate = s->bit_rate; |
|
| 92 | 94 |
|
| 93 | 95 |
return i; |
| 94 | 96 |
} |