[xiph-cvs] cvs commit: vorbis/lib/modes mode_44c_A.h

Monty xiphmont at xiph.org
Fri Nov 23 21:26:12 PST 2001



xiphmont    01/11/23 21:26:12

  Modified:    lib      Tag: branch_monty_20011009 bitrate.c bitrate.h
                        mapping0.c
               lib/modes Tag: branch_monty_20011009 mode_44c_A.h
  Log:
  Bitrate management scheme passes all tests.  On to mundane bugfixes and tuning.
  
  Monty

Revision  Changes    Path
No                   revision

No                   revision

1.1.2.4   +30 -22    vorbis/lib/Attic/bitrate.c

Index: bitrate.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/Attic/bitrate.c,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -r1.1.2.3 -r1.1.2.4
--- bitrate.c	2001/11/22 07:54:41	1.1.2.3
+++ bitrate.c	2001/11/24 05:26:10	1.1.2.4
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: bitrate tracking and management
- last mod: $Id: bitrate.c,v 1.1.2.3 2001/11/22 07:54:41 xiphmont Exp $
+ last mod: $Id: bitrate.c,v 1.1.2.4 2001/11/24 05:26:10 xiphmont Exp $
 
  ********************************************************************/
 
@@ -30,6 +30,11 @@
 #define LIMITBITS(pos,bin) ((bin)>-bins?\
                  bm->minmax_binstack[(pos)*bins*2+((bin)+bins)-1]:0)
 
+static long LACING_ADJUST(long bits){
+  int addto=((bits+7)/8+1)/256+1;
+  return( ((bits+7)/8+addto)*8 );
+}
+
 static double floater_interpolate(bitrate_manager_state *bm,vorbis_info *vi,
                                   double desired_rate){
   int bin=bm->avgfloat*BITTRACK_DIVISOR-1.;
@@ -95,9 +100,11 @@
   
   /* first find the max possible needed queue size */
   maxlatency=max(bm->avg_sampledesired-bm->avg_centerdesired,
-		 bi->queue_minmax_time)+bm->avg_centerdesired;
+		 bm->minmax_sampledesired)+bm->avg_centerdesired;
   
-  if(maxlatency>0){
+  if(maxlatency>0 &&
+     (bi->queue_avgmin>0 || bi->queue_avgmax>0 || bi->queue_hardmax>0 ||
+      bi->queue_hardmin>0)){
     long maxpackets=maxlatency/(ci->blocksizes[0]>>1)+3;
     long bins=BITTRACK_DIVISOR*ci->passlimit[ci->coupling_passes-1];
     
@@ -113,6 +120,8 @@
       bm->avgfloat=bi->avgfloat_initial;
       
       
+    }else{
+      bm->avg_tail= -1;
     }
     
     if((bi->queue_hardmin>0 || bi->queue_hardmax>0) &&
@@ -124,6 +133,8 @@
                                       sizeof(bm->minmax_posstack));
       bm->minmax_limitstack=_ogg_malloc((bins+1)*
                                         sizeof(bm->minmax_limitstack));
+    }else{
+      bm->minmax_tail= -1;
     }
     
     /* space for the packet queueing */
@@ -191,20 +202,10 @@
   int                    next_head=head+1;
   int                    bins=bm->queue_bins;
   int                    minmax_head,new_minmax_head;
-  long                   maxbits;
   
   ogg_uint32_t           *head_ptr;
   oggpack_buffer          temp;
 
