scalarproduct instead. Patch by Aurelien Jacobs. Originally committed as revision 16391 to svn://svn.ffmpeg.org/ffmpeg/trunktags/v0.5
| @@ -21,6 +21,7 @@ | |||||
| */ | */ | ||||
| #include "avcodec.h" | #include "avcodec.h" | ||||
| #include "dsputil.h" | |||||
| #include "acelp_pitch_delay.h" | #include "acelp_pitch_delay.h" | ||||
| #include "celp_math.h" | #include "celp_math.h" | ||||
| @@ -87,6 +88,7 @@ void ff_acelp_update_past_gain( | |||||
| } | } | ||||
| int16_t ff_acelp_decode_gain_code( | int16_t ff_acelp_decode_gain_code( | ||||
| DSPContext *dsp, | |||||
| int gain_corr_factor, | int gain_corr_factor, | ||||
| const int16_t* fc_v, | const int16_t* fc_v, | ||||
| int mr_energy, | int mr_energy, | ||||
| @@ -103,7 +105,7 @@ int16_t ff_acelp_decode_gain_code( | |||||
| mr_energy += quant_energy[i] * ma_prediction_coeff[i]; | mr_energy += quant_energy[i] * ma_prediction_coeff[i]; | ||||
| #ifdef G729_BITEXACT | #ifdef G729_BITEXACT | ||||
| mr_energy += (((-6165LL * ff_log2(dot_product(fc_v, fc_v, subframe_size, 0))) >> 3) & ~0x3ff); | |||||
| mr_energy += (((-6165LL * ff_log2(dsp->scalarproduct_int16(fc_v, fc_v, subframe_size, 0))) >> 3) & ~0x3ff); | |||||
| mr_energy = (5439 * (mr_energy >> 15)) >> 8; // (0.15) = (0.15) * (7.23) | mr_energy = (5439 * (mr_energy >> 15)) >> 8; // (0.15) = (0.15) * (7.23) | ||||
| @@ -113,7 +115,7 @@ int16_t ff_acelp_decode_gain_code( | |||||
| ); | ); | ||||
| #else | #else | ||||
| mr_energy = gain_corr_factor * exp(M_LN10 / (20 << 23) * mr_energy) / | mr_energy = gain_corr_factor * exp(M_LN10 / (20 << 23) * mr_energy) / | ||||
| sqrt(dot_product(fc_v, fc_v, subframe_size, 0)); | |||||
| sqrt(dsp->scalarproduct_int16(fc_v, fc_v, subframe_size, 0)); | |||||
| return mr_energy >> 12; | return mr_energy >> 12; | ||||
| #endif | #endif | ||||
| } | } | ||||
| @@ -24,6 +24,7 @@ | |||||
| #define AVCODEC_ACELP_PITCH_DELAY_H | #define AVCODEC_ACELP_PITCH_DELAY_H | ||||
| #include <stdint.h> | #include <stdint.h> | ||||
| #include "dsputil.h" | |||||
| #define PITCH_DELAY_MIN 20 | #define PITCH_DELAY_MIN 20 | ||||
| #define PITCH_DELAY_MAX 143 | #define PITCH_DELAY_MAX 143 | ||||
| @@ -140,6 +141,7 @@ void ff_acelp_update_past_gain( | |||||
| /** | /** | ||||
| * \brief Decode the adaptive codebook gain and add | * \brief Decode the adaptive codebook gain and add | ||||
| * correction (4.1.5 and 3.9.1 of G.729). | * correction (4.1.5 and 3.9.1 of G.729). | ||||
| * \param dsp initialized dsputil context | |||||
| * \param gain_corr_factor gain correction factor (2.13) | * \param gain_corr_factor gain correction factor (2.13) | ||||
| * \param fc_v fixed-codebook vector (2.13) | * \param fc_v fixed-codebook vector (2.13) | ||||
| * \param mr_energy mean innovation energy and fixed-point correction (7.13) | * \param mr_energy mean innovation energy and fixed-point correction (7.13) | ||||
| @@ -209,6 +211,7 @@ void ff_acelp_update_past_gain( | |||||
| * \remark The routine is used in G.729 and AMR (all modes). | * \remark The routine is used in G.729 and AMR (all modes). | ||||
| */ | */ | ||||
| int16_t ff_acelp_decode_gain_code( | int16_t ff_acelp_decode_gain_code( | ||||
| DSPContext *dsp, | |||||
| int gain_corr_factor, | int gain_corr_factor, | ||||
| const int16_t* fc_v, | const int16_t* fc_v, | ||||
| int mr_energy, | int mr_energy, | ||||
| @@ -50,26 +50,6 @@ int ff_exp2(uint16_t power); | |||||
| */ | */ | ||||
| int ff_log2(uint32_t value); | int ff_log2(uint32_t value); | ||||
| /** | |||||
| * returns the dot product. | |||||
| * @param a input data array | |||||
| * @param b input data array | |||||
| * @param length number of elements | |||||
| * @param shift right shift by this value will be done after multiplication | |||||
| * | |||||
| * @return dot product = sum of elementwise products | |||||
| */ | |||||
| static int dot_product(const int16_t* a, const int16_t* b, int length, int shift) | |||||
| { | |||||
| int sum = 0; | |||||
| int i; | |||||
| for(i=0; i<length; i++) | |||||
| sum += (a[i] * b[i]) >> shift; | |||||
| return sum; | |||||
| } | |||||
| /** | /** | ||||
| * Shift value left or right depending on sign of offset parameter. | * Shift value left or right depending on sign of offset parameter. | ||||
| * @param value value to shift | * @param value value to shift | ||||