Commit af1238f8 authored by Hendrik Leppkes's avatar Hendrik Leppkes

Merge commit 'aebf0707'

* commit 'aebf0707':
  dca: change the core to work with integer coefficients.
Merged-by: 's avatarHendrik Leppkes <h.leppkes@gmail.com>
parents a51c2fcd aebf0707
...@@ -140,8 +140,8 @@ typedef struct DCAAudioHeader { ...@@ -140,8 +140,8 @@ typedef struct DCAAudioHeader {
int transient_huffman[DCA_PRIM_CHANNELS_MAX]; ///< transient mode code book int transient_huffman[DCA_PRIM_CHANNELS_MAX]; ///< transient mode code book
int scalefactor_huffman[DCA_PRIM_CHANNELS_MAX]; ///< scale factor code book int scalefactor_huffman[DCA_PRIM_CHANNELS_MAX]; ///< scale factor code book
int bitalloc_huffman[DCA_PRIM_CHANNELS_MAX]; ///< bit allocation quantizer select int bitalloc_huffman[DCA_PRIM_CHANNELS_MAX]; ///< bit allocation quantizer select
int quant_index_huffman[DCA_PRIM_CHANNELS_MAX][DCA_ABITS_MAX]; ///< quantization index codebook select int quant_index_huffman[DCA_PRIM_CHANNELS_MAX][DCA_ABITS_MAX]; ///< quantization index codebook select
float scalefactor_adj[DCA_PRIM_CHANNELS_MAX][DCA_ABITS_MAX]; ///< scale factor adjustment uint32_t scalefactor_adj[DCA_PRIM_CHANNELS_MAX][DCA_ABITS_MAX]; ///< scale factor adjustment
int subframes; ///< number of subframes int subframes; ///< number of subframes
int total_channels; ///< number of channels including extensions int total_channels; ///< number of channels including extensions
...@@ -149,10 +149,10 @@ typedef struct DCAAudioHeader { ...@@ -149,10 +149,10 @@ typedef struct DCAAudioHeader {
} DCAAudioHeader; } DCAAudioHeader;
typedef struct DCAChan { typedef struct DCAChan {
DECLARE_ALIGNED(32, float, subband_samples)[DCA_BLOCKS_MAX][DCA_SUBBANDS][8]; DECLARE_ALIGNED(32, int32_t, subband_samples)[DCA_BLOCKS_MAX][DCA_SUBBANDS][8];
/* Subband samples history (for ADPCM) */ /* Subband samples history (for ADPCM) */
DECLARE_ALIGNED(16, float, subband_samples_hist)[DCA_SUBBANDS][4]; DECLARE_ALIGNED(32, int32_t, subband_samples_hist)[DCA_SUBBANDS][4];
int hist_index; int hist_index;
/* Half size is sufficient for core decoding, but for 96 kHz data /* Half size is sufficient for core decoding, but for 96 kHz data
......
This diff is collapsed.
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "libavutil/intreadwrite.h" #include "libavutil/intreadwrite.h"
#include "dcadsp.h" #include "dcadsp.h"
#include "dcamath.h"
static void decode_hf_c(float dst[DCA_SUBBANDS][8], static void decode_hf_c(float dst[DCA_SUBBANDS][8],
const int32_t vq_num[DCA_SUBBANDS], const int32_t vq_num[DCA_SUBBANDS],
...@@ -44,6 +45,21 @@ static void decode_hf_c(float dst[DCA_SUBBANDS][8], ...@@ -44,6 +45,21 @@ static void decode_hf_c(float dst[DCA_SUBBANDS][8],
} }
} }
static void decode_hf_int_c(int32_t dst[DCA_SUBBANDS][8],
const int32_t vq_num[DCA_SUBBANDS],
const int8_t hf_vq[1024][32], intptr_t vq_offset,
int32_t scale[DCA_SUBBANDS][2],
intptr_t start, intptr_t end)
{
int i, j;
for (j = start; j < end; j++) {
const int8_t *ptr = &hf_vq[vq_num[j]][vq_offset];
for (i = 0; i < 8; i++)
dst[j][i] = ptr[i] * scale[j][0] + 8 >> 4;
}
}
static inline void dca_lfe_fir(float *out, const float *in, const float *coefs, static inline void dca_lfe_fir(float *out, const float *in, const float *coefs,
int decifactor) int decifactor)
{ {
...@@ -93,6 +109,22 @@ static void dca_qmf_32_subbands(float samples_in[32][8], int sb_act, ...@@ -93,6 +109,22 @@ static void dca_qmf_32_subbands(float samples_in[32][8], int sb_act,
} }
} }
static void dequantize_c(int32_t *samples, uint32_t step_size, uint32_t scale)
{
int64_t step = (int64_t)step_size * scale;
int shift, i;
int32_t step_scale;
if (step > (1 << 23))
shift = av_log2(step >> 23) + 1;
else
shift = 0;
step_scale = (int32_t)(step >> shift);
for (i = 0; i < 8; i++)
samples[i] = dca_clip23(dca_norm((int64_t)samples[i] * step_scale, 22 - shift));
}
static void dca_lfe_fir0_c(float *out, const float *in, const float *coefs) static void dca_lfe_fir0_c(float *out, const float *in, const float *coefs)
{ {
dca_lfe_fir(out, in, coefs, 32); dca_lfe_fir(out, in, coefs, 32);
...@@ -109,6 +141,8 @@ av_cold void ff_dcadsp_init(DCADSPContext *s) ...@@ -109,6 +141,8 @@ av_cold void ff_dcadsp_init(DCADSPContext *s)
s->lfe_fir[1] = dca_lfe_fir1_c; s->lfe_fir[1] = dca_lfe_fir1_c;
s->qmf_32_subbands = dca_qmf_32_subbands; s->qmf_32_subbands = dca_qmf_32_subbands;
s->decode_hf = decode_hf_c; s->decode_hf = decode_hf_c;
s->decode_hf_int = decode_hf_int_c;
s->dequantize = dequantize_c;
if (ARCH_AARCH64) if (ARCH_AARCH64)
ff_dcadsp_init_aarch64(s); ff_dcadsp_init_aarch64(s);
......
...@@ -37,6 +37,12 @@ typedef struct DCADSPContext { ...@@ -37,6 +37,12 @@ typedef struct DCADSPContext {
const int8_t hf_vq[1024][32], intptr_t vq_offset, const int8_t hf_vq[1024][32], intptr_t vq_offset,
int32_t scale[DCA_SUBBANDS][2], int32_t scale[DCA_SUBBANDS][2],
intptr_t start, intptr_t end); intptr_t start, intptr_t end);
void (*decode_hf_int)(int32_t dst[DCA_SUBBANDS][8],
const int32_t vq_num[DCA_SUBBANDS],
const int8_t hf_vq[1024][32], intptr_t vq_offset,
int32_t scale[DCA_SUBBANDS][2],
intptr_t start, intptr_t end);
void (*dequantize)(int32_t *samples, uint32_t step_size, uint32_t scale);
} DCADSPContext; } DCADSPContext;
void ff_dcadsp_init(DCADSPContext *s); void ff_dcadsp_init(DCADSPContext *s);
......
...@@ -32,6 +32,14 @@ static void int32_to_float_fmul_scalar_c(float *dst, const int32_t *src, ...@@ -32,6 +32,14 @@ static void int32_to_float_fmul_scalar_c(float *dst, const int32_t *src,
dst[i] = src[i] * mul; dst[i] = src[i] * mul;
} }
static void int32_to_float_c(float *dst, const int32_t *src, intptr_t len)
{
int i;
for (i = 0; i < len; i++)
dst[i] = (float)src[i];
}
static void int32_to_float_fmul_array8_c(FmtConvertContext *c, float *dst, static void int32_to_float_fmul_array8_c(FmtConvertContext *c, float *dst,
const int32_t *src, const float *mul, const int32_t *src, const float *mul,
int len) int len)
...@@ -43,6 +51,7 @@ static void int32_to_float_fmul_array8_c(FmtConvertContext *c, float *dst, ...@@ -43,6 +51,7 @@ static void int32_to_float_fmul_array8_c(FmtConvertContext *c, float *dst,
av_cold void ff_fmt_convert_init(FmtConvertContext *c, AVCodecContext *avctx) av_cold void ff_fmt_convert_init(FmtConvertContext *c, AVCodecContext *avctx)
{ {
c->int32_to_float = int32_to_float_c;
c->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_c; c->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_c;
c->int32_to_float_fmul_array8 = int32_to_float_fmul_array8_c; c->int32_to_float_fmul_array8 = int32_to_float_fmul_array8_c;
......
...@@ -37,6 +37,16 @@ typedef struct FmtConvertContext { ...@@ -37,6 +37,16 @@ typedef struct FmtConvertContext {
*/ */
void (*int32_to_float_fmul_scalar)(float *dst, const int32_t *src, void (*int32_to_float_fmul_scalar)(float *dst, const int32_t *src,
float mul, int len); float mul, int len);
/**
* Convert an array of int32_t to float.
* @param dst destination array of float.
* constraints: 32-byte aligned
* @param src source array of int32_t.
* constraints: 32-byte aligned
* @param len number of elements to convert.
* constraints: multiple of 8
*/
void (*int32_to_float)(float *dst, const int32_t *src, intptr_t len);
/** /**
* Convert an array of int32_t to float and multiply by a float value from another array, * Convert an array of int32_t to float and multiply by a float value from another array,
......
...@@ -24,7 +24,7 @@ fate-dca-core: REF = $(SAMPLES)/dts/dts.pcm ...@@ -24,7 +24,7 @@ fate-dca-core: REF = $(SAMPLES)/dts/dts.pcm
FATE_DCA-$(CONFIG_DTS_DEMUXER) += fate-dca-xll FATE_DCA-$(CONFIG_DTS_DEMUXER) += fate-dca-xll
fate-dca-xll: CMD = pcm -disable_xll 0 -i $(TARGET_SAMPLES)/dts/master_audio_7.1_24bit.dts fate-dca-xll: CMD = pcm -disable_xll 0 -i $(TARGET_SAMPLES)/dts/master_audio_7.1_24bit.dts
fate-dca-xll: CMP = oneoff fate-dca-xll: CMP = oneoff
fate-dca-xll: REF = $(SAMPLES)/dts/master_audio_7.1_24bit.pcm fate-dca-xll: REF = $(SAMPLES)/dts/master_audio_7.1_24bit_2.pcm
FATE_SAMPLES_AUDIO-$(CONFIG_DCA_DECODER) += $(FATE_DCA-yes) FATE_SAMPLES_AUDIO-$(CONFIG_DCA_DECODER) += $(FATE_DCA-yes)
fate-dca: $(FATE_DCA-yes) fate-dca: $(FATE_DCA-yes)
...@@ -39,7 +39,7 @@ fate-dss-sp: CMD = framecrc -i $(TARGET_SAMPLES)/dss/sp.dss -frames 30 ...@@ -39,7 +39,7 @@ fate-dss-sp: CMD = framecrc -i $(TARGET_SAMPLES)/dss/sp.dss -frames 30
FATE_SAMPLES_AUDIO-$(call DEMDEC, DTS, DCA) += fate-dts_es FATE_SAMPLES_AUDIO-$(call DEMDEC, DTS, DCA) += fate-dts_es
fate-dts_es: CMD = pcm -i $(TARGET_SAMPLES)/dts/dts_es.dts fate-dts_es: CMD = pcm -i $(TARGET_SAMPLES)/dts/dts_es.dts
fate-dts_es: CMP = oneoff fate-dts_es: CMP = oneoff
fate-dts_es: REF = $(SAMPLES)/dts/dts_es.pcm fate-dts_es: REF = $(SAMPLES)/dts/dts_es_2.pcm
FATE_SAMPLES_AUDIO-$(call DEMDEC, AVI, IMC) += fate-imc FATE_SAMPLES_AUDIO-$(call DEMDEC, AVI, IMC) += fate-imc
fate-imc: CMD = pcm -i $(TARGET_SAMPLES)/imc/imc.avi fate-imc: CMD = pcm -i $(TARGET_SAMPLES)/imc/imc.avi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment