diff options
author | Michael Niedermayer <[email protected]> | 2013-09-22 13:50:57 +0200 |
---|---|---|
committer | Michael Niedermayer <[email protected]> | 2013-09-22 13:51:05 +0200 |
commit | 9e552b65127aa51bf60726a38fb086ddaca74fdf (patch) | |
tree | 01d330a36fbaf4c995adb003c707fc37bca5ac87 | |
parent | 506ad68d87f967640519a4d568c9236d53642a9a (diff) | |
parent | 68b100871961c3e6450871367630e5bf830f6cfd (diff) |
Merge remote-tracking branch 'qatar/release/0.8' into release/0.10
* qatar/release/0.8:
adpcm: Unbreak ima-dk4
ac3dec: validate channel output mode against channel count
dca: Respect the current limits in the downmixing capabilities
Merged-by: Michael Niedermayer <[email protected]>
-rw-r--r-- | libavcodec/ac3dec.c | 14 | ||||
-rw-r--r-- | libavcodec/dca.c | 7 |
2 files changed, 15 insertions, 6 deletions
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c index 8c94254cf9..9384dc7fbf 100644 --- a/libavcodec/ac3dec.c +++ b/libavcodec/ac3dec.c @@ -1373,8 +1373,10 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, if (!err) { avctx->sample_rate = s->sample_rate; avctx->bit_rate = s->bit_rate; + } - /* channel config */ + /* channel config */ + if (!err || (s->channels && s->out_channels != s->channels)) { s->out_channels = s->channels; s->output_mode = s->channel_mode; if (s->lfe_on) @@ -1397,18 +1399,18 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, 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; + } else if (!s->channels) { + av_log(avctx, AV_LOG_ERROR, "unable to determine channel mode\n"); + return AVERROR_INVALIDDATA; } + avctx->channels = s->out_channels; + /* set audio service type based on bitstream mode for AC-3 */ avctx->audio_service_type = s->bitstream_mode; if (s->bitstream_mode == 0x7 && s->channels > 1) avctx->audio_service_type = AV_AUDIO_SERVICE_TYPE_KARAOKE; /* get output buffer */ - avctx->channels = s->out_channels; s->frame.nb_samples = s->num_blocks * 256; if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); diff --git a/libavcodec/dca.c b/libavcodec/dca.c index a442e7f06b..ea40821766 100644 --- a/libavcodec/dca.c +++ b/libavcodec/dca.c @@ -804,6 +804,13 @@ static int dca_subframe_header(DCAContext *s, int base_channel, int block_index) "Invalid channel mode %d\n", am); return AVERROR_INVALIDDATA; } + + if (s->prim_channels > FF_ARRAY_ELEMS(dca_default_coeffs[0])) { + av_log_ask_for_sample(s->avctx, "Downmixing %d channels", + s->prim_channels); + return AVERROR_PATCHWELCOME; + } + for (j = base_channel; j < s->prim_channels; j++) { s->downmix_coef[j][0] = dca_default_coeffs[am][j][0]; s->downmix_coef[j][1] = dca_default_coeffs[am][j][1]; |