[xiph-cvs] cvs commit: Tremor Makefile.am block.c codec_internal.h floor0.c floor1.c info.c ivorbiscodec.h mapping0.c synthesis.c registry.c window.c window.h

Monty xiphmont at xiph.org
Sun Apr 13 18:13:44 PDT 2003



xiphmont    03/04/13 21:13:44

  Modified:    .        Tag: lowmem-branch Makefile.am block.c
                        codec_internal.h floor0.c floor1.c info.c
                        ivorbiscodec.h mapping0.c synthesis.c
  Removed:     .        Tag: lowmem-branch registry.c window.c window.h
  Log:
  Kill a floor0 bug; need to repair _LOW_ACCURACY_ for floor0 next

Revision  Changes    Path
No                   revision

<p>No                   revision

<p>1.8.2.3   +3 -3      Tremor/Makefile.am

Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/Tremor/Makefile.am,v
retrieving revision 1.8.2.2
retrieving revision 1.8.2.3
diff -u -r1.8.2.2 -r1.8.2.3
--- Makefile.am	13 Apr 2003 09:03:09 -0000	1.8.2.2
+++ Makefile.am	14 Apr 2003 01:13:44 -0000	1.8.2.3
@@ -4,14 +4,14 @@
 
 lib_LTLIBRARIES = libvorbisidec.la
 
-libvorbisidec_la_SOURCES = mdct.c block.c window.c \
+libvorbisidec_la_SOURCES = mdct.c block.c \
                         synthesis.c info.c misc.c \
                         floor1.c floor0.c vorbisfile.c \
-                        res012.c mapping0.c registry.c codebook.c \
+                        res012.c mapping0.c codebook.c \
                         framing.c bitwise.c \
                         codebook.h misc.h mdct_lookup.h\
                         os.h mdct.h ivorbisfile.h lsp_lookup.h\
-                        registry.h window.h window_lookup.h\
+                        window_lookup.h\
                         codec_internal.h ogg.h \
                         asm_arm.h ivorbiscodec.h
 libvorbisidec_la_LDFLAGS = -version-info @V_LIB_CURRENT@:@V_LIB_REVISION@:@V_LIB_AGE@

<p><p>1.4.2.4   +9 -55     Tremor/block.c

Index: block.c
===================================================================
RCS file: /usr/local/cvsroot/Tremor/block.c,v
retrieving revision 1.4.2.3
retrieving revision 1.4.2.4
diff -u -r1.4.2.3 -r1.4.2.4
--- block.c	13 Apr 2003 09:03:09 -0000	1.4.2.3
+++ block.c	14 Apr 2003 01:13:44 -0000	1.4.2.4
@@ -21,20 +21,8 @@
 #include "ogg.h"
 #include "ivorbiscodec.h"
 #include "codec_internal.h"
-
-#include "window.h"
 #include "misc.h"
 
-static int ilog(unsigned int v){
-  int ret=0;
-  if(v)--v;
-  while(v){
-    ret++;
-    v>>=1;
-  }
-  return(ret);
-}
-
 /* pcm accumulator examples (not exhaustive):
 
  <-------------- lW ---------------->
@@ -145,17 +133,9 @@
 static int _vds_init(vorbis_dsp_state *v,vorbis_info *vi){
   int i;
   codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
-  private_state *b=NULL;
-
   memset(v,0,sizeof(*v));
-  b=(private_state *)(v->backend_state=_ogg_calloc(1,sizeof(*b)));
 
   v->vi=vi;
-  b->modebits=ilog(ci->modes);
-
-  /* Vorbis I uses only window type 0 */
-  b->window[0]=_vorbis_window(0,ci->blocksizes[0]/2);
-  b->window[1]=_vorbis_window(0,ci->blocksizes[1]/2);
 
   v->pcm_storage=ci->blocksizes[1];
   v->pcm=(ogg_int32_t **)_ogg_malloc(vi->channels*sizeof(*v->pcm));
@@ -168,13 +148,6 @@
   v->lW=0; /* previous window size */
   v->W=0;  /* current window size */
 
-  /* initialize all the mapping/backend lookups */
-  b->mode=(vorbis_look_mapping **)_ogg_calloc(ci->modes,sizeof(*b->mode));
-  for(i=0;i<ci->modes;i++){
-    int mapnum=ci->mode_param[i].mapping;
-    b->mode[i]=_mapping_P[0]->look(v,ci->mode_param+i,
-				   ci->map_param[mapnum]);
-  }
   return(0);
 }
 
