#include "dca.h"
#include "synth_filter.h"
#include "dcadsp.h"
+#include "fmtconvert.h"
//#define TRACE
DECLARE_ALIGNED(16, float, raXin)[32];
int output; ///< type of output
- float add_bias; ///< output bias
float scale_bias; ///< output scale
DECLARE_ALIGNED(16, float, subband_samples)[DCA_BLOCKS_MAX][DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS][8];
FFTContext imdct;
SynthFilterContext synth;
DCADSPContext dcadsp;
+ FmtConvertContext fmt_conv;
} DCAContext;
static const uint16_t dca_vlc_offs[] = {
static void qmf_32_subbands(DCAContext * s, int chans,
float samples_in[32][8], float *samples_out,
- float scale, float bias)
+ float scale)
{
const float *prCoeff;
int i;
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, bias);
+ samples_out, s->raXin, scale);
samples_out+= 32;
}
static void lfe_interpolation_fir(DCAContext *s, int decimation_select,
int num_deci_sample, float *samples_in,
- float *samples_out, float scale,
- float bias)
+ float *samples_out, float scale)
{
/* samples_in: An array holding decimated samples.
* Samples in current subframe starts from samples_in[0],
/* Interpolation */
for (deciindex = 0; deciindex < num_deci_sample; deciindex++) {
s->dcadsp.lfe_fir(samples_out, samples_in, prCoeff, decifactor,
- scale, bias);
+ scale);
samples_in++;
samples_out += 2 * decifactor;
}
/* downmixing routines */
#define MIX_REAR1(samples, si1, rs, coef) \
- samples[i] += (samples[si1] - add_bias) * coef[rs][0]; \
- samples[i+256] += (samples[si1] - add_bias) * coef[rs][1];
+ samples[i] += samples[si1] * coef[rs][0]; \
+ samples[i+256] += samples[si1] * coef[rs][1];
#define MIX_REAR2(samples, si1, si2, rs, coef) \
- samples[i] += (samples[si1] - add_bias) * coef[rs][0] + (samples[si2] - add_bias) * coef[rs+1][0]; \
- samples[i+256] += (samples[si1] - add_bias) * coef[rs][1] + (samples[si2] - add_bias) * coef[rs+1][1];
+ samples[i] += samples[si1] * coef[rs][0] + samples[si2] * coef[rs+1][0]; \
+ samples[i+256] += samples[si1] * coef[rs][1] + samples[si2] * coef[rs+1][1];
#define MIX_FRONT3(samples, coef) \
- t = samples[i+c] - add_bias; \
- u = samples[i+l] - add_bias; \
- v = samples[i+r] - add_bias; \
- samples[i] = t * coef[0][0] + u * coef[1][0] + v * coef[2][0] + add_bias; \
- samples[i+256] = t * coef[0][1] + u * coef[1][1] + v * coef[2][1] + add_bias;
+ t = samples[i+c]; \
+ u = samples[i+l]; \
+ v = samples[i+r]; \
+ samples[i] = t * coef[0][0] + u * coef[1][0] + v * coef[2][0]; \
+ samples[i+256] = t * coef[0][1] + u * coef[1][1] + v * coef[2][1];
#define DOWNMIX_TO_STEREO(op1, op2) \
for (i = 0; i < 256; i++){ \
static void dca_downmix(float *samples, int srcfmt,
int downmix_coef[DCA_PRIM_CHANNELS_MAX][2],
- const int8_t *channel_mapping, float add_bias)
+ const int8_t *channel_mapping)
{
int c,l,r,sl,sr,s;
int i;
block[m] = get_bitalloc(&s->gb, &dca_smpl_bitalloc[abits], sel);
}
- s->dsp.int32_to_float_fmul_scalar(subband_samples[k][l],
+ s->fmt_conv.int32_to_float_fmul_scalar(subband_samples[k][l],
block, rscale, 8);
}
/* static float pcm_to_double[8] =
{32768.0, 32768.0, 524288.0, 524288.0, 0, 8388608.0, 8388608.0};*/
qmf_32_subbands(s, k, subband_samples[k], &s->samples[256 * s->channel_order_tab[k]],
- M_SQRT1_2*s->scale_bias /*pcm_to_double[s->source_pcm_res] */ ,
- s->add_bias );
+ M_SQRT1_2*s->scale_bias /*pcm_to_double[s->source_pcm_res] */ );
}
/* Down mixing */
if (s->avctx->request_channels == 2 && s->prim_channels > 2) {
- dca_downmix(s->samples, s->amode, s->downmix_coef, s->channel_order_tab, s->add_bias);
+ dca_downmix(s->samples, s->amode, s->downmix_coef, s->channel_order_tab);
}
/* Generate LFE samples for this subsubframe FIXME!!! */
lfe_interpolation_fir(s, s->lfe, 2 * s->lfe,
s->lfe_data + 2 * s->lfe * (block_index + 4),
&s->samples[256 * dca_lfe_index[s->amode]],
- (1.0/256.0)*s->scale_bias, s->add_bias);
+ (1.0/256.0)*s->scale_bias);
/* Outputs 20bits pcm samples */
}
*/
static void dca_exss_skip_mix_coeffs(GetBitContext *gb, int channels, int out_ch)
{
- for (int i = 0; i < channels; i++) {
+ int i;
+
+ for (i = 0; i < channels; i++) {
int mix_map_mask = get_bits(gb, out_ch);
int num_coeffs = av_popcount(mix_map_mask);
skip_bits_long(gb, num_coeffs * 6);
if (extensions_mask & DCA_EXT_EXSS_XLL)
s->profile = FF_PROFILE_DTS_HD_MA;
- else if (extensions_mask & DCA_EXT_EXSS_XBR)
+ else if (extensions_mask & (DCA_EXT_EXSS_XBR | DCA_EXT_EXSS_X96 |
+ DCA_EXT_EXSS_XXCH))
s->profile = FF_PROFILE_DTS_HD_HRA;
- else if (extensions_mask & DCA_EXT_EXSS_X96)
- s->profile = FF_PROFILE_DTS_96_24;
- else if (extensions_mask & DCA_EXT_EXSS_XXCH)
- s->profile = FFMAX(s->profile, FF_PROFILE_DTS_ES);
if (!(extensions_mask & DCA_EXT_CORE))
av_log(s->avctx, AV_LOG_WARNING, "DTS core detection mismatch.\n");
float* rt_chan = s->samples + s->channel_order_tab[s->xch_base_channel - 1] * 256;
int j;
for(j = 0; j < 256; ++j) {
- lt_chan[j] -= (back_chan[j] - s->add_bias) * M_SQRT1_2;
- rt_chan[j] -= (back_chan[j] - s->add_bias) * M_SQRT1_2;
+ lt_chan[j] -= back_chan[j] * M_SQRT1_2;
+ rt_chan[j] -= back_chan[j] * M_SQRT1_2;
}
}
- s->dsp.float_to_int16_interleave(samples, s->samples_chanptr, 256, channels);
+ s->fmt_conv.float_to_int16_interleave(samples, s->samples_chanptr, 256, channels);
samples += 256 * channels;
}
ff_mdct_init(&s->imdct, 6, 1, 1.0);
ff_synth_filter_init(&s->synth);
ff_dcadsp_init(&s->dcadsp);
+ ff_fmt_convert_init(&s->fmt_conv, avctx);
for (i = 0; i < DCA_PRIM_CHANNELS_MAX+1; i++)
s->samples_chanptr[i] = s->samples + i * 256;
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
- if (s->dsp.float_to_int16_interleave == ff_float_to_int16_interleave_c) {
- s->add_bias = 385.0f;
- s->scale_bias = 1.0 / 32768.0;
- } else {
- s->add_bias = 0.0f;
- s->scale_bias = 1.0;
+ s->scale_bias = 1.0;
- /* allow downmixing to stereo */
- if (avctx->channels > 0 && avctx->request_channels < avctx->channels &&
- avctx->request_channels == 2) {
- avctx->channels = avctx->request_channels;
- }
+ /* allow downmixing to stereo */
+ if (avctx->channels > 0 && avctx->request_channels < avctx->channels &&
+ avctx->request_channels == 2) {
+ avctx->channels = avctx->request_channels;
}
-
return 0;
}
return 0;
}
-AVCodec dca_decoder = {
+static const AVProfile profiles[] = {
+ { FF_PROFILE_DTS, "DTS" },
+ { FF_PROFILE_DTS_ES, "DTS-ES" },
+ { FF_PROFILE_DTS_96_24, "DTS 96/24" },
+ { FF_PROFILE_DTS_HD_HRA, "DTS-HD HRA" },
+ { FF_PROFILE_DTS_HD_MA, "DTS-HD MA" },
+ { FF_PROFILE_UNKNOWN },
+};
+
+AVCodec ff_dca_decoder = {
.name = "dca",
.type = AVMEDIA_TYPE_AUDIO,
.id = CODEC_ID_DTS,
.close = dca_decode_end,
.long_name = NULL_IF_CONFIG_SMALL("DCA (DTS Coherent Acoustics)"),
.capabilities = CODEC_CAP_CHANNEL_CONF,
+ .profiles = NULL_IF_CONFIG_SMALL(profiles),
};