Commit b6dd3d99 authored by Monty's avatar Monty
Browse files

Commit minor speed patch (sliding window in vorbis_blockin)
Commit Segher floating constant patch
Commit addition of vq targets to vq/ Makefile.am

svn path=/trunk/vorbis/; revision=1121
parent fbb7b98b
......@@ -12,7 +12,7 @@
********************************************************************
function: simple example decoder
last mod: $Id: decoder_example.c,v 1.14 2000/11/06 00:06:53 xiphmont Exp $
last mod: $Id: decoder_example.c,v 1.15 2000/12/21 21:04:37 xiphmont Exp $
********************************************************************/
......@@ -240,9 +240,9 @@ int main(int argc, char **argv){
float *mono=pcm[i];
for(j=0;j<bout;j++){
#if 1
int val=mono[j]*32767.;
int val=mono[j]*32767.f;
#else /* optional dither */
int val=mono[j]*32767.+drand48()-0.5;
int val=mono[j]*32767.f+drand48()-0.5f;
#endif
/* might as well guard against clipping */
if(val>32767){
......
......@@ -12,7 +12,7 @@
********************************************************************
function: simple example encoder
last mod: $Id: encoder_example.c,v 1.16 2000/12/12 08:54:26 xiphmont Exp $
last mod: $Id: encoder_example.c,v 1.17 2000/12/21 21:04:37 xiphmont Exp $
********************************************************************/
......@@ -147,9 +147,9 @@ int main(){
/* uninterleave samples */
for(i=0;i<bytes/4;i++){
buffer[0][i]=((readbuffer[i*4+1]<<8)|
(0x00ff&(int)readbuffer[i*4]))/32768.;
(0x00ff&(int)readbuffer[i*4]))/32768.f;
buffer[1][i]=((readbuffer[i*4+3]<<8)|
(0x00ff&(int)readbuffer[i*4+2]))/32768.;
(0x00ff&(int)readbuffer[i*4+2]))/32768.f;
}
/* tell the library how much we actually submitted */
......
......@@ -12,7 +12,7 @@
********************************************************************
function: single-block PCM analysis mode dispatch
last mod: $Id: analysis.c,v 1.39 2000/11/16 22:15:28 xiphmont Exp $
last mod: $Id: analysis.c,v 1.40 2000/12/21 21:04:38 xiphmont Exp $
********************************************************************/
......@@ -91,7 +91,7 @@ void _analysis_output(char *base,int i,float *v,int n,int bark,int dB){
fprintf(of,"\n\n");
else{
if(bark)
fprintf(of,"%g ",toBARK(22050.*j/n));
fprintf(of,"%g ",toBARK(22050.f*j/n));
else
fprintf(of,"%g ",(double)j);
......
......@@ -12,7 +12,7 @@
********************************************************************
function: bark scale utility
last mod: $Id: barkmel.c,v 1.2 2000/11/06 00:07:00 xiphmont Exp $
last mod: $Id: barkmel.c,v 1.3 2000/12/21 21:04:38 xiphmont Exp $
********************************************************************/
......@@ -22,31 +22,31 @@ int main(){
int i;
double rate;
for(i=64;i<32000;i*=2){
rate=48000.;
rate=48000.f;
fprintf(stderr,"rate=%gHz, block=%d, f(1)=%.2gHz bark(1)=%.2g (of %.2g)\n",
rate,i,rate/2 / (i/2),toBARK(rate/2 /(i/2)),toBARK(rate/2));
rate=44100.;
rate=44100.f;
fprintf(stderr,"rate=%gHz, block=%d, f(1)=%.2gHz bark(1)=%.2g (of %.2g)\n",
rate,i,rate/2 / (i/2),toBARK(rate/2 /(i/2)),toBARK(rate/2));
rate=32000.;
rate=32000.f;
fprintf(stderr,"rate=%gHz, block=%d, f(1)=%.2gHz bark(1)=%.2g (of %.2g)\n",
rate,i,rate/2 / (i/2),toBARK(rate/2 /(i/2)),toBARK(rate/2));
rate=22050.;
rate=22050.f;
fprintf(stderr,"rate=%gHz, block=%d, f(1)=%.2gHz bark(1)=%.2g (of %.2g)\n",
rate,i,rate/2 / (i/2),toBARK(rate/2 /(i/2)),toBARK(rate/2));
rate=16000.;
rate=16000.f;
fprintf(stderr,"rate=%gHz, block=%d, f(1)=%.2gHz bark(1)=%.2g (of %.2g)\n",
rate,i,rate/2 / (i/2),toBARK(rate/2 /(i/2)),toBARK(rate/2));
rate=11025.;
rate=11025.f;
fprintf(stderr,"rate=%gHz, block=%d, f(1)=%.2gHz bark(1)=%.2g (of %.2g)\n",
rate,i,rate/2 / (i/2),toBARK(rate/2 /(i/2)),toBARK(rate/2));
rate=8000.;
rate=8000.f;
fprintf(stderr,"rate=%gHz, block=%d, f(1)=%.2gHz bark(1)=%.2g (of %.2g)\n\n",
rate,i,rate/2 / (i/2),toBARK(rate/2 /(i/2)),toBARK(rate/2));
......
......@@ -12,7 +12,7 @@
********************************************************************
function: flexible, delayed bitpacking abstraction
last mod: $Id: bitbuffer.c,v 1.1 2000/11/17 11:57:49 xiphmont Exp $
last mod: $Id: bitbuffer.c,v 1.2 2000/12/21 21:04:38 xiphmont Exp $
********************************************************************/
......@@ -46,7 +46,6 @@ void bitbuf_write(vorbis_bitbuffer *vbb,unsigned long word,int length){
}
void bitbuf_pack(oggpack_buffer *dest,vorbis_bitbuffer *vbb){
vorbis_block *vb=vbb->vb;
vorbis_bitbuffer_chain *vbc=vbb->first;
int i;
......
......@@ -12,15 +12,11 @@
********************************************************************
function: PCM data vector blocking, windowing and dis/reassembly
last mod: $Id: block.c,v 1.41 2000/11/14 00:05:30 xiphmont Exp $
last mod: $Id: block.c,v 1.42 2000/12/21 21:04:38 xiphmont Exp $
Handle windowing, overlap-add, etc of the PCM vectors. This is made
more amusing by Vorbis' current two allowed block sizes.
Vorbis manipulates the dynamic range of the incoming PCM data
envelope to minimise time-domain energy leakage from percussive and
plosive waveforms being quantized in the MDCT domain.
********************************************************************/
#include <stdio.h>
......@@ -614,7 +610,12 @@ int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){
/* Shift out any PCM that we returned previously */
/* centerW is currently the center of the last block added */
if(v->pcm_returned && v->centerW>ci->blocksizes[1]/2){
if(v->centerW>ci->blocksizes[1]/2 &&
/* Quick additional hack; to avoid *alot* of shifts, use an
oversized buffer. This increases memory usage, but doesn't make
much difference wrt L1/L2 cache pressure. */
v->pcm_returned>8192){
/* don't shift too much; we need to have a minimum PCM buffer of
1/2 long block */
......@@ -677,6 +678,8 @@ int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){
beginSl=ci->blocksizes[1]/4-ci->blocksizes[v->lW]/4;
endSl=beginSl+ci->blocksizes[v->lW]/2;
break;
default:
return(-1);
}
for(j=0;j<vi->channels;j++){
......
......@@ -12,7 +12,7 @@
********************************************************************
function: basic codebook pack/unpack/code/decode operations
last mod: $Id: codebook.c,v 1.19 2000/11/06 00:07:00 xiphmont Exp $
last mod: $Id: codebook.c,v 1.20 2000/12/21 21:04:39 xiphmont Exp $
********************************************************************/
......@@ -127,6 +127,8 @@ int vorbis_staticbook_pack(const static_codebook *c,oggpack_buffer *opb){
/* every value (c->entries*c->dim total) specified explicitly */
quantvals=c->entries*c->dim;
break;
default: /* NOT_REACHABLE */
quantvals=-1;
}
/* quantized values */
......@@ -429,55 +431,55 @@ long s_vorbis_book_decodevs(codebook *book,float *a,oggpack_buffer *b,
#define TESTSIZE 40
float test1[TESTSIZE]={
0.105939,
0.215373,
0.429117,
0.587974,
0.181173,
0.296583,
0.515707,
0.715261,
0.162327,
0.263834,
0.342876,
0.406025,
0.103571,
0.223561,
0.368513,
0.540313,
0.136672,
0.395882,
0.587183,
0.652476,
0.114338,
0.417300,
0.525486,
0.698679,
0.147492,
0.324481,
0.643089,
0.757582,
0.139556,
0.215795,
0.324559,
0.399387,
0.120236,
0.267420,
0.446940,
0.608760,
0.115587,
0.287234,
0.571081,
0.708603,
0.105939f,
0.215373f,
0.429117f,
0.587974f,
0.181173f,
0.296583f,
0.515707f,
0.715261f,
0.162327f,
0.263834f,
0.342876f,
0.406025f,
0.103571f,
0.223561f,
0.368513f,
0.540313f,
0.136672f,
0.395882f,
0.587183f,
0.652476f,
0.114338f,
0.417300f,
0.525486f,
0.698679f,
0.147492f,
0.324481f,
0.643089f,
0.757582f,
0.139556f,
0.215795f,
0.324559f,
0.399387f,
0.120236f,
0.267420f,
0.446940f,
0.608760f,
0.115587f,
0.287234f,
0.571081f,
0.708603f,
};
float test3[TESTSIZE]={
......
......@@ -12,7 +12,7 @@
********************************************************************
function: PCM data envelope analysis and manipulation
last mod: $Id: envelope.c,v 1.27 2000/12/13 07:37:20 msmith Exp $
last mod: $Id: envelope.c,v 1.28 2000/12/21 21:04:39 xiphmont Exp $
Preecho calculation.
......@@ -41,36 +41,38 @@
#if 0
static int cheb_bandpass_stages=10;
static float cheb_bandpass_gain=5.589612458e+01;
static float cheb_bandpass_B[]={-1.,0.,5.,0.,-10.,0.,10.,0.,-5.,0.,1};
static float cheb_bandpass_gain=5.589612458e+01f;
static float cheb_bandpass_B[]={-1.f,0.f,5.f,0.f,-10.f,0.f,
10.f,0.f,-5.f,0.f,1f};
static float cheb_bandpass_A[]={
-0.1917409386,
0.0078657069,
-0.7126903444,
0.0266343467,
-1.4047174730,
0.0466964232,
-1.9032773429,
0.0451493360,
-1.4471447397,
0.0303413711};
-0.1917409386f,
0.0078657069f,
-0.7126903444f,
0.0266343467f,
-1.4047174730f,
0.0466964232f,
-1.9032773429f,
0.0451493360f,
-1.4471447397f,
0.0303413711f};
#endif
static int cheb_highpass_stages=10;
static float cheb_highpass_gain= 5.291963434e+01;
static float cheb_highpass_gain= 5.291963434e+01f;
/* z^-stage, z^-stage+1... */
static float cheb_highpass_B[]={1,-10,45,-120,210,-252,210,-120,45,-10,1};
static float cheb_highpass_B[]={1.f,-10.f,45.f,-120.f,210.f,
-252.f,210.f,-120.f,45.f,-10.f,1.f};
static float cheb_highpass_A[]={
-0.1247628029,
0.1334086523,
-0.3997715614,
0.3213011089,
-1.1131924119,
1.7692446626,
-3.6241199038,
4.1950871291,
-4.2771757867,
2.3920318913};
-0.1247628029f,
0.1334086523f,
-0.3997715614f,
0.3213011089f,
-1.1131924119f,
1.7692446626f,
-3.6241199038f,
4.1950871291f,
-4.2771757867f,
2.3920318913f};
void _ve_envelope_init(envelope_lookup *e,vorbis_info *vi){
codec_setup_info *ci=vi->codec_setup;
......@@ -109,13 +111,13 @@ void _ve_envelope_clear(envelope_lookup *e){
memset(e,0,sizeof(envelope_lookup));
}
static float _ve_deltai(envelope_lookup *ve,IIR_state *iir,
static float _ve_deltai(envelope_lookup *ve,
float *pre,float *post){
long n2=ve->winlength*2;
long n=ve->winlength;
float *workA=alloca(sizeof(float)*n2),A=0.;
float *workB=alloca(sizeof(float)*n2),B=0.;
float *workA=alloca(sizeof(float)*n2),A=0.f;
float *workB=alloca(sizeof(float)*n2),B=0.f;
long i;
/*_analysis_output("A",granulepos,pre,n,0,0);
......@@ -196,8 +198,7 @@ long _ve_envelope_search(vorbis_dsp_state *v,long searchpoint){
while(j+ve->winlength<=v->pcm_current){
for(i=0;i<ve->ch;i++){
float *filtered=ve->filtered[i]+j;
IIR_state *iir=ve->iir+i;
float m=_ve_deltai(ve,iir,filtered-ve->winlength,filtered);
float m=_ve_deltai(ve,filtered-ve->winlength,filtered);
if(m>ci->preecho_thresh){
/*granulepos++;*/
......
......@@ -12,7 +12,7 @@
********************************************************************
function: floor backend 0 implementation
last mod: $Id: floor0.c,v 1.33 2000/12/12 08:54:27 xiphmont Exp $
last mod: $Id: floor0.c,v 1.34 2000/12/21 21:04:39 xiphmont Exp $
********************************************************************/
......@@ -51,7 +51,7 @@ static long _f0_fit(codebook *book,
float *workfit,
int cursor){
int dim=book->dim;
float norm,base=0.;
float norm,base=0.f;
int i,best=0;
float *lsp=workfit+cursor;
......@@ -163,7 +163,7 @@ static vorbis_look_floor *floor0_look (vorbis_dsp_state *vd,vorbis_info_mode *mi
/* we choose a scaling constant so that:
floor(bark(rate/2-1)*C)=mapped-1
floor(bark(rate/2)*C)=mapped */
scale=look->ln/toBARK(info->rate/2.);
scale=look->ln/toBARK(info->rate/2.f);
/* the mapping from a linear scale to a smaller bark scale is
straightforward. We do *not* make sure that the linear mapping
......@@ -173,7 +173,7 @@ static vorbis_look_floor *floor0_look (vorbis_dsp_state *vd,vorbis_info_mode *mi
accurate */
look->linearmap=_ogg_malloc((look->n+1)*sizeof(int));
for(j=0;j<look->n;j++){
int val=floor( toBARK((info->rate/2.)/look->n*j)
int val=floor( toBARK((info->rate/2.f)/look->n*j)
*scale); /* bark numbers represent band edges */
if(val>=look->ln)val=look->ln; /* guard against the approximation */
look->linearmap[j]=val;
......@@ -224,7 +224,7 @@ float _curve_to_lpc(float *curve,float *lpc,
long span=bark-last;
for(j=1;j<span;j++){
float del=(float)j/span;
work[j+last]=work[bark]*del+work[last]*(1.-del);
work[j+last]=work[bark]*del+work[last]*(1.f-del);
}
}
last=bark;
......@@ -318,7 +318,7 @@ static int floor0_forward(vorbis_block *vb,vorbis_look_floor *i,
#if 1
#ifdef TRAIN_LSP
{
float last=0.;
float last=0.f;
for(j=0;j<look->m;j++){
fprintf(of,"%.12g, ",out[j]-last);
last=out[j];
......@@ -389,7 +389,7 @@ static float floor0_forward2(vorbis_block *vb,vorbis_look_floor *i,
oggpack_write(&vb->opb,0,info->ampbits);
bitbuf_pack(&vb->opb,vbb);
}
return(0.);
return(0.f);
}
......@@ -408,7 +408,7 @@ static int floor0_inverse(vorbis_block *vb,vorbis_look_floor *i,float *out){
if(booknum!=-1){
backend_lookup_state *be=vb->vd->backend_state;
codebook *b=be->fullbooks+info->books[booknum];
float last=0.;
float last=0.f;
memset(out,0,sizeof(float)*look->m);
......
......@@ -12,7 +12,7 @@
********************************************************************
function: Direct Form I, II IIR filters, plus some specializations
last mod: $Id: iir.c,v 1.5 2000/11/14 00:05:31 xiphmont Exp $
last mod: $Id: iir.c,v 1.6 2000/12/21 21:04:39 xiphmont Exp $
********************************************************************/
......@@ -99,154 +99,154 @@ float IIR_filter_ChebBand(IIR_state *s,float in){
#ifdef _V_SELFTEST
/* z^-stage, z^-stage+1... */
static float cheb_bandpass_B[]={-1.,0.,5.,0.,-10.,0.,10.,0.,-5.,0.,1};
static float cheb_bandpass_A[]={-0.6665900311,
1.0070146601,
-3.1262875409,
3.5017171569,
-6.2779211945,
5.2966481740,
-6.7570216587,
4.0760335768,
-3.9134284363,
1.3997338886};
static float cheb_bandpass_B[]={-1.f,0.f,5.f,0.f,-10.f,0.f,10.f,0.f,-5.f,0.f,1f};
static float cheb_bandpass_A[]={-0.6665900311f,
1.0070146601f,
-3.1262875409f,
3.5017171569f,
-6.2779211945f,
5.2966481740f,
-6.7570216587f,
4.0760335768f,
-3.9134284363f,
1.3997338886f};
static float data[128]={
0.0426331,
0.0384521,
0.0345764,
0.0346069,
0.0314636,
0.0310059,
0.0318604,
0.0336304,
0.036438,
0.0348511,
0.0354919,
0.0343628,
0.0325623,
0.0318909,
0.0263367,
0.0225525,
0.0195618,
0.0160828,
0.0168762,
0.0145569,
0.0126343,
0.0127258,
0.00820923,
0.00787354,
0.00558472,
0.00204468,
3.05176e-05,
-0.00357056,
-0.00570679,
-0.00991821,
-0.0101013,
-0.00881958,
-0.0108948,
-0.0110168,
-0.0119324,
-0.0161438,
-0.0194702,
-0.0229187,
-0.0260315,
-0.0282288,
-0.0306091,
-0.0330505,
-0.0364685,
-0.0385742,
-0.0428772,
-0.043457,
-0.0425415,
-0.0462341,
-0.0467529,
-0.0489807,
-0.0520325,
-0.0558167,
-0.0596924,
-0.0591431,
-0.0612793,
-0.0618591,
-0.0615845,
-0.0634155,
-0.0639648,
-0.0683594,
-0.0718079,
-0.0729675,
-0.0791931,
-0.0860901,
-0.0885315,
-0.088623,
-0.089386,
-0.0899353,
-0.0886841,
-0.0910645,
-0.0948181,
-0.0919495,
-0.0891418,
-0.0916443,
-0.096344,
-0.100464,
-0.105499,
-0.108612,
-0.112213,
-0.117676,
-0.120911,
-0.124329,
-0.122162,
-0.120605,
-0.12326,
-0.12619,
-0.128998,
-0.13205,
-0.134247,
-0.137939,
-0.143555,
-0.14389,
-0.14859,
-0.153717,
-0.159851,
-0.164551,
-0.162811,
-0.164276,
-0.156952,
-0.140564,
-0.123291,
-0.10321,
-0.0827637,
-0.0652466,
-0.053772,
-0.0509949,
-0.0577698,
-0.0818176,
-0.114929,
-0.148895,
-0.181122,
-0.200714,
-0.21048,
-0.203644,
-0.179413,
-0.145325,