@@ -182,7 +155,6 @@
   vorbis_info *vi=v->vi;
   codec_setup_info *ci;
 
-  if(!v->backend_state)return -1;
   if(!vi)return -1;
   ci=vi->codec_setup;
   if(!ci)return -1;
@@ -193,7 +165,7 @@
   v->pcm_returned=-1;
   v->granulepos=-1;
   v->sequence=-1;
-  ((private_state *)(v->backend_state))->sample_count=-1;
+  v->sample_count=-1;
 
   return(0);
 }
@@ -210,7 +182,6 @@
   if(v){
     vorbis_info *vi=v->vi;
     codec_setup_info *ci=(codec_setup_info *)(vi?vi->codec_setup:NULL);
-    private_state *b=(private_state *)v->backend_state;
 
     if(v->pcm){
       for(i=0;i<vi->channels;i++)
@@ -219,19 +190,6 @@
       if(v->pcmret)_ogg_free(v->pcmret);
     }
 
-    /* free mode lookups; these are actually vorbis_look_mapping structs */
-    if(ci){
-      for(i=0;i<ci->modes;i++){
-	int mapnum=ci->mode_param[i].mapping;
-	if(b && b->mode)_mapping_P[0]->free_look(b->mode[i]);
-      }
-    }
-
-    if(b){
-      if(b->mode)_ogg_free(b->mode);    
-      _ogg_free(b);
-    }
-    
     memset(v,0,sizeof(*v));
   }
 }
