#include <stddef.h>
#include <stdio.h>
+#include "libavutil/channel_layout.h"
#include "libavutil/common.h"
#include "libavutil/float_dsp.h"
#include "libavutil/intmath.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mathematics.h"
-#include "libavutil/audioconvert.h"
#include "libavutil/samplefmt.h"
#include "avcodec.h"
#include "dsputil.h"
#include "synth_filter.h"
#include "dcadsp.h"
#include "fmtconvert.h"
+#include "internal.h"
#if ARCH_ARM
# include "arm/dca.h"
s->lfe = get_bits(&s->gb, 2);
s->predictor_history = get_bits(&s->gb, 1);
+ if (s->lfe == 3) {
+ s->lfe = 0;
+ av_log_ask_for_sample(s->avctx, "LFE is 3\n");
+ return AVERROR_PATCHWELCOME;
+ }
+
/* TODO: check CRC */
if (s->crc_present)
s->header_crc = get_bits(&s->gb, 16);
case DCA_STEREO_TOTAL:
case DCA_STEREO_SUMDIFF:
case DCA_4F2R:
- av_log(NULL, 0, "Not implemented!\n");
+ av_log(NULL, AV_LOG_ERROR, "Not implemented!\n");
break;
case DCA_STEREO:
break;
for (k = 0; k < s->prim_channels; k++) {
/* static float pcm_to_double[8] = { 32768.0, 32768.0, 524288.0, 524288.0,
0, 8388608.0, 8388608.0 };*/
- if(s->channel_order_tab[k] >= 0)
- qmf_32_subbands(s, k, subband_samples[k],
- s->samples_chanptr[s->channel_order_tab[k]],
- M_SQRT1_2 / 32768.0 /* pcm_to_double[s->source_pcm_res] */);
+ if (s->channel_order_tab[k] >= 0)
+ qmf_32_subbands(s, k, subband_samples[k],
+ s->samples_chanptr[s->channel_order_tab[k]],
+ M_SQRT1_2 / 32768.0 /* pcm_to_double[s->source_pcm_res] */);
}
/* Down mixing */
continue;
}
+ if (s->xch_base_channel < 2) {
+ av_log_ask_for_sample(avctx, "XCh with fewer than 2 base channels is not supported\n");
+ continue;
+ }
+
/* much like core primary audio coding header */
dca_parse_audio_coding_header(s, s->xch_base_channel, 0);
s->channel_order_tab[channels - 1 - !!s->lfe] < 0)
return AVERROR_INVALIDDATA;
+ if (av_get_channel_layout_nb_channels(avctx->channel_layout) != channels) {
+ av_log(avctx, AV_LOG_ERROR, "Number of channels %d mismatches layout %d\n", channels, av_get_channel_layout_nb_channels(avctx->channel_layout));
+ return AVERROR_INVALIDDATA;
+ }
+
if (avctx->request_channels == 2 && s->prim_channels > 2) {
channels = 2;
s->output = DCA_STEREO;
/* get output buffer */
s->frame.nb_samples = 256 * (s->sample_blocks / 8);
- if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
+ if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}