[xiph-cvs] cvs commit: vorbis/lib/modes psych_44.h
Monty
xiphmont at xiph.org
Wed Dec 19 00:10:05 PST 2001
xiphmont 01/12/19 00:10:04
Modified: examples encoder_example.c
include/vorbis vorbisenc.h
lib bitrate.c vorbisenc.c
lib/modes psych_44.h
Log:
eliminate printfs
fix bug in management when only a hard minimum rate is specced
minor default tuning tweaks
Revision Changes Path
1.31 +5 -4 vorbis/examples/encoder_example.c
Index: encoder_example.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/examples/encoder_example.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- encoder_example.c 2001/12/19 01:08:13 1.30
+++ encoder_example.c 2001/12/19 08:10:02 1.31
@@ -11,7 +11,7 @@
********************************************************************
function: simple example encoder
- last mod: $Id: encoder_example.c,v 1.30 2001/12/19 01:08:13 xiphmont Exp $
+ last mod: $Id: encoder_example.c,v 1.31 2001/12/19 08:10:02 xiphmont Exp $
********************************************************************/
@@ -93,14 +93,15 @@
/********** Encode setup ************/
/* choose an encoding mode */
- /* (mode 0: 44kHz stereo uncoupled, roughly 128kbps VBR) */
+ /* (quality mode .4: 44kHz stereo coupled, roughly 128kbps VBR) */
vorbis_info_init(&vi);
- vorbis_encode_init_vbr(&vi,2,44100,.4);
+ vorbis_encode_init_vbr(&vi,2,44100,.1);
+ //vorbis_encode_init(&vi,2,44100,70000,64000,-1);
/* add a comment */
vorbis_comment_init(&vc);
- vorbis_comment_add(&vc,"ENCODER=encoder_example.c");
+ vorbis_comment_add_tag(&vc,"ENCODER","encoder_example.c");
/* set up the analysis state and auxiliary encoding storage */
vorbis_analysis_init(&vd,&vi);
1.7 +18 -1 vorbis/include/vorbis/vorbisenc.h
Index: vorbisenc.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis/include/vorbis/vorbisenc.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- vorbisenc.h 2001/12/19 02:08:55 1.6
+++ vorbisenc.h 2001/12/19 08:10:03 1.7
@@ -11,7 +11,7 @@
********************************************************************
function: vorbis encode-engine setup
- last mod: $Id: vorbisenc.h,v 1.6 2001/12/19 02:08:55 jack Exp $
+ last mod: $Id: vorbisenc.h,v 1.7 2001/12/19 08:10:03 xiphmont Exp $
********************************************************************/
@@ -33,12 +33,29 @@
long nominal_bitrate,
long min_bitrate);
+extern int vorbis_encode_setup_managed(vorbis_info *vi,
+ long channels,
+ long rate,
+
+ long max_bitrate,
+ long nominal_bitrate,
+ long min_bitrate);
+
+extern int vorbis_encode_setup_vbr(vorbis_info *vi,
+ long channels,
+ long rate,
+
+ float /* quality level from 0. (lo) to 1. (hi) */
+ );
+
extern int vorbis_encode_init_vbr(vorbis_info *vi,
long channels,
long rate,
float base_quality /* quality level from 0. (lo) to 1. (hi) */
);
+
+extern int vorbis_encode_setup_init(vorbis_info *vi);
extern int vorbis_encode_ctl(vorbis_info *vi,int number,void *arg);
1.6 +2 -9 vorbis/lib/bitrate.c
Index: bitrate.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/bitrate.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- bitrate.c 2001/12/19 07:33:51 1.5
+++ bitrate.c 2001/12/19 08:10:03 1.6
@@ -11,7 +11,7 @@
********************************************************************
function: bitrate tracking and management
- last mod: $Id: bitrate.c,v 1.5 2001/12/19 07:33:51 xiphmont Exp $
+ last mod: $Id: bitrate.c,v 1.6 2001/12/19 08:10:03 xiphmont Exp $
********************************************************************/
@@ -310,7 +310,6 @@
/* apply the average floater to new blocks */
bin=bm->avgfloat*BITTRACK_DIVISOR; /* truncate on purpose */
- fprintf(stderr,"u:%f l:%f float:%d ",upper,lower,bin);
while(bm->avg_centeracc>desired_center){
int samples=
samples=ci->blocksizes[bm->queue_actual[bm->avg_center]&
@@ -364,9 +363,6 @@
if(bm->avgnoise>bi->avgfloat_noise_maxval)
bm->avgnoise=bi->avgfloat_noise_maxval;
}
- fprintf(stderr,"noise:%f req:%f trigger:%ld\n",bm->avgnoise,
- bm->noisetrigger_request,bm->noisetrigger_postpone);
-
}
}else{
/* if we're not using an average tracker, the 'float' is nailed to
@@ -440,7 +436,6 @@
double bitrate=(double)bm->minmax_acctotal/bm->minmax_sampleacc*vi->rate;
int limit=0;
- fprintf(stderr,"prelimit:%dkbps ",(int)bitrate/1000);
if((bi->queue_hardmax>0 && bitrate>bi->queue_hardmax) ||
(bi->queue_hardmin>0 && bitrate<bi->queue_hardmin)){
int newstack;
@@ -451,7 +446,7 @@
/* we're off rate. Iteratively try out new hard floater
limits until we find one that brings us inside. Here's
where we see the whole point of the limit stacks. */
- if(bitrate>bi->queue_hardmax){
+ if(bi->queue_hardmax>0 && bitrate>bi->queue_hardmax){
for(limit=-1;limit>-bins;limit--){
long bitsum=limit_sum(bm,limit);
bitrate=(double)bitsum/bm->minmax_sampleacc*vi->rate;
@@ -468,7 +463,6 @@
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;
@@ -495,7 +489,6 @@
stackctr++;
bm->minmax_posstack[stackctr]=bm->minmax_posstack[bm->minmax_stackptr];
bm->minmax_limitstack[stackctr]=limit;
- fprintf(stderr,"limit:%d\n",limit);
/* set up new blank stack entry */
stackctr++;
1.27 +18 -11 vorbis/lib/vorbisenc.c
Index: vorbisenc.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/vorbisenc.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- vorbisenc.c 2001/12/19 07:33:51 1.26
+++ vorbisenc.c 2001/12/19 08:10:03 1.27
@@ -11,7 +11,7 @@
********************************************************************
function: simple programmatic interface for encoder mode setup
- last mod: $Id: vorbisenc.c,v 1.26 2001/12/19 07:33:51 xiphmont Exp $
+ last mod: $Id: vorbisenc.c,v 1.27 2001/12/19 08:10:03 xiphmont Exp $
********************************************************************/
@@ -804,7 +804,7 @@
bitrate/=ch;
- if(bitrate<r[0])return(0.);
+ if(bitrate<=r[0])return(0.);
for(i=0;i<10;i++)
if(r[i]<bitrate && r[i+1]>=bitrate)break;
if(i==10)return(10.);
@@ -953,16 +953,21 @@
if(hi->stereo_point_dB && hi->stereo_couple_p && channels==2){
hi->stereo_point_dB++;
if(hi->stereo_point_dB>3)hi->stereo_point_dB=3;
- }else{
- /* else, slug the vbr noise setting */
- int i;
- for(i=0;i<4;i++){
- hi->blocktype[i].noise_bias_quality-=.1;
- if(hi->blocktype[i].noise_bias_quality<0.)
- hi->blocktype[i].noise_bias_quality=0.;
- }
- }
-
+ }
+ /* slug the vbr noise setting*/
+ hi->blocktype[0].noise_bias_quality-=.1;
+ if(hi->blocktype[0].noise_bias_quality<0.)
+ hi->blocktype[0].noise_bias_quality=0.;
+ hi->blocktype[1].noise_bias_quality-=.1;
+ if(hi->blocktype[1].noise_bias_quality<0.)
+ hi->blocktype[1].noise_bias_quality=0.;
+ hi->blocktype[2].noise_bias_quality-=.05;
+ if(hi->blocktype[2].noise_bias_quality<0.)
+ hi->blocktype[2].noise_bias_quality=0.;
+ hi->blocktype[3].noise_bias_quality-=.05;
+ if(hi->blocktype[3].noise_bias_quality<0.)
+ hi->blocktype[3].noise_bias_quality=0.;
+
/* initialize management. Currently hardcoded for 44, but so is above. */
memcpy(&ci->bi,&_bm_44_default,sizeof(ci->bi));
ci->bi.queue_hardmin=min_bitrate;
@@ -976,6 +981,8 @@
/* 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];
+
}
return(ret);
1.5 +7 -1 vorbis/lib/modes/psych_44.h
Index: psych_44.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/modes/psych_44.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- psych_44.h 2001/12/19 01:10:27 1.4
+++ psych_44.h 2001/12/19 08:10:04 1.5
@@ -11,7 +11,7 @@
********************************************************************
function: key psychoacoustic settings for 44.1/48kHz
- last mod: $Id: psych_44.h,v 1.4 2001/12/19 01:10:27 xiphmont Exp $
+ last mod: $Id: psych_44.h,v 1.5 2001/12/19 08:10:04 xiphmont Exp $
********************************************************************/
@@ -638,4 +638,10 @@
/* lowpass **************/
static double _psy_lowpass_44[11]={
15.1,15.8,16.5,17.9,20.5,48.,999.,999.,999.,999.,999.
+};
+
+/* management noise offset */
+
+static double _bm_max_noise_offset[11]={
+ 1.,2.,3.,3.,4.,4.,4.,4.,4.,4.,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