[FFmpeg-devel] [PATCH 1/2] Add 'i' suffix to fixed-point ff_cos/exp2/log2 functions
Mans Rullgard
mans
Tue Jan 12 16:55:10 CET 2010
---
libavcodec/acelp_pitch_delay.c | 6 +++---
libavcodec/celp_math.c | 10 +++++-----
libavcodec/celp_math.h | 6 +++---
libavcodec/lsp.c | 2 +-
4 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/libavcodec/acelp_pitch_delay.c b/libavcodec/acelp_pitch_delay.c
index c3e2409..0451f1b 100644
--- a/libavcodec/acelp_pitch_delay.c
+++ b/libavcodec/acelp_pitch_delay.c
@@ -84,7 +84,7 @@ void ff_acelp_update_past_gain(
if(erasure)
quant_energy[0] = FFMAX(avg_gain >> log2_ma_pred_order, -10240) - 4096; // -10 and -4 in (5.10)
else
- quant_energy[0] = (6165 * ((ff_log2(gain_corr_factor) >> 2) - (13 << 13))) >> 13;
+ quant_energy[0] = (6165 * ((ff_log2i(gain_corr_factor) >> 2) - (13 << 13))) >> 13;
}
int16_t ff_acelp_decode_gain_code(
@@ -105,12 +105,12 @@ int16_t ff_acelp_decode_gain_code(
mr_energy += quant_energy[i] * ma_prediction_coeff[i];
#ifdef G729_BITEXACT
- mr_energy += (((-6165LL * ff_log2(dsp->scalarproduct_int16(fc_v, fc_v, subframe_size, 0))) >> 3) & ~0x3ff);
+ mr_energy += (((-6165LL * ff_log2i(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)
return bidir_sal(
- ((ff_exp2(mr_energy & 0x7fff) + 16) >> 5) * (gain_corr_factor >> 1),
+ ((ff_exp2i(mr_energy & 0x7fff) + 16) >> 5) * (gain_corr_factor >> 1),
(mr_energy >> 15) - 25
);
#else
diff --git a/libavcodec/celp_math.c b/libavcodec/celp_math.c
index 09111da..0fa4a96 100644
--- a/libavcodec/celp_math.c
+++ b/libavcodec/celp_math.c
@@ -74,7 +74,7 @@ static const uint16_t tab_exp2[33] =
31379, 32066, 32767
};
-int16_t ff_cos(uint16_t arg)
+int16_t ff_cosi(uint16_t arg)
{
uint8_t offset= arg;
uint8_t ind = arg >> 8;
@@ -84,7 +84,7 @@ int16_t ff_cos(uint16_t arg)
return FFMAX(base_cos[ind] + ((slope_cos[ind] * offset) >> 12), -0x8000);
}
-int ff_exp2(uint16_t power)
+int ff_exp2i(uint16_t power)
{
uint16_t frac_x0;
uint16_t frac_dx;
@@ -134,7 +134,7 @@ static const uint16_t exp2b[]=
17176, 17898, 18620, 19343, 20066, 20790, 21514, 22238,
};
-int16_t ff_cos(uint16_t arg)
+int16_t ff_cosi(uint16_t arg)
{
uint8_t offset= arg;
uint8_t ind = arg >> 8;
@@ -144,7 +144,7 @@ int16_t ff_cos(uint16_t arg)
return tab_cos[ind] + (offset * (tab_cos[ind+1] - tab_cos[ind]) >> 8);
}
-int ff_exp2(uint16_t power)
+int ff_exp2i(uint16_t power)
{
unsigned int result= exp2a[power>>10] + 0x10000;
@@ -176,7 +176,7 @@ static const uint16_t tab_log2[33] =
#endif
};
-int ff_log2(uint32_t value)
+int ff_log2i(uint32_t value)
{
uint8_t power_int;
uint8_t frac_x0;
diff --git a/libavcodec/celp_math.h b/libavcodec/celp_math.h
index 7cf7861..9a3ccda 100644
--- a/libavcodec/celp_math.h
+++ b/libavcodec/celp_math.h
@@ -31,7 +31,7 @@
*
* @return value of (1<<15) * cos(arg * PI / (1<<14)), -0x8000 <= result <= 0x7fff
*/
-int16_t ff_cos(uint16_t arg);
+int16_t ff_cosi(uint16_t arg);
/**
* fixed-point implementation of exp2(x) in [0; 1] domain.
@@ -40,7 +40,7 @@ int16_t ff_cos(uint16_t arg);
* @return value of (1<<20) * exp2(power / (1<<15))
* 0x8000c <= result <= 0xfffea
*/
-int ff_exp2(uint16_t power);
+int ff_exp2i(uint16_t power);
/**
* Calculates log2(x).
@@ -48,7 +48,7 @@ int ff_exp2(uint16_t power);
*
* @return value of (1<<15) * log2(value)
*/
-int ff_log2(uint32_t value);
+int ff_log2i(uint32_t value);
/**
* Shift value left or right depending on sign of offset parameter.
diff --git a/libavcodec/lsp.c b/libavcodec/lsp.c
index 003ffbc..9d1b970 100644
--- a/libavcodec/lsp.c
+++ b/libavcodec/lsp.c
@@ -62,7 +62,7 @@ void ff_acelp_lsf2lsp(int16_t *lsp, const int16_t *lsf, int lp_order)
/* Convert LSF to LSP, lsp=cos(lsf) */
for(i=0; i<lp_order; i++)
// 20861 = 2.0 / PI in (0.15)
- lsp[i] = ff_cos(lsf[i] * 20861 >> 15); // divide by PI and (0,13) -> (0,14)
+ lsp[i] = ff_cosi(lsf[i] * 20861 >> 15); // divide by PI and (0,13) -> (0,14)
}
/**
--
1.6.6
More information about the ffmpeg-devel
mailing list