summaryrefslogtreecommitdiff
path: root/libavcodec/g729postfilter.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2015-11-10 14:35:08 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2015-11-10 15:44:46 +0100
commit6e3244fb09f22d019906f3029d86a483179c55ec (patch)
treeb098e4168035c240969f0701f2a9de0b172a35b2 /libavcodec/g729postfilter.c
parentdafe4cd29cada351a2785433b24401fc602911c4 (diff)
avcodec/g729postfilter: Avoid function calls in FFMAX() arguments
This avoid double calling functions Found-by: Muhammad Faiz <mfcc64@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/g729postfilter.c')
-rw-r--r--libavcodec/g729postfilter.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/libavcodec/g729postfilter.c b/libavcodec/g729postfilter.c
index 9a775c47b2..d9076ec735 100644
--- a/libavcodec/g729postfilter.c
+++ b/libavcodec/g729postfilter.c
@@ -165,7 +165,8 @@ static int16_t long_term_filter(AudioDSPContext *adsp, int pitch_delay_int,
sig_scaled + RES_PREV_DATA_SIZE,
subframe_size);
if (ener) {
- sh_ener = FFMAX(av_log2(ener) - 14, 0);
+ sh_ener = av_log2(ener) - 14;
+ sh_ener = FFMAX(sh_ener, 0);
ener >>= sh_ener;
/* Search for best pitch delay.
@@ -320,7 +321,8 @@ static int16_t long_term_filter(AudioDSPContext *adsp, int pitch_delay_int,
gain_long_num = 0;
sh_gain_long_num = 0;
} else {
- tmp = FFMAX(av_log2(sum) - 14, 0);
+ tmp = av_log2(sum) - 14;
+ tmp = FFMAX(tmp, 0);
sum >>= tmp;
gain_long_num = sum;
sh_gain_long_num = tmp;
@@ -329,7 +331,8 @@ static int16_t long_term_filter(AudioDSPContext *adsp, int pitch_delay_int,
/* Compute R'(k) correlation's denominator. */
sum = adsp->scalarproduct_int16(residual_filt, residual_filt, subframe_size);
- tmp = FFMAX(av_log2(sum) - 14, 0);
+ tmp = av_log2(sum) - 14;
+ tmp = FFMAX(tmp, 0);
sum >>= tmp;
gain_long_den = sum;
sh_gain_long_den = tmp;
@@ -541,9 +544,10 @@ void ff_g729_postfilter(AudioDSPContext *adsp, int16_t* ht_prev_data, int* voici
/* long-term filter. If long-term prediction gain is larger than 3dB (returned value is
nonzero) then declare current subframe as periodic. */
- *voicing = FFMAX(*voicing, long_term_filter(adsp, pitch_delay_int,
+ i = long_term_filter(adsp, pitch_delay_int,
residual, residual_filt_buf + 10,
- subframe_size));
+ subframe_size);
+ *voicing = FFMAX(*voicing, i);
/* shift residual for using in next subframe */
memmove(residual, residual + subframe_size, RES_PREV_DATA_SIZE * sizeof(int16_t));