[xiph-cvs] cvs commit: Tremor block.c info.c ivorbiscodec.h ivorbisfile.h vorbisfile.c

Monty xiphmont at xiph.org
Sun Apr 13 23:40:51 PDT 2003



xiphmont    03/04/14 02:40:51

  Modified:    .        Tag: lowmem-branch block.c info.c ivorbiscodec.h
                        ivorbisfile.h vorbisfile.c
  Log:
  Hide internal decode structures from vorbisfile structure; gives a
  better shot at binary compat from release to release.

Revision  Changes    Path
No                   revision

<p>No                   revision

<p>1.4.2.5   +29 -28    Tremor/block.c

Index: block.c
===================================================================
RCS file: /usr/local/cvsroot/Tremor/block.c,v
retrieving revision 1.4.2.4
retrieving revision 1.4.2.5
diff -u -r1.4.2.4 -r1.4.2.5
--- block.c	14 Apr 2003 01:13:44 -0000	1.4.2.4
+++ block.c	14 Apr 2003 06:40:51 -0000	1.4.2.5
@@ -67,13 +67,13 @@
 #define WORD_ALIGN 8
 #endif
 
-int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb){
-  memset(vb,0,sizeof(*vb));
+vorbis_block *vorbis_block_create(vorbis_dsp_state *v){
+  vorbis_block *vb=_ogg_calloc(1,sizeof(*vb));
   vb->vd=v;
   vb->localalloc=0;
   vb->localstore=NULL;
   
-  return(0);
+  return vb;
 }
 
 void *_vorbis_block_alloc(vorbis_block *vb,long bytes){
@@ -122,12 +122,11 @@
   vb->reap=NULL;
 }
 
-int vorbis_block_clear(vorbis_block *vb){
+int vorbis_block_destroy(vorbis_block *vb){
   _vorbis_block_ripcord(vb);
   if(vb->localstore)_ogg_free(vb->localstore);
-
-  memset(vb,0,sizeof(*vb));
-  return(0);
+  _ogg_free(vb);
+  return 0;
 }
 
 static int _vds_init(vorbis_dsp_state *v,vorbis_info *vi){
@@ -152,32 +151,34 @@
 }
 
 int vorbis_synthesis_restart(vorbis_dsp_state *v){
-  vorbis_info *vi=v->vi;
-  codec_setup_info *ci;
-
-  if(!vi)return -1;
-  ci=vi->codec_setup;
-  if(!ci)return -1;
-
-  v->centerW=ci->blocksizes[1]/2;
-  v->pcm_current=v->centerW;
-  
-  v->pcm_returned=-1;
-  v->granulepos=-1;
-  v->sequence=-1;
-  v->sample_count=-1;
-
-  return(0);
+  if(!v)return -1;
+  {
+    vorbis_info *vi=v->vi;
+    codec_setup_info *ci;
+    
+    if(!vi)return -1;
+    ci=vi->codec_setup;
+    if(!ci)return -1;
+    
+    v->centerW=ci->blocksizes[1]/2;
+    v->pcm_current=v->centerW;
+    
+    v->pcm_returned=-1;
+    v->granulepos=-1;
+    v->sequence=-1;
+    v->sample_count=-1;
+  }
+  return 0;
 }
 
-int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi){
+vorbis_dsp_state *vorbis_dsp_create(vorbis_info *vi){
+  vorbis_dsp_state *v=_ogg_calloc(1,sizeof(*v));
   _vds_init(v,vi);
   vorbis_synthesis_restart(v);
-
-  return(0);
+  return v;
 }
 
-void vorbis_dsp_clear(vorbis_dsp_state *v){
+void vorbis_dsp_destroy(vorbis_dsp_state *v){
   int i;
   if(v){
     vorbis_info *vi=v->vi;
@@ -190,7 +191,7 @@
       if(v->pcmret)_ogg_free(v->pcmret);
     }
 
-    memset(v,0,sizeof(*v));
+    _ogg_free(v);
   }
 }
 

<p><p>1.3.2.5   +1 -2      Tremor/info.c

Index: info.c
===================================================================
RCS file: /usr/local/cvsroot/Tremor/info.c,v
retrieving revision 1.3.2.4
retrieving revision 1.3.2.5
diff -u -r1.3.2.4 -r1.3.2.5
--- info.c	14 Apr 2003 01:13:44 -0000	1.3.2.4
+++ info.c	14 Apr 2003 06:40:51 -0000	1.3.2.5
@@ -222,8 +222,7 @@
 
   /* codebooks */
   ci->books=oggpack_read(opb,8)+1;
-  ci->book_param=(codebook *)
-    _ogg_calloc(ci->books,sizeof(*ci->book_param));
+  ci->book_param=(codebook *)_ogg_calloc(ci->books,sizeof(*ci->book_param));
   for(i=0;i<ci->books;i++)
     if(vorbis_book_unpack(opb,ci->book_param+i))goto err_out;
 

<p><p>1.3.2.2   +5 -4      Tremor/ivorbiscodec.h

Index: ivorbiscodec.h
===================================================================
RCS file: /usr/local/cvsroot/Tremor/ivorbiscodec.h,v
retrieving revision 1.3.2.1
retrieving revision 1.3.2.2
diff -u -r1.3.2.1 -r1.3.2.2
--- ivorbiscodec.h	14 Apr 2003 01:13:44 -0000	1.3.2.1
+++ ivorbiscodec.h	14 Apr 2003 06:40:51 -0000	1.3.2.2
@@ -156,15 +156,16 @@
 extern int      vorbis_comment_query_count(vorbis_comment *vc, char *tag);
 extern void     vorbis_comment_clear(vorbis_comment *vc);
 
-extern int      vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb);
-extern int      vorbis_block_clear(vorbis_block *vb);
-extern void     vorbis_dsp_clear(vorbis_dsp_state *v);
+extern vorbis_block *vorbis_block_create(vorbis_dsp_state *v);
+extern int      vorbis_block_destroy(vorbis_block *vb);
+
+extern vorbis_dsp_state *vorbis_dsp_create(vorbis_info *vi);
+extern void     vorbis_dsp_destroy(vorbis_dsp_state *v);
 
 /* Vorbis PRIMITIVES: synthesis layer *******************************/
 extern int      vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc,
                                           ogg_packet *op);
 
