diff options
author | Monty <xiphmont@xiph.org> | 2001-12-06 09:58:56 +0000 |
---|---|---|
committer | Monty <xiphmont@xiph.org> | 2001-12-06 09:58:56 +0000 |
commit | 34b47f195fa6ca2b812b4e973d058ccd6db9ac63 (patch) | |
tree | 93c84ba65a6febed079fcf5b7629471feeba30e2 | |
parent | d37d89ec96536216db586b113dd231833ccdb619 (diff) | |
download | libvorbis-git-34b47f195fa6ca2b812b4e973d058ccd6db9ac63.tar.gz |
continued debugging of vorbisenc.c
svn path=/branches/branch_monty_20011009/vorbis/; revision=2424
-rw-r--r-- | lib/modes/residue_44.h | 45 | ||||
-rw-r--r-- | lib/vorbisenc.c | 35 |
2 files changed, 46 insertions, 34 deletions
diff --git a/lib/modes/residue_44.h b/lib/modes/residue_44.h index d1e42673..a03f8090 100644 --- a/lib/modes/residue_44.h +++ b/lib/modes/residue_44.h @@ -11,7 +11,7 @@ ******************************************************************** function: toplevel residue templates for 32/44.1/48kHz - last mod: $Id: residue_44.h,v 1.1.2.2 2001/12/05 08:03:20 xiphmont Exp $ + last mod: $Id: residue_44.h,v 1.1.2.3 2001/12/06 09:58:56 xiphmont Exp $ ********************************************************************/ @@ -49,8 +49,7 @@ static bitrate_manager_info _bm_44_default={ 0 4 4 4 3 4 4 4 3 7 */ static vorbis_info_residue0 _residue_44_low={ 0,-1, -1, 10,-1, - /* 0 1 2 3 4 5 6 7 8 9 */ - { 0, 4, 4, 4, 3, 4, 4, 4, 3, 7}, + {0}, {-1}, {9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999}, { .5, 1.5, 2.5, 4.5, 22.5, 1.5, 2.5, 4.5, 22.5}, @@ -70,7 +69,7 @@ static vorbis_info_residue0 _residue_44_low={ static vorbis_info_residue0 _residue_44_mid={ 0,-1, -1, 10,-1, /* 0 1 2 3 4 5 6 7 8 9 */ - { 0, 4, 4, 4, 4, 4, 4, 3, 3, 7}, + {0}, {-1}, {9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999}, { .5, 1.5, 2.5, 4.5, 1.5, 2.5, 4.5, 22.5, 84.5}, @@ -91,7 +90,7 @@ static vorbis_info_residue0 _residue_44_mid={ static vorbis_info_residue0 _residue_44_high={ 0,-1, -1, 10,-1, /* 0 1 2 3 4 5 6 7 8 9 */ - { 0, 4, 3, 4, 4, 4, 4, 3, 3, 7}, + {0}, {-1}, {9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999}, { .5, 4.5, 22.5, 1.5, 2.5, 4.5, 7.5, 22.5, 84.5}, @@ -106,32 +105,32 @@ static vorbis_info_residue0 _residue_44_high={ static vorbis_residue_template _residue_template_44_stereo[11]={ /* mode 0; 64-ish */ {&_residue_44_low, {&44c0_short,&44c0_long}, - { {{-1}}, /* lossless stereo */ - {{-1}}, /* 6dB (2.5) stereo */ - {{-1}}, /* 12dB (4.5) stereo */ - {{-1}}, /* 17dB (7.5) stereo */ - {{&44c0_s0_p1_0},{&44c0_s0_p2_0},{&44c0_s0_p3_0},{&44c0_s0_p4_0,&44c0_p4_1}, - {&44c0_s1_p5_0},{&44c0_s1_p6_0},{&44c0_s2_p7_0},{&44c0_s4_p8_0,&44c0_s4_p8_1}, + { {{0}}, /* lossless stereo */ + {{0}}, /* 6dB (2.5) stereo */ + {{0}}, /* 12dB (4.5) stereo */ + {{0}}, /* 17dB (7.5) stereo */ + {{0,0,&44c0_s0_p1_0},{0,0,&44c0_s0_p2_0},{0,0,&44c0_s0_p3_0},{&44c0_s0_p4_0,&44c0_p4_1}, + {0,0,&44c0_s1_p5_0},{0,0,&44c0_s1_p6_0},{0,0,&44c0_s2_p7_0},{&44c0_s4_p8_0,&44c0_s4_p8_1}, {&44c0_s4_p9_0,&44c0_s4_p9_1,&44c0_s4_p9_2}}, /* 22dB (12.5) stereo */ - {{-1}}, /* 27dB (22.5) stereo */ + {{0}}, /* 27dB (22.5) stereo */ }, - { {-1}, /* lossless stereo */ - {-1}, /* 6dB (2.5) stereo */ - {-1}, /* 12dB (4.5) stereo */ - {-1}, /* 17dB (7.5) stereo */ - {-1,-1,-1,-1,-1,-1,-1,-1,&44c0_s4_s8,&44c0_s4_s9},/* 22dB (12.5) stereo */ - {-1}, /* 27dB (22.5) stereo */ + { {0}, /* lossless stereo */ + {0}, /* 6dB (2.5) stereo */ + {0}, /* 12dB (4.5) stereo */ + {0}, /* 17dB (7.5) stereo */ + {0,0,0,0,0,0,0,0,&44c0_s4_s8,&44c0_s4_s9},/* 22dB (12.5) stereo */ + {0}, /* 27dB (22.5) stereo */ }, - { {{-1}}, /* lossless stereo */ - {{-1}}, /* 6dB (2.5) stereo */ - {{-1}}, /* 12dB (4.5) stereo */ + { {{0}}, /* lossless stereo */ + {{0}}, /* 6dB (2.5) stereo */ + {{0}}, /* 12dB (4.5) stereo */ {{&44c0_s0_r0_0,&44c0_s0_r0_1},{&44c0_s0_r1_0,&44c0_s0_r1_1}, {&44c0_s0_r2_0,&44c0_s0_r2_1},{&44c0_s0_r3_0,&44c0_s0_r3_1}, {&44c0_s0_r4_0,&44c0_s0_r4_1},{&44c0_s1_r5_0,&44c0_s1_r5_1}, {&44c0_s1_r6_0,&44c0_s1_r6_1},{&44c0_s2_r7_0,&44c0_s2_r7_1}, {&44c0_s4_r8_0,&44c0_s3_r8_1},{&44c0_s4_r9_0,&44c0_s3_r9_1}}, /* 17dB (7.5) stereo */ - {{-1}}, /* 22dB (12.5) stereo */ - {{-1}}, /* 27dB (22.5) stereo */ + {{0}}, /* 22dB (12.5) stereo */ + {{0}}, /* 27dB (22.5) stereo */ }, } diff --git a/lib/vorbisenc.c b/lib/vorbisenc.c index a0c01cdf..eaa620d8 100644 --- a/lib/vorbisenc.c +++ b/lib/vorbisenc.c @@ -11,7 +11,7 @@ ******************************************************************** function: simple programmatic interface for encoder mode setup - last mod: $Id: vorbisenc.c,v 1.17.2.4 2001/12/06 08:56:16 xiphmont Exp $ + last mod: $Id: vorbisenc.c,v 1.17.2.5 2001/12/06 09:58:56 xiphmont Exp $ ********************************************************************/ @@ -400,21 +400,15 @@ static int vorbis_encode_residue_init(vorbis_info *vi,double q,int block, r=ci->residue_param[block]=malloc(sizeof(*r)); memcpy(r,in[iq].res,sizeof(*r)); - n=r->end=ci->blocksizes[block?1:0]>>1; /* to be adjusted by lowpass later */ - if(block){ r->grouping=32; }else{ r->grouping=16; } - res_position=rint((double)c[iq]*1000/vi->rate*n); - partition_position=res_position/r->grouping; - for(i=0;i<r->partitions;i++) - if(r->blimit[i]<0)r->blimit[i]=partition_position; - /* for uncoupled, we use type 1, else type 2 */ if(coupled_p){ + int k; vorbis_info_mapping0 *map=ci->map_param[block]; map->coupling_steps=1; @@ -435,6 +429,12 @@ static int vorbis_encode_residue_init(vorbis_info *vi,double q,int block, psy->couple_pass[0].couple_pass[1].outofphase_requant_limit=9e10; psy->couple_pass[0].couple_pass[1].amppost_point=stereo_threshholds[a[iq]]; amplitude_select=a[iq]; + + for(i=0;i<r->partitions;i++) + for(k=0;k<3;k++) + if(in[iq].books_base[a[iq]][i][k]) + r->secondstages[i]|=(1<<k); + ci->passlimit[0]=3; if(stereo_backfill_p && a[iq]){ @@ -520,7 +520,20 @@ static int vorbis_encode_residue_init(vorbis_info *vi,double q,int block, } } } - + + switch(ci->residue_type[block]){ + case 1: + n=r->end=ci->blocksizes[block?1:0]>>1; /* to be adjusted by lowpass later */ + break; + case 2: + n=r->end=ci->blocksizes[block?1:0]; /* to be adjusted by lowpass later */ + break; + } + + partition_position=rint((double)c[iq]*1000/(vi->rate/2)*n/r->grouping); + for(i=0;i<r->partitions;i++) + if(r->blimit[i]<0)r->blimit[i]=partition_position; + return(0); } @@ -547,14 +560,14 @@ static int vorbis_encode_lowpass_init(vorbis_info *vi,double q,int block,...){ dq=q*10.-iq; } - freq=x[iq]*(1.-dq)+x[iq+1]*dq; + freq=(x[iq]*(1.-dq)+x[iq+1]*dq)*1000.; /* lowpass needs to be set in the floor and the residue. */ /* in the floor, the granularity can be very fine; it doesn't alter the encoding structure, only the samples used to fit the floor approximation */ - f->n=freq*1000/nyq*blocksize; + f->n=freq/nyq*blocksize; /* in the residue, we're constrained, physically, by partition boundaries. We still lowpass 'wherever', but we have to round up |