summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2015-02-16 02:07:39 +0100
committerMichael Niedermayer <michaelni@gmx.at>2015-02-16 02:07:42 +0100
commit39b40be2a1303013783df7cc184ffe1860ff31ce (patch)
tree9c891e25ff58d349fa130f2c55c3c829c80198a5
parent9e0a1bd2b977e69638a691e4ff4c9ceb21d45c33 (diff)
parent73ae0a9d12857852222363f9a7c14d07058ebfd3 (diff)
downloadffmpeg-39b40be2a1303013783df7cc184ffe1860ff31ce.tar.gz
Merge commit '73ae0a9d12857852222363f9a7c14d07058ebfd3'
* commit '73ae0a9d12857852222363f9a7c14d07058ebfd3': g722: Split out computation of band->s_zero and unroll code Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/g722.c50
1 files changed, 32 insertions, 18 deletions
diff --git a/libavcodec/g722.c b/libavcodec/g722.c
index 19ee6662a8..ee3b85f845 100644
--- a/libavcodec/g722.c
+++ b/libavcodec/g722.c
@@ -71,6 +71,36 @@ const int16_t ff_g722_low_inv_quant6[64] = {
211, 170, 130, 91, 54, 17, -54, -17
};
+static inline void s_zero(int cur_diff, struct G722Band *band)
+{
+ int s_zero = 0;
+
+ #define ACCUM(k, x, d) do { \
+ int tmp = x; \
+ band->zero_mem[k] = ((band->zero_mem[k] * 255) >> 8) + \
+ d*((band->diff_mem[k]^cur_diff) < 0 ? -128 : 128); \
+ band->diff_mem[k] = tmp; \
+ s_zero += (tmp * band->zero_mem[k]) >> 15; \
+ } while (0)
+ if (cur_diff) {
+ ACCUM(5, band->diff_mem[4], 1);
+ ACCUM(4, band->diff_mem[3], 1);
+ ACCUM(3, band->diff_mem[2], 1);
+ ACCUM(2, band->diff_mem[1], 1);
+ ACCUM(1, band->diff_mem[0], 1);
+ ACCUM(0, cur_diff << 1, 1);
+ } else {
+ ACCUM(5, band->diff_mem[4], 0);
+ ACCUM(4, band->diff_mem[3], 0);
+ ACCUM(3, band->diff_mem[2], 0);
+ ACCUM(2, band->diff_mem[1], 0);
+ ACCUM(1, band->diff_mem[0], 0);
+ ACCUM(0, cur_diff << 1, 0);
+ }
+ #undef ACCUM
+ band->s_zero = s_zero;
+}
+
/**
* adaptive predictor
*
@@ -79,7 +109,7 @@ const int16_t ff_g722_low_inv_quant6[64] = {
*/
static void do_adaptive_prediction(struct G722Band *band, const int cur_diff)
{
- int sg[2], limit, i, cur_qtzd_reconst;
+ int sg[2], limit, cur_qtzd_reconst;
const int cur_part_reconst = band->s_zero + cur_diff < 0;
@@ -94,23 +124,7 @@ static void do_adaptive_prediction(struct G722Band *band, const int cur_diff)
limit = 15360 - band->pole_mem[1];
band->pole_mem[0] = av_clip(-192 * sg[0] + (band->pole_mem[0] * 255 >> 8), -limit, limit);
-
- if (cur_diff) {
- for (i = 0; i < 6; i++)
- band->zero_mem[i] = ((band->zero_mem[i]*255) >> 8) +
- ((band->diff_mem[i]^cur_diff) < 0 ? -128 : 128);
- } else
- for (i = 0; i < 6; i++)
- band->zero_mem[i] = (band->zero_mem[i]*255) >> 8;
-
- for (i = 5; i > 0; i--)
- band->diff_mem[i] = band->diff_mem[i-1];
- band->diff_mem[0] = av_clip_int16(cur_diff << 1);
-
- band->s_zero = 0;
- for (i = 5; i >= 0; i--)
- band->s_zero += (band->zero_mem[i]*band->diff_mem[i]) >> 15;
-
+ s_zero(cur_diff, band);
cur_qtzd_reconst = av_clip_int16((band->s_predictor + cur_diff) << 1);
band->s_predictor = av_clip_int16(band->s_zero +