#include "libavutil/channel_layout.h"
#include "libavutil/common.h"
#include "libavutil/float_dsp.h"
-#include "libavutil/intmath.h"
+#include "libavutil/internal.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mathematics.h"
#include "libavutil/samplefmt.h"
#include "avcodec.h"
-#include "dsputil.h"
#include "fft.h"
#include "get_bits.h"
#include "put_bits.h"
#include "dcadata.h"
#include "dcahuff.h"
#include "dca.h"
-#include "dca_parser.h"
+#include "mathops.h"
#include "synth_filter.h"
#include "dcadsp.h"
#include "fmtconvert.h"
typedef struct {
AVCodecContext *avctx;
- AVFrame frame;
/* Frame header */
int frame_type; ///< type of the current frame
int samples_deficit; ///< deficit sample count
"Invalid channel mode %d\n", am);
return AVERROR_INVALIDDATA;
}
+ if (s->prim_channels > FF_ARRAY_ELEMS(dca_default_coeffs[0])) {
+ avpriv_request_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];
float scale)
{
const float *prCoeff;
- int i;
int sb_act = s->subband_activity[chans];
- int subindex;
scale *= sqrt(1 / 8.0);
else /* Perfect reconstruction */
prCoeff = fir_32bands_perfect;
- for (i = sb_act; i < 32; i++)
- s->raXin[i] = 0.0;
-
- /* Reconstructed channel sample index */
- for (subindex = 0; subindex < 8; subindex++) {
- /* Load in one sample from each subband and clear inactive subbands */
- for (i = 0; i < sb_act; i++) {
- unsigned sign = (i - 1) & 2;
- uint32_t v = AV_RN32A(&samples_in[i][subindex]) ^ sign << 30;
- AV_WN32A(&s->raXin[i], v);
- }
-
- s->synth.synth_filter_float(&s->imdct,
- s->subband_fir_hist[chans],
- &s->hist_index[chans],
- s->subband_fir_noidea[chans], prCoeff,
- samples_out, s->raXin, scale);
- samples_out += 32;
- }
+ s->dcadsp.qmf_32_subbands(samples_in, sb_act, &s->synth, &s->imdct,
+ s->subband_fir_hist[chans],
+ &s->hist_index[chans],
+ s->subband_fir_noidea[chans], prCoeff,
+ samples_out, s->raXin, scale);
}
static void lfe_interpolation_fir(DCAContext *s, int decimation_select,
#ifndef decode_blockcodes
/* Very compact version of the block code decoder that does not use table
* look-up but is slightly slower */
-static int decode_blockcode(int code, int levels, int *values)
+static int decode_blockcode(int code, int levels, int32_t *values)
{
int i;
int offset = (levels - 1) >> 1;
return code;
}
-static int decode_blockcodes(int code1, int code2, int levels, int *values)
+static int decode_blockcodes(int code1, int code2, int levels, int32_t *values)
{
return decode_blockcode(code1, levels, values) |
decode_blockcode(code2, levels, values + 4);
/* FIXME */
float (*subband_samples)[DCA_SUBBANDS][8] = s->subband_samples[block_index];
- LOCAL_ALIGNED_16(int, block, [8]);
+ LOCAL_ALIGNED_16(int32_t, block, [8 * DCA_SUBBANDS]);
/*
* Audio data
quant_step_table = lossy_quant_d;
for (k = base_channel; k < s->prim_channels; k++) {
+ float rscale[DCA_SUBBANDS];
+
if (get_bits_left(&s->gb) < 0)
return AVERROR_INVALIDDATA;
* Extract bits from the bit stream
*/
if (!abits) {
- memset(subband_samples[k][l], 0, 8 * sizeof(subband_samples[0][0][0]));
+ rscale[l] = 0;
+ memset(block + 8 * l, 0, 8 * sizeof(block[0]));
} else {
/* Deal with transients */
int sfi = s->transition_mode[k][l] && subsubframe >= s->transition_mode[k][l];
- float rscale = quant_step_size * s->scale_factor[k][l][sfi] *
+ rscale[l] = quant_step_size * s->scale_factor[k][l][sfi] *
s->scalefactor_adj[k][sel];
if (abits >= 11 || !dca_smpl_bitalloc[abits].vlc[sel].table) {
block_code1 = get_bits(&s->gb, size);
block_code2 = get_bits(&s->gb, size);
err = decode_blockcodes(block_code1, block_code2,
- levels, block);
+ levels, block + 8 * l);
if (err) {
av_log(s->avctx, AV_LOG_ERROR,
"ERROR: block code look-up failed\n");
} else {
/* no coding */
for (m = 0; m < 8; m++)
- block[m] = get_sbits(&s->gb, abits - 3);
+ block[8 * l + m] = get_sbits(&s->gb, abits - 3);
}
} else {
/* Huffman coded */
for (m = 0; m < 8; m++)
- block[m] = get_bitalloc(&s->gb,
+ block[8 * l + m] = get_bitalloc(&s->gb,
&dca_smpl_bitalloc[abits], sel);
}
- s->fmt_conv.int32_to_float_fmul_scalar(subband_samples[k][l],
- block, rscale, 8);
}
+ }
+ s->fmt_conv.int32_to_float_fmul_array8(&s->fmt_conv, subband_samples[k][0],
+ block, rscale, 8 * s->vq_start_subband[k]);
+
+ for (l = 0; l < s->vq_start_subband[k]; l++) {
+ int m;
/*
* Inverse ADPCM if in prediction mode
*/
#endif
} else {
av_log(s->avctx, AV_LOG_ERROR, "Didn't get subframe DSYNC\n");
+ return AVERROR_INVALIDDATA;
}
}
num_audiop = get_bits(&s->gb, 3) + 1;
if (num_audiop > 1) {
- av_log_ask_for_sample(s->avctx, "Multiple DTS-HD audio presentations.");
+ avpriv_request_sample(s->avctx,
+ "Multiple DTS-HD audio presentations");
/* ignore such streams for now */
return;
}
num_assets = get_bits(&s->gb, 3) + 1;
if (num_assets > 1) {
- av_log_ask_for_sample(s->avctx, "Multiple DTS-HD audio assets.");
+ avpriv_request_sample(s->avctx, "Multiple DTS-HD audio assets");
/* ignore such streams for now */
return;
}
static int dca_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
+ AVFrame *frame = data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
avctx->channels = channels;
/* get output buffer */
- s->frame.nb_samples = 256 * (s->sample_blocks / 8);
- if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {
+ frame->nb_samples = 256 * (s->sample_blocks / 8);
+ if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
- samples_flt = (float **) s->frame.extended_data;
+ samples_flt = (float **)frame->extended_data;
/* allocate buffer for extra channels if downmixing */
if (avctx->channels < full_channels) {
ret = av_samples_get_buffer_size(NULL, full_channels - channels,
- s->frame.nb_samples,
+ frame->nb_samples,
avctx->sample_fmt, 0);
if (ret < 0)
return ret;
ret = av_samples_fill_arrays((uint8_t **)s->extra_channels, NULL,
s->extra_channels_buffer,
full_channels - channels,
- s->frame.nb_samples, avctx->sample_fmt, 0);
+ frame->nb_samples, avctx->sample_fmt, 0);
if (ret < 0)
return ret;
}
for (i = 0; i < 2 * s->lfe * 4; i++)
s->lfe_data[i] = s->lfe_data[i + lfe_samples];
- *got_frame_ptr = 1;
- *(AVFrame *) data = s->frame;
+ *got_frame_ptr = 1;
return buf_size;
}
avctx->channels = avctx->request_channels;
}
- avcodec_get_frame_defaults(&s->frame);
- avctx->coded_frame = &s->frame;
-
return 0;
}