Mercurial > libavcodec.hg
changeset 6889:ff5fd5a1abf5 libavcodec
safer solution for setting audio parameters
author | jbr |
---|---|
date | Sun, 25 May 2008 20:02:24 +0000 |
parents | b2f2c09af893 |
children | 5ddf098691d3 |
files | ac3dec.c |
diffstat | 1 files changed, 9 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/ac3dec.c Sun May 25 19:48:03 2008 +0000 +++ b/ac3dec.c Sun May 25 20:02:24 2008 +0000 @@ -324,12 +324,6 @@ 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 @@ } } - /* 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 @@ 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 */