aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/dcadec.c
diff options
context:
space:
mode:
authorJanne Grunau <janne-libav@jannau.net>2014-02-21 13:13:36 +0100
committerJanne Grunau <janne-libav@jannau.net>2014-02-28 13:00:48 +0100
commit7686afd049be98d18663682b92d983340fa2c305 (patch)
treee50dd1c93c3eef3bdb920b223bfcbb900816c915 /libavcodec/dcadec.c
parent08e3ea60ff4059341b74be04a428a38f7c3630b0 (diff)
downloadffmpeg-7686afd049be98d18663682b92d983340fa2c305.tar.gz
dca: factorize scaling in inverse ADPCM
Based on a patch from Christophe Gisquet. Unrolling of the m == 0 case avoids a possible use of the uninitilized value sum when s->predictor_history is not set. I failed to find a sample for it. It also reduced the cycle count from 220 to 150 on sandy bridge, x86_64 linux, gcc 4.8.2 compared to his patch.
Diffstat (limited to 'libavcodec/dcadec.c')
-rw-r--r--libavcodec/dcadec.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/libavcodec/dcadec.c b/libavcodec/dcadec.c
index c251db80a9..5ede61db33 100644
--- a/libavcodec/dcadec.c
+++ b/libavcodec/dcadec.c
@@ -1192,16 +1192,27 @@ static int dca_subsubframe(DCAContext *s, int base_channel, int block_index)
*/
if (s->prediction_mode[k][l]) {
int n;
- for (m = 0; m < 8; m++) {
- for (n = 1; n <= 4; n++)
+ if (s->predictor_history)
+ subband_samples[k][l][0] += (adpcm_vb[s->prediction_vq[k][l]][0] *
+ s->subband_samples_hist[k][l][3] +
+ adpcm_vb[s->prediction_vq[k][l]][1] *
+ s->subband_samples_hist[k][l][2] +
+ adpcm_vb[s->prediction_vq[k][l]][2] *
+ s->subband_samples_hist[k][l][1] +
+ adpcm_vb[s->prediction_vq[k][l]][3] *
+ s->subband_samples_hist[k][l][0]) *
+ (1.0f / 8192);
+ for (m = 1; m < 8; m++) {
+ float sum = adpcm_vb[s->prediction_vq[k][l]][0] *
+ subband_samples[k][l][m - 1];
+ for (n = 2; n <= 4; n++)
if (m >= n)
- subband_samples[k][l][m] +=
- (adpcm_vb[s->prediction_vq[k][l]][n - 1] *
- subband_samples[k][l][m - n] / 8192);
+ sum += adpcm_vb[s->prediction_vq[k][l]][n - 1] *
+ subband_samples[k][l][m - n];
else if (s->predictor_history)
- subband_samples[k][l][m] +=
- (adpcm_vb[s->prediction_vq[k][l]][n - 1] *
- s->subband_samples_hist[k][l][m - n + 4] / 8192);
+ sum += adpcm_vb[s->prediction_vq[k][l]][n - 1] *
+ s->subband_samples_hist[k][l][m - n + 4];
+ subband_samples[k][l][m] += sum * 1.0f / 8192;
}
}
}