summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2008-05-25 20:02:24 +0000
committerJustin Ruggles <justin.ruggles@gmail.com>2008-05-25 20:02:24 +0000
commiteccba2bc4bde88755dc2a8569e44ea0373f5e0c7 (patch)
treea0a2c51d4619d17cb6a2c3ede90c156f17c616e7 /libavcodec
parent5012cf88a304a48629821cf29e3a795a647d17fc (diff)
safer solution for setting audio parameters
Originally committed as revision 13402 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/ac3dec.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index ab811f1c31..4272a6d35f 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -324,12 +324,6 @@ static int ac3_parse_header(AC3DecodeContext *s)
s->center_mix_level = hdr.center_mix_level;
s->surround_mix_level = hdr.surround_mix_level;
- /* set default output to all source channels */
- s->out_channels = s->channels;
- s->output_mode = s->channel_mode;
- if(s->lfe_on)
- s->output_mode |= AC3_OUTPUT_LFEON;
-
/* read the rest of the bsi. read twice for dual mono mode. */
i = !(s->channel_mode);
do {
@@ -1188,13 +1182,16 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size,
}
}
- /* if frame header is ok, set audio parameters */
- if (err >= 0) {
+ /* if frame is ok, set audio parameters */
+ if (!err) {
avctx->sample_rate = s->sample_rate;
avctx->bit_rate = s->bit_rate;
/* channel config */
s->out_channels = s->channels;
+ s->output_mode = s->channel_mode;
+ if(s->lfe_on)
+ s->output_mode |= AC3_OUTPUT_LFEON;
if (avctx->request_channels > 0 && avctx->request_channels <= 2 &&
avctx->request_channels < s->channels) {
s->out_channels = avctx->request_channels;
@@ -1207,6 +1204,10 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size,
s->fbw_channels == s->out_channels)) {
set_downmix_coeffs(s);
}
+ } else if (!s->out_channels) {
+ s->out_channels = avctx->channels;
+ if(s->out_channels < s->channels)
+ s->output_mode = s->out_channels == 1 ? AC3_CHMODE_MONO : AC3_CHMODE_STEREO;
}
/* parse the audio blocks */