[FFmpeg-cvslog] avcodec/aacenc_is: replace pow(x, 0.75) by x/sqrtf(sqrtf(x))
Claudio Freire
git at videolan.org
Thu Jan 14 05:25:30 CET 2016
ffmpeg | branch: master | Claudio Freire <klaussfreire at gmail.com> | Thu Jan 14 00:38:22 2016 -0300| [62dfe1d40d87f8f67cd77d4b769b7c6163083c5e] | committer: Claudio Freire
avcodec/aacenc_is: replace pow(x, 0.75) by x/sqrtf(sqrtf(x))
This is quite an accurate approximation; testing shows ~ 2ulp error in
the floating point result. Tested with FATE.
Alternatively, if one wants "full accuracy", one can use powf, or sqrt
instead of sqrtf. With powf, one gets 1 ulp error (theoretically should be 0, as
0.75 is exactly representable) on GNU libm, with sqrt, 0 ulp error.
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>
Abstracted into pos_pow34 utility function
Signed-off-by: Claudio Freire <klaussfreire at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=62dfe1d40d87f8f67cd77d4b769b7c6163083c5e
---
libavcodec/aacenc_is.c | 2 +-
libavcodec/aacenc_utils.h | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/libavcodec/aacenc_is.c b/libavcodec/aacenc_is.c
index 405f178..46a9773 100644
--- a/libavcodec/aacenc_is.c
+++ b/libavcodec/aacenc_is.c
@@ -54,7 +54,7 @@ struct AACISError ff_aac_is_encoding_err(AACEncContext *s, ChannelElement *cpe,
FFPsyBand *band0 = &s->psy.ch[s->cur_channel+0].psy_bands[(w+w2)*16+g];
FFPsyBand *band1 = &s->psy.ch[s->cur_channel+1].psy_bands[(w+w2)*16+g];
int is_band_type, is_sf_idx = FFMAX(1, sce0->sf_idx[w*16+g]-4);
- float e01_34 = phase*pow(ener1/ener0, 3.0/4.0);
+ float e01_34 = phase*pos_pow34(ener1/ener0);
float maxval, dist_spec_err = 0.0f;
float minthr = FFMIN(band0->threshold, band1->threshold);
for (i = 0; i < sce0->ics.swb_sizes[g]; i++)
diff --git a/libavcodec/aacenc_utils.h b/libavcodec/aacenc_utils.h
index 736e4a0..cb5bc8d 100644
--- a/libavcodec/aacenc_utils.h
+++ b/libavcodec/aacenc_utils.h
@@ -45,6 +45,11 @@ static inline void abs_pow34_v(float *out, const float *in, const int size)
}
}
+static inline float pos_pow34(float a)
+{
+ return sqrtf(a * sqrtf(a));
+}
+
/**
* Quantize one coefficient.
* @return absolute value of the quantized coefficient
More information about the ffmpeg-cvslog
mailing list