diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-11-20 10:47:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-20 10:47:09 +0100 |
commit | 58443f73fe52520e39ab306f9fdefec08ff587dc (patch) | |
tree | 4f52814f5cb2c3c3aa07f763dc52fba6844278a0 /thirdparty/libvorbis/sharedbook.c | |
parent | e97634f56d4910cf57e8aa4e4c570a71e99eb7ba (diff) | |
parent | 28ad2e8c72b81beefa65d37f94fa45a8a4604d09 (diff) |
Merge pull request #55129 from akien-mga/libvorbis-1.3.7
Diffstat (limited to 'thirdparty/libvorbis/sharedbook.c')
-rw-r--r-- | thirdparty/libvorbis/sharedbook.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/thirdparty/libvorbis/sharedbook.c b/thirdparty/libvorbis/sharedbook.c index 4545d4f459..62a9a00afb 100644 --- a/thirdparty/libvorbis/sharedbook.c +++ b/thirdparty/libvorbis/sharedbook.c @@ -6,7 +6,7 @@ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2015 * - * by the Xiph.Org Foundation http://www.xiph.org/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** @@ -50,7 +50,7 @@ long _float32_pack(float val){ sign=0x80000000; val= -val; } - exp= floor(log(val)/log(2.f)+.001); //+epsilon + exp= floor(log(val)/log(2.f)+.001); /* +epsilon */ mant=rint(ldexp(val,(VQ_FMAN-1)-exp)); exp=(exp+VQ_FEXP_BIAS)<<VQ_FMAN; @@ -62,7 +62,15 @@ float _float32_unpack(long val){ int sign=val&0x80000000; long exp =(val&0x7fe00000L)>>VQ_FMAN; if(sign)mant= -mant; - return(ldexp(mant,exp-(VQ_FMAN-1)-VQ_FEXP_BIAS)); + exp=exp-(VQ_FMAN-1)-VQ_FEXP_BIAS; + /* clamp excessive exponent values */ + if (exp>63){ + exp=63; + } + if (exp<-63){ + exp=-63; + } + return(ldexp(mant,exp)); } /* given a list of word lengths, generate a list of codewords. Works @@ -294,7 +302,7 @@ int vorbis_book_init_encode(codebook *c,const static_codebook *s){ c->used_entries=s->entries; c->dim=s->dim; c->codelist=_make_words(s->lengthlist,s->entries,0); - //c->valuelist=_book_unquantize(s,s->entries,NULL); + /* c->valuelist=_book_unquantize(s,s->entries,NULL); */ c->quantvals=_book_maptype1_quantvals(s); c->minval=(int)rint(_float32_unpack(s->q_min)); c->delta=(int)rint(_float32_unpack(s->q_delta)); @@ -573,6 +581,7 @@ void run_test(static_codebook *b,float *comp){ exit(1); } } + free(out); } int main(){ |