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

Monty xiphmont at xiph.org
Fri Nov 23 23:16:40 PST 2001



xiphmont    01/11/23 23:16:40

  Modified:    include/vorbis Tag: branch_monty_20011009 codec.h
                        vorbisfile.h
               lib      Tag: branch_monty_20011009 info.c mapping0.c
                        vorbisfile.c
  Log:
  commit a number of Tim Janik suggestions to the API.

Revision  Changes    Path
No                   revision

No                   revision

1.38.6.2  +2 -1      vorbis/include/vorbis/codec.h

Index: codec.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis/include/vorbis/codec.h,v
retrieving revision 1.38.6.1
retrieving revision 1.38.6.2
diff -u -r1.38.6.1 -r1.38.6.2
--- codec.h	2001/11/22 06:21:06	1.38.6.1
+++ codec.h	2001/11/24 07:16:37	1.38.6.2
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: libvorbis codec headers
- last mod: $Id: codec.h,v 1.38.6.1 2001/11/22 06:21:06 xiphmont Exp $
+ last mod: $Id: codec.h,v 1.38.6.2 2001/11/24 07:16:37 xiphmont Exp $
 
  ********************************************************************/
 
@@ -164,6 +164,7 @@
 
 extern void     vorbis_info_init(vorbis_info *vi);
 extern void     vorbis_info_clear(vorbis_info *vi);
+extern int      vorbis_info_blocksize(vorbis_info *vi,int zo);
 extern void     vorbis_comment_init(vorbis_comment *vc);
 extern void     vorbis_comment_add(vorbis_comment *vc, char *comment); 
 extern void     vorbis_comment_add_tag(vorbis_comment *vc, 

1.14.6.1  +3 -1      vorbis/include/vorbis/vorbisfile.h

Index: vorbisfile.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis/include/vorbis/vorbisfile.h,v
retrieving revision 1.14
retrieving revision 1.14.6.1
diff -u -r1.14 -r1.14.6.1
--- vorbisfile.h	2001/05/27 06:43:59	1.14
+++ vorbisfile.h	2001/11/24 07:16:37	1.14.6.1
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: stdio-based convenience library for opening/seeking/decoding
- last mod: $Id: vorbisfile.h,v 1.14 2001/05/27 06:43:59 xiphmont Exp $
+ last mod: $Id: vorbisfile.h,v 1.14.6.1 2001/11/24 07:16:37 xiphmont Exp $
 
  ********************************************************************/
 
@@ -117,6 +117,8 @@
 extern vorbis_info *ov_info(OggVorbis_File *vf,int link);
 extern vorbis_comment *ov_comment(OggVorbis_File *vf,int link);
 
+extern long ov_read_float(OggVorbis_File *vf,float ***pcm_channels,
+			  int *bitstream);
 extern long ov_read(OggVorbis_File *vf,char *buffer,int length,
                     int bigendianp,int word,int sgned,int *bitstream);
 

No                   revision

No                   revision

1.46.2.2  +8 -1      vorbis/lib/info.c

Index: info.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/info.c,v
retrieving revision 1.46.2.1
retrieving revision 1.46.2.2
diff -u -r1.46.2.1 -r1.46.2.2
--- info.c	2001/10/11 15:41:44	1.46.2.1
+++ info.c	2001/11/24 07:16:38	1.46.2.2
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: maintain the info structure, info <-> header packets
- last mod: $Id: info.c,v 1.46.2.1 2001/10/11 15:41:44 xiphmont Exp $
+ last mod: $Id: info.c,v 1.46.2.2 2001/11/24 07:16:38 xiphmont Exp $
 
  ********************************************************************/
 
@@ -134,6 +134,13 @@
     if(vc->vendor)_ogg_free(vc->vendor);
   }
   memset(vc,0,sizeof(*vc));
+}
+
+/* blocksize 0 is guaranteed to be short, 1 is guarantted to be long.
+   They may be equal, but short will never ge greater than long */
+int vorbis_info_blocksize(vorbis_info *vi,int zo){
+  codec_setup_info *ci = vi->codec_setup;
+  return ci ? ci->blocksizes[zo] : -1;
 }
 
 /* used by synthesis, which has a full, alloced vi */

1.37.2.10 +1 -2      vorbis/lib/mapping0.c

Index: mapping0.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/mapping0.c,v
retrieving revision 1.37.2.9
retrieving revision 1.37.2.10
diff -u -r1.37.2.9 -r1.37.2.10
--- mapping0.c	2001/11/24 05:26:10	1.37.2.9
+++ mapping0.c	2001/11/24 07:16:38	1.37.2.10
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: channel mapping 0 implementation
- last mod: $Id: mapping0.c,v 1.37.2.9 2001/11/24 05:26:10 xiphmont Exp $
+ last mod: $Id: mapping0.c,v 1.37.2.10 2001/11/24 07:16:38 xiphmont Exp $
 
  ********************************************************************/
 
