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

Monty xiphmont at xiph.org
Sun Dec 23 03:53:55 PST 2001



xiphmont    01/12/23 03:53:54

  Modified:    lib      bitrate.c bitrate.h block.c vorbisenc.c
               lib/modes residue_44.h
  Log:
  beginning-of-stream tuning oops in bitrate management

Revision  Changes    Path
1.8       +29 -28    vorbis/lib/bitrate.c

Index: bitrate.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/bitrate.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- bitrate.c	2001/12/23 10:12:03	1.7
+++ bitrate.c	2001/12/23 11:53:52	1.8
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: bitrate tracking and management
- last mod: $Id: bitrate.c,v 1.7 2001/12/23 10:12:03 xiphmont Exp $
+ last mod: $Id: bitrate.c,v 1.8 2001/12/23 11:53:52 xiphmont Exp $
 
  ********************************************************************/
 
@@ -294,17 +294,6 @@
 
     if(bm->avg_sampleacc>bm->avg_sampledesired || eofflag){
 
-      /* update the avg tail if needed */
-      while(bm->avg_sampleacc>bm->avg_sampledesired){
-	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]-=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;
-      }
-      
       /* update the avg center */
       if(bm->avg_centeracc>desired_center){
         /* choose the new average floater */
@@ -321,14 +310,14 @@
         
         slew=(new-bm->avgfloat)/samples*vi->rate;
         
-	if(slew<bi->avgfloat_downhyst || slew>bi->avgfloat_uphyst){
-	  if(slew<bi->avgfloat_downslew_max)
-	    new=bm->avgfloat+bi->avgfloat_downslew_max/vi->rate*samples;
-	  if(slew>bi->avgfloat_upslew_max)
-	    new=bm->avgfloat+bi->avgfloat_upslew_max/vi->rate*samples;
-	  
-	  bm->avgfloat=new;
-	}
+	if(slew<bi->avgfloat_downslew_max)
+	  new=bm->avgfloat+bi->avgfloat_downslew_max/vi->rate*samples;
+	if(slew>bi->avgfloat_upslew_max)
+	  new=bm->avgfloat+bi->avgfloat_upslew_max/vi->rate*samples;
+	
+	bm->avgfloat=new;
+
+	fprintf(stderr,"%d float: %f\n",bm->avg_center,new);
         
         /* apply the average floater to new blocks */
         bin=bm->avgfloat*(BITTRACK_DIVISOR<<BITTRACK_BPT);
@@ -372,7 +361,7 @@
               bm->avgnoise+=1.f;
             bm->noisetrigger_postpone=bm->avg_sampleacc/2;
           }
-
+	  
           /* we generally want the noise bias to drift back to zero */
           bm->noisetrigger_request=0.f;
           if(bm->avgnoise>0)
@@ -386,6 +375,19 @@
             bm->avgnoise=bi->avgfloat_noise_maxval;
         }
       }
+      
+      /* update the avg tail if needed */
+      while(bm->avg_sampleacc>bm->avg_sampledesired){
+	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]-=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;
+      }
+      
+      
     }
   }else{
     /* if we're not using an average tracker, the 'float' is nailed to
@@ -399,13 +401,13 @@
   /* update the min/max queues and enforce limits */
   if(bm->minmax_binstack){
     unsigned long sampledesired=eofflag?0:bm->minmax_sampledesired;
-
+    
     /* add to stack recent */
     while(minmax_head!=new_minmax_head){
       unsigned int i;
       int samples=ci->blocksizes[bm->queue_actual[minmax_head]&
                                 0x80000000UL?1:0]>>1;
-
+      
         /* the construction here is not parallel to the floater's
            stack.  
 
@@ -451,13 +453,12 @@
       bm->minmax_limitstack[bm->minmax_stackptr]=0;
       bm->minmax_sampleacc+=samples;
       bm->minmax_acctotal+=
-	LACING_ADJUST(
-	BINBITS(bm,minmax_head,bm->queue_actual[minmax_head]));
+	LACING_ADJUST(BINBITS(bm,minmax_head,bm->queue_actual[minmax_head]));
       
       minmax_head++;
       if(minmax_head>=bm->queue_size)minmax_head=0;
     }
-
+    
     /* check limits, enforce changes */
     if(bm->minmax_sampleacc>sampledesired){
       double bitrate=(double)bm->minmax_acctotal/bm->minmax_sampleacc*vi->rate;
@@ -575,7 +576,7 @@
                 sizeof(*bm->minmax_limitstack)*bm->minmax_stackptr);
         bm->minmax_stackptr--;
       }
-
+      
       bm->minmax_tail++;
       if(bm->minmax_tail>=bm->queue_size)bm->minmax_tail=0;
     }
@@ -610,12 +611,12 @@
     bytes=(BINBITS(bm,bm->next_to_flush,bin)+7)/8;
     
     memcpy(op,bm->queue_packets+bm->next_to_flush,sizeof(*op));
+
     if(bytes<op->bytes)op->bytes=bytes;
 
     bm->next_to_flush++;
     if(bm->next_to_flush>=bm->queue_size)bm->next_to_flush=0;
 
-    if(bytes==0)exit(1);
   }
 
   return(1);

