X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fon2avc.c;h=62c71ccea53515c14c646cab29d1ff577b6791b0;hb=ba7d16a30353a7ff2833fd2ac2fbd3cd977d278f;hp=15f4dd1c66ebaffa3fd271414864b5340f35baf0;hpb=3564dfd535743ad586c10800c7f931e5bf3cbde7;p=ffmpeg diff --git a/libavcodec/on2avc.c b/libavcodec/on2avc.c index 15f4dd1c66e..62c71ccea53 100644 --- a/libavcodec/on2avc.c +++ b/libavcodec/on2avc.c @@ -22,6 +22,7 @@ #include "libavutil/channel_layout.h" #include "libavutil/float_dsp.h" +#include "libavutil/internal.h" #include "avcodec.h" #include "bytestream.h" #include "fft.h" @@ -211,9 +212,16 @@ static inline int get_egolomb(GetBitContext *gb) { int v = 4; - while (get_bits1(gb)) v++; + while (get_bits1(gb)) { + v++; + if (v > 30) { + av_log(NULL, AV_LOG_WARNING, "Too large golomb code in get_egolomb.\n"); + v = 30; + break; + } + } - return (1 << v) + get_bits(gb, v); + return (1 << v) + get_bits_long(gb, v); } static int on2avc_decode_pairs(On2AVCContext *c, GetBitContext *gb, float *dst, @@ -926,10 +934,13 @@ 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"); + // We add -0.01 before ceil() to avoid any values to fall at exactly the + // midpoint between different ceil values. The results are identical to + // using pow(10, i / 10.0) without such bias for (i = 0; i < 20; i++) - c->scale_tab[i] = ceil(pow(10.0, i * 0.1) * 16) / 32; + c->scale_tab[i] = ceil(ff_exp10(i * 0.1) * 16 - 0.01) / 32; for (; i < 128; i++) - c->scale_tab[i] = ceil(pow(10.0, i * 0.1) * 0.5); + c->scale_tab[i] = ceil(ff_exp10(i * 0.1) * 0.5 - 0.01); if (avctx->sample_rate < 32000 || avctx->channels == 1) memcpy(c->long_win, ff_on2avc_window_long_24000,