summaryrefslogtreecommitdiffstats
path: root/libavcodec/on2avc.c
diff options
context:
space:
mode:
authorGanesh Ajjanagadde <gajjanagadde@gmail.com>2015-12-26 16:53:12 -0800
committerGanesh Ajjanagadde <gajjanagadde@gmail.com>2015-12-26 17:20:55 -0800
commit71af38954b18c2956932f0221b1874e228c983fe (patch)
treef688ac181bdec3a9b75937f982a90f4f8ce46750 /libavcodec/on2avc.c
parente70d56b8ad5d77d7e5611b5c4994ae09b115d504 (diff)
downloadffmpeg-streaming-71af38954b18c2956932f0221b1874e228c983fe.zip
ffmpeg-streaming-71af38954b18c2956932f0221b1874e228c983fe.tar.gz
avcodec/on2avc: fix regression on icc since 5495c7f
Should fix the regression, and also speeds up table generation. Tables tested on GNU/Linux+clang: they are identical to the ones prior to 5495c7f. ff_exp10 caused one slight change in one entry, 50000 became 50001 due to somewhat incorrect rounding. Untested on ICC; passes FATE on GNU/Linux+gcc. Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
Diffstat (limited to 'libavcodec/on2avc.c')
-rw-r--r--libavcodec/on2avc.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/libavcodec/on2avc.c b/libavcodec/on2avc.c
index 879b71a..3309d99 100644
--- a/libavcodec/on2avc.c
+++ b/libavcodec/on2avc.c
@@ -912,7 +912,23 @@ static av_cold void on2avc_free_vlcs(On2AVCContext *c)
static av_cold int on2avc_decode_init(AVCodecContext *avctx)
{
On2AVCContext *c = avctx->priv_data;
- int i;
+ int i, ph;
+ /* 10^(i*0.1) for 0 <= i < 10 */
+ /* TODO: possibly statically allocate scale_tab; this may help with FATE
+ * and reproducibility if the binary size is not impacted much */
+ static const double exp10_lut[] = {
+ 1,
+ 1.2589254117941673,
+ 1.5848931924611136,
+ 1.9952623149688795,
+ 2.5118864315095806,
+ 3.1622776601683795,
+ 3.9810717055349727,
+ 5.0118723362727229,
+ 6.3095734448019334,
+ 7.9432823472428158,
+ };
+ int64_t exp10_base = 10;
if (avctx->channels > 2U) {
avpriv_request_sample(avctx, "Decoding more than 2 channels");
@@ -934,10 +950,23 @@ static av_cold int on2avc_decode_init(AVCodecContext *avctx)
av_log(avctx, AV_LOG_WARNING,
"Stereo mode support is not good, patch is welcome\n");
- for (i = 0; i < 20; i++)
+
+ /* Fast and more accurate way of doing for (i = 0; i < 20; i++)
c->scale_tab[i] = ceil(ff_exp10(i * 0.1) * 16) / 32;
for (; i < 128; i++)
- c->scale_tab[i] = ceil(ff_exp10(i * 0.1) * 0.5);
+ c->scale_tab[i] = ceil(ff_exp10(i * 0.1) * 0.5); */
+ for (i = 0; i < 10; i++) {
+ c->scale_tab[i] = ceil(exp10_lut[i] * 16) / 32;
+ c->scale_tab[i+10] = ceil(exp10_lut[i] * 160) / 32;
+ }
+
+ for (i = 20, ph = 0; i < 128; i++, ph++) {
+ if (i % 10 == 0) {
+ exp10_base *= 10;
+ ph = 0;
+ }
+ c->scale_tab[i] = ceil(exp10_base * exp10_lut[ph] * 0.5);
+ }
if (avctx->sample_rate < 32000 || avctx->channels == 1)
memcpy(c->long_win, ff_on2avc_window_long_24000,
OpenPOWER on IntegriCloud