1.5       +1 -3      vorbis/lib/bitrate.h

Index: bitrate.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/bitrate.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- bitrate.h	2001/12/23 10:12:03	1.4
+++ bitrate.h	2001/12/23 11:53:52	1.5
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: bitrate tracking and management
- last mod: $Id: bitrate.h,v 1.4 2001/12/23 10:12:03 xiphmont Exp $
+ last mod: $Id: bitrate.h,v 1.5 2001/12/23 11:53:52 xiphmont Exp $
 
  ********************************************************************/
 
@@ -79,8 +79,6 @@
   double avgfloat_minimum; /* set by mode */
   double avgfloat_downslew_max;
   double avgfloat_upslew_max;
-  double avgfloat_downhyst;
-  double avgfloat_uphyst;
   double avgfloat_noise_lowtrigger;
   double avgfloat_noise_hightrigger;
   double avgfloat_noise_minval;

1.55      +21 -28    vorbis/lib/block.c

Index: block.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/block.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -r1.54 -r1.55
--- block.c	2001/12/21 14:52:35	1.54
+++ block.c	2001/12/23 11:53:52	1.55
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: PCM data vector blocking, windowing and dis/reassembly
- last mod: $Id: block.c,v 1.54 2001/12/21 14:52:35 segher Exp $
+ last mod: $Id: block.c,v 1.55 2001/12/23 11:53:52 xiphmont Exp $
 
  Handle windowing, overlap-add, etc of the PCM vectors.  This is made
  more amusing by Vorbis' current two allowed block sizes.
@@ -502,7 +502,6 @@
     if(bp==-1)return(0); /* not enough data currently to search for a
                             full long block */
     v->nW=bp;
-    /*v->nW=0;*/
 
   }else
     v->nW=0;
@@ -551,35 +550,31 @@
   }
  
   vb->vd=v;
-  vb->sequence=v->sequence;
+  vb->sequence=v->sequence++;
   vb->granulepos=v->granulepos;
   vb->pcmend=ci->blocksizes[v->W];
-
   
   /* copy the vectors; this uses the local storage in vb */