-  /* enforce maxbits; min is enforced in the mapping */
-  /*if(bi->queue_hardmax){
-    maxbits=bi->queue_hardmax/vi->rate*ci->blocksizes[vb->W?1:0]/2;
-    if(maxbits<oggpack_bits(&vb->opb)){
-      vb->opb.endbyte=maxbits/8;
-      vb->opb.endbit=maxbits%8;
-    }
-    }*/
-
   if(!bm->queue_binned){
     oggpack_buffer temp;
     /* not a bitrate managed stream, but for API simplicity, we'll
@@ -270,7 +271,7 @@
 
     /* update the avg head */
     for(i=0;i<bins;i++)
-      bm->avg_binacc[i]+=head_ptr[i];
+      bm->avg_binacc[i]+=LACING_ADJUST(head_ptr[i]);
     bm->avg_sampleacc+=ci->blocksizes[vb->W]>>1;
     bm->avg_centeracc+=ci->blocksizes[vb->W]>>1;
 
@@ -279,7 +280,7 @@
       int samples=
         ci->blocksizes[bm->queue_actual[bm->avg_tail]&0x80000000UL?1:0]>>1;
       for(i=0;i<bm->queue_bins;i++)
-	bm->avg_binacc[i]-=bm->queue_binned[bins*bm->avg_tail+i];
+	bm->avg_binacc[i]-=LACING_ADJUST(bm->queue_binned[bins*bm->avg_tail+i]);
       bm->avg_sampleacc-=samples;
       bm->avg_tail++;
       if(bm->avg_tail>=bm->queue_size)bm->avg_tail=0;
@@ -400,14 +401,16 @@
         */
       for(i=0;i<bins;i++){
         bm->minmax_binstack[bm->minmax_stackptr*bins*2+bins+i]+=
+	  LACING_ADJUST(
           BINBITS(minmax_head,
                   (bm->queue_actual[minmax_head]&0x7fffffffUL)>i+1?
-		  (bm->queue_actual[minmax_head]&0x7fffffffUL):i+1);
+		  (bm->queue_actual[minmax_head]&0x7fffffffUL):i+1));
         
         bm->minmax_binstack[bm->minmax_stackptr*bins*2+i]+=
+	  LACING_ADJUST(
           BINBITS(minmax_head,
                   (bm->queue_actual[minmax_head]&0x7fffffffUL)<i+1?
-		  (bm->queue_actual[minmax_head]&0x7fffffffUL):i+1);
+		  (bm->queue_actual[minmax_head]&0x7fffffffUL):i+1));
       }
       
       bm->minmax_posstack[bm->minmax_stackptr]=minmax_head; /* not one
@@ -417,7 +420,8 @@
       bm->minmax_limitstack[bm->minmax_stackptr]=0;
       bm->minmax_sampleacc+=samples;
       bm->minmax_acctotal+=
-	BINBITS(minmax_head,(bm->queue_actual[minmax_head]&0x7fffffffUL));
+	LACING_ADJUST(
+	BINBITS(minmax_head,(bm->queue_actual[minmax_head]&0x7fffffffUL)));
       
       minmax_head++;
       if(minmax_head>=bm->queue_size)minmax_head=0;
@@ -453,6 +457,10 @@
           if(bitrate>bi->queue_hardmax)limit--;
         }
 
+	bitsum=limit_sum(bm,limit);
+	bitrate=(double)bitsum/bm->minmax_sampleacc*vi->rate;
+	fprintf(stderr,"postlimit:%dkbps ",(int)bitrate/1000);
+
         /* trace the limit backward, stop when we see a lower limit */
         newstack=bm->minmax_stackptr-1;
         while(newstack>=0){
@@ -500,9 +508,9 @@
 
       for(i=0;i<bins;i++){
         bm->minmax_binstack[bins+i]-= /* always comes off the stack bottom */
-	  BINBITS(bm->minmax_tail,actual>i+1?actual:i+1);
+	  LACING_ADJUST(BINBITS(bm->minmax_tail,actual>i+1?actual:i+1));
         bm->minmax_binstack[i]-= 
-	  BINBITS(bm->minmax_tail,actual<i+1?actual:i+1);
+	  LACING_ADJUST(BINBITS(bm->minmax_tail,actual<i+1?actual:i+1));
       }
 
       /* always perform in this order; max overrules min */
@@ -511,7 +519,7 @@
       if(bins+bm->minmax_limitstack[0]<actual)
         actual=bins+bm->minmax_limitstack[0];
 
-      bm->minmax_acctotal-=BINBITS(bm->minmax_tail,actual);
+      bm->minmax_acctotal-=LACING_ADJUST(BINBITS(bm->minmax_tail,actual));
       bm->minmax_sampleacc-=samples;
      
       /* revise queue_actual to reflect the limit */
@@ -559,7 +567,7 @@
 
     if(bm->next_to_flush==bm->last_to_flush)return(0);
 
-    bin=bm->queue_actual[bm->next_to_flush];
+    bin=bm->queue_actual[bm->next_to_flush]&0x7fffffffUL;
     bytes=(BINBITS(bm->next_to_flush,bin)+7)/8;
     
     memcpy(op,bm->queue_packets+bm->next_to_flush,sizeof(*op));

1.1.2.3   +1 -6      vorbis/lib/Attic/bitrate.h

Index: bitrate.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/Attic/bitrate.h,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- bitrate.h	2001/11/22 06:21:07	1.1.2.2
+++ bitrate.h	2001/11/24 05:26:10	1.1.2.3
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: bitrate tracking and management
- last mod: $Id: bitrate.h,v 1.1.2.2 2001/11/22 06:21:07 xiphmont Exp $
+ last mod: $Id: bitrate.h,v 1.1.2.3 2001/11/24 05:26:10 xiphmont Exp $
 
  ********************************************************************/
 
@@ -66,11 +66,6 @@
 
 typedef struct bitrate_manager_info{
   /* detailed bitrate management setup */
-  double absolute_min_short;
-  double absolute_min_long;
-  double absolute_max_short;
-  double absolute_max_long;
-
   double queue_avg_time;
   double queue_avg_center;
   double queue_minmax_time;

1.37.2.9  +1 -9      vorbis/lib/mapping0.c

Index: mapping0.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/mapping0.c,v
retrieving revision 1.37.2.8
retrieving revision 1.37.2.9
diff -u -r1.37.2.8 -r1.37.2.9
--- mapping0.c	2001/11/22 06:21:08	1.37.2.8
+++ mapping0.c	2001/11/24 05:26:10	1.37.2.9
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: channel mapping 0 implementation
- last mod: $Id: mapping0.c,v 1.37.2.8 2001/11/22 06:21:08 xiphmont Exp $
+ last mod: $Id: mapping0.c,v 1.37.2.9 2001/11/24 05:26:10 xiphmont Exp $
 
  ********************************************************************/
 
@@ -466,8 +466,6 @@
     int     *chbundle=alloca(sizeof(*chbundle)*info->submaps);
     int      chcounter=0;
 
-    long  minbits;
-
     /* play a little loose with this abstraction */
     int   quant_passes=ci->coupling_passes;
 
@@ -532,12 +530,6 @@
       classifications[i]=look->residue_func[i]->
         class(vb,look->residue_look[i],pcmbundle[i],zerobundle[i],chbundle[i]);
     }
-
-    /* this is the only good place to enforce minimum by-packet bitrate */
-    if(vb->W)
-      minbits=bi->absolute_min_long/vi->rate*ci->blocksizes[1]/2;
-    else
-      minbits=bi->absolute_min_short/vi->rate*ci->blocksizes[0]/2;
 
     /* actual encoding loop; we pack all the iterations to collect
        management data */

No                   revision

No                   revision

1.4.2.11  +6 -4      vorbis/lib/modes/mode_44c_A.h

Index: mode_44c_A.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/modes/mode_44c_A.h,v
retrieving revision 1.4.2.10
retrieving revision 1.4.2.11
diff -u -r1.4.2.10 -r1.4.2.11
--- mode_44c_A.h	2001/11/22 07:54:41	1.4.2.10
+++ mode_44c_A.h	2001/11/24 05:26:11	1.4.2.11
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: predefined encoding modes; 44kHz stereo ~64kbps true VBR
- last mod: $Id: mode_44c_A.h,v 1.4.2.10 2001/11/22 07:54:41 xiphmont Exp $
+ last mod: $Id: mode_44c_A.h,v 1.4.2.11 2001/11/24 05:26:11 xiphmont Exp $
 
  ********************************************************************/
 
@@ -82,10 +82,12 @@
 
 static bitrate_manager_info _bm_set_44c_A={
   /* progressive coding and bitrate controls */
-            110000,90000,     -1,-1,
   2.,.5,
-  2.,       128000,           128000,  
-            128000,           128000,
+  //2.,       128000,           128000,  
+  //          128000,           128000,
+
+  2.,       0,           0,  
+            0,           0,
            
   4.0, 0.,  -1.,              .05, 
             -.05,             .05,

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