diff options
Diffstat (limited to 'libavcodec/dca.c')
-rw-r--r-- | libavcodec/dca.c | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/libavcodec/dca.c b/libavcodec/dca.c index 103f0588e3..d9fafbad01 100644 --- a/libavcodec/dca.c +++ b/libavcodec/dca.c @@ -5,20 +5,20 @@ * Copyright (C) 2006 Benjamin Larsson * Copyright (C) 2007 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * Libav is distributed in the hope that it will be useful, + * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -315,7 +315,6 @@ typedef struct { /* Primary audio coding header */ int subframes; ///< number of subframes - int is_channels_set; ///< check for if the channel number is already set int total_channels; ///< number of channels including extensions int prim_channels; ///< number of primary audio channels int subband_activity[DCA_PRIM_CHANNELS_MAX]; ///< subband activity count @@ -834,6 +833,7 @@ static int dca_subframe_header(DCAContext *s, int base_channel, int block_index) /* Low frequency effect data */ if (!base_channel && s->lfe) { + int quant7; /* LFE samples */ int lfe_samples = 2 * s->lfe * (4 + block_index); int lfe_end_sample = 2 * s->lfe * (4 + block_index + s->subsubframes[s->current_subframe]); @@ -845,8 +845,12 @@ static int dca_subframe_header(DCAContext *s, int base_channel, int block_index) } /* Scale factor index */ - skip_bits(&s->gb, 1); - s->lfe_scale_factor = scale_factor_quant7[get_bits(&s->gb, 7)]; + quant7 = get_bits(&s->gb, 8); + if (quant7 > 127) { + av_log_ask_for_sample(s->avctx, "LFEScaleIndex larger than 127\n"); + return AVERROR_INVALIDDATA; + } + s->lfe_scale_factor = scale_factor_quant7[quant7]; /* Quantization step size * scale factor */ lfe_scale = 0.035 * s->lfe_scale_factor; @@ -1416,11 +1420,11 @@ static int dca_exss_parse_asset_header(DCAContext *s) { int header_pos = get_bits_count(&s->gb); int header_size; - int channels; + int channels = 0; int embedded_stereo = 0; int embedded_6ch = 0; int drc_code_present; - int extensions_mask; + int av_uninit(extensions_mask); int i, j; if (get_bits_left(&s->gb) < 16) @@ -1825,25 +1829,19 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, s->output = DCA_STEREO; avctx->channel_layout = AV_CH_LAYOUT_STEREO; } + else if (avctx->request_channel_layout & AV_CH_LAYOUT_NATIVE) { + static const int8_t dca_channel_order_native[9] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 }; + s->channel_order_tab = dca_channel_order_native; + } } else { av_log(avctx, AV_LOG_ERROR, "Non standard configuration %d !\n", s->amode); return AVERROR_INVALIDDATA; } - - /* There is nothing that prevents a dts frame to change channel configuration - but Libav doesn't support that so only set the channels if it is previously - unset. Ideally during the first probe for channels the crc should be checked - and only set avctx->channels when the crc is ok. Right now the decoder could - set the channels based on a broken first frame.*/ - if (s->is_channels_set == 0) { - s->is_channels_set = 1; - avctx->channels = channels; - } if (avctx->channels != channels) { - av_log(avctx, AV_LOG_ERROR, "DCA decoder does not support number of " - "channels changing in stream. Skipping frame.\n"); - return AVERROR_PATCHWELCOME; + if (avctx->channels) + av_log(avctx, AV_LOG_INFO, "Number of channels changed in DCA decoder (%d -> %d)\n", avctx->channels, channels); + avctx->channels = channels; } /* get output buffer */ |