-  {
-    vorbis_block_internal *vbi=(vorbis_block_internal *)vb->internal;
-
-    /* this tracks 'strongest peak' for later psychoacoustics */
-    /* moved to the global psy state; clean this mess up */
-    if(vbi->ampmax>g->ampmax)g->ampmax=vbi->ampmax;
-    g->ampmax=_vp_ampmax_decay(g->ampmax,v);
-    vbi->ampmax=g->ampmax;
-
-    vb->pcm=_vorbis_block_alloc(vb,sizeof(*vb->pcm)*vi->channels);
-    vbi->pcmdelay=_vorbis_block_alloc(vb,sizeof(*vbi->pcmdelay)*vi->channels);
-    for(i=0;i<vi->channels;i++){
-      vbi->pcmdelay[i]=
-	_vorbis_block_alloc(vb,(vb->pcmend+beginW)*sizeof(*vbi->pcmdelay[i]));
-      memcpy(vbi->pcmdelay[i],v->pcm[i],(vb->pcmend+beginW)*sizeof(*vbi->pcmdelay[i]));
-      vb->pcm[i]=vbi->pcmdelay[i]+beginW;
-      
-      /* before we added the delay 
-      vb->pcm[i]=_vorbis_block_alloc(vb,vb->pcmend*sizeof(*vb->pcm[i]));
-      memcpy(vb->pcm[i],v->pcm[i]+beginW,ci->blocksizes[v->W]*sizeof(*vb->pcm[i]));
-      */
 
-    }
+  /* this tracks 'strongest peak' for later psychoacoustics */
+  /* moved to the global psy state; clean this mess up */
+  if(vbi->ampmax>g->ampmax)g->ampmax=vbi->ampmax;
+  g->ampmax=_vp_ampmax_decay(g->ampmax,v);
+  vbi->ampmax=g->ampmax;
+  
+  vb->pcm=_vorbis_block_alloc(vb,sizeof(*vb->pcm)*vi->channels);
+  vbi->pcmdelay=_vorbis_block_alloc(vb,sizeof(*vbi->pcmdelay)*vi->channels);
+  for(i=0;i<vi->channels;i++){
+    vbi->pcmdelay[i]=
+      _vorbis_block_alloc(vb,(vb->pcmend+beginW)*sizeof(*vbi->pcmdelay[i]));
+    memcpy(vbi->pcmdelay[i],v->pcm[i],(vb->pcmend+beginW)*sizeof(*vbi->pcmdelay[i]));
+    vb->pcm[i]=vbi->pcmdelay[i]+beginW;
+    
+    /* before we added the delay 
+       vb->pcm[i]=_vorbis_block_alloc(vb,vb->pcmend*sizeof(*vb->pcm[i]));
+       memcpy(vb->pcm[i],v->pcm[i]+beginW,ci->blocksizes[v->W]*sizeof(*vb->pcm[i]));
+    */
+    
   }
   
   /* handle eof detection: eof==0 means that we've not yet received EOF
@@ -612,8 +607,6 @@
       v->lW=v->W;
       v->W=v->nW;
       v->centerW=new_centerNext;
-      
-      v->sequence++;
       
       if(v->eofflag){
         v->eofflag-=movementW;

1.33      +1 -5      vorbis/lib/vorbisenc.c

Index: vorbisenc.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/vorbisenc.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- vorbisenc.c	2001/12/23 10:12:03	1.32
+++ vorbisenc.c	2001/12/23 11:53:53	1.33
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: simple programmatic interface for encoder mode setup
- last mod: $Id: vorbisenc.c,v 1.32 2001/12/23 10:12:03 xiphmont Exp $
+ last mod: $Id: vorbisenc.c,v 1.33 2001/12/23 11:53:53 xiphmont Exp $
 
  ********************************************************************/
 
@@ -978,10 +978,6 @@
     ci->bi.queue_avgmax=tnominal;
 
     /* adjust management */
-    if(max_bitrate<=0. && min_bitrate<=0.){
-      /* just an average tracker; no reason for the window to be as small as 2s. */
-      //ci->bi.queue_avg_time=4.;
-    }
     ci->bi.avgfloat_noise_maxval=_bm_max_noise_offset[(int)approx_vbr];
 
   }

1.11      +3 -3      vorbis/lib/modes/residue_44.h

Index: residue_44.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/modes/residue_44.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- residue_44.h	2001/12/23 10:12:04	1.10
+++ residue_44.h	2001/12/23 11:53:54	1.11
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: toplevel residue templates for 32/44.1/48kHz
- last mod: $Id: residue_44.h,v 1.10 2001/12/23 10:12:04 xiphmont Exp $
+ last mod: $Id: residue_44.h,v 1.11 2001/12/23 11:53:54 xiphmont Exp $
 
  ********************************************************************/
 
@@ -24,8 +24,8 @@
   2.,       0,           0,  
             0,           0,
            
-  4.0,2.3, -350,              .02, 
-            -.00,             .00,
+  4.0,2.3, -9999,              .02, 
+
   3.2,5.0,
   0.,0.
 };

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