diff options
author | Harish Mahendrakar <harish.mahendrakar@ittiam.com> | 2020-04-25 06:49:14 +0530 |
---|---|---|
committer | Ray Essick <essick@google.com> | 2020-04-30 13:41:12 -0700 |
commit | 7cc2d368820823df3796af4ed4c1610942e9f19c (patch) | |
tree | abf859855808317ce05bb926772bcdeef59f51fa | |
parent | 344e643d6defaced02b658fbd57ba890c4abbfeb (diff) | |
download | tremolo-7cc2d368820823df3796af4ed4c1610942e9f19c.tar.gz |
Support 64 bit amplitude values
Bug: 145790628
Bug: 154663644
Test: poc in bug
Test: atest android.mediav2.cts
Change-Id: Ia6226b8c1a6bfd78a040dc7a9c2ccd274091d7e4
-rw-r--r-- | Tremolo/floor0.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/Tremolo/floor0.c b/Tremolo/floor0.c index b6ece29..7e74d1e 100644 --- a/Tremolo/floor0.c +++ b/Tremolo/floor0.c @@ -402,13 +402,20 @@ ogg_int32_t *floor0_inverse1(vorbis_dsp_state *vd,vorbis_info_floor *i, ogg_int32_t *lsp){ vorbis_info_floor0 *info=(vorbis_info_floor0 *)i; int j,k; - - int ampraw=oggpack_read(&vd->opb,info->ampbits); + uint64_t ampraw; + if(info->ampbits<=32){ + ampraw=oggpack_read(&vd->opb,info->ampbits); + }else{ + //max value possible for info->ampbits is 63 + ampraw=oggpack_read(&vd->opb,info->ampbits-32); + ampraw<<=32; + ampraw|=oggpack_read(&vd->opb,32); + } if(ampraw>0){ /* also handles the -1 out of data case */ - long maxval=(1<<info->ampbits)-1; - int amp=((ampraw*info->ampdB)<<4)/maxval; + uint64_t maxval=(1<<info->ampbits)-1; + float ampRatio=(float)ampraw/maxval; + int amp=ampRatio*(info->ampdB<<4); int booknum=oggpack_read(&vd->opb,_ilog(info->numbooks)); - if(booknum!=-1 && booknum<info->numbooks){ /* be paranoid */ codec_setup_info *ci=(codec_setup_info *)vd->vi->codec_setup; codebook *b=ci->book_param+info->books[booknum]; |