[xiph-cvs] cvs commit: vorbis/lib block.c vorbisfile.c

Monty xiphmont at xiph.org
Tue Aug 26 22:29:25 PDT 2003



xiphmont    03/08/27 01:29:24

  Modified:    lib      block.c vorbisfile.c
  Log:
  Several more halfrate fixes:
  
  1) crosslapping was using the wrong windowsizes (fullrate for
  halfrate) for overlap; this would usually still work fine, so the bug
  went unnoticed.
  
  2) fixed a segfault from multiple lapped seeks happening with no
  decode happening between.

Revision  Changes    Path
1.74      +7 -2      vorbis/lib/block.c

Index: block.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/block.c,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -r1.73 -r1.74
--- block.c	18 Aug 2003 05:34:01 -0000	1.73
+++ block.c	27 Aug 2003 05:29:24 -0000	1.74
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: PCM data vector blocking, windowing and dis/reassembly
- last mod: $Id: block.c,v 1.73 2003/08/18 05:34:01 xiphmont Exp $
+ last mod: $Id: block.c,v 1.74 2003/08/27 05:29:24 xiphmont Exp $
 
  Handle windowing, overlap-add, etc of the PCM vectors.  This is made
  more amusing by Vorbis' current two allowed block sizes.
@@ -957,7 +957,12 @@
 }
 
 float *vorbis_window(vorbis_dsp_state *v,int W){
+  vorbis_info *vi=v->vi;
+  codec_setup_info *ci=vi->codec_setup;
+  int hs=ci->halfrate_flag; 
   private_state *b=v->backend_state;
-  return _vorbis_window_get(b->window[W]);
+
+  if(b->window[W]-1<0)return NULL;
+  return _vorbis_window_get(b->window[W]-hs);
 }
         

<p><p>1.71      +32 -17    vorbis/lib/vorbisfile.c

Index: vorbisfile.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/vorbisfile.c,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -r1.70 -r1.71
--- vorbisfile.c	18 Aug 2003 05:34:01 -0000	1.70
+++ vorbisfile.c	27 Aug 2003 05:29:24 -0000	1.71
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: stdio-based convenience library for opening/seeking/decoding
- last mod: $Id: vorbisfile.c,v 1.70 2003/08/18 05:34:01 xiphmont Exp $
+ last mod: $Id: vorbisfile.c,v 1.71 2003/08/27 05:29:24 xiphmont Exp $
 
  ********************************************************************/
 
@@ -1691,6 +1691,8 @@
 }
 
 extern float *vorbis_window(vorbis_dsp_state *v,int W);
+extern void _analysis_output_always(char *base,int i,float *v,int n,int bark,int dB,
+			     ogg_int64_t off);
 
 static void _ov_splice(float **pcm,float **lappcm,
                        int n1, int n2,
@@ -1709,6 +1711,7 @@
   for(j=0;j<ch1 && j<ch2;j++){
     float *s=lappcm[j];
     float *d=pcm[j];
+
     for(i=0;i<n;i++){
       float wd=w[i]*w[i];
       float ws=1.-wd;
@@ -1723,6 +1726,7 @@
       d[i]=d[i]*wd;
     }
   }
+
 }
                 
 /* make sure vf is INITSET */
@@ -1784,11 +1788,16 @@
        postextrapolation buffering, or the second half of the MDCT
        from the last packet */
     int samples=vorbis_synthesis_lapout(&vf->vd,&pcm);
-    if(samples>lapsize-lapcount)samples=lapsize-lapcount;
-    for(i=0;i<vi->channels;i++)
-      memcpy(lappcm[i]+lapcount,pcm[i],sizeof(**pcm)*samples);
-    lapcount+=samples;
-
+    if(samples==0){
+      for(i=0;i<vi->channels;i++)
+	memset(lappcm[i]+lapcount,0,sizeof(**pcm)*lapsize-lapcount);
+      lapcount=lapsize;
+    }else{
+      if(samples>lapsize-lapcount)samples=lapsize-lapcount;
+      for(i=0;i<vi->channels;i++)
+	memcpy(lappcm[i]+lapcount,pcm[i],sizeof(**pcm)*samples);
+      lapcount+=samples;
+    }
   }
 }
 
