Lines Matching refs:v

34 static int ilog2(unsigned int v){  in ilog2()  argument
36 if(v)--v; in ilog2()
37 while(v){ in ilog2()
39 v>>=1; in ilog2()
88 int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb){ in vorbis_block_init() argument
91 vb->vd=v; in vorbis_block_init()
94 if(v->analysisp){ in vorbis_block_init()
181 static int _vds_shared_init(vorbis_dsp_state *v,vorbis_info *vi,int encp){ in _vds_shared_init() argument
190 memset(v,0,sizeof(*v)); in _vds_shared_init()
191 b=v->backend_state=_ogg_calloc(1,sizeof(*b)); in _vds_shared_init()
193 v->vi=vi; in _vds_shared_init()
232 v->analysisp=1; in _vds_shared_init()
250 v->pcm_storage=ci->blocksizes[1]; in _vds_shared_init()
251 v->pcm=_ogg_malloc(vi->channels*sizeof(*v->pcm)); in _vds_shared_init()
252 v->pcmret=_ogg_malloc(vi->channels*sizeof(*v->pcmret)); in _vds_shared_init()
256 v->pcm[i]=_ogg_calloc(v->pcm_storage,sizeof(*v->pcm[i])); in _vds_shared_init()
261 v->lW=0; /* previous window size */ in _vds_shared_init()
262 v->W=0; /* current window size */ in _vds_shared_init()
265 v->centerW=ci->blocksizes[1]/2; in _vds_shared_init()
267 v->pcm_current=v->centerW; in _vds_shared_init()
275 look(v,ci->floor_param[i]); in _vds_shared_init()
279 look(v,ci->residue_param[i]); in _vds_shared_init()
289 vorbis_dsp_clear(v); in _vds_shared_init()
294 int vorbis_analysis_init(vorbis_dsp_state *v,vorbis_info *vi){ in vorbis_analysis_init() argument
297 if(_vds_shared_init(v,vi,1))return 1; in vorbis_analysis_init()
298 b=v->backend_state; in vorbis_analysis_init()
309 v->sequence=3; in vorbis_analysis_init()
314 void vorbis_dsp_clear(vorbis_dsp_state *v){ in vorbis_dsp_clear() argument
316 if(v){ in vorbis_dsp_clear()
317 vorbis_info *vi=v->vi; in vorbis_dsp_clear()
319 private_state *b=v->backend_state; in vorbis_dsp_clear()
368 if(v->pcm){ in vorbis_dsp_clear()
371 if(v->pcm[i])_ogg_free(v->pcm[i]); in vorbis_dsp_clear()
372 _ogg_free(v->pcm); in vorbis_dsp_clear()
373 if(v->pcmret)_ogg_free(v->pcmret); in vorbis_dsp_clear()
384 memset(v,0,sizeof(*v)); in vorbis_dsp_clear()
388 float **vorbis_analysis_buffer(vorbis_dsp_state *v, int vals){ in vorbis_analysis_buffer() argument
390 vorbis_info *vi=v->vi; in vorbis_analysis_buffer()
391 private_state *b=v->backend_state; in vorbis_analysis_buffer()
401 if(v->pcm_current+vals>=v->pcm_storage){ in vorbis_analysis_buffer()
402 v->pcm_storage=v->pcm_current+vals*2; in vorbis_analysis_buffer()
405 v->pcm[i]=_ogg_realloc(v->pcm[i],v->pcm_storage*sizeof(*v->pcm[i])); in vorbis_analysis_buffer()
410 v->pcmret[i]=v->pcm[i]+v->pcm_current; in vorbis_analysis_buffer()
412 return(v->pcmret); in vorbis_analysis_buffer()
415 static void _preextrapolate_helper(vorbis_dsp_state *v){ in _preextrapolate_helper() argument
419 float *work=alloca(v->pcm_current*sizeof(*work)); in _preextrapolate_helper()
421 v->preextrapolate=1; in _preextrapolate_helper()
423 if(v->pcm_current-v->centerW>order*2){ /* safety */ in _preextrapolate_helper()
424 for(i=0;i<v->vi->channels;i++){ in _preextrapolate_helper()
426 for(j=0;j<v->pcm_current;j++) in _preextrapolate_helper()
427 work[j]=v->pcm[i][v->pcm_current-j-1]; in _preextrapolate_helper()
430 vorbis_lpc_from_data(work,lpc,v->pcm_current-v->centerW,order); in _preextrapolate_helper()
433 if(v->vi->channels==2){ in _preextrapolate_helper()
435 _analysis_output("predataL",0,work,v->pcm_current-v->centerW,0,0,0); in _preextrapolate_helper()
437 _analysis_output("predataR",0,work,v->pcm_current-v->centerW,0,0,0); in _preextrapolate_helper()
439 _analysis_output("predata",0,work,v->pcm_current-v->centerW,0,0,0); in _preextrapolate_helper()
444 vorbis_lpc_predict(lpc,work+v->pcm_current-v->centerW-order, in _preextrapolate_helper()
446 work+v->pcm_current-v->centerW, in _preextrapolate_helper()
447 v->centerW); in _preextrapolate_helper()
449 for(j=0;j<v->pcm_current;j++) in _preextrapolate_helper()
450 v->pcm[i][v->pcm_current-j-1]=work[j]; in _preextrapolate_helper()
459 int vorbis_analysis_wrote(vorbis_dsp_state *v, int vals){ in vorbis_analysis_wrote() argument
460 vorbis_info *vi=v->vi; in vorbis_analysis_wrote()
469 if(!v->preextrapolate) in vorbis_analysis_wrote()
470 _preextrapolate_helper(v); in vorbis_analysis_wrote()
478 vorbis_analysis_buffer(v,ci->blocksizes[1]*3); in vorbis_analysis_wrote()
479 v->eofflag=v->pcm_current; in vorbis_analysis_wrote()
480 v->pcm_current+=ci->blocksizes[1]*3; in vorbis_analysis_wrote()
483 if(v->eofflag>order*2){ in vorbis_analysis_wrote()
488 n=v->eofflag; in vorbis_analysis_wrote()
490 vorbis_lpc_from_data(v->pcm[i]+v->eofflag-n,lpc,n,order); in vorbis_analysis_wrote()
493 vorbis_lpc_predict(lpc,v->pcm[i]+v->eofflag-order,order, in vorbis_analysis_wrote()
494 v->pcm[i]+v->eofflag,v->pcm_current-v->eofflag); in vorbis_analysis_wrote()
499 memset(v->pcm[i]+v->eofflag,0, in vorbis_analysis_wrote()
500 (v->pcm_current-v->eofflag)*sizeof(*v->pcm[i])); in vorbis_analysis_wrote()
506 if(v->pcm_current+vals>v->pcm_storage) in vorbis_analysis_wrote()
509 v->pcm_current+=vals; in vorbis_analysis_wrote()
514 if(!v->preextrapolate && v->pcm_current-v->centerW>ci->blocksizes[1]) in vorbis_analysis_wrote()
515 _preextrapolate_helper(v); in vorbis_analysis_wrote()
523 int vorbis_analysis_blockout(vorbis_dsp_state *v,vorbis_block *vb){ in vorbis_analysis_blockout() argument
525 vorbis_info *vi=v->vi; in vorbis_analysis_blockout()
527 private_state *b=v->backend_state; in vorbis_analysis_blockout()
529 long beginW=v->centerW-ci->blocksizes[v->W]/2,centerNext; in vorbis_analysis_blockout()
533 if(!v->preextrapolate)return(0); in vorbis_analysis_blockout()
536 if(v->eofflag==-1)return(0); in vorbis_analysis_blockout()
546 long bp=_ve_envelope_search(v); in vorbis_analysis_blockout()
549 if(v->eofflag==0)return(0); /* not enough data currently to search for a in vorbis_analysis_blockout()
551 v->nW=0; in vorbis_analysis_blockout()
555 v->nW=0; in vorbis_analysis_blockout()
557 v->nW=bp; in vorbis_analysis_blockout()
561 centerNext=v->centerW+ci->blocksizes[v->W]/4+ci->blocksizes[v->nW]/4; in vorbis_analysis_blockout()
566 long blockbound=centerNext+ci->blocksizes[v->nW]/2; in vorbis_analysis_blockout()
567 if(v->pcm_current<blockbound)return(0); /* not enough data yet; in vorbis_analysis_blockout()
582 vb->lW=v->lW; in vorbis_analysis_blockout()
583 vb->W=v->W; in vorbis_analysis_blockout()
584 vb->nW=v->nW; in vorbis_analysis_blockout()
586 if(v->W){ in vorbis_analysis_blockout()
587 if(!v->lW || !v->nW){ in vorbis_analysis_blockout()
595 if(_ve_envelope_mark(v)){ in vorbis_analysis_blockout()
606 vb->vd=v; in vorbis_analysis_blockout()
607 vb->sequence=v->sequence++; in vorbis_analysis_blockout()
608 vb->granulepos=v->granulepos; in vorbis_analysis_blockout()
609 vb->pcmend=ci->blocksizes[v->W]; in vorbis_analysis_blockout()
616 g->ampmax=_vp_ampmax_decay(g->ampmax,v); in vorbis_analysis_blockout()
624 memcpy(vbi->pcmdelay[i],v->pcm[i],(vb->pcmend+beginW)*sizeof(*vbi->pcmdelay[i])); in vorbis_analysis_blockout()
638 if(v->eofflag){ in vorbis_analysis_blockout()
639 if(v->centerW>=v->eofflag){ in vorbis_analysis_blockout()
640 v->eofflag=-1; in vorbis_analysis_blockout()
654 v->pcm_current-=movementW; in vorbis_analysis_blockout()
657 memmove(v->pcm[i],v->pcm[i]+movementW, in vorbis_analysis_blockout()
658 v->pcm_current*sizeof(*v->pcm[i])); in vorbis_analysis_blockout()
661 v->lW=v->W; in vorbis_analysis_blockout()
662 v->W=v->nW; in vorbis_analysis_blockout()
663 v->centerW=new_centerNext; in vorbis_analysis_blockout()
665 if(v->eofflag){ in vorbis_analysis_blockout()
666 v->eofflag-=movementW; in vorbis_analysis_blockout()
667 if(v->eofflag<=0)v->eofflag=-1; in vorbis_analysis_blockout()
669 if(v->centerW>=v->eofflag){ in vorbis_analysis_blockout()
670 v->granulepos+=movementW-(v->centerW-v->eofflag); in vorbis_analysis_blockout()
672 v->granulepos+=movementW; in vorbis_analysis_blockout()
675 v->granulepos+=movementW; in vorbis_analysis_blockout()
684 int vorbis_synthesis_restart(vorbis_dsp_state *v){ in vorbis_synthesis_restart() argument
685 vorbis_info *vi=v->vi; in vorbis_synthesis_restart()
689 if(!v->backend_state)return -1; in vorbis_synthesis_restart()
695 v->centerW=ci->blocksizes[1]>>(hs+1); in vorbis_synthesis_restart()
696 v->pcm_current=v->centerW>>hs; in vorbis_synthesis_restart()
698 v->pcm_returned=-1; in vorbis_synthesis_restart()
699 v->granulepos=-1; in vorbis_synthesis_restart()
700 v->sequence=-1; in vorbis_synthesis_restart()
701 v->eofflag=0; in vorbis_synthesis_restart()
702 ((private_state *)(v->backend_state))->sample_count=-1; in vorbis_synthesis_restart()
707 int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi){ in vorbis_synthesis_init() argument
708 if(_vds_shared_init(v,vi,0)){ in vorbis_synthesis_init()
709 vorbis_dsp_clear(v); in vorbis_synthesis_init()
712 vorbis_synthesis_restart(v); in vorbis_synthesis_init()
720 int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){ in vorbis_synthesis_blockin() argument
721 vorbis_info *vi=v->vi; in vorbis_synthesis_blockin()
723 private_state *b=v->backend_state; in vorbis_synthesis_blockin()
728 if(v->pcm_current>v->pcm_returned && v->pcm_returned!=-1)return(OV_EINVAL); in vorbis_synthesis_blockin()
730 v->lW=v->W; in vorbis_synthesis_blockin()
731 v->W=vb->W; in vorbis_synthesis_blockin()
732 v->nW=-1; in vorbis_synthesis_blockin()
734 if((v->sequence==-1)|| in vorbis_synthesis_blockin()
735 (v->sequence+1 != vb->sequence)){ in vorbis_synthesis_blockin()
736 v->granulepos=-1; /* out of sequence; lose count */ in vorbis_synthesis_blockin()
740 v->sequence=vb->sequence; in vorbis_synthesis_blockin()
744 int n=ci->blocksizes[v->W]>>(hs+1); in vorbis_synthesis_blockin()
751 v->glue_bits+=vb->glue_bits; in vorbis_synthesis_blockin()
752 v->time_bits+=vb->time_bits; in vorbis_synthesis_blockin()
753 v->floor_bits+=vb->floor_bits; in vorbis_synthesis_blockin()
754 v->res_bits+=vb->res_bits; in vorbis_synthesis_blockin()
756 if(v->centerW){ in vorbis_synthesis_blockin()
770 if(v->lW){ in vorbis_synthesis_blockin()
771 if(v->W){ in vorbis_synthesis_blockin()
774 float *pcm=v->pcm[j]+prevCenter; in vorbis_synthesis_blockin()
781 float *pcm=v->pcm[j]+prevCenter+n1/2-n0/2; in vorbis_synthesis_blockin()
787 if(v->W){ in vorbis_synthesis_blockin()
790 float *pcm=v->pcm[j]+prevCenter; in vorbis_synthesis_blockin()
799 float *pcm=v->pcm[j]+prevCenter; in vorbis_synthesis_blockin()
808 float *pcm=v->pcm[j]+thisCenter; in vorbis_synthesis_blockin()
815 if(v->centerW) in vorbis_synthesis_blockin()
816 v->centerW=0; in vorbis_synthesis_blockin()
818 v->centerW=n1; in vorbis_synthesis_blockin()
824 if(v->pcm_returned==-1){ in vorbis_synthesis_blockin()
825 v->pcm_returned=thisCenter; in vorbis_synthesis_blockin()
826 v->pcm_current=thisCenter; in vorbis_synthesis_blockin()
828 v->pcm_returned=prevCenter; in vorbis_synthesis_blockin()
829 v->pcm_current=prevCenter+ in vorbis_synthesis_blockin()
830 ((ci->blocksizes[v->lW]/4+ in vorbis_synthesis_blockin()
831 ci->blocksizes[v->W]/4)>>hs); in vorbis_synthesis_blockin()
850 b->sample_count+=ci->blocksizes[v->lW]/4+ci->blocksizes[v->W]/4; in vorbis_synthesis_blockin()
853 if(v->granulepos==-1){ in vorbis_synthesis_blockin()
856 v->granulepos=vb->granulepos; in vorbis_synthesis_blockin()
859 if(b->sample_count>v->granulepos){ in vorbis_synthesis_blockin()
869 v->pcm_current-=(b->sample_count-v->granulepos)>>hs; in vorbis_synthesis_blockin()
872 v->pcm_returned+=(b->sample_count-v->granulepos)>>hs; in vorbis_synthesis_blockin()
873 if(v->pcm_returned>v->pcm_current) in vorbis_synthesis_blockin()
874 v->pcm_returned=v->pcm_current; in vorbis_synthesis_blockin()
881 v->granulepos+=ci->blocksizes[v->lW]/4+ci->blocksizes[v->W]/4; in vorbis_synthesis_blockin()
882 if(vb->granulepos!=-1 && v->granulepos!=vb->granulepos){ in vorbis_synthesis_blockin()
884 if(v->granulepos>vb->granulepos){ in vorbis_synthesis_blockin()
885 long extra=v->granulepos-vb->granulepos; in vorbis_synthesis_blockin()
890 v->pcm_current-=extra>>hs; in vorbis_synthesis_blockin()
895 v->granulepos=vb->granulepos; in vorbis_synthesis_blockin()
901 if(vb->eofflag)v->eofflag=1; in vorbis_synthesis_blockin()
907 int vorbis_synthesis_pcmout(vorbis_dsp_state *v,float ***pcm){ in vorbis_synthesis_pcmout() argument
908 vorbis_info *vi=v->vi; in vorbis_synthesis_pcmout()
910 if(v->pcm_returned>-1 && v->pcm_returned<v->pcm_current){ in vorbis_synthesis_pcmout()
914 v->pcmret[i]=v->pcm[i]+v->pcm_returned; in vorbis_synthesis_pcmout()
915 *pcm=v->pcmret; in vorbis_synthesis_pcmout()
917 return(v->pcm_current-v->pcm_returned); in vorbis_synthesis_pcmout()
922 int vorbis_synthesis_read(vorbis_dsp_state *v,int n){ in vorbis_synthesis_read() argument
923 if(n && v->pcm_returned+n>v->pcm_current)return(OV_EINVAL); in vorbis_synthesis_read()
924 v->pcm_returned+=n; in vorbis_synthesis_read()
933 int vorbis_synthesis_lapout(vorbis_dsp_state *v,float ***pcm){ in vorbis_synthesis_lapout() argument
934 vorbis_info *vi=v->vi; in vorbis_synthesis_lapout()
938 int n=ci->blocksizes[v->W]>>(hs+1); in vorbis_synthesis_lapout()
943 if(v->pcm_returned<0)return 0; in vorbis_synthesis_lapout()
955 if(v->centerW==n1){ in vorbis_synthesis_lapout()
959 float *p=v->pcm[j]; in vorbis_synthesis_lapout()
967 v->pcm_current-=n1; in vorbis_synthesis_lapout()
968 v->pcm_returned-=n1; in vorbis_synthesis_lapout()
969 v->centerW=0; in vorbis_synthesis_lapout()
973 if((v->lW^v->W)==1){ in vorbis_synthesis_lapout()
976 float *s=v->pcm[j]; in vorbis_synthesis_lapout()
977 float *d=v->pcm[j]+(n1-n0)/2; in vorbis_synthesis_lapout()
981 v->pcm_returned+=(n1-n0)/2; in vorbis_synthesis_lapout()
982 v->pcm_current+=(n1-n0)/2; in vorbis_synthesis_lapout()
984 if(v->lW==0){ in vorbis_synthesis_lapout()
987 float *s=v->pcm[j]; in vorbis_synthesis_lapout()
988 float *d=v->pcm[j]+n1-n0; in vorbis_synthesis_lapout()
992 v->pcm_returned+=n1-n0; in vorbis_synthesis_lapout()
993 v->pcm_current+=n1-n0; in vorbis_synthesis_lapout()
1000 v->pcmret[i]=v->pcm[i]+v->pcm_returned; in vorbis_synthesis_lapout()
1001 *pcm=v->pcmret; in vorbis_synthesis_lapout()
1004 return(n1+n-v->pcm_returned); in vorbis_synthesis_lapout()
1008 float *vorbis_window(vorbis_dsp_state *v,int W){ in vorbis_window() argument
1009 vorbis_info *vi=v->vi; in vorbis_window()
1012 private_state *b=v->backend_state; in vorbis_window()