diff options
author | Monty <xiphmont@xiph.org> | 2015-01-21 01:17:41 +0000 |
---|---|---|
committer | Monty <xiphmont@xiph.org> | 2015-01-21 01:17:41 +0000 |
commit | 4b67376da7ded7f16dfebb8a05fb559ac7fbcf55 (patch) | |
tree | 80b92bfe5790338ee179c02e68440661a4b03d8a /lib/synthesis.c | |
parent | d61e0b2a8ae2d8743c9807bf7aa6896151ccec7f (diff) | |
download | libvorbis-git-4b67376da7ded7f16dfebb8a05fb559ac7fbcf55.tar.gz |
Remove multiple subtly different inline and static implementaitonos of ilog()
Add a few additional sanity checks, mostly functioning to ensure we're always
calling ilog() with >=0 input.
svn path=/trunk/vorbis/; revision=19441
Diffstat (limited to 'lib/synthesis.c')
-rw-r--r-- | lib/synthesis.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/lib/synthesis.c b/lib/synthesis.c index f55091ff..3fa5ab93 100644 --- a/lib/synthesis.c +++ b/lib/synthesis.c @@ -145,6 +145,11 @@ long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op){ oggpack_buffer opb; int mode; + if(ci==NULL || ci->modes<=0){ + /* codec setup not properly intialized */ + return(OV_EFAULT); + } + oggpack_readinit(&opb,op->packet,op->bytes); /* Check the packet type */ @@ -153,17 +158,8 @@ long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op){ return(OV_ENOTAUDIO); } - { - int modebits=0; - int v=ci->modes; - while(v>1){ - modebits++; - v>>=1; - } - - /* read our mode and pre/post windowsize */ - mode=oggpack_read(&opb,modebits); - } + /* read our mode and pre/post windowsize */ + mode=oggpack_read(&opb,ov_ilog(ci->modes-1)); if(mode==-1 || !ci->mode_param[mode])return(OV_EBADPACKET); return(ci->blocksizes[ci->mode_param[mode]->blockflag]); } |