@@ -1799,7 +1808,7 @@
   float **lappcm;
   float **pcm;
   float *w1,*w2;
-  int n1,n2,i,ret;
+  int n1,n2,i,ret,hs1,hs2;
 
   if(vf1==vf2)return(0); /* degenerate case */
   if(vf1->ready_state<OPENED)return(OV_EINVAL);
@@ -1816,10 +1825,12 @@
 
   vi1=ov_info(vf1,-1);
   vi2=ov_info(vf2,-1);
-  
+  hs1=ov_halfrate_p(vf1);
+  hs2=ov_halfrate_p(vf2);
+
   lappcm=alloca(sizeof(*lappcm)*vi1->channels);
-  n1=vorbis_info_blocksize(vi1,0)/2;
-  n2=vorbis_info_blocksize(vi2,0)/2;
+  n1=vorbis_info_blocksize(vi1,0)>>(1+hs1);
+  n2=vorbis_info_blocksize(vi2,0)>>(1+hs2);
   w1=vorbis_window(&vf1->vd,0);
   w2=vorbis_window(&vf2->vd,0);
 
@@ -1832,6 +1843,8 @@
      buffer of vf2 */
   /* consolidate and expose the buffer. */
   vorbis_synthesis_lapout(&vf2->vd,&pcm);
+  _analysis_output_always("pcmL",0,pcm[0],n1*2,0,0,0);
+  _analysis_output_always("pcmR",0,pcm[1],n1*2,0,0,0);
 
   /* splice */
   _ov_splice(pcm,lappcm,n1,n2,vi1->channels,vi2->channels,w1,w2);
@@ -1846,16 +1859,17 @@
   float **lappcm;
   float **pcm;
   float *w1,*w2;
-  int n1,n2,ch1,ch2;
+  int n1,n2,ch1,ch2,hs;
   int i,ret;
 
   if(vf->ready_state<OPENED)return(OV_EINVAL);
   ret=_ov_initset(vf);
   if(ret)return(ret);
   vi=ov_info(vf,-1);
+  hs=ov_halfrate_p(vf);
   
   ch1=vi->channels;
-  n1=vorbis_info_blocksize(vi,0)/2;
+  n1=vorbis_info_blocksize(vi,0)>>(1+hs);
   w1=vorbis_window(&vf->vd,0);  /* window arrays from libvorbis are
                                    persistent; even if the decode state
                                    from this link gets dumped, this
@@ -1875,7 +1889,7 @@
  /* Guard against cross-link changes; they're perfectly legal */
   vi=ov_info(vf,-1);
   ch2=vi->channels;
-  n2=vorbis_info_blocksize(vi,0)/2;
+  n2=vorbis_info_blocksize(vi,0)>>(1+hs);
   w2=vorbis_window(&vf->vd,0);
 
   /* consolidate and expose the buffer. */
@@ -1906,16 +1920,17 @@
   float **lappcm;
   float **pcm;
   float *w1,*w2;
-  int n1,n2,ch1,ch2;
+  int n1,n2,ch1,ch2,hs;
   int i,ret;
 
   if(vf->ready_state<OPENED)return(OV_EINVAL);
   ret=_ov_initset(vf);
   if(ret)return(ret);
   vi=ov_info(vf,-1);
-  
+  hs=ov_halfrate_p(vf);
+
   ch1=vi->channels;
-  n1=vorbis_info_blocksize(vi,0)/2;
+  n1=vorbis_info_blocksize(vi,0)>>(1+hs);
   w1=vorbis_window(&vf->vd,0);  /* window arrays from libvorbis are
                                    persistent; even if the decode state
                                    from this link gets dumped, this
@@ -1935,7 +1950,7 @@
  /* Guard against cross-link changes; they're perfectly legal */
   vi=ov_info(vf,-1);
   ch2=vi->channels;
-  n2=vorbis_info_blocksize(vi,0)/2;
+  n2=vorbis_info_blocksize(vi,0)>>(1+hs);
   w2=vorbis_window(&vf->vd,0);
 
   /* consolidate and expose the buffer. */

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list