summaryrefslogtreecommitdiff
path: root/libavcodec/ac3dsp.c
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2015-10-28 15:38:21 +0100
committerDiego Biurrun <diego@biurrun.de>2016-10-01 00:46:18 +0200
commita9ba59591ed509fb7e6decfde8da4cbfd4ddf4b8 (patch)
tree6cd06b2beb3c028317d7c9cf40df13a43815f4a3 /libavcodec/ac3dsp.c
parent43717469f9daa402f6acb48997255827a56034e9 (diff)
downloadffmpeg-a9ba59591ed509fb7e6decfde8da4cbfd4ddf4b8.tar.gz
ac3dsp: Add some special-case handling for the C downmix function
This is about 200% faster for in-decoder downmixing of 5.0 and 5.1 content. Signed-off-by: Diego Biurrun <diego@biurrun.de>
Diffstat (limited to 'libavcodec/ac3dsp.c')
-rw-r--r--libavcodec/ac3dsp.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/libavcodec/ac3dsp.c b/libavcodec/ac3dsp.c
index d1bf37e943..8eae5ad866 100644
--- a/libavcodec/ac3dsp.c
+++ b/libavcodec/ac3dsp.c
@@ -174,9 +174,46 @@ static void ac3_extract_exponents_c(uint8_t *exp, int32_t *coef, int nb_coefs)
static void ac3_downmix_c(float **samples, float **matrix,
int out_ch, int in_ch, int len)
{
+ int **matrix_cmp = (int **)matrix;
int i, j;
float v0, v1;
- if (out_ch == 2) {
+
+ if (in_ch == 5 && out_ch == 2 &&
+ !(matrix_cmp[1][0] | matrix_cmp[0][2] |
+ matrix_cmp[1][3] | matrix_cmp[0][4] |
+ (matrix_cmp[0][1] ^ matrix_cmp[1][1]) |
+ (matrix_cmp[0][0] ^ matrix_cmp[1][2]))) {
+ float front_mix = matrix[0][0];
+ float center_mix = matrix[0][1];
+ float surround_mix = matrix[0][3];
+
+ for (i = 0; i < len; i++) {
+ v0 = samples[0][i] * front_mix +
+ samples[1][i] * center_mix +
+ samples[3][i] * surround_mix;
+
+ v1 = samples[1][i] * center_mix +
+ samples[2][i] * front_mix +
+ samples[4][i] * surround_mix;
+
+ samples[0][i] = v0;
+ samples[1][i] = v1;
+ }
+ } else if (in_ch == 5 && out_ch == 1 &&
+ matrix_cmp[0][0] == matrix_cmp[0][2] &&
+ matrix_cmp[0][3] == matrix_cmp[0][4]) {
+ float front_mix = matrix[0][0];
+ float center_mix = matrix[0][1];
+ float surround_mix = matrix[0][3];
+
+ for (i = 0; i < len; i++) {
+ samples[0][i] = samples[0][i] * front_mix +
+ samples[1][i] * center_mix +
+ samples[2][i] * front_mix +
+ samples[3][i] * surround_mix +
+ samples[4][i] * surround_mix;
+ }
+ } else if (out_ch == 2) {
for (i = 0; i < len; i++) {
v0 = v1 = 0.0f;
for (j = 0; j < in_ch; j++) {