OLD | NEW |
1 /* | 1 /* |
2 * Common AAC and AC-3 parser | 2 * Common AAC and AC-3 parser |
3 * Copyright (c) 2003 Fabrice Bellard | 3 * Copyright (c) 2003 Fabrice Bellard |
4 * Copyright (c) 2003 Michael Niedermayer | 4 * Copyright (c) 2003 Michael Niedermayer |
5 * | 5 * |
6 * This file is part of FFmpeg. | 6 * This file is part of FFmpeg. |
7 * | 7 * |
8 * FFmpeg is free software; you can redistribute it and/or | 8 * FFmpeg is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Lesser General Public | 9 * modify it under the terms of the GNU Lesser General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 s->remaining_size -= FFMIN(s->remaining_size, buf_size); | 64 s->remaining_size -= FFMIN(s->remaining_size, buf_size); |
65 *poutbuf = NULL; | 65 *poutbuf = NULL; |
66 *poutbuf_size = 0; | 66 *poutbuf_size = 0; |
67 return buf_size; | 67 return buf_size; |
68 } | 68 } |
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; |
77 | 76 |
78 /* allow downmixing to stereo (or mono for AC-3) */ | 77 /* Due to backwards compatible HE-AAC the sample rate, channel count, |
79 if(avctx->request_channels > 0 && | 78 and total number of samples found in an AAC ADTS header are not |
80 avctx->request_channels < s->channels && | 79 reliable. Bit rate is still accurate because the total frame duration in |
81 (avctx->request_channels <= 2 || | 80 seconds is still correct (as is the number of bits in the frame). */ |
82 (avctx->request_channels == 1 && | 81 if (avctx->codec_id != CODEC_ID_AAC) { |
83 (avctx->codec_id == CODEC_ID_AC3 || | 82 avctx->sample_rate = s->sample_rate; |
84 avctx->codec_id == CODEC_ID_EAC3)))) { | 83 |
85 avctx->channels = avctx->request_channels; | 84 /* allow downmixing to stereo (or mono for AC-3) */ |
86 } else if (avctx->codec_id != CODEC_ID_AAC || s->channels) { | 85 if(avctx->request_channels > 0 && |
87 avctx->channels = s->channels; | 86 avctx->request_channels < s->channels && |
88 avctx->channel_layout = s->channel_layout; | 87 (avctx->request_channels <= 2 || |
| 88 (avctx->request_channels == 1 && |
| 89 (avctx->codec_id == CODEC_ID_AC3 || |
| 90 avctx->codec_id == CODEC_ID_EAC3)))) { |
| 91 avctx->channels = avctx->request_channels; |
| 92 } else { |
| 93 avctx->channels = s->channels; |
| 94 avctx->channel_layout = s->channel_layout; |
| 95 } |
| 96 avctx->frame_size = s->samples; |
89 } | 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 } |
OLD | NEW |