1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

Merge commit '73ae0a9d12857852222363f9a7c14d07058ebfd3'

* commit '73ae0a9d12857852222363f9a7c14d07058ebfd3':
  g722: Split out computation of band->s_zero and unroll code

Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2015-02-16 02:07:39 +01:00
commit 39b40be2a1

View File

@ -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 +