X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=lib%2Fblock.c;h=db245b3e69668fb2be8c123e49596c1c94c39f03;hb=018ca26dece618457dd13585cad52941193c4a25;hp=2dc28c24ab48987b90be6ca6b3f62e52b75a7212;hpb=5fb866e8f3feae2ca9a0742312c5a6fa41627ef8;p=platform%2Fupstream%2Flibvorbis.git diff --git a/lib/block.c b/lib/block.c index 2dc28c2..db245b3 100644 --- a/lib/block.c +++ b/lib/block.c @@ -5,13 +5,12 @@ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * + * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2015 * * by the Xiph.Org Foundation http://www.xiph.org/ * * * ******************************************************************** function: PCM data vector blocking, windowing and dis/reassembly - last mod: $Id$ Handle windowing, overlap-add, etc of the PCM vectors. This is made more amusing by Vorbis' current two allowed block sizes. @@ -31,16 +30,6 @@ #include "registry.h" #include "misc.h" -static int ilog2(unsigned int v){ - int ret=0; - if(v)--v; - while(v){ - ret++; - v>>=1; - } - return(ret); -} - /* pcm accumulator examples (not exhaustive): <-------------- lW ----------------> @@ -184,14 +173,19 @@ static int _vds_shared_init(vorbis_dsp_state *v,vorbis_info *vi,int encp){ private_state *b=NULL; int hs; - if(ci==NULL) return 1; + if(ci==NULL|| + ci->modes<=0|| + ci->blocksizes[0]<64|| + ci->blocksizes[1]blocksizes[0]){ + return 1; + } hs=ci->halfrate_flag; memset(v,0,sizeof(*v)); b=v->backend_state=_ogg_calloc(1,sizeof(*b)); v->vi=vi; - b->modebits=ilog2(ci->modes); + b->modebits=ov_ilog(ci->modes-1); b->transform[0]=_ogg_calloc(VI_TRANSFORMB,sizeof(*b->transform[0])); b->transform[1]=_ogg_calloc(VI_TRANSFORMB,sizeof(*b->transform[1])); @@ -204,8 +198,14 @@ static int _vds_shared_init(vorbis_dsp_state *v,vorbis_info *vi,int encp){ mdct_init(b->transform[1][0],ci->blocksizes[1]>>hs); /* Vorbis I uses only window type 0 */ - b->window[0]=ilog2(ci->blocksizes[0])-6; - b->window[1]=ilog2(ci->blocksizes[1])-6; + /* note that the correct computation below is technically: + b->window[0]=ov_ilog(ci->blocksizes[0]-1)-6; + b->window[1]=ov_ilog(ci->blocksizes[1]-1)-6; + but since blocksizes are always powers of two, + the below is equivalent. + */ + b->window[0]=ov_ilog(ci->blocksizes[0])-7; + b->window[1]=ov_ilog(ci->blocksizes[1])-7; if(encp){ /* encode/decode differ here */ @@ -771,14 +771,14 @@ int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){ if(v->lW){ if(v->W){ /* large/large */ - float *w=_vorbis_window_get(b->window[1]-hs); + const float *w=_vorbis_window_get(b->window[1]-hs); float *pcm=v->pcm[j]+prevCenter; float *p=vb->pcm[j]; for(i=0;iwindow[0]-hs); + const float *w=_vorbis_window_get(b->window[0]-hs); float *pcm=v->pcm[j]+prevCenter+n1/2-n0/2; float *p=vb->pcm[j]; for(i=0;iW){ /* small/large */ - float *w=_vorbis_window_get(b->window[0]-hs); + const float *w=_vorbis_window_get(b->window[0]-hs); float *pcm=v->pcm[j]+prevCenter; float *p=vb->pcm[j]+n1/2-n0/2; for(i=0;iwindow[0]-hs); + const float *w=_vorbis_window_get(b->window[0]-hs); float *pcm=v->pcm[j]+prevCenter; float *p=vb->pcm[j]; for(i=0;ivi; codec_setup_info *ci=vi->codec_setup; int hs=ci->halfrate_flag;