@@ -243,7 +201,6 @@
 int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){
   vorbis_info *vi=v->vi;
   codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
-  private_state *b=v->backend_state;
   int i,j;
 
   if(v->pcm_current>v->pcm_returned  && v->pcm_returned!=-1)return(OV_EINVAL);
@@ -255,7 +212,7 @@
   if((v->sequence==-1)||
      (v->sequence+1 != vb->sequence)){
     v->granulepos=-1; /* out of sequence; lose count */
-    b->sample_count=-1;
+    v->sample_count=-1;
   }
 
   v->sequence=vb->sequence;
@@ -358,10 +315,10 @@
      is.  For this reason, vorbisfile will always try to make sure
      it reads the last two marked pages in proper sequence */
   
-  if(b->sample_count==-1){
-    b->sample_count=0;
+  if(v->sample_count==-1){
+    v->sample_count=0;
   }else{
-    b->sample_count+=ci->blocksizes[v->lW]/4+ci->blocksizes[v->W]/4;
+    v->sample_count+=ci->blocksizes[v->lW]/4+ci->blocksizes[v->W]/4;
   }
     
   if(v->granulepos==-1){
@@ -370,7 +327,7 @@
       v->granulepos=vb->granulepos;
       
       /* is this a short page? */
-      if(b->sample_count>v->granulepos){
+      if(v->sample_count>v->granulepos){
         /* corner case; if this is both the first and last audio page,
            then spec says the end is cut, not beginning */
         if(vb->eofflag){
@@ -380,10 +337,10 @@
           /* granulepos could be -1 due to a seek, but that would result
              in a long coun`t, not short count */
           
-	  v->pcm_current-=(b->sample_count-v->granulepos);
+	  v->pcm_current-=(v->sample_count-v->granulepos);
         }else{
           /* trim the beginning */
-	  v->pcm_returned+=(b->sample_count-v->granulepos);
+	  v->pcm_returned+=(v->sample_count-v->granulepos);
           if(v->pcm_returned>v->pcm_current)
             v->pcm_returned=v->pcm_current;
         }
@@ -409,10 +366,7 @@
       v->granulepos=vb->granulepos;
     }
   }
-  
-  /* Update, cleanup */
-  
-  if(vb->eofflag)v->eofflag=1;
+
   return(0);
 }
 

<p><p>1.5.6.4   +20 -36    Tremor/codec_internal.h

Index: codec_internal.h
===================================================================
RCS file: /usr/local/cvsroot/Tremor/codec_internal.h,v
retrieving revision 1.5.6.3
retrieving revision 1.5.6.4
diff -u -r1.5.6.3 -r1.5.6.4
--- codec_internal.h	13 Apr 2003 09:03:09 -0000	1.5.6.3
+++ codec_internal.h	14 Apr 2003 01:13:44 -0000	1.5.6.4
@@ -19,6 +19,7 @@
 #define _V_CODECI_H_
 
 #include "codebook.h"
+#include "ivorbiscodec.h"
 
 #define VI_TRANSFORMB 1
 #define VI_WINDOWB 1
@@ -28,16 +29,20 @@
 #define VI_MAPB 1
 
 typedef void vorbis_info_floor;
-typedef void vorbis_info_mapping;
 
 /* Floor backend generic *****************************************/
-typedef struct{
-  vorbis_info_floor     *(*unpack)(vorbis_info *,oggpack_buffer *);
-  void (*free_info) (vorbis_info_floor *);
-  void *(*inverse1)  (struct vorbis_block *,vorbis_info_floor *);
-  int   (*inverse2)  (struct vorbis_block *,vorbis_info_floor *,
-		     void *buffer,ogg_int32_t *);
-} vorbis_func_floor;
+
+extern vorbis_info_floor *floor0_info_unpack(vorbis_info *,oggpack_buffer *);
+extern void floor0_free_info(vorbis_info_floor *);
+extern void *floor0_inverse1(struct vorbis_block *,vorbis_info_floor *);
+extern int floor0_inverse2 (struct vorbis_block *,vorbis_info_floor *,
+			    void *buffer,ogg_int32_t *);
+
+extern vorbis_info_floor *floor1_info_unpack(vorbis_info *,oggpack_buffer *);
+extern void floor1_free_info(vorbis_info_floor *);
+extern void *floor1_inverse1(struct vorbis_block *,vorbis_info_floor *);
+extern int floor1_inverse2 (struct vorbis_block *,vorbis_info_floor *,
+			    void *buffer,ogg_int32_t *);
 
 typedef struct{
   int   order;
@@ -105,18 +110,7 @@
 
 /* Mapping backend generic *****************************************/
 
-typedef void vorbis_look_mapping;
-
-typedef struct{
-  vorbis_info_mapping *(*unpack)(vorbis_info *,oggpack_buffer *);
-  vorbis_look_mapping *(*look)  (vorbis_dsp_state *,vorbis_info_mode *,
-				 vorbis_info_mapping *);
-  void (*free_info)    (vorbis_info_mapping *);
-  void (*free_look)    (vorbis_look_mapping *);
-  int  (*inverse)      (struct vorbis_block *vb,vorbis_look_mapping *);
-} vorbis_func_mapping;
-
-typedef struct vorbis_info_mapping0{
+typedef struct vorbis_info_mapping{
   int   submaps;  /* <= 16 */
   int   chmuxlist[256];   /* up to 256 channels in a Vorbis stream */
   
@@ -129,19 +123,12 @@
   int   coupling_steps;
   int   coupling_mag[256];
   int   coupling_ang[256];
-} vorbis_info_mapping0;
+} vorbis_info_mapping;
 
-typedef struct private_state {
-  /* local lookup storage */
-  const void             *window[2];
-
-  /* backend lookups are tied to the mode, not the backend or naked mapping */
-  int                     modebits;
-  vorbis_look_mapping   **mode;
-
-  ogg_int64_t sample_count;
-
-} private_state;
+extern int mapping_info_unpack(vorbis_info_mapping *,vorbis_info *,
+			       oggpack_buffer *);
+extern void mapping_clear_info(vorbis_info_mapping *);
+extern int mapping_inverse(struct vorbis_block *vb,vorbis_info_mapping *);
 
 /* codec_setup_info contains all the setup information specific to the
    specific compression/decompression mode in progress (eg,
@@ -168,15 +155,12 @@
   int        books;
 
   vorbis_info_mode       *mode_param;
-  vorbis_info_mapping    *map_param[64];
+  vorbis_info_mapping    *map_param;
   char                   *floor_type;
   vorbis_info_floor     **floor_param;
   vorbis_info_residue    *residue_param;
   codebook               *book_param;
 
 } codec_setup_info;
-
-extern vorbis_func_floor     *_floor_P[];
-extern vorbis_func_mapping   *_mapping_P[];
 
 #endif

<p><p>1.4.6.5   +26 -29    Tremor/floor0.c

Index: floor0.c
===================================================================
RCS file: /usr/local/cvsroot/Tremor/floor0.c,v
retrieving revision 1.4.6.4
retrieving revision 1.4.6.5
diff -u -r1.4.6.4 -r1.4.6.5
--- floor0.c	13 Apr 2003 09:03:09 -0000	1.4.6.4
+++ floor0.c	14 Apr 2003 01:13:44 -0000	1.4.6.5
@@ -75,24 +75,27 @@
     (COS_LOOKUP_I_SHIFT-LSP_FRACBITS+14);
 }
 
-static const ogg_int32_t barklook[28]={
-  0,100,200,301,          405,516,635,766,
-  912,1077,1263,1476,     1720,2003,2333,2721,
-  3184,3742,4428,5285,    6376,7791,9662,12181,
-  15624,20397,27087,36554
+static const ogg_uint16_t barklook[54]={
+  0,51,102,154,            206,258,311,365,
+  420,477,535,594,         656,719,785,854,
+  926,1002,1082,1166,      1256,1352,1454,1564,
+  1683,1812,1953,2107,     2276,2463,2670,2900,
+  3155,3440,3756,4106,     4493,4919,5387,5901,
+  6466,7094,7798,8599,     9528,10623,11935,13524,
+  15453,17775,20517,23667, 27183,31004
 };
 
 /* used in init only; interpolate the long way */
 static inline ogg_int32_t toBARK(int n){
   int i;
-  for(i=0;i<27;i++) 
+  for(i=0;i<54;i++) 
     if(n>=barklook[i] && n<barklook[i+1])break;
   
-  if(i==27){
-    return 27<<15;
+  if(i==54){
+    return 54<<14;
   }else{
-    return (i<<15)+(((n-barklook[i])*  
-		     ((1<<31)/(barklook[i+1]-barklook[i])))>>16);
+    return (i<<14)+(((n-barklook[i])*  
+		     ((1UL<<31)/(barklook[i+1]-barklook[i])))>>17);
   }
 }
 
@@ -112,7 +115,6 @@
 
 static const unsigned char MLOOP_3[8]={0,1,2,2,3,3,3,3};
 
-#include <stdio.h>
 void vorbis_lsp_to_curve(ogg_int32_t *curve,int n,int ln,
                          ogg_int32_t *lsp,int m,
                          ogg_int32_t amp,
@@ -139,9 +141,9 @@
   int fdy=nyq-fbase*fdx;
   int map=0;
 
-  ogg_uint32_t nextbark=MULT31(imap>>1,toBARK(nyq));
-  int nextf=barklook[nextbark>>15]+(((nextbark&0x7fff)*
-	    (barklook[(nextbark>>15)+1]-barklook[nextbark>>15]))>>15);
+  ogg_uint32_t nextbark=MULT31(imap>>1,tBnyq1);
+  int nextf=barklook[nextbark>>14]+(((nextbark&0x3fff)*
+	    (barklook[(nextbark>>14)+1]-barklook[nextbark>>14]))>>14);
 
   /* lsp is in 8.24, range 0 to PI; coslook wants it in .16 0 to 1*/
   for(i=0;i<m;i++){
@@ -292,16 +294,18 @@
       f+=fbase;
       
       if(f>=nextf)break;
+
       curve[i]= MULT31_SHIFT15(curve[i],amp);
     }
 
     while(1){
       map++;
+
       nextbark=MULT31((map+1)*(imap>>1),tBnyq1);
-      nextf=barklook[nextbark>>15]+
-	(((nextbark&0x7fff)*
-	  (barklook[(nextbark>>15)+1]-barklook[nextbark>>15]))>>15);
-      if(f<nextf)break;
+      nextf=barklook[nextbark>>14]+
+	(((nextbark&0x3fff)*
+	  (barklook[(nextbark>>14)+1]-barklook[nextbark>>14]))>>14);
+      if(f<=nextf)break;
     }
     if(map>=ln){
       map=ln-1; /* guard against the approximation */      
@@ -312,12 +316,12 @@
 
 /*************** vorbis decode glue ************/
 
-static void floor0_free_info(vorbis_info_floor *i){
+void floor0_free_info(vorbis_info_floor *i){
   vorbis_info_floor0 *info=(vorbis_info_floor0 *)i;
   if(info)_ogg_free(info);
 }
 
-static vorbis_info_floor *floor0_unpack (vorbis_info *vi,oggpack_buffer *opb){
+vorbis_info_floor *floor0_info_unpack (vorbis_info *vi,oggpack_buffer *opb){
   codec_setup_info     *ci=(codec_setup_info *)vi->codec_setup;
   int j;
 
@@ -346,7 +350,7 @@
   return(NULL);
 }
 
-static void *floor0_inverse1(vorbis_block *vb,vorbis_info_floor *i){
+void *floor0_inverse1(vorbis_block *vb,vorbis_info_floor *i){
   vorbis_info_floor0 *info=(vorbis_info_floor0 *)i;
   int j,k;
   
@@ -378,7 +382,7 @@
   return(NULL);
 }
 
-static int floor0_inverse2(vorbis_block *vb,vorbis_info_floor *i,
+int floor0_inverse2(vorbis_block *vb,vorbis_info_floor *i,
                            void *memo,ogg_int32_t *out){
   vorbis_info_floor0 *info=(vorbis_info_floor0 *)i;
   
@@ -395,11 +399,4 @@
   memset(out,0,sizeof(*out)*vb->pcmend/2);
   return(0);
 }
-
-/* export hooks */
-vorbis_func_floor floor0_exportbundle={
-  &floor0_unpack,&floor0_free_info,
-  &floor0_inverse1,&floor0_inverse2
-};
-
 

<p><p>1.6.6.6   +4 -11     Tremor/floor1.c

Index: floor1.c
===================================================================
RCS file: /usr/local/cvsroot/Tremor/floor1.c,v
retrieving revision 1.6.6.5
retrieving revision 1.6.6.6
diff -u -r1.6.6.5 -r1.6.6.6
--- floor1.c	13 Apr 2003 09:03:09 -0000	1.6.6.5
+++ floor1.c	14 Apr 2003 01:13:44 -0000	1.6.6.6
@@ -29,7 +29,7 @@
 
 /***********************************************/
  
-static void floor1_free_info(vorbis_info_floor *i){
+void floor1_free_info(vorbis_info_floor *i){
   vorbis_info_floor1 *info=(vorbis_info_floor1 *)i;
   if(info){
     if(info->class)_ogg_free(info->class);
@@ -56,7 +56,7 @@
   return(**(int **)a-**(int **)b);
 }
 
-static vorbis_info_floor *floor1_unpack (vorbis_info *vi,oggpack_buffer *opb){
+vorbis_info_floor *floor1_info_unpack (vorbis_info *vi,oggpack_buffer *opb){
   codec_setup_info     *ci=(codec_setup_info *)vi->codec_setup;
   int j,k,count=0,maxclass=-1,rangebits;
   ogg_uint16_t *sortpointer[VIF_POSIT+2];
@@ -271,7 +271,7 @@
 
 static int quant_look[4]={256,128,86,64};
 
-static void *floor1_inverse1(vorbis_block *vb,vorbis_info_floor *in){
+void *floor1_inverse1(vorbis_block *vb,vorbis_info_floor *in){
   vorbis_info_floor1 *info=(vorbis_info_floor1 *)in;
   codec_setup_info   *ci=(codec_setup_info *)vb->vd->vi->codec_setup;
   
@@ -359,7 +359,7 @@
   return(NULL);
 }
 
-static int floor1_inverse2(vorbis_block *vb,vorbis_info_floor *in,void *memo,
+int floor1_inverse2(vorbis_block *vb,vorbis_info_floor *in,void *memo,
                           ogg_int32_t *out){
   vorbis_info_floor1 *info=(vorbis_info_floor1 *)in;
 
@@ -393,10 +393,3 @@
   memset(out,0,sizeof(*out)*n);
   return(0);
 }
-
-/* export hooks */
-vorbis_func_floor floor1_exportbundle={
-  &floor1_unpack,&floor1_free_info,
-  &floor1_inverse1,&floor1_inverse2
-};
-

<p><p>1.3.2.4   +15 -7     Tremor/info.c

Index: info.c
===================================================================
RCS file: /usr/local/cvsroot/Tremor/info.c,v
retrieving revision 1.3.2.3
retrieving revision 1.3.2.4
diff -u -r1.3.2.3 -r1.3.2.4
--- info.c	13 Apr 2003 09:03:09 -0000	1.3.2.3
+++ info.c	14 Apr 2003 01:13:44 -0000	1.3.2.4
@@ -25,7 +25,6 @@
 #include "ivorbiscodec.h"
 #include "codec_internal.h"
 #include "codebook.h"
-#include "window.h"
 #include "misc.h"
 #include "os.h"
 
@@ -121,12 +120,18 @@
 
     if(ci->mode_param)_ogg_free(ci->mode_param);
 
-    for(i=0;i<ci->maps;i++) /* unpack does the range checking */
-      _mapping_P[0]->free_info(ci->map_param[i]);
+    if(ci->map_param){
+      for(i=0;i<ci->maps;i++) /* unpack does the range checking */
+	mapping_clear_info(ci->map_param+i);
+      _ogg_free(ci->map_param);
+    }
 
     if(ci->floor_param){
       for(i=0;i<ci->floors;i++) /* unpack does the range checking */
-	_floor_P[ci->floor_type[i]]->free_info(ci->floor_param[i]);
+	if(ci->floor_type[i])
+	  floor1_free_info(ci->floor_param[i]);
+	else
+	  floor0_free_info(ci->floor_param[i]);
       _ogg_free(ci->floor_param);
       _ogg_free(ci->floor_type);
     }
@@ -234,7 +239,10 @@
   for(i=0;i<ci->floors;i++){
     ci->floor_type[i]=oggpack_read(opb,16);
     if(ci->floor_type[i]<0 || ci->floor_type[i]>=VI_FLOORB)goto err_out;
-    ci->floor_param[i]=_floor_P[ci->floor_type[i]]->unpack(vi,opb);
+    if(ci->floor_type[i])
+      ci->floor_param[i]=floor1_info_unpack(vi,opb);
+    else
+      ci->floor_param[i]=floor0_info_unpack(vi,opb);
     if(!ci->floor_param[i])goto err_out;
   }
 
@@ -246,10 +254,10 @@
 
   /* map backend settings */
   ci->maps=oggpack_read(opb,6)+1;
+  ci->map_param=_ogg_malloc(sizeof(*ci->map_param)*ci->maps);
   for(i=0;i<ci->maps;i++){
     if(oggpack_read(opb,16)!=0)goto err_out;
-    ci->map_param[i]=_mapping_P[0]->unpack(vi,opb);
-    if(!ci->map_param[i])goto err_out;
+    if(mapping_info_unpack(ci->map_param+i,vi,opb))goto err_out;
   }
   
   /* mode settings */

<p><p>1.3.2.1   +1 -5      Tremor/ivorbiscodec.h

Index: ivorbiscodec.h
===================================================================
RCS file: /usr/local/cvsroot/Tremor/ivorbiscodec.h,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -r1.3 -r1.3.2.1
--- ivorbiscodec.h	29 Mar 2003 03:07:21 -0000	1.3
+++ ivorbiscodec.h	14 Apr 2003 01:13:44 -0000	1.3.2.1
@@ -57,7 +57,6 @@
    analysis/synthesis state.  The DSP state belongs to a specific
    logical bitstream ****************************************************/
 typedef struct vorbis_dsp_state{
-  int analysisp;
   vorbis_info *vi;
 
   ogg_int32_t **pcm;
@@ -66,9 +65,6 @@
   int      pcm_current;
   int      pcm_returned;
 
-  int  preextrapolate;
-  int  eofflag;
-
   long lW;
   long W;
   long nW;
@@ -76,8 +72,8 @@
 
   ogg_int64_t granulepos;
   ogg_int64_t sequence;
+  ogg_int64_t sample_count;
 
-  void       *backend_state;
 } vorbis_dsp_state;
 
 typedef struct vorbis_block{

<p><p>1.3.6.5   +76 -75    Tremor/mapping0.c

Index: mapping0.c
===================================================================
RCS file: /usr/local/cvsroot/Tremor/mapping0.c,v
retrieving revision 1.3.6.4
retrieving revision 1.3.6.5
diff -u -r1.3.6.4 -r1.3.6.5
--- mapping0.c	13 Apr 2003 09:03:09 -0000	1.3.6.4
+++ mapping0.c	14 Apr 2003 01:13:44 -0000	1.3.6.5
@@ -24,68 +24,69 @@
 #include "mdct.h"
 #include "codec_internal.h"
 #include "codebook.h"
-#include "window.h"
 #include "misc.h"
+#include "window_lookup.h"
 
-/* simplistic, wasteful way of doing this (unique lookup for each
-   mode/submapping); there should be a central repository for
-   identical lookups.  That will require minor work, so I'm putting it
-   off as low priority.
+static const void *_vorbis_window(int left){
+  switch(left){
+  case 32:
+    return vwin64;
+  case 64:
+    return vwin128;
+  case 128:
+    return vwin256;
+  case 256:
+    return vwin512;
+  case 512:
+    return vwin1024;
+  case 1024:
+    return vwin2048;
+  case 2048:
+    return vwin4096;
+  case 4096:
+    return vwin8192;
+  default:
+    return(0);
+  }
+}
 
-   Why a lookup for each backend in a given mode?  Because the
-   blocksize is set by the mode, and low backend lookups may require
-   parameters from other areas of the mode/mapping */
+static void _vorbis_apply_window(ogg_int32_t *d,
+				 long *blocksizes,
+				 int lW,int W,int nW){
+  
+  LOOKUP_T *window[2];
+  long n=blocksizes[W];
+  long ln=blocksizes[lW];
+  long rn=blocksizes[nW];
 
-typedef struct {
-  vorbis_info_mode *mode;
-  vorbis_info_mapping0 *map;
+  long leftbegin=n/4-ln/4;
+  long leftend=leftbegin+ln/2;
 
-  vorbis_func_floor **floor_func;
+  long rightbegin=n/2+n/4-rn/4;
+  long rightend=rightbegin+rn/2;
+  
+  int i,p;
 
+  window[0]=_vorbis_window(blocksizes[0]>>1);
+  window[1]=_vorbis_window(blocksizes[1]>>1);
 
-  int ch;
-  long lastframe; /* if a different mode is called, we need to 
-		     invalidate decay */
-} vorbis_look_mapping0;
+  for(i=0;i<leftbegin;i++)
+    d[i]=0;
 
-static void mapping0_free_info(vorbis_info_mapping *i){
-  vorbis_info_mapping0 *info=(vorbis_info_mapping0 *)i;
-  if(info){
-    memset(info,0,sizeof(*info));
-    _ogg_free(info);
-  }
-}
+  for(p=0;i<leftend;i++,p++)
+    d[i]=MULT31(d[i],window[lW][p]);
 
-static void mapping0_free_look(vorbis_look_mapping *look){
-  int i;
-  vorbis_look_mapping0 *l=(vorbis_look_mapping0 *)look;
-  if(l){
+  for(i=rightbegin,p=rn/2-1;i<rightend;i++,p--)
+    d[i]=MULT31(d[i],window[nW][p]);
 
-    _ogg_free(l->floor_func);
-    memset(l,0,sizeof(*l));
-    _ogg_free(l);
-  }
+  for(;i<n;i++)
+    d[i]=0;
 }
 
-static vorbis_look_mapping *mapping0_look(vorbis_dsp_state *vd,vorbis_info_mode *vm,
-			  vorbis_info_mapping *m){
-  int i;
-  vorbis_info          *vi=vd->vi;
-  codec_setup_info     *ci=(codec_setup_info *)vi->codec_setup;
-  vorbis_look_mapping0 *look=(vorbis_look_mapping0 *)_ogg_calloc(1,sizeof(*look));
-  vorbis_info_mapping0 *info=look->map=(vorbis_info_mapping0 *)m;
-  look->mode=vm;
-  
-  look->floor_func=(vorbis_func_floor **)_ogg_calloc(info->submaps,sizeof(*look->floor_func));
-  
-  for(i=0;i<info->submaps;i++){
-    int floornum=info->floorsubmap[i];
-    look->floor_func[i]=_floor_P[ci->floor_type[floornum]];
+void mapping_clear_info(vorbis_info_mapping *info){
+  if(info){
+    memset(info,0,sizeof(*info));
   }
-
-  look->ch=vi->channels;
-
-  return(look);
 }
 
 static int ilog(unsigned int v){
@@ -99,9 +100,9 @@
 }
 
 /* also responsible for range checking */
-static vorbis_info_mapping *mapping0_unpack(vorbis_info *vi,oggpack_buffer *opb){
+int mapping_info_unpack(vorbis_info_mapping *info,vorbis_info *vi,
+			oggpack_buffer *opb){
   int i;
-  vorbis_info_mapping0 *info=(vorbis_info_mapping0 *)_ogg_calloc(1,sizeof(*info));
   codec_setup_info     *ci=(codec_setup_info *)vi->codec_setup;
   memset(info,0,sizeof(*info));
 
@@ -142,21 +143,17 @@
     if(info->residuesubmap[i]>=ci->residues)goto err_out;
   }
 
-  return info;
+  return 0;
 
  err_out:
-  mapping0_free_info(info);
-  return(NULL);
+  mapping_clear_info(info);
+  return -1;
 }
 
-static int seq=0;
-static int mapping0_inverse(vorbis_block *vb,vorbis_look_mapping *l){
+int mapping_inverse(vorbis_block *vb,vorbis_info_mapping *info){
   vorbis_dsp_state     *vd=vb->vd;
   vorbis_info          *vi=vd->vi;
   codec_setup_info     *ci=(codec_setup_info *)vi->codec_setup;
-  private_state        *b=(private_state *)vd->backend_state;
-  vorbis_look_mapping0 *look=(vorbis_look_mapping0 *)l;
-  vorbis_info_mapping0 *info=look->map;
 
   int                   i,j;
   long                  n=vb->pcmend=ci->blocksizes[vb->W];
@@ -170,8 +167,16 @@
   /* recover the spectral envelope; store it in the PCM vector for now */
   for(i=0;i<vi->channels;i++){
     int submap=info->chmuxlist[i];
-    floormemo[i]=look->floor_func[submap]->
-      inverse1(vb,ci->floor_param[info->floorsubmap[submap]]);
+    int floorno=info->floorsubmap[submap];
+
+    if(ci->floor_type[floorno]){
+      /* floor 1 */
+      floormemo[i]=floor1_inverse1(vb,ci->floor_param[floorno]);
+    }else{
+      /* floor 0 */
+      floormemo[i]=floor0_inverse1(vb,ci->floor_param[floorno]);
+    }
+
     if(floormemo[i])
       nonzero[i]=1;
     else
@@ -243,9 +248,15 @@
   for(i=0;i<vi->channels;i++){
     ogg_int32_t *pcm=vb->pcm[i];
     int submap=info->chmuxlist[i];
-    look->floor_func[submap]->
-      inverse2(vb,ci->floor_param[info->floorsubmap[submap]],
-	       floormemo[i],pcm);
+    int floorno=info->floorsubmap[submap];
+
+    if(ci->floor_type[floorno]){
+      /* floor 1 */
+      floor1_inverse2(vb,ci->floor_param[floorno],floormemo[i],pcm);
+    }else{
+      /* floor 0 */
+      floor0_inverse2(vb,ci->floor_param[floorno],floormemo[i],pcm);
+    }
   }
 
   //for(j=0;j<vi->channels;j++)
@@ -265,7 +276,7 @@
   for(i=0;i<vi->channels;i++){
     ogg_int32_t *pcm=vb->pcm[i];
     if(nonzero[i])
-      _vorbis_apply_window(pcm,b->window,ci->blocksizes,vb->lW,vb->W,vb->nW);
+      _vorbis_apply_window(pcm,ci->blocksizes,vb->lW,vb->W,vb->nW);
     else
       for(j=0;j<n;j++)
         pcm[j]=0;
@@ -275,16 +286,6 @@
   //for(j=0;j<vi->channels;j++)
   //_analysis_output("window",seq+j,vb->pcm[j],-24,n,0,0);
 
-  seq+=vi->channels;
   /* all done! */
   return(0);
 }
-
-/* export hooks */
-vorbis_func_mapping mapping0_exportbundle={
-  &mapping0_unpack,
-  &mapping0_look,
-  &mapping0_free_info,
-  &mapping0_free_look,
-  &mapping0_inverse
-};

<p><p>1.4.2.3   +13 -4     Tremor/synthesis.c

Index: synthesis.c
===================================================================
RCS file: /usr/local/cvsroot/Tremor/synthesis.c,v
retrieving revision 1.4.2.2
retrieving revision 1.4.2.3
diff -u -r1.4.2.2 -r1.4.2.3
--- synthesis.c	13 Apr 2003 09:03:09 -0000	1.4.2.2
+++ synthesis.c	14 Apr 2003 01:13:44 -0000	1.4.2.3
@@ -12,7 +12,7 @@
  ********************************************************************
 
  function: single-block PCM synthesis
- last mod: $Id: synthesis.c,v 1.4.2.2 2003/04/13 09:03:09 xiphmont Exp $
+ last mod: $Id: synthesis.c,v 1.4.2.3 2003/04/14 01:13:44 xiphmont Exp $
 
  ********************************************************************/
 
@@ -23,9 +23,18 @@
 #include "misc.h"
 #include "os.h"
 
+static int ilog(unsigned int v){
+  int ret=0;
+  if(v)--v;
+  while(v){
+    ret++;
+    v>>=1;
+  }
+  return(ret);
+}
+
 int vorbis_synthesis(vorbis_block *vb,ogg_packet *op,int decodep){
   vorbis_dsp_state     *vd=vb->vd;
-  private_state        *b=(private_state *)vd->backend_state;
   vorbis_info          *vi=vd->vi;
   codec_setup_info     *ci=(codec_setup_info *)vi->codec_setup;
   oggpack_buffer       *opb=&vb->opb;
@@ -42,7 +51,7 @@
   }
 
   /* read our mode and pre/post windowsize */
-  mode=oggpack_read(opb,b->modebits);
+  mode=oggpack_read(opb,ilog(ci->modes));
   if(mode==-1)return(OV_EBADPACKET);
   
   vb->mode=mode;
@@ -69,7 +78,7 @@
       vb->pcm[i]=(ogg_int32_t *)_vorbis_block_alloc(vb,vb->pcmend*sizeof(*vb->pcm[i]));
     
     /* unpack_header enforces range checking */
-    return(_mapping_P[0]->inverse(vb,b->mode[mode]));
+    return(mapping_inverse(vb,ci->map_param+ci->mode_param[mode].mapping));
   }else{
     /* no pcm */
     vb->pcmend=0;

<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