1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-01-24 13:56:33 +02:00

truehd: break out part of rematrix_channels into platform-specific callback.

Verified with profiling that this doesn't have a measurable effect upon
overall performance.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Ben Avison 2014-03-20 18:59:15 +00:00 committed by Michael Niedermayer
parent f38af0143c
commit 3f4e73afe9
3 changed files with 68 additions and 25 deletions

View File

@ -1024,7 +1024,7 @@ static void fill_noise_buffer(MLPDecodeContext *m, unsigned int substr)
static void rematrix_channels(MLPDecodeContext *m, unsigned int substr) static void rematrix_channels(MLPDecodeContext *m, unsigned int substr)
{ {
SubStream *s = &m->substream[substr]; SubStream *s = &m->substream[substr];
unsigned int mat, src_ch, i; unsigned int mat;
unsigned int maxchan; unsigned int maxchan;
maxchan = s->max_matrix_channel; maxchan = s->max_matrix_channel;
@ -1036,31 +1036,18 @@ static void rematrix_channels(MLPDecodeContext *m, unsigned int substr)
} }
for (mat = 0; mat < s->num_primitive_matrices; mat++) { for (mat = 0; mat < s->num_primitive_matrices; mat++) {
int matrix_noise_shift = s->matrix_noise_shift[mat];
unsigned int dest_ch = s->matrix_out_ch[mat]; unsigned int dest_ch = s->matrix_out_ch[mat];
int32_t mask = MSB_MASK(s->quant_step_size[dest_ch]); m->dsp.mlp_rematrix_channel(&m->sample_buffer[0][0],
int32_t *coeffs = s->matrix_coeff[mat]; s->matrix_coeff[mat],
int index = s->num_primitive_matrices - mat; &m->bypassed_lsbs[0][mat],
int index2 = 2 * index + 1; m->noise_buffer,
s->num_primitive_matrices - mat,
/* TODO: DSPContext? */ dest_ch,
s->blockpos,
for (i = 0; i < s->blockpos; i++) { maxchan,
int32_t bypassed_lsb = m->bypassed_lsbs[i][mat]; s->matrix_noise_shift[mat],
int32_t *samples = m->sample_buffer[i]; m->access_unit_size_pow2,
int64_t accum = 0; MSB_MASK(s->quant_step_size[dest_ch]));
for (src_ch = 0; src_ch <= maxchan; src_ch++)
accum += (int64_t) samples[src_ch] * coeffs[src_ch];
if (matrix_noise_shift) {
index &= m->access_unit_size_pow2 - 1;
accum += m->noise_buffer[index] << (matrix_noise_shift + 7);
index += index2;
}
samples[dest_ch] = ((accum >> 14) & mask) + bypassed_lsb;
}
} }
} }

View File

@ -57,9 +57,42 @@ static void mlp_filter_channel(int32_t *state, const int32_t *coeff,
} }
} }
void ff_mlp_rematrix_channel(int32_t *samples,
const int32_t *coeffs,
const uint8_t *bypassed_lsbs,
const int8_t *noise_buffer,
int index,
unsigned int dest_ch,
uint16_t blockpos,
unsigned int maxchan,
int matrix_noise_shift,
int access_unit_size_pow2,
int32_t mask)
{
unsigned int src_ch, i;
int index2 = 2 * index + 1;
for (i = 0; i < blockpos; i++) {
int64_t accum = 0;
for (src_ch = 0; src_ch <= maxchan; src_ch++)
accum += (int64_t) samples[src_ch] * coeffs[src_ch];
if (matrix_noise_shift) {
index &= access_unit_size_pow2 - 1;
accum += noise_buffer[index] << (matrix_noise_shift + 7);
index += index2;
}
samples[dest_ch] = ((accum >> 14) & mask) + *bypassed_lsbs;
bypassed_lsbs += MAX_CHANNELS;
samples += MAX_CHANNELS;
}
}
av_cold void ff_mlpdsp_init(MLPDSPContext *c) av_cold void ff_mlpdsp_init(MLPDSPContext *c)
{ {
c->mlp_filter_channel = mlp_filter_channel; c->mlp_filter_channel = mlp_filter_channel;
c->mlp_rematrix_channel = ff_mlp_rematrix_channel;
if (ARCH_ARM) if (ARCH_ARM)
ff_mlpdsp_init_arm(c); ff_mlpdsp_init_arm(c);
if (ARCH_X86) if (ARCH_X86)

View File

@ -24,11 +24,34 @@
#include <stdint.h> #include <stdint.h>
void ff_mlp_rematrix_channel(int32_t *samples,
const int32_t *coeffs,
const uint8_t *bypassed_lsbs,
const int8_t *noise_buffer,
int index,
unsigned int dest_ch,
uint16_t blockpos,
unsigned int maxchan,
int matrix_noise_shift,
int access_unit_size_pow2,
int32_t mask);
typedef struct MLPDSPContext { typedef struct MLPDSPContext {
void (*mlp_filter_channel)(int32_t *state, const int32_t *coeff, void (*mlp_filter_channel)(int32_t *state, const int32_t *coeff,
int firorder, int iirorder, int firorder, int iirorder,
unsigned int filter_shift, int32_t mask, unsigned int filter_shift, int32_t mask,
int blocksize, int32_t *sample_buffer); int blocksize, int32_t *sample_buffer);
void (*mlp_rematrix_channel)(int32_t *samples,
const int32_t *coeffs,
const uint8_t *bypassed_lsbs,
const int8_t *noise_buffer,
int index,
unsigned int dest_ch,
uint16_t blockpos,
unsigned int maxchan,
int matrix_noise_shift,
int access_unit_size_pow2,
int32_t mask);
} MLPDSPContext; } MLPDSPContext;
void ff_mlpdsp_init(MLPDSPContext *c); void ff_mlpdsp_init(MLPDSPContext *c);