[xiph-cvs] cvs commit: Tremor codec_internal.h mapping0.c

Monty xiphmont at xiph.org
Sun Apr 13 22:26:09 PDT 2003



xiphmont    03/04/14 01:26:09

  Modified:    .        Tag: lowmem-branch codec_internal.h mapping0.c
  Log:
  Pared down mapping info structures

Revision  Changes    Path
No                   revision

<p>No                   revision

<p>1.5.6.5   +16 -12    Tremor/codec_internal.h

Index: codec_internal.h
===================================================================
RCS file: /usr/local/cvsroot/Tremor/codec_internal.h,v
retrieving revision 1.5.6.4
retrieving revision 1.5.6.5
diff -u -r1.5.6.4 -r1.5.6.5
--- codec_internal.h	14 Apr 2003 01:13:44 -0000	1.5.6.4
+++ codec_internal.h	14 Apr 2003 05:26:09 -0000	1.5.6.5
@@ -104,25 +104,29 @@
 
 /* mode ************************************************************/
 typedef struct {
-  int blockflag;
-  int mapping;
+  unsigned char blockflag;
+  unsigned char mapping;
 } vorbis_info_mode;
 
 /* Mapping backend generic *****************************************/
+typedef struct coupling_step{
+  unsigned char mag;
+  unsigned char ang;
+} coupling_step;
+
+typedef struct submap{
+  char floor;
+  char residue;
+} submap;
 
 typedef struct vorbis_info_mapping{
-  int   submaps;  /* <= 16 */
-  int   chmuxlist[256];   /* up to 256 channels in a Vorbis stream */
+  int            submaps; 
   
-  int   floorsubmap[16];   /* [mux] submap to floors */
-  int   residuesubmap[16]; /* [mux] submap to residue */
-
-  int   psy[2]; /* by blocktype; impulse/padding for short,
-                   transition/normal for long */
+  unsigned char *chmuxlist;
+  submap        *submaplist;
 
-  int   coupling_steps;
-  int   coupling_mag[256];
-  int   coupling_ang[256];
+  int            coupling_steps;
+  coupling_step *coupling;
 } vorbis_info_mapping;
 
 extern int mapping_info_unpack(vorbis_info_mapping *,vorbis_info *,

<p><p>1.3.6.6   +44 -25    Tremor/mapping0.c

Index: mapping0.c
===================================================================
RCS file: /usr/local/cvsroot/Tremor/mapping0.c,v
retrieving revision 1.3.6.5
retrieving revision 1.3.6.6
diff -u -r1.3.6.5 -r1.3.6.6
--- mapping0.c	14 Apr 2003 01:13:44 -0000	1.3.6.5
+++ mapping0.c	14 Apr 2003 05:26:09 -0000	1.3.6.6
@@ -85,6 +85,9 @@
 
 void mapping_clear_info(vorbis_info_mapping *info){
   if(info){
+    if(info->chmuxlist)_ogg_free(info->chmuxlist);
+    if(info->submaplist)_ogg_free(info->submaplist);
+    if(info->coupling)_ogg_free(info->coupling);
     memset(info,0,sizeof(*info));
   }
 }
@@ -113,10 +116,12 @@
 
   if(oggpack_read(opb,1)){
     info->coupling_steps=oggpack_read(opb,8)+1;
-
+    info->coupling=
+      _ogg_malloc(info->coupling_steps*sizeof(*info->coupling));
+    
     for(i=0;i<info->coupling_steps;i++){
-      int testM=info->coupling_mag[i]=oggpack_read(opb,ilog(vi->channels));
-      int testA=info->coupling_ang[i]=oggpack_read(opb,ilog(vi->channels));
+      int testM=info->coupling[i].mag=oggpack_read(opb,ilog(vi->channels));
+      int testA=info->coupling[i].ang=oggpack_read(opb,ilog(vi->channels));
 
       if(testM<0 || 
          testA<0 || 
@@ -130,17 +135,20 @@
   if(oggpack_read(opb,2)>0)goto err_out; /* 2,3:reserved */
     
   if(info->submaps>1){
+    info->chmuxlist=_ogg_malloc(sizeof(*info->chmuxlist)*vi->channels);
     for(i=0;i<vi->channels;i++){
       info->chmuxlist[i]=oggpack_read(opb,4);
       if(info->chmuxlist[i]>=info->submaps)goto err_out;
     }
   }
+
+  info->submaplist=_ogg_malloc(sizeof(*info->submaplist)*info->submaps);
   for(i=0;i<info->submaps;i++){
     int temp=oggpack_read(opb,8);
-    info->floorsubmap[i]=oggpack_read(opb,8);
-    if(info->floorsubmap[i]>=ci->floors)goto err_out;
-    info->residuesubmap[i]=oggpack_read(opb,8);
-    if(info->residuesubmap[i]>=ci->residues)goto err_out;
+    info->submaplist[i].floor=oggpack_read(opb,8);
+    if(info->submaplist[i].floor>=ci->floors)goto err_out;
+    info->submaplist[i].residue=oggpack_read(opb,8);
+    if(info->submaplist[i].residue>=ci->residues)goto err_out;
   }
 
   return 0;
@@ -158,17 +166,24 @@
   int                   i,j;
   long                  n=vb->pcmend=ci->blocksizes[vb->W];
 
-  ogg_int32_t **pcmbundle=(ogg_int32_t **)alloca(sizeof(*pcmbundle)*vi->channels);
-  int    *zerobundle=(int *)alloca(sizeof(*zerobundle)*vi->channels);
-  
-  int   *nonzero  =(int *)alloca(sizeof(*nonzero)*vi->channels);
-  void **floormemo=(void **)alloca(sizeof(*floormemo)*vi->channels);
+  ogg_int32_t **pcmbundle=
+    (ogg_int32_t **)alloca(sizeof(*pcmbundle)*vi->channels);
+  int          *zerobundle=
+    (int *)alloca(sizeof(*zerobundle)*vi->channels);
+  int          *nonzero=
+    (int *)alloca(sizeof(*nonzero)*vi->channels);
+  void        **floormemo=
+    (void **)alloca(sizeof(*floormemo)*vi->channels);
   
   /* recover the spectral envelope; store it in the PCM vector for now */
   for(i=0;i<vi->channels;i++){
-    int submap=info->chmuxlist[i];
-    int floorno=info->floorsubmap[submap];
-
+    int submap=0;
+    int floorno;
+    
+    if(info->submaps>1)
+      submap=info->chmuxlist[i];
+    floorno=info->submaplist[submap].floor;
+    
     if(ci->floor_type[floorno]){
       /* floor 1 */
       floormemo[i]=floor1_inverse1(vb,ci->floor_param[floorno]);
@@ -186,10 +201,10 @@
 
   /* channel coupling can 'dirty' the nonzero listing */
   for(i=0;i<info->coupling_steps;i++){
-    if(nonzero[info->coupling_mag[i]] ||
-       nonzero[info->coupling_ang[i]]){
-      nonzero[info->coupling_mag[i]]=1; 
-      nonzero[info->coupling_ang[i]]=1; 
+    if(nonzero[info->coupling[i].mag] ||
+       nonzero[info->coupling[i].ang]){
+      nonzero[info->coupling[i].mag]=1; 
+      nonzero[info->coupling[i].ang]=1; 
     }
   }
 
@@ -197,7 +212,7 @@
   for(i=0;i<info->submaps;i++){
     int ch_in_bundle=0;
     for(j=0;j<vi->channels;j++){
-      if(info->chmuxlist[j]==i){
+      if(!info->chmuxlist || info->chmuxlist[j]==i){
         if(nonzero[j])
           zerobundle[ch_in_bundle]=1;
         else
@@ -206,7 +221,7 @@
       }
     }
     
-    res_inverse(vb,ci->residue_param+info->residuesubmap[i],
+    res_inverse(vb,ci->residue_param+info->submaplist[i].residue,
                 pcmbundle,zerobundle,ch_in_bundle);
   }
 
@@ -215,8 +230,8 @@
 
   /* channel coupling */
   for(i=info->coupling_steps-1;i>=0;i--){
-    ogg_int32_t *pcmM=vb->pcm[info->coupling_mag[i]];
-    ogg_int32_t *pcmA=vb->pcm[info->coupling_ang[i]];
+    ogg_int32_t *pcmM=vb->pcm[info->coupling[i].mag];
+    ogg_int32_t *pcmA=vb->pcm[info->coupling[i].ang];
     
     for(j=0;j<n/2;j++){
       ogg_int32_t mag=pcmM[j];
@@ -247,8 +262,12 @@
   /* compute and apply spectral envelope */
   for(i=0;i<vi->channels;i++){
     ogg_int32_t *pcm=vb->pcm[i];
-    int submap=info->chmuxlist[i];
-    int floorno=info->floorsubmap[submap];
+    int submap=0;
+    int floorno;
+
+    if(info->submaps>1)
+      submap=info->chmuxlist[i];
+    floorno=info->submaplist[submap].floor;
 
     if(ci->floor_type[floorno]){
       /* floor 1 */

<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