-extern int      vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi);
 extern int      vorbis_synthesis_restart(vorbis_dsp_state *v);
 extern int      vorbis_synthesis(vorbis_block *vb,ogg_packet *op,int decodep);
 extern int      vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb);

<p><p>1.3.2.1   +2 -2      Tremor/ivorbisfile.h

Index: ivorbisfile.h
===================================================================
RCS file: /usr/local/cvsroot/Tremor/ivorbisfile.h,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -r1.3 -r1.3.2.1
--- ivorbisfile.h	29 Mar 2003 03:07:21 -0000	1.3
+++ ivorbisfile.h	14 Apr 2003 06:40:51 -0000	1.3.2.1
@@ -78,8 +78,8 @@
 
   ogg_stream_state *os; /* take physical pages, weld into a logical
                           stream of packets */
-  vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */
-  vorbis_block     vb; /* local working space for packet->PCM decode */
+  vorbis_dsp_state *vd; /* central working state for the packet->PCM decoder */
+  vorbis_block     *vb; /* local working space for packet->PCM decode */
 
   ov_callbacks callbacks;
 

<p><p>1.6.2.2   +25 -21    Tremor/vorbisfile.c

Index: vorbisfile.c
===================================================================
RCS file: /usr/local/cvsroot/Tremor/vorbisfile.c,v
retrieving revision 1.6.2.1
retrieving revision 1.6.2.2
diff -u -r1.6.2.1 -r1.6.2.2
--- vorbisfile.c	9 Apr 2003 09:43:49 -0000	1.6.2.1
+++ vorbisfile.c	14 Apr 2003 06:40:51 -0000	1.6.2.2
@@ -12,7 +12,7 @@
  ********************************************************************
 
  function: stdio-based convenience library for opening/seeking/decoding
- last mod: $Id: vorbisfile.c,v 1.6.2.1 2003/04/09 09:43:49 xiphmont Exp $
+ last mod: $Id: vorbisfile.c,v 1.6.2.2 2003/04/14 06:40:51 xiphmont Exp $
 
  ********************************************************************/
 
