[xiph-cvs] cvs commit: vorbis/lib/modes mode_44c_A.h
Monty
xiphmont at xiph.org
Fri Oct 19 20:00:12 PDT 2001
xiphmont 01/10/19 20:00:11
Modified: lib Tag: branch_monty_20011009 block.c codec_internal.h
mapping0.c
lib/modes Tag: branch_monty_20011009 mode_44c_A.h
Log:
OK, I think we've mostly got it. Moved to single queue system, added hysterysis
Monty
Revision Changes Path
No revision
No revision
1.50.2.4 +12 -14 vorbis/lib/block.c
Index: block.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/block.c,v
retrieving revision 1.50.2.3
retrieving revision 1.50.2.4
diff -u -r1.50.2.3 -r1.50.2.4
--- block.c 2001/10/16 20:10:10 1.50.2.3
+++ block.c 2001/10/20 03:00:09 1.50.2.4
@@ -11,7 +11,7 @@
********************************************************************
function: PCM data vector blocking, windowing and dis/reassembly
- last mod: $Id: block.c,v 1.50.2.3 2001/10/16 20:10:10 xiphmont Exp $
+ last mod: $Id: block.c,v 1.50.2.4 2001/10/20 03:00:09 xiphmont Exp $
Handle windowing, overlap-add, etc of the PCM vectors. This is made
more amusing by Vorbis' current two allowed block sizes.
@@ -272,22 +272,20 @@
{
codec_setup_info *ci=vi->codec_setup;
/* first find the max possible needed queue size */
- long maxpackets=(max(ci->bitrate_bound_queuetime,
- ci->bitrate_avg_queuetime)*
- vi->rate+(ci->blocksizes[0]-1))/ci->blocksizes[0]+1;
+ long maxpackets=(ci->bitrate_queue_time*vi->rate+(ci->blocksizes[0]-1))/ci->blocksizes[0]+1;
long bins=BITTRACK_DIVISOR*ci->passlimit[ci->coupling_passes-1];
- if(ci->bitrate_queue_loweravg<=0. &&
- ci->bitrate_queue_upperavg<=0.)bins=0;
+ if(ci->bitrate_queue_avgmin<=0. &&
+ ci->bitrate_queue_avgmax<=0.)bins=0;
b->bitrate_queue_size=maxpackets;
b->bitrate_bins=bins;
- b->bitrate_queue=_ogg_malloc(maxpackets*sizeof(*b->bitrate_queue));
+ b->bitrate_queue_actual=_ogg_malloc(maxpackets*sizeof(*b->bitrate_queue_actual));
if(bins){
- b->bitrate_queue_bin=_ogg_malloc(maxpackets*bins*
- sizeof(*b->bitrate_queue));
- b->bitrate_avgbitacc=_ogg_malloc(bins*sizeof(*b->bitrate_avgbitacc));
+ b->bitrate_queue_binned=_ogg_malloc(maxpackets*bins*
+ sizeof(*b->bitrate_queue_binned));
+ b->bitrate_queue_binacc=_ogg_malloc(bins*sizeof(*b->bitrate_queue_binacc));
}
- b->bitrate_floatinglimit=ci->bitrate_floatinglimit_initial;
+ b->bitrate_avgfloat=ci->bitrate_avgfloat_initial;
}
return(0);
@@ -330,9 +328,9 @@
_ogg_free(b->transform[1]);
}
if(b->psy_g_look)_vp_global_free(b->psy_g_look);
- if(b->bitrate_queue)_ogg_free(b->bitrate_queue);
- if(b->bitrate_queue_bin)_ogg_free(b->bitrate_queue_bin);
- if(b->bitrate_avgbitacc)_ogg_free(b->bitrate_avgbitacc);
+ if(b->bitrate_queue_actual)_ogg_free(b->bitrate_queue_actual);
+ if(b->bitrate_queue_binned)_ogg_free(b->bitrate_queue_binned);
+ if(b->bitrate_queue_binacc)_ogg_free(b->bitrate_queue_binacc);
}
1.9.4.4 +21 -23 vorbis/lib/codec_internal.h
Index: codec_internal.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/codec_internal.h,v
retrieving revision 1.9.4.3
retrieving revision 1.9.4.4
diff -u -r1.9.4.3 -r1.9.4.4
--- codec_internal.h 2001/10/16 20:10:10 1.9.4.3
+++ codec_internal.h 2001/10/20 03:00:09 1.9.4.4
@@ -10,7 +10,7 @@
********************************************************************
function: libvorbis codec headers
- last mod: $Id: codec_internal.h,v 1.9.4.3 2001/10/16 20:10:10 xiphmont Exp $
+ last mod: $Id: codec_internal.h,v 1.9.4.4 2001/10/20 03:00:09 xiphmont Exp $
********************************************************************/
@@ -68,22 +68,19 @@
unsigned char *header2;
/* encode side bitrate tracking */
- ogg_uint32_t *bitrate_queue;
- ogg_uint32_t *bitrate_queue_bin;
+ ogg_uint32_t *bitrate_queue_actual;
+ ogg_uint32_t *bitrate_queue_binned;
int bitrate_queue_size;
int bitrate_queue_head;
int bitrate_bins;
/* 0, -1, -4, -16, -n/16, -n/8, -n/4, -n/2 */
- long bitrate_boundbitacc[8];
- long bitrate_boundsampleacc[8];
- long bitrate_boundtail[8];
-
- long *bitrate_avgbitacc;
- long bitrate_avgsampleacc;
- long bitrate_avgtail;
+ long bitrate_queue_bitacc[8];
+ long bitrate_queue_sampleacc[8];
+ long bitrate_queue_tail[8];
+ long *bitrate_queue_binacc;
- double bitrate_floatinglimit;
+ double bitrate_avgfloat;
} backend_lookup_state;
@@ -128,23 +125,24 @@
vorbis_info_psy_global *psy_g_param;
/* detailed bitrate management setup */
- double bitrate_floatinglimit_initial; /* set by mode */
- double bitrate_floatinglimit_minimum; /* set by mode */
- double bitrate_floatinglimit_upslew_max;
- double bitrate_floatinglimit_downslew_max;
-
- double bitrate_bound_queuetime;
- double bitrate_avg_queuetime;
-
double bitrate_absolute_min_short;
double bitrate_absolute_min_long;
double bitrate_absolute_max_short;
double bitrate_absolute_max_long;
+
+ double bitrate_queue_time;
+ double bitrate_queue_hardmin;
+ double bitrate_queue_hardmax;
+ double bitrate_queue_avgmin;
+ double bitrate_queue_avgmax;
+
+ double bitrate_avgfloat_initial; /* set by mode */
+ double bitrate_avgfloat_minimum; /* set by mode */
+ double bitrate_avgfloat_downslew_max;
+ double bitrate_avgfloat_upslew_max;
+ double bitrate_avgfloat_downhyst;
+ double bitrate_avgfloat_uphyst;
- double bitrate_queue_min;
- double bitrate_queue_max;
- double bitrate_queue_loweravg;
- double bitrate_queue_upperavg;
int passlimit[32]; /* iteration limit per couple/quant pass */
int coupling_passes;
1.37.2.5 +67 -136 vorbis/lib/mapping0.c
Index: mapping0.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/mapping0.c,v
retrieving revision 1.37.2.4
retrieving revision 1.37.2.5
diff -u -r1.37.2.4 -r1.37.2.5
--- mapping0.c 2001/10/20 01:03:59 1.37.2.4
+++ mapping0.c 2001/10/20 03:00:10 1.37.2.5
@@ -11,7 +11,7 @@
********************************************************************
function: channel mapping 0 implementation
- last mod: $Id: mapping0.c,v 1.37.2.4 2001/10/20 01:03:59 xiphmont Exp $
+ last mod: $Id: mapping0.c,v 1.37.2.5 2001/10/20 03:00:10 xiphmont Exp $
********************************************************************/
@@ -284,26 +284,26 @@
static double floater_interpolate(backend_lookup_state *b,vorbis_info *vi,
double desired_rate){
- int bin=b->bitrate_floatinglimit*BITTRACK_DIVISOR-1.;
+ int bin=b->bitrate_avgfloat*BITTRACK_DIVISOR-1.;
double lobitrate;
double hibitrate;
if(desired_rate<=0.)return(0.);
lobitrate=(double)(bin==0?0.:
- b->bitrate_avgbitacc[bin-1])/b->bitrate_avgsampleacc*vi->rate;
+ b->bitrate_queue_binacc[bin-1])/b->bitrate_queue_sampleacc[0]*vi->rate;
while(lobitrate>desired_rate && bin>0){
bin--;
lobitrate=(double)(bin==0?0.:
- b->bitrate_avgbitacc[bin-1])/b->bitrate_avgsampleacc*vi->rate;
+ b->bitrate_queue_binacc[bin-1])/b->bitrate_queue_sampleacc[0]*vi->rate;
}
- hibitrate=(bin>=b->bitrate_bins?b->bitrate_avgbitacc[b->bitrate_bins-1]:
- (double)b->bitrate_avgbitacc[bin])/b->bitrate_avgsampleacc*vi->rate;
+ hibitrate=(bin>=b->bitrate_bins?b->bitrate_queue_binacc[b->bitrate_bins-1]:
+ (double)b->bitrate_queue_binacc[bin])/b->bitrate_queue_sampleacc[0]*vi->rate;
while(hibitrate<desired_rate && bin<b->bitrate_bins){
bin++;
if(bin<b->bitrate_bins)
- hibitrate=(double)b->bitrate_avgbitacc[bin]/b->bitrate_avgsampleacc*vi->rate;
+ hibitrate=(double)b->bitrate_queue_binacc[bin]/b->bitrate_queue_sampleacc[0]*vi->rate;
}
/* interpolate */
@@ -584,22 +584,22 @@
ci->bitrate_absolute_min_long/vi->rate*ci->blocksizes[1]/2:
ci->bitrate_absolute_min_short/vi->rate*ci->blocksizes[0]/2);
- long minbits_period=ci->bitrate_queue_min/vi->rate*
- (b->bitrate_boundsampleacc[0]+ci->blocksizes[vb->W]/2)-
- b->bitrate_boundbitacc[0];
+ long minbits_period=ci->bitrate_queue_hardmin/vi->rate*
+ (b->bitrate_queue_sampleacc[0]+ci->blocksizes[vb->W]/2)-
+ b->bitrate_queue_bitacc[0];
- long period_samples=max(ci->bitrate_bound_queuetime*vi->rate,
- b->bitrate_boundsampleacc[0]);
+ long period_samples=max(ci->bitrate_queue_time*vi->rate,
+ b->bitrate_queue_sampleacc[0]);
long maxbits_period=-1;
/* pessimistic checkahead */
for(i=0;i<8;i++){
- long ahead_samples=period_samples-b->bitrate_boundsampleacc[i];
+ long ahead_samples=period_samples-b->bitrate_queue_sampleacc[i];
if(ahead_samples>=0){
- long maxbits_local=ci->bitrate_queue_max/vi->rate*
+ long maxbits_local=ci->bitrate_queue_hardmax/vi->rate*
(period_samples+ci->blocksizes[vb->W]/2)-
- b->bitrate_boundbitacc[i]-
- ci->bitrate_queue_min/vi->rate*ahead_samples;
+ b->bitrate_queue_bitacc[i]-
+ ci->bitrate_queue_hardmin/vi->rate*ahead_samples;
if(maxbits_period==-1 || maxbits_local<maxbits_period)
maxbits_period=maxbits_local;
@@ -609,7 +609,7 @@
if(maxbits_absolute){
- if(ci->bitrate_queue_max>0.){
+ if(ci->bitrate_queue_hardmax>0.){
maxbits=min(maxbits_period,maxbits_absolute);
}else{
maxbits=maxbits_absolute;
@@ -636,91 +636,25 @@
vector, according residue mapping */
for(j=0;j<info->submaps;j++){
- ogg_uint32_t *queueptr=b->bitrate_queue_bin;
+ ogg_uint32_t *queueptr=b->bitrate_queue_binned;
if(queueptr)queueptr+=b->bitrate_queue_head*b->bitrate_bins;
if(stoppos){
look->residue_func[j]->
forward(vb,look->residue_look[j],
qbundle[j],sobundle[j],zerobundle[j],chbundle[j],
- i,classifications[j],b->bitrate_floatinglimit,queueptr);
+ i,classifications[j],b->bitrate_avgfloat,queueptr);
}else{
stoppos=look->residue_func[j]->
forward(vb,look->residue_look[j],
qbundle[j],sobundle[j],zerobundle[j],chbundle[j],
- i,classifications[j],b->bitrate_floatinglimit,queueptr);
+ i,classifications[j],b->bitrate_avgfloat,queueptr);
}
i++;
}
- {
- char buf[80];
- int k;
- float *pcmM=sofar[info->coupling_mag[0]];
- float *pcmA=sofar[info->coupling_ang[0]];
- float *a=alloca(sizeof(*a)*n/2);
- float *b=alloca(sizeof(*b)*n/2);
- sprintf(buf,"sofar%d",i);
-
- /* channel coupling */
-
- for(j=0;j<n/2;j++){
- float mag=pcmM[j];
- float ang=pcmA[j];
-
- if(mag>0)
- if(ang>0){
- a[j]=mag;
- b[j]=mag-ang;
- }else{
- b[j]=mag;
- a[j]=mag+ang;
- }
- else
- if(ang>0){
- a[j]=mag;
- b[j]=mag+ang;
- }else{
- b[j]=mag;
- a[j]=mag-ang;
- }
- }
-
- _analysis_output(buf,seq,a,n/2,1,0);
- _analysis_output(buf,seq+1,b,n/2,1,0);
-
- pcmM=quantized[info->coupling_mag[0]];
- pcmA=quantized[info->coupling_ang[0]];
- sprintf(buf,"uquant%d",i);
-
- for(j=0;j<n/2;j++){
- float mag=pcmM[j];
- float ang=pcmA[j];
-
- if(mag>0)
- if(ang>0){
- a[j]=mag;
- b[j]=mag-ang;
- }else{
- b[j]=mag;
- a[j]=mag+ang;
- }
- else
- if(ang>0){
- a[j]=mag;
- b[j]=mag+ang;
- }else{
- b[j]=mag;
- a[j]=mag-ang;
- }
- }
-
- _analysis_output(buf,seq,a,n/2,1,0);
- _analysis_output(buf,seq+1,b,n/2,1,0);
- }
-
/* bitrate management.... deciding when it's time to stop. */
if(i<quant_passes){
if(b->bitrate_bins==0){ /* average bitrate always runs
@@ -735,7 +669,7 @@
stopflag=1;
}else{
if(current_bytes>(minbits+7)/8){
- if(ci->passlimit[i-1]>=b->bitrate_floatinglimit){
+ if(ci->passlimit[i-1]>=b->bitrate_avgfloat){
if(!stoppos)stoppos=current_bytes;
if(stoppos<current_bytes)
stopflag=1;
@@ -791,14 +725,14 @@
fprintf(stderr,"Bitrate: cav %d, cmin %ld, cmax %ld, float %.1f,"
" this %ld\n",
- (int)((double)b->bitrate_boundbitacc[0]*vi->rate/b->bitrate_boundsampleacc[0]),
- minbits,maxbits,b->bitrate_floatinglimit,
+ (int)((double)b->bitrate_queue_bitacc[0]*vi->rate/b->bitrate_queue_sampleacc[0]),
+ minbits,maxbits,b->bitrate_avgfloat,
oggpack_bytes(&vb->opb)*8);
/* track bitrate*/
/* update boundary accumulators */
for(i=0;i<8;i++){
- long desired=ci->bitrate_bound_queuetime*vi->rate;
+ long desired=ci->bitrate_queue_time*vi->rate;
switch(i){
case 0:
break;
@@ -812,64 +746,59 @@
desired-=ci->blocksizes[0]*8;
break;
case 4:
- desired-=ci->bitrate_bound_queuetime*vi->rate*(1./16.);
+ desired-=ci->bitrate_queue_time*vi->rate*(1./16.);
break;
case 5:
- desired-=ci->bitrate_bound_queuetime*vi->rate*(1./8.);
+ desired-=ci->bitrate_queue_time*vi->rate*(1./8.);
break;
case 6:
- desired-=ci->bitrate_bound_queuetime*vi->rate*(1./4.);
+ desired-=ci->bitrate_queue_time*vi->rate*(1./4.);
break;
case 7:
- desired-=ci->bitrate_bound_queuetime*vi->rate*(1./2.);
+ desired-=ci->bitrate_queue_time*vi->rate*(1./2.);
break;
}
- while(b->bitrate_boundsampleacc[i]>desired){
+ while(b->bitrate_queue_sampleacc[i]>desired){
int samples=ci->blocksizes[0]>>1;
- if(b->bitrate_queue[b->bitrate_boundtail[i]]&0x80000000UL)
+ if(b->bitrate_queue_actual[b->bitrate_queue_tail[i]]&0x80000000UL)
samples=ci->blocksizes[1]>>1;
- b->bitrate_boundsampleacc[i]-=samples;
- b->bitrate_boundbitacc[i]-=
- b->bitrate_queue[b->bitrate_boundtail[i]]&0x7fffffffUL;
- b->bitrate_boundtail[i]++;
- if(b->bitrate_boundtail[i]>=b->bitrate_queue_size)
- b->bitrate_boundtail[i]=0;
+ b->bitrate_queue_sampleacc[i]-=samples;
+ b->bitrate_queue_bitacc[i]-=
+ b->bitrate_queue_actual[b->bitrate_queue_tail[i]]&0x7fffffffUL;
+
+ /* update moving average accumulators */
+ if(i==0){
+ for(j=0;j<b->bitrate_bins;j++)
+ b->bitrate_queue_binacc[j]-=
+ b->bitrate_queue_binned[b->bitrate_queue_tail[0]*b->bitrate_bins+j];
+ }
+
+ b->bitrate_queue_tail[i]++;
+ if(b->bitrate_queue_tail[i]>=b->bitrate_queue_size)
+ b->bitrate_queue_tail[i]=0;
+
}
}
- /* update moving average accumulators */
- while(b->bitrate_avgsampleacc>ci->bitrate_avg_queuetime*vi->rate){
- int samples=ci->blocksizes[0]>>1;
- if(b->bitrate_queue[b->bitrate_avgtail]&0x80000000UL)
- samples=ci->blocksizes[1]>>1;
- b->bitrate_avgsampleacc-=samples;
- for(i=0;i<b->bitrate_bins;i++)
- b->bitrate_avgbitacc[i]-=
- b->bitrate_queue_bin[b->bitrate_avgtail*b->bitrate_bins+i];
- b->bitrate_avgtail++;
- if(b->bitrate_avgtail>=b->bitrate_queue_size)b->bitrate_avgtail=0;
- }
-
/* update queue head */
if(oggpack_bytes(&vb->opb)>2){
int bits=oggpack_bytes(&vb->opb)*8;
/* boundaries */
- b->bitrate_queue[b->bitrate_queue_head]=bits;
- if(vb->W)b->bitrate_queue[b->bitrate_queue_head]|=0x80000000UL;
+ b->bitrate_queue_actual[b->bitrate_queue_head]=bits;
+ if(vb->W)b->bitrate_queue_actual[b->bitrate_queue_head]|=0x80000000UL;
for(i=0;i<8;i++){
- b->bitrate_boundbitacc[i]+=bits;
- b->bitrate_boundsampleacc[i]+=ci->blocksizes[vb->W]>>1;
+ b->bitrate_queue_bitacc[i]+=bits;
+ b->bitrate_queue_sampleacc[i]+=ci->blocksizes[vb->W]>>1;
}
/* bins */
if(b->bitrate_bins){
for(i=0;i<b->bitrate_bins;i++)
- b->bitrate_avgbitacc[i]+=
- b->bitrate_queue_bin[b->bitrate_queue_head*b->bitrate_bins+i];
- b->bitrate_avgsampleacc+=ci->blocksizes[vb->W]>>1;
+ b->bitrate_queue_binacc[i]+=
+ b->bitrate_queue_binned[b->bitrate_queue_head*b->bitrate_bins+i];
}
b->bitrate_queue_head++;
@@ -882,28 +811,30 @@
flaoter setting we want */
if(b->bitrate_bins>0 &&
- (b->bitrate_avgsampleacc>ci->bitrate_avg_queuetime*vi->rate/8 ||
- b->bitrate_avgsampleacc>8192)){
- double upper=floater_interpolate(b,vi,ci->bitrate_queue_upperavg);
- double lower=floater_interpolate(b,vi,ci->bitrate_queue_loweravg);
- double new=ci->bitrate_floatinglimit_initial;
+ (b->bitrate_queue_sampleacc[0]>ci->bitrate_queue_time*vi->rate/8 ||
+ b->bitrate_queue_sampleacc[0]>8192)){
+ double upper=floater_interpolate(b,vi,ci->bitrate_queue_avgmax);
+ double lower=floater_interpolate(b,vi,ci->bitrate_queue_avgmin);
+ double new=ci->bitrate_avgfloat_initial;
double slew;
fprintf(stderr,"\tupper:%g :: lower:%g\n",upper,lower);
if(upper>0. && upper<new)new=upper;
- if(lower<ci->bitrate_floatinglimit_minimum)
- lower=ci->bitrate_floatinglimit_minimum;
+ if(lower<ci->bitrate_avgfloat_minimum)
+ lower=ci->bitrate_avgfloat_minimum;
if(lower>new)new=lower;
- slew=new-b->bitrate_floatinglimit;
+ slew=new-b->bitrate_avgfloat;
- if(slew<ci->bitrate_floatinglimit_downslew_max)
- new=b->bitrate_floatinglimit+ci->bitrate_floatinglimit_downslew_max;
- if(slew>ci->bitrate_floatinglimit_upslew_max)
- new=b->bitrate_floatinglimit+ci->bitrate_floatinglimit_upslew_max;
-
- b->bitrate_floatinglimit=new;
+ if(slew<ci->bitrate_avgfloat_downhyst || slew>ci->bitrate_avgfloat_uphyst){
+ if(slew<ci->bitrate_avgfloat_downslew_max)
+ new=b->bitrate_avgfloat+ci->bitrate_avgfloat_downslew_max;
+ if(slew>ci->bitrate_avgfloat_upslew_max)
+ new=b->bitrate_avgfloat+ci->bitrate_avgfloat_upslew_max;
+
+ b->bitrate_avgfloat=new;
+ }
}
}
No revision
No revision
1.4.2.7 +6 -9 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.6
retrieving revision 1.4.2.7
diff -u -r1.4.2.6 -r1.4.2.7
--- mode_44c_A.h 2001/10/20 01:04:08 1.4.2.6
+++ mode_44c_A.h 2001/10/20 03:00:11 1.4.2.7
@@ -11,7 +11,7 @@
********************************************************************
function: predefined encoding modes; 44kHz stereo ~64kbps true VBR
- last mod: $Id: mode_44c_A.h,v 1.4.2.6 2001/10/20 01:04:08 xiphmont Exp $
+ last mod: $Id: mode_44c_A.h,v 1.4.2.7 2001/10/20 03:00:11 xiphmont Exp $
********************************************************************/
@@ -386,15 +386,12 @@
&_psy_set_44c_AG,
/* progressive coding and bitrate controls */
- 4.0, 0., .1, -1.,
-
- 1.,4.,
-
- 110000,90000, 0,0,
-
- 112000,140000,
-
- 124000,128000,
+ 110000,90000, 0,0,
+ 4., 112000, 140000,
+ 124000, 128000,
+
+ 4.0, 0., -1., .05,
+ -.05, .05,
{4,5,6,7},
4,
--- >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