@@ -287,7 +287,6 @@
   vorbis_dsp_state      *vd=vb->vd;
   vorbis_info           *vi=vd->vi;
   codec_setup_info      *ci=vi->codec_setup;
-  bitrate_manager_info  *bi=ci->bi;
   backend_lookup_state  *b=vb->vd->backend_state;
   bitrate_manager_state *bm=&b->bms;
   vorbis_look_mapping0  *look=(vorbis_look_mapping0 *)l;

1.50.2.1  +115 -97   vorbis/lib/vorbisfile.c

Index: vorbisfile.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/vorbisfile.c,v
retrieving revision 1.50
retrieving revision 1.50.2.1
diff -u -r1.50 -r1.50.2.1
--- vorbisfile.c	2001/10/02 00:14:32	1.50
+++ vorbisfile.c	2001/11/24 07:16:38	1.50.2.1
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: stdio-based convenience library for opening/seeking/decoding
- last mod: $Id: vorbisfile.c,v 1.50 2001/10/02 00:14:32 segher Exp $
+ last mod: $Id: vorbisfile.c,v 1.50.2.1 2001/11/24 07:16:38 xiphmont Exp $
 
  ********************************************************************/
 
@@ -1119,7 +1119,6 @@
 int ov_pcm_seek(OggVorbis_File *vf,ogg_int64_t pos){
   int thisblock,lastblock=0;
   int ret=ov_pcm_seek_page(vf,pos);
-  codec_setup_info *ci=vf->vi->codec_setup;
   if(ret<0)return(ret);
 
   /* discard leading packets we don't need for the lapping of the
@@ -1134,7 +1133,8 @@
       thisblock=vorbis_packet_blocksize(vf->vi+vf->current_link,&op);
       if(lastblock)vf->pcm_offset+=(lastblock+thisblock)>>2;
 
-      if(vf->pcm_offset+((thisblock+ci->blocksizes[1])>>2)>=pos)break;
+      if(vf->pcm_offset+((thisblock+
+			  vorbis_info_blocksize(vf->vi,1))>>2)>=pos)break;
 
       ogg_stream_packetout(&vf->os,NULL);
       
@@ -1368,10 +1368,7 @@
 
             *section) set to the logical bitstream number */
 
-long ov_read(OggVorbis_File *vf,char *buffer,int length,
-		    int bigendianp,int word,int sgned,int *bitstream){
-  int i,j;
-  int host_endian = host_is_big_endian();
+long ov_read_float(OggVorbis_File *vf,float ***pcm_channels,int *bitstream){
 
   if(vf->ready_state<OPENED)return(OV_EINVAL);
 
@@ -1380,100 +1377,13 @@
       float **pcm;
       long samples=vorbis_synthesis_pcmout(&vf->vd,&pcm);
       if(samples){
-	/* yay! proceed to pack data into the byte buffer */
-
-	long channels=ov_info(vf,-1)->channels;
-	long bytespersample=word * channels;
-	vorbis_fpu_control fpu;
-	if(samples>length/bytespersample)samples=length/bytespersample;
-	
-	/* a tight loop to pack each size */
-	{
-	  int val;
-	  if(word==1){
-	    int off=(sgned?0:128);
-	    vorbis_fpu_setround(&fpu);
-	    for(j=0;j<samples;j++)
-	      for(i=0;i<channels;i++){
-		val=vorbis_ftoi(pcm[i][j]*128.f);
-		if(val>127)val=127;
-		else if(val<-128)val=-128;
-		*buffer++=val+off;
-	      }
-	    vorbis_fpu_restore(fpu);
-	  }else{
-	    int off=(sgned?0:32768);
-
-	    if(host_endian==bigendianp){
-	      if(sgned){
-
-		vorbis_fpu_setround(&fpu);
-		for(i=0;i<channels;i++) { /* It's faster in this order */
-		  float *src=pcm[i];
-		  short *dest=((short *)buffer)+i;
-		  for(j=0;j<samples;j++) {
-		    val=vorbis_ftoi(src[j]*32768.f);
-		    if(val>32767)val=32767;
-		    else if(val<-32768)val=-32768;
-		    *dest=val;
-		    dest+=channels;
-		  }
-		}
-		vorbis_fpu_restore(fpu);
 
-	      }else{
-
-		vorbis_fpu_setround(&fpu);
-		for(i=0;i<channels;i++) {
-		  float *src=pcm[i];
-		  short *dest=((short *)buffer)+i;
-		  for(j=0;j<samples;j++) {
-		    val=vorbis_ftoi(src[j]*32768.f);
-		    if(val>32767)val=32767;
-		    else if(val<-32768)val=-32768;
-		    *dest=val+off;
-		    dest+=channels;
-		  }
-		}
-		vorbis_fpu_restore(fpu);
-
-	      }
-	    }else if(bigendianp){
-
-	      vorbis_fpu_setround(&fpu);
-	      for(j=0;j<samples;j++)
-		for(i=0;i<channels;i++){
-		  val=vorbis_ftoi(pcm[i][j]*32768.f);
-		  if(val>32767)val=32767;
-		  else if(val<-32768)val=-32768;
-		  val+=off;
-		  *buffer++=(val>>8);
-		  *buffer++=(val&0xff);
-		}
-	      vorbis_fpu_restore(fpu);
-
-	    }else{
-	      int val;
-	      vorbis_fpu_setround(&fpu);
-	      for(j=0;j<samples;j++)
-	 	for(i=0;i<channels;i++){
-		  val=vorbis_ftoi(pcm[i][j]*32768.f);
-		  if(val>32767)val=32767;
-		  else if(val<-32768)val=-32768;
-		  val+=off;
-		  *buffer++=(val&0xff);
-		  *buffer++=(val>>8);
-	  	}
-	      vorbis_fpu_restore(fpu);  
-
-	    }
-	  }
-	}
-	
+	if(pcm_channels)*pcm_channels=pcm;
         vorbis_synthesis_read(&vf->vd,samples);
         vf->pcm_offset+=samples;
         if(bitstream)*bitstream=vf->current_link;
-	return(samples*bytespersample);
+	return samples;
+
       }
     }
 
@@ -1484,6 +1394,114 @@
       if(ret<=0)return(ret);
     }
 
+  }
+}
+
+long ov_read(OggVorbis_File *vf,char *buffer,int length,
+		    int bigendianp,int word,int sgned,int *bitstream){
+  int i,j;
+  int host_endian = host_is_big_endian();
+
+  float **pcm;
+  long samples=ov_read_float(vf,&pcm,bitstream);
+  if(samples>0){
+  
+    /* yay! proceed to pack data into the byte buffer */
+    
+    long channels=ov_info(vf,-1)->channels;
+    long bytespersample=word * channels;
+    vorbis_fpu_control fpu;
+    if(samples>length/bytespersample)samples=length/bytespersample;
+    
+    /* a tight loop to pack each size */
+    {
+      int val;
+      if(word==1){
+	int off=(sgned?0:128);
+	vorbis_fpu_setround(&fpu);
+	for(j=0;j<samples;j++)
+	  for(i=0;i<channels;i++){
+	    val=vorbis_ftoi(pcm[i][j]*128.f);
+	    if(val>127)val=127;
+	    else if(val<-128)val=-128;
+	    *buffer++=val+off;
+	  }
+	vorbis_fpu_restore(fpu);
+      }else{
+	int off=(sgned?0:32768);
+	
+	if(host_endian==bigendianp){
+	  if(sgned){
+	    
+	    vorbis_fpu_setround(&fpu);
+	    for(i=0;i<channels;i++) { /* It's faster in this order */
+	      float *src=pcm[i];
+	      short *dest=((short *)buffer)+i;
+	      for(j=0;j<samples;j++) {
+		val=vorbis_ftoi(src[j]*32768.f);
+		if(val>32767)val=32767;
+		else if(val<-32768)val=-32768;
+		*dest=val;
+		dest+=channels;
+	      }
+	    }
+	    vorbis_fpu_restore(fpu);
+	    
+	  }else{
+	    
+	    vorbis_fpu_setround(&fpu);
+	    for(i=0;i<channels;i++) {
+	      float *src=pcm[i];
+	      short *dest=((short *)buffer)+i;
+	      for(j=0;j<samples;j++) {
+		val=vorbis_ftoi(src[j]*32768.f);
+		if(val>32767)val=32767;
+		else if(val<-32768)val=-32768;
+		*dest=val+off;
+		dest+=channels;
+	      }
+	    }
+	    vorbis_fpu_restore(fpu);
+	    
+	  }
+	}else if(bigendianp){
+	  
+	  vorbis_fpu_setround(&fpu);
+	  for(j=0;j<samples;j++)
+	    for(i=0;i<channels;i++){
+	      val=vorbis_ftoi(pcm[i][j]*32768.f);
+	      if(val>32767)val=32767;
+	      else if(val<-32768)val=-32768;
+	      val+=off;
+	      *buffer++=(val>>8);
+	      *buffer++=(val&0xff);
+	    }
+	  vorbis_fpu_restore(fpu);
+	  
+	}else{
+	  int val;
+	  vorbis_fpu_setround(&fpu);
+	  for(j=0;j<samples;j++)
+	    for(i=0;i<channels;i++){
+	      val=vorbis_ftoi(pcm[i][j]*32768.f);
+	      if(val>32767)val=32767;
+	      else if(val<-32768)val=-32768;
+	      val+=off;
+	      *buffer++=(val&0xff);
+	      *buffer++=(val>>8);
+	  	}
+	  vorbis_fpu_restore(fpu);  
+	  
+	}
+      }
+    }
+    
+    vorbis_synthesis_read(&vf->vd,samples);
+    vf->pcm_offset+=samples;
+    if(bitstream)*bitstream=vf->current_link;
+    return(samples*bytespersample);
+  }else{
+    return(samples);
   }
 }
 

--- >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