aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHendrik Leppkes2016-01-02 17:52:34 +0100
committerHendrik Leppkes2016-01-02 17:52:34 +0100
commit7fe77aa62ea2ca376057436a6c36a759e8273f15 (patch)
tree95c4471532ba5811cb5f249a6b90909ba46c448f
parent2214207d048187b85cd3af3e54b064f87728aa07 (diff)
parent40d949677335a564f769823f4afdb7e7a3da8d6b (diff)
Merge commit '40d949677335a564f769823f4afdb7e7a3da8d6b'
* commit '40d949677335a564f769823f4afdb7e7a3da8d6b': dca: use defines for subband related constants Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
-rw-r--r--libavcodec/dca.h2
-rw-r--r--libavcodec/dcadec.c21
-rw-r--r--libavcodec/dcadsp.c6
-rw-r--r--libavcodec/dcadsp.h9
4 files changed, 20 insertions, 18 deletions
diff --git a/libavcodec/dca.h b/libavcodec/dca.h
index 5c35bae912..dea82aeb2a 100644
--- a/libavcodec/dca.h
+++ b/libavcodec/dca.h
@@ -149,7 +149,7 @@ typedef struct DCAAudioHeader {
} DCAAudioHeader;
typedef struct DCAChan {
- DECLARE_ALIGNED(32, int32_t, subband_samples)[DCA_BLOCKS_MAX][DCA_SUBBANDS][8];
+ DECLARE_ALIGNED(32, int32_t, subband_samples)[DCA_BLOCKS_MAX][DCA_SUBBANDS][SAMPLES_PER_SUBBAND];
/* Subband samples history (for ADPCM) */
DECLARE_ALIGNED(32, int32_t, subband_samples_hist)[DCA_SUBBANDS][4];
diff --git a/libavcodec/dcadec.c b/libavcodec/dcadec.c
index 187e1728be..b36397a8c5 100644
--- a/libavcodec/dcadec.c
+++ b/libavcodec/dcadec.c
@@ -113,8 +113,6 @@ enum DCAXxchSpeakerMask {
#define DCA_NSYNCAUX 0x9A1105A0
-#define SAMPLES_PER_SUBBAND 8 // number of samples per subband per subsubframe
-
/** Bit allocation */
typedef struct BitAlloc {
int offset; ///< code values offset
@@ -623,7 +621,7 @@ static int dca_subframe_header(DCAContext *s, int base_channel, int block_index)
}
static void qmf_32_subbands(DCAContext *s, int chans,
- float samples_in[32][SAMPLES_PER_SUBBAND], float *samples_out,
+ float samples_in[DCA_SUBBANDS][SAMPLES_PER_SUBBAND], float *samples_out,
float scale)
{
const float *prCoeff;
@@ -671,7 +669,8 @@ static QMF64_table *qmf64_precompute(void)
/* FIXME: Totally unoptimized. Based on the reference code and
* http://multimedia.cx/mirror/dca-transform.pdf, with guessed tweaks
* for doubling the size. */
-static void qmf_64_subbands(DCAContext *s, int chans, float samples_in[64][SAMPLES_PER_SUBBAND],
+static void qmf_64_subbands(DCAContext *s, int chans,
+ float samples_in[DCA_SUBBANDS_X96K][SAMPLES_PER_SUBBAND],
float *samples_out, float scale)
{
float raXin[64];
@@ -680,7 +679,7 @@ static void qmf_64_subbands(DCAContext *s, int chans, float samples_in[64][SAMPL
float *raZ = s->dca_chan[chans].subband_fir_noidea;
unsigned i, j, k, subindex;
- for (i = s->audio_header.subband_activity[chans]; i < 64; i++)
+ for (i = s->audio_header.subband_activity[chans]; i < DCA_SUBBANDS_X96K; i++)
raXin[i] = 0.0;
for (subindex = 0; subindex < SAMPLES_PER_SUBBAND; subindex++) {
for (i = 0; i < s->audio_header.subband_activity[chans]; i++)
@@ -701,14 +700,14 @@ static void qmf_64_subbands(DCAContext *s, int chans, float samples_in[64][SAMPL
raX[63 - k] = s->qmf64_table->rsin[k] * (A[k] - B[k]);
}
- for (i = 0; i < 64; i++) {
+ for (i = 0; i < DCA_SUBBANDS_X96K; i++) {
float out = raZ[i];
for (j = 0; j < 1024; j += 128)
out += ff_dca_fir_64bands[j + i] * (raX[j + i] - raX[j + 63 - i]);
*samples_out++ = out * scale;
}
- for (i = 0; i < 64; i++) {
+ for (i = 0; i < DCA_SUBBANDS_X96K; i++) {
float hist = 0.0;
for (j = 0; j < 1024; j += 128)
hist += ff_dca_fir_64bands[64 + j + i] * (-raX[i + j] - raX[j + 63 - i]);
@@ -1017,7 +1016,7 @@ static int dca_filter_channels(DCAContext *s, int block_index, int upsample)
int k;
if (upsample) {
- LOCAL_ALIGNED(32, float, samples, [64], [SAMPLES_PER_SUBBAND]);
+ LOCAL_ALIGNED(32, float, samples, [DCA_SUBBANDS_X96K], [SAMPLES_PER_SUBBAND]);
if (!s->qmf64_table) {
s->qmf64_table = qmf64_precompute();
@@ -1031,7 +1030,7 @@ static int dca_filter_channels(DCAContext *s, int block_index, int upsample)
s->dca_chan[k].subband_samples[block_index];
s->fmt_conv.int32_to_float(samples[0], subband_samples[0],
- 64 * SAMPLES_PER_SUBBAND);
+ DCA_SUBBANDS_X96K * SAMPLES_PER_SUBBAND);
if (s->channel_order_tab[k] >= 0)
qmf_64_subbands(s, k, samples,
@@ -1041,14 +1040,14 @@ static int dca_filter_channels(DCAContext *s, int block_index, int upsample)
}
} else {
/* 32 subbands QMF */
- LOCAL_ALIGNED(32, float, samples, [32], [SAMPLES_PER_SUBBAND]);
+ LOCAL_ALIGNED(32, float, samples, [DCA_SUBBANDS], [SAMPLES_PER_SUBBAND]);
for (k = 0; k < s->audio_header.prim_channels; k++) {
int32_t (*subband_samples)[SAMPLES_PER_SUBBAND] =
s->dca_chan[k].subband_samples[block_index];
s->fmt_conv.int32_to_float(samples[0], subband_samples[0],
- 32 * SAMPLES_PER_SUBBAND);
+ DCA_SUBBANDS * SAMPLES_PER_SUBBAND);
if (s->channel_order_tab[k] >= 0)
qmf_32_subbands(s, k, samples,
diff --git a/libavcodec/dcadsp.c b/libavcodec/dcadsp.c
index 3fb70c6c4c..32b149d09c 100644
--- a/libavcodec/dcadsp.c
+++ b/libavcodec/dcadsp.c
@@ -27,7 +27,7 @@
#include "dcadsp.h"
#include "dcamath.h"
-static void decode_hf_c(int32_t dst[DCA_SUBBANDS][8],
+static void decode_hf_c(int32_t dst[DCA_SUBBANDS][SAMPLES_PER_SUBBAND],
const int32_t vq_num[DCA_SUBBANDS],
const int8_t hf_vq[1024][32], intptr_t vq_offset,
int32_t scale[DCA_SUBBANDS][2],
@@ -62,7 +62,7 @@ static inline void dca_lfe_fir(float *out, const float *in, const float *coefs,
}
}
-static void dca_qmf_32_subbands(float samples_in[32][8], int sb_act,
+static void dca_qmf_32_subbands(float samples_in[DCA_SUBBANDS][SAMPLES_PER_SUBBAND], int sb_act,
SynthFilterContext *synth, FFTContext *imdct,
float synth_buf_ptr[512],
int *synth_buf_offset, float synth_buf2[32],
@@ -103,7 +103,7 @@ static void dequantize_c(int32_t *samples, uint32_t step_size, uint32_t scale)
shift = 0;
step_scale = (int32_t)(step >> shift);
- for (i = 0; i < 8; i++)
+ for (i = 0; i < SAMPLES_PER_SUBBAND; i++)
samples[i] = dca_clip23(dca_norm((int64_t)samples[i] * step_scale, 22 - shift));
}
diff --git a/libavcodec/dcadsp.h b/libavcodec/dcadsp.h
index ccb2955470..8c8db854a4 100644
--- a/libavcodec/dcadsp.h
+++ b/libavcodec/dcadsp.h
@@ -22,17 +22,20 @@
#include "avfft.h"
#include "synth_filter.h"
-#define DCA_SUBBANDS 64
+#define DCA_SUBBANDS_X96K 64
+#define DCA_SUBBANDS 64
+#define SAMPLES_PER_SUBBAND 8 // number of samples per subband per subsubframe
+
typedef struct DCADSPContext {
void (*lfe_fir[2])(float *out, const float *in, const float *coefs);
- void (*qmf_32_subbands)(float samples_in[32][8], int sb_act,
+ void (*qmf_32_subbands)(float samples_in[DCA_SUBBANDS][SAMPLES_PER_SUBBAND], int sb_act,
SynthFilterContext *synth, FFTContext *imdct,
float synth_buf_ptr[512],
int *synth_buf_offset, float synth_buf2[32],
const float window[512], float *samples_out,
float raXin[32], float scale);
- void (*decode_hf)(int32_t dst[DCA_SUBBANDS][8],
+ void (*decode_hf)(int32_t dst[DCA_SUBBANDS][SAMPLES_PER_SUBBAND],
const int32_t vq_num[DCA_SUBBANDS],
const int8_t hf_vq[1024][32], intptr_t vq_offset,
int32_t scale[DCA_SUBBANDS][2],