aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorPeter Meerwald <pmeerw@pmeerw.net>2015-02-15 12:21:24 +0100
committerMartin Storsjö <martin@martin.st>2015-02-15 22:47:19 +0200
commit73ae0a9d12857852222363f9a7c14d07058ebfd3 (patch)
tree714b2d74bf77dbea08d340c120b18fc8362997ac /libavcodec
parentb16057b5fe9f02442c52388037891c2e381205fc (diff)
downloadffmpeg-73ae0a9d12857852222363f9a7c14d07058ebfd3.tar.gz
g722: Split out computation of band->s_zero and unroll code
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net> Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/g722.c50
1 files changed, 32 insertions, 18 deletions
diff --git a/libavcodec/g722.c b/libavcodec/g722.c
index 74c0868028..830877e336 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 +