summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty <xiphmont@xiph.org>2001-08-02 22:14:22 +0000
committerMonty <xiphmont@xiph.org>2001-08-02 22:14:22 +0000
commit3cc399a7b03eea5451970a393275beff676378cf (patch)
tree8022bc58e04f261c22b93388dc95cc9d1297a28a
parent62b37b3fba2de52ecb1a0db1a88f78b1cf3472d0 (diff)
downloadlibvorbis-git-3cc399a7b03eea5451970a393275beff676378cf.tar.gz
In progress build/run fixes to upcoming rc encoder
svn path=/branches/branch_monty_20010708/vorbis/; revision=1675
-rw-r--r--lib/backends.h6
-rw-r--r--lib/floor1.c12
-rw-r--r--lib/mapping0.c47
-rw-r--r--lib/psy.c31
-rw-r--r--lib/psy.h26
-rw-r--r--lib/res0.c40
-rw-r--r--lib/vorbisenc.c27
7 files changed, 115 insertions, 74 deletions
diff --git a/lib/backends.h b/lib/backends.h
index e351dbe6..410ff474 100644
--- a/lib/backends.h
+++ b/lib/backends.h
@@ -12,7 +12,7 @@
function: libvorbis backend and mapping structures; needed for
static mode headers
- last mod: $Id: backends.h,v 1.9.2.2 2001/08/02 06:14:44 xiphmont Exp $
+ last mod: $Id: backends.h,v 1.9.2.3 2001/08/02 22:14:22 xiphmont Exp $
********************************************************************/
@@ -127,7 +127,7 @@ typedef struct{
vorbis_info_residue *(*copy_info)(vorbis_info_residue *);
void (*free_info) (vorbis_info_residue *);
void (*free_look) (vorbis_look_residue *);
- long (**class) (struct vorbis_block *,vorbis_look_residue *,
+ long **(*class) (struct vorbis_block *,vorbis_look_residue *,
float **,int *,int);
int (*forward) (struct vorbis_block *,vorbis_look_residue *,
float **,float **,int *,int,int,long **);
@@ -152,7 +152,7 @@ typedef struct vorbis_info_residue0{
float ampmax[64]; /* book amp threshholds*/
int subgrp[64]; /* book heuristic subgroup size */
int blimit[64]; /* subgroup position limits */
- int passlimit[8]; /* iteration limit per couple/quant pass */
+ int passlimit[32]; /* iteration limit per couple/quant pass */
} vorbis_info_residue0;
/* Mapping backend generic *****************************************/
diff --git a/lib/floor1.c b/lib/floor1.c
index 2b147d81..d96f3a5a 100644
--- a/lib/floor1.c
+++ b/lib/floor1.c
@@ -11,7 +11,7 @@
********************************************************************
function: floor backend 1 implementation
- last mod: $Id: floor1.c,v 1.10.2.2 2001/08/02 06:14:43 xiphmont Exp $
+ last mod: $Id: floor1.c,v 1.10.2.3 2001/08/02 22:14:21 xiphmont Exp $
********************************************************************/
@@ -964,9 +964,13 @@ static int floor1_forward(vorbis_block *vb,vorbis_look_floor *in,
for(k=0;k<cdim;k++){
int book=info->class_subbook[class][bookas[k]];
if(book>=0){
- look->postbits+=vorbis_book_encode(books+book,
- fit_valueB[j+k],&vb->opb);
-
+ /* hack to allow training with 'bad' books */
+ if(fit_valueB[j+k]<(books+book)->entries)
+ look->postbits+=vorbis_book_encode(books+book,
+ fit_valueB[j+k],&vb->opb);
+ else
+ fprintf(stderr,"+!");
+
#ifdef TRAIN_FLOOR1
{
FILE *of;
diff --git a/lib/mapping0.c b/lib/mapping0.c
index b17ca930..8261cfa4 100644
--- a/lib/mapping0.c
+++ b/lib/mapping0.c
@@ -11,7 +11,7 @@
********************************************************************
function: channel mapping 0 implementation
- last mod: $Id: mapping0.c,v 1.33.2.3 2001/08/02 06:14:43 xiphmont Exp $
+ last mod: $Id: mapping0.c,v 1.33.2.4 2001/08/02 22:14:21 xiphmont Exp $
********************************************************************/
@@ -282,11 +282,11 @@ static int mapping0_forward(vorbis_block *vb,vorbis_look_mapping *l){
/* the following makes things clearer to *me* anyway */
float *pcm =vb->pcm[i];
- float *mdct =pcm;
float *fft =work;
float *logfft =pcm+n/2;
/*float *res =pcm;
+ float *mdct =pcm;
float *codedflr=pcm+n/2;
float *logmax =work;
float *logmask =work+n/2;*/
@@ -329,7 +329,7 @@ static int mapping0_forward(vorbis_block *vb,vorbis_look_mapping *l){
for(j=0;j<n/2;j++)
logmdct[j]=todB(mdct+j);
- _analysis_output("mdct",seq,logmdct,n/2,1,0);
+ _analysis_output("mdct",seq+i,logmdct,n/2,1,0);
/* perform psychoacoustics; do masking */
@@ -343,7 +343,7 @@ static int mapping0_forward(vorbis_block *vb,vorbis_look_mapping *l){
local_ampmax[i],
ci->blocksizes[vb->lW]/2);
- _analysis_output("mask",seq,logmask,n/2,1,0);
+ _analysis_output("mask",seq+i,logmask,n/2,1,0);
/* perform floor encoding */
nonzero[i]=look->floor_func[submap]->
@@ -356,6 +356,7 @@ static int mapping0_forward(vorbis_block *vb,vorbis_look_mapping *l){
codedflr);
+ _analysis_output("mdct2",seq+i,mdct,n/2,1,1);
_vp_remove_floor(look->psy_look,
b->psy_g_look,
logmdct,
@@ -365,11 +366,11 @@ static int mapping0_forward(vorbis_block *vb,vorbis_look_mapping *l){
local_ampmax[i]);
for(j=0;j<n/2;j++)
- if(fabs(vb->pcm[i][j])>1500)
- fprintf(stderr,"%ld ",seq);
+ if(fabs(res[j])>1500)
+ fprintf(stderr,"%ld ",seq+i);
- _analysis_output("res",seq,res,n,1,0);
- _analysis_output("codedflr",seq++,codedflr,n/2,1,1);
+ _analysis_output("res",seq+i,res,n/2,1,0);
+ _analysis_output("codedflr",seq+i,codedflr,n/2,1,1);
}
@@ -405,6 +406,7 @@ static int mapping0_forward(vorbis_block *vb,vorbis_look_mapping *l){
long ***classifications=alloca(sizeof(long**)*info->submaps);
float ***pcmbundle=alloca(sizeof(float **)*info->submaps);
+ float ***sobundle=alloca(sizeof(float **)*info->submaps);
int **zerobundle=alloca(sizeof(int *)*info->submaps);
int *chbundle=alloca(sizeof(int)*info->submaps);
int chcounter=0;
@@ -414,14 +416,14 @@ static int mapping0_forward(vorbis_block *vb,vorbis_look_mapping *l){
int stopflag=0;
for(i=0;i<vi->channels;i++){
- quantized[i]=perfect[i]+n/2;
+ quantized[i]=pcm[i]+n/2;
sofar[i]=_vorbis_block_alloc(vb,n/2*sizeof(float));
memset(sofar[i],0,sizeof(float)*n/2);
}
- pcmbundle=alloca(sizeof(float *)*vi->channels);
- sobundle=alloca(sizeof(float *)*vi->channels);
- zerobundle=alloca(sizeof(int)*vi->channels);
+ pcmbundle[0]=alloca(sizeof(float *)*vi->channels);
+ sobundle[0]=alloca(sizeof(float *)*vi->channels);
+ zerobundle[0]=alloca(sizeof(int)*vi->channels);
/* initial down-quantized coupling */
_vp_quantize_couple(look->psy_look,
@@ -431,14 +433,18 @@ static int mapping0_forward(vorbis_block *vb,vorbis_look_mapping *l){
quantized,
nonzero,
0);
+
+ for(i=0;i<vi->channels;i++)
+ _analysis_output("quant",seq+i,quantized[i],n/2,1,0);
+
/* classify, by submap */
for(i=0;i<info->submaps;i++){
int ch_in_bundle=0;
- pcmbundle[i]=pcmbundle+chcounter;
- sobundle[i]=sobundle+chcounter;
- zerobundle[i]=zerobundle+chcounter;
+ pcmbundle[i]=pcmbundle[0]+chcounter;
+ sobundle[i]=sobundle[0]+chcounter;
+ zerobundle[i]=zerobundle[0]+chcounter;
for(j=0;j<vi->channels;j++){
if(info->chmuxlist[j]==i){
@@ -488,6 +494,7 @@ static int mapping0_forward(vorbis_block *vb,vorbis_look_mapping *l){
}
/* steady as she goes */
}
+ seq+=vi->channels;
}
look->lastframe=vb->sequence;
@@ -620,6 +627,12 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_look_mapping *l){
/* export hooks */
vorbis_func_mapping mapping0_exportbundle={
- &mapping0_pack,&mapping0_unpack,&mapping0_look,&mapping0_copy_info,
- &mapping0_free_info,&mapping0_free_look,&mapping0_forward,&mapping0_inverse
+ &mapping0_pack,
+ &mapping0_unpack,
+ &mapping0_look,
+ &mapping0_copy_info,
+ &mapping0_free_info,
+ &mapping0_free_look,
+ &mapping0_forward,
+ &mapping0_inverse
};
diff --git a/lib/psy.c b/lib/psy.c
index 5f7cb07a..36646251 100644
--- a/lib/psy.c
+++ b/lib/psy.c
@@ -11,7 +11,7 @@
********************************************************************
function: psychoacoustics not including preecho
- last mod: $Id: psy.c,v 1.48.2.3 2001/08/02 06:14:44 xiphmont Exp $
+ last mod: $Id: psy.c,v 1.48.2.4 2001/08/02 22:14:21 xiphmont Exp $
********************************************************************/
@@ -318,17 +318,20 @@ void _vp_psy_init(vorbis_look_psy *p,vorbis_info_psy *vi,
for(i=0;i<P_BANDS;i+=2)
for(j=4;j<P_LEVELS;j+=2){
float neutraldB=-vi->toneatt[i][j];
- for(k=2;k<EHMER_MAX+2;k++)
+ for(k=2;k<EHMER_MAX+2;k++){
+ p->tonecurves[i][j][k]+=vi->tone_masteratt;
if(p->tonecurves[i][j][k]-neutraldB>vi->peakatt[i][j])
p->tonecurves[i][j][k]=neutraldB+vi->peakatt[i][j];
+ }
}
if(vi->peakattp) /* we limit depth only optionally */
- for(j=4;j<P_LEVELS;j+=2){
- float neutraldB=-vi->toneatt[i][j];
- if(p->tonecurves[i][j][EHMER_OFFSET]-neutraldB<vi->peakatt[i][j])
- p->tonecurves[i][j][EHMER_OFFSET]=neutraldB+vi->peakatt[i][j];
- }
+ for(i=0;i<P_BANDS;i+=2)
+ for(j=4;j<P_LEVELS;j+=2){
+ float neutraldB=-vi->toneatt[i][j];
+ if(p->tonecurves[i][j][EHMER_OFFSET]-neutraldB<vi->peakatt[i][j])
+ p->tonecurves[i][j][EHMER_OFFSET]=neutraldB+vi->peakatt[i][j];
+ }
/* interpolate curves between */
@@ -470,7 +473,7 @@ static void seed_loop(vorbis_look_psy *p,
if(vi->tonemaskp)
seed_curve(seed,
curves[oc],
- max+vi->tone_masteratt,
+ max,
p->octave[i]-p->firstoc,
p->total_octave_lines,
p->eighth_octave_lines,
@@ -931,13 +934,13 @@ void _vp_quantize_couple(vorbis_look_psy *p,
float **pcm,
float **sofar,
float **quantized,
- int *nonzero
+ int *nonzero,
int passno){
- int i,j,k,l,n=p->n;
+ int i,j,k,n=p->n;
vorbis_info_psy *info=p->vi;
- float granule=info->couple_pass[passno]->granule;
- float igranule=info->couple_pass[passno]->igranule;
+ float granule=info->couple_pass[passno].granule;
+ float igranule=info->couple_pass[passno].igranule;
/* perform any requested channel coupling */
for(i=0;i<vi->coupling_steps;i++){
@@ -958,9 +961,9 @@ void _vp_quantize_couple(vorbis_look_psy *p,
nonzero[vi->coupling_ang[i]]=1;
for(j=0,k=0;j<n;k++){
- vp_couple *part=info->couple_pass[passno]->couple+k;
+ vp_couple *part=info->couple_pass[passno].couple+k;
- for(;j<info->partition*part->partition_limit && j<p->n;j++){
+ for(;j<part->limit && j<p->n;j++){
/* partition by partition; k is our by-location partition
class counter */
float ang,mag=max(fabs(pcmM[j]),fabs(pcmA[j]));
diff --git a/lib/psy.h b/lib/psy.h
index 123b5669..671e7e4c 100644
--- a/lib/psy.h
+++ b/lib/psy.h
@@ -11,7 +11,7 @@
********************************************************************
function: random psychoacoustics (not including preecho)
- last mod: $Id: psy.h,v 1.21.2.2 2001/08/02 06:14:44 xiphmont Exp $
+ last mod: $Id: psy.h,v 1.21.2.3 2001/08/02 22:14:22 xiphmont Exp $
********************************************************************/
@@ -30,8 +30,13 @@
#define P_BANDS 17
#define P_LEVELS 11
+typedef struct couple_part{
+ float amppost;
+ float threshhold;
+} couple_part;
+
typedef struct vp_couple{
- int partition_limit; /* partition post */
+ int limit; /* sample post */
couple_part couple_lossless;
couple_part couple_eightphase;
@@ -40,7 +45,7 @@ typedef struct vp_couple{
} vp_couple;
-typedef struct vp_couple_pass={
+typedef struct vp_couple_pass{
float granule;
float igranule;
@@ -154,14 +159,13 @@ extern void _vp_compute_mask(vorbis_look_psy *p,
float local_specmax,
int lastsize);
-extern void _vp_partition_prequant(vorbis_look_psy *p,
- vorbis_info *vi,
- float **vbpcm,
- int *nonzero);
-extern void _vp_couple(vorbis_look_psy *p,
- vorbis_info_mapping0 *vi,
- float **vbpcm,
- int *nonzero);
+extern void _vp_quantize_couple(vorbis_look_psy *p,
+ vorbis_info_mapping0 *vi,
+ float **pcm,
+ float **sofar,
+ float **quantized,
+ int *nonzero,
+ int passno);
extern float _vp_ampmax_decay(float amp,vorbis_dsp_state *vd);
diff --git a/lib/res0.c b/lib/res0.c
index 32ac0f8d..f6707594 100644
--- a/lib/res0.c
+++ b/lib/res0.c
@@ -11,7 +11,7 @@
********************************************************************
function: residue backend 0, 1 and 2 implementation
- last mod: $Id: res0.c,v 1.32.2.2 2001/08/02 06:14:44 xiphmont Exp $
+ last mod: $Id: res0.c,v 1.32.2.3 2001/08/02 22:14:21 xiphmont Exp $
********************************************************************/
@@ -285,7 +285,7 @@ static int _interleaved_testhack(float *vec,int n,vorbis_look_residue0 *look,
static int _testhack(float *vec,int n,vorbis_look_residue0 *look,
int auxparts,int auxpartnum){
vorbis_info_residue0 *info=look->info;
- int i,j=0;
+ int i;
float max=0.f;
float temp[128];
float entropy=0.f;
@@ -370,18 +370,16 @@ static long **_01class(vorbis_block *vb,vorbis_look_residue *vl,
float **in,int ch,
int (*classify)(float *,int,vorbis_look_residue0 *,
int,int)){
- long i,j,s;
+ long i,j;
vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl;
vorbis_info_residue0 *info=look->info;
/* move all this setup out later */
int samples_per_partition=info->grouping;
int possible_partitions=info->partitions;
- int partitions_per_word=look->phrasebook->dim;
int n=info->end-info->begin;
int partvals=n/samples_per_partition;
- int partwords=(partvals+partitions_per_word-1)/partitions_per_word;
long **partword=_vorbis_block_alloc(vb,ch*sizeof(long *));
/* we find the partition type for each partition of each
@@ -412,7 +410,7 @@ static long **_01class(vorbis_block *vb,vorbis_look_residue *vl,
sprintf(buffer,"resaux_%d.vqd",vb->mode);
of=fopen(buffer,"a");
for(j=0;j<partvals;j++)
- fprintf(of,"%d, ",partword[i][j]);
+ fprintf(of,"%ld, ",partword[i][j]);
fprintf(of,"\n");
fclose(of);
}
@@ -427,18 +425,16 @@ static long **_2class(vorbis_block *vb,vorbis_look_residue *vl,
float **in,int ch,
int (*classify)(float *,int,vorbis_look_residue0 *,
int,int)){
- long i,j,k,l,s;
+ long i,j,k,l;
vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl;
vorbis_info_residue0 *info=look->info;
/* move all this setup out later */
int samples_per_partition=info->grouping;
int possible_partitions=info->partitions;
- int partitions_per_word=look->phrasebook->dim;
int n=info->end-info->begin;
int partvals=n/samples_per_partition;
- int partwords=(partvals+partitions_per_word-1)/partitions_per_word;
long **partword=_vorbis_block_alloc(vb,sizeof(long *));
float *work=alloca(sizeof(float)*samples_per_partition);
@@ -466,7 +462,7 @@ static long **_2class(vorbis_block *vb,vorbis_look_residue *vl,
sprintf(buffer,"resaux_%d.vqd",vb->mode);
of=fopen(buffer,"a");
for(i=0;i<partvals;i++)
- fprintf(of,"%d, ",partword[0][i]);
+ fprintf(of,"%ld, ",partword[0][i]);
fprintf(of,"\n");
fclose(of);
}
@@ -492,8 +488,7 @@ static int _01forward(vorbis_block *vb,vorbis_look_residue *vl,
int n=info->end-info->begin;
int partvals=n/samples_per_partition;
- int partwords=(partvals+partitions_per_word-1)/partitions_per_word;
-
+
#ifdef TRAIN_RES
FILE *of;
char buffer[80];
@@ -526,17 +521,24 @@ static int _01forward(vorbis_block *vb,vorbis_look_residue *vl,
val*=possible_partitions;
if(i+k<partvals)
val+=partword[j][i+k];
+ }
+
+ /* training hack */
+ if(val<look->phrasebook->entries)
+ ret=vorbis_book_encode(look->phrasebook,val,&vb->opb);
+ else
+ fprintf(stderr,"!");
- ret=vorbis_book_encode(look->phrasebook,val,&vb->opb);
look->phrasebits+=ret;
+
}
}
/* now we encode interleaved residual values for the partitions */
for(k=0;k<partitions_per_word && i<partvals;k++,i++){
+ long offset=i*samples_per_partition+info->begin;
for(j=0;j<ch;j++){
- long offset=i*partvals+info->begin;
/*if(s==0)look->resvals[partword[j][i]]++;*/
if(info->secondstages[partword[j][i]]&(1<<s)){
codebook *statebook=look->partbooks[partword[j][i]][s];
@@ -631,7 +633,7 @@ int res0_forward(vorbis_block *vb,vorbis_look_residue *vl,
float **in,float **out,int *nonzero,int ch,
int pass, long **partword){
/* we encode only the nonzero parts of a bundle */
- int i,used=0,n=vb->pcmend/2;
+ int i,j,used=0,n=vb->pcmend/2;
for(i=0;i<ch;i++)
if(nonzero[i]){
for(j=0;j<n;j++)
@@ -668,7 +670,7 @@ int res0_inverse(vorbis_block *vb,vorbis_look_residue *vl,
int res1_forward(vorbis_block *vb,vorbis_look_residue *vl,
float **in,float **out,int *nonzero,int ch,
int pass, long **partword){
- int i,used=0,n=vb->pcmend/2;
+ int i,j,used=0,n=vb->pcmend/2;
for(i=0;i<ch;i++)
if(nonzero[i]){
for(j=0;j<n;j++)
@@ -677,7 +679,7 @@ int res1_forward(vorbis_block *vb,vorbis_look_residue *vl,
}
if(used){
- int ret=_01forward(vb,vl,work,used,pass,partword,_encodepart);
+ int ret=_01forward(vb,vl,in,used,pass,partword,_encodepart);
used=0;
for(i=0;i<ch;i++)
if(nonzero[i]){
@@ -691,7 +693,7 @@ int res1_forward(vorbis_block *vb,vorbis_look_residue *vl,
}
long **res1_class(vorbis_block *vb,vorbis_look_residue *vl,
- float **in,int *nonzero,int ch{
+ float **in,int *nonzero,int ch){
int i,used=0;
for(i=0;i<ch;i++)
if(nonzero[i])
@@ -715,7 +717,7 @@ int res1_inverse(vorbis_block *vb,vorbis_look_residue *vl,
}
long **res2_class(vorbis_block *vb,vorbis_look_residue *vl,
- float **in,int *nonzero,int ch{
+ float **in,int *nonzero,int ch){
int i,used=0;
for(i=0;i<ch;i++)
if(nonzero[i])
diff --git a/lib/vorbisenc.c b/lib/vorbisenc.c
index f09235de..6550c8e6 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.7.2.1 2001/07/08 08:48:02 xiphmont Exp $
+ last mod: $Id: vorbisenc.c,v 1.7.2.2 2001/08/02 22:14:21 xiphmont Exp $
********************************************************************/
@@ -83,12 +83,22 @@ static void codec_setup_partialcopy(codec_setup_info *ci,
}
-/* right now, this just encapsultes the old modes behind the interface
- we'll be using from here on out. After beta 3, the new bitrate
- tracking/modding/tuning engine will lurk inside */
/* encoders will need to use vorbis_info_init beforehand and call
vorbis_info clear when all done */
+int vorbis_encode_init_vbr(vorbis_info *vi,
+ long channels,
+ long rate,
+
+ float base_quality /* 0. to 1. */
+ ){
+
+
+
+
+}
+
+
int vorbis_encode_init(vorbis_info *vi,
long channels,
long rate,
@@ -114,9 +124,13 @@ int vorbis_encode_init(vorbis_info *vi,
/* copy a mode into our allocated storage */
bpch=nominal_bitrate/channels;
+
+ mode=&info_A;
+
+#if 0
if(bpch<60000){
- /* mode A */
- //mode=&info_AA;
+ /* mode AA */
+ mode=&info_AA;
}else if(bpch<75000){
/* mode A */
mode=&info_A;
@@ -133,6 +147,7 @@ int vorbis_encode_init(vorbis_info *vi,
/* mode E */
mode=&info_E;
}
+#endif
/* now we have to deepcopy */
codec_setup_partialcopy(ci,mode);