diff options
Diffstat (limited to 'libavcodec/g723_1.c')
-rw-r--r-- | libavcodec/g723_1.c | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/libavcodec/g723_1.c b/libavcodec/g723_1.c index 3d45f9d1cf..a11fec8a9e 100644 --- a/libavcodec/g723_1.c +++ b/libavcodec/g723_1.c @@ -3,20 +3,20 @@ * Copyright (c) 2006 Benjamin Larsson * Copyright (c) 2010 Mohamed Naufal Basheer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * Libav is distributed in the hope that it will be useful, + * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -37,8 +37,8 @@ int ff_g723_1_scale_vector(int16_t *dst, const int16_t *vector, int length) for (i = 0; i < length; i++) max |= FFABS(vector[i]); - max = FFMIN(max, 0x7FFF); - bits = ff_g723_1_normalize_bits(max, 15); + bits= 14 - av_log2_16bit(max); + bits= FFMAX(bits, 0); for (i = 0; i < length; i++) dst[i] = vector[i] << bits >> 3; @@ -97,16 +97,16 @@ void ff_g723_1_gen_acb_excitation(int16_t *vector, int16_t *prev_excitation, ff_g723_1_get_residual(residual, prev_excitation, lag); /* Select quantization table */ - if (cur_rate == RATE_6300 && pitch_lag < SUBFRAME_LEN - 2) + if (cur_rate == RATE_6300 && pitch_lag < SUBFRAME_LEN - 2) { cb_ptr = adaptive_cb_gain85; - else + } else cb_ptr = adaptive_cb_gain170; /* Calculate adaptive vector */ cb_ptr += subfrm->ad_cb_gain * 20; for (i = 0; i < SUBFRAME_LEN; i++) { - sum = ff_g723_1_dot_product(residual + i, cb_ptr, PITCH_ORDER); - vector[i] = av_sat_dadd32(1 << 15, sum) >> 16; + sum = ff_dot_product(residual + i, cb_ptr, PITCH_ORDER); + vector[i] = av_sat_dadd32(1 << 15, av_sat_add32(sum, sum)) >> 16; } } @@ -123,11 +123,11 @@ static void lsp2lpc(int16_t *lpc) /* Calculate negative cosine */ for (j = 0; j < LPC_ORDER; j++) { - int index = (lpc[j] >> 7) & 0x1FF; - int offset = lpc[j] & 0x7f; - int temp1 = cos_tab[index] << 16; - int temp2 = (cos_tab[index + 1] - cos_tab[index]) * - ((offset << 8) + 0x80) << 1; + int index = (lpc[j] >> 7) & 0x1FF; + int offset = lpc[j] & 0x7f; + int temp1 = cos_tab[index] << 16; + int temp2 = (cos_tab[index + 1] - cos_tab[index]) * + ((offset << 8) + 0x80) << 1; lpc[j] = -(av_sat_dadd32(1 << 15, temp1 + temp2) >> 16); } @@ -162,8 +162,8 @@ static void lsp2lpc(int16_t *lpc) f1[0] >>= 1; f2[0] >>= 1; - f1[1] = ((lpc[2 * i] << 16 >> i) + f1[1]) >> 1; - f2[1] = ((lpc[2 * i + 1] << 16 >> i) + f2[1]) >> 1; + f1[1] = ((lpc[2 * i] << 16 >> i) + f1[1]) >> 1; + f2[1] = ((lpc[2 * i + 1] << 16 >> i) + f2[1]) >> 1; } /* Convert polynomial coefficients to LPC coefficients */ @@ -171,8 +171,7 @@ static void lsp2lpc(int16_t *lpc) int64_t ff1 = f1[i + 1] + f1[i]; int64_t ff2 = f2[i + 1] - f2[i]; - lpc[i] = av_clipl_int32(((ff1 + ff2) << 3) + - (1 << 15)) >> 16; + lpc[i] = av_clipl_int32(((ff1 + ff2) << 3) + (1 << 15)) >> 16; lpc[LPC_ORDER - i - 1] = av_clipl_int32(((ff1 - ff2) << 3) + (1 << 15)) >> 16; } @@ -234,7 +233,7 @@ void ff_g723_1_inverse_quant(int16_t *cur_lsp, int16_t *prev_lsp, } for (i = 0; i < LPC_ORDER; i++) { - cur_lsp[0] = FFMAX(cur_lsp[0], 0x180); + cur_lsp[0] = FFMAX(cur_lsp[0], 0x180); cur_lsp[LPC_ORDER - 1] = FFMIN(cur_lsp[LPC_ORDER - 1], 0x7e00); /* Stability check */ |