@@ -409,11 +409,11 @@
 static void _make_decode_ready(OggVorbis_File *vf){
   if(vf->ready_state!=STREAMSET)return;
   if(vf->seekable){
-    vorbis_synthesis_init(&vf->vd,vf->vi+vf->current_link);
+    vf->vd=vorbis_dsp_create(vf->vi+vf->current_link);
   }else{
-    vorbis_synthesis_init(&vf->vd,vf->vi);
+    vf->vd=vorbis_dsp_create(vf->vi);
   }    
-  vorbis_block_init(&vf->vd,&vf->vb);
+  vf->vb=vorbis_block_create(vf->vd);
   vf->ready_state=INITSET;
   vf->bittrack=0;
   vf->samptrack=0;
@@ -461,8 +461,10 @@
 
 /* clear out the current logical bitstream decoder */ 
 static void _decode_clear(OggVorbis_File *vf){
-  vorbis_dsp_clear(&vf->vd);
-  vorbis_block_clear(&vf->vb);
+  vorbis_dsp_destroy(vf->vd);
+  vorbis_block_destroy(vf->vb);
+  vf->vd=0;
+  vf->vb=0;
   vf->ready_state=OPENED;
 }
 
@@ -502,7 +504,7 @@
         if(result>0){
           /* got a packet.  process it */
           granulepos=op.granulepos;
-	  if(!vorbis_synthesis(&vf->vb,&op,1)){ /* lazy check for lazy
+	  if(!vorbis_synthesis(vf->vb,&op,1)){ /* lazy check for lazy
                                                       header handling.  The
                                                       header packets aren't
                                                       audio, so if/when we
@@ -512,7 +514,7 @@
 
             /* suck in the synthesis data and track bitrate */
             {
-	      int oldsamples=vorbis_synthesis_pcmout(&vf->vd,NULL);
+	      int oldsamples=vorbis_synthesis_pcmout(vf->vd,NULL);
               /* for proper use of libvorbis within libvorbisfile,
                  oldsamples will always be zero. */
               if(oldsamples){
@@ -520,8 +522,8 @@
                 goto cleanup;
               }
 
-	      vorbis_synthesis_blockin(&vf->vd,&vf->vb);
-	      vf->samptrack+=vorbis_synthesis_pcmout(&vf->vd,NULL)-oldsamples;
+	      vorbis_synthesis_blockin(vf->vd,vf->vb);
+	      vf->samptrack+=vorbis_synthesis_pcmout(vf->vd,NULL)-oldsamples;
               vf->bittrack+=op.bytes*8;
             }
           
@@ -550,7 +552,7 @@
                                                here unless the stream
                                                is very broken */
 
-	      samples=vorbis_synthesis_pcmout(&vf->vd,NULL);
+	      samples=vorbis_synthesis_pcmout(vf->vd,NULL);
             
               granulepos-=samples;
               for(i=0;i<link;i++)
@@ -726,8 +728,10 @@
 /* clear out the OggVorbis_File struct */
 int ov_clear(OggVorbis_File *vf){
   if(vf){
-    vorbis_block_clear(&vf->vb);
-    vorbis_dsp_clear(&vf->vd);
+    vorbis_block_destroy(vf->vb);
+    vorbis_dsp_destroy(vf->vd);
+    vf->vd=0;
+    vf->vb=0;
     ogg_stream_destroy(vf->os);
     
     if(vf->vi && vf->links){
@@ -970,7 +974,7 @@
   vf->pcm_offset=-1;
   ogg_stream_reset_serialno(vf->os,
                             vf->current_serialno); /* must set serialno */
-  vorbis_synthesis_restart(&vf->vd);
+  vorbis_synthesis_restart(vf->vd);
     
   _seek_helper(vf,pos);
 
@@ -1214,7 +1218,7 @@
         vf->ready_state=STREAMSET;
         
       }else{
-	vorbis_synthesis_restart(&vf->vd);
+	vorbis_synthesis_restart(vf->vd);
       }
 
       ogg_stream_reset_serialno(vf->os,vf->current_serialno);
@@ -1309,10 +1313,10 @@
       
       /* remove the packet from packet queue and track its granulepos */
       ogg_stream_packetout(vf->os,NULL);
-      vorbis_synthesis(&vf->vb,&op,0);  /* set up a vb with
+      vorbis_synthesis(vf->vb,&op,0);  /* set up a vb with
                                            only tracking, no
                                            pcm_decode */
-      vorbis_synthesis_blockin(&vf->vd,&vf->vb); 
+      vorbis_synthesis_blockin(vf->vd,vf->vb); 
       
       /* end of logical stream case is hard, especially with exact
          length positioning. */
@@ -1364,10 +1368,10 @@
      logical bitstream boundary with abandon is OK. */
   while(vf->pcm_offset<pos){
     ogg_int64_t target=pos-vf->pcm_offset;
-    long samples=vorbis_synthesis_pcmout(&vf->vd,NULL);
+    long samples=vorbis_synthesis_pcmout(vf->vd,NULL);
 
     if(samples>target)samples=target;
-    vorbis_synthesis_read(&vf->vd,samples);
+    vorbis_synthesis_read(vf->vd,samples);
     vf->pcm_offset+=samples;
     
     if(samples<target)
@@ -1549,7 +1553,7 @@
 
   while(1){
     if(vf->ready_state==INITSET){
-      samples=vorbis_synthesis_pcmout(&vf->vd,&pcm);
+      samples=vorbis_synthesis_pcmout(vf->vd,&pcm);
       if(samples)break;
     }
 
@@ -1587,7 +1591,7 @@
       }
     }
     
-    vorbis_synthesis_read(&vf->vd,samples);
+    vorbis_synthesis_read(vf->vd,samples);
     vf->pcm_offset+=samples;
     if(bitstream)*bitstream=vf->current_link;
     return(samples*2*channels);

<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