********************************************************************
function: simple example encoder
- last mod: $Id: encoder_example.c,v 1.21 2001/02/26 03:50:38 xiphmont Exp $
+ last mod: $Id: encoder_example.c,v 1.22 2001/08/13 11:33:39 xiphmont Exp $
********************************************************************/
#endif
#define READ 1024
-signed char readbuffer[READ*4+44]; /* out of the data segment, not the stack */
+signed char readbuffer[READ*2+44]; /* out of the data segment, not the stack */
int main(){
ogg_stream_state os; /* take physical pages, weld into a logical
/* choose an encoding mode */
/* (mode 0: 44kHz stereo uncoupled, roughly 128kbps VBR) */
vorbis_info_init(&vi);
- vorbis_encode_init(&vi,2,44100, -1, 128000, -1);
+ vorbis_encode_init(&vi,1,44100, -1, 999000, -1);
/* add a comment */
vorbis_comment_init(&vc);
while(!eos){
long i;
- long bytes=fread(readbuffer,1,READ*4,stdin); /* stereo hardwired here */
+ long bytes=fread(readbuffer,1,READ*2,stdin); /* stereo hardwired here */
if(bytes==0){
/* end of file. this can be done implicitly in the mainline,
float **buffer=vorbis_analysis_buffer(&vd,READ);
/* uninterleave samples */
- for(i=0;i<bytes/4;i++){
- buffer[0][i]=((readbuffer[i*4+1]<<8)|
- (0x00ff&(int)readbuffer[i*4]))/32768.f;
- buffer[1][i]=((readbuffer[i*4+3]<<8)|
- (0x00ff&(int)readbuffer[i*4+2]))/32768.f;
+ for(i=0;i<bytes/2;i++){
+ buffer[0][i]=((readbuffer[i*2+1]<<8)|
+ (0x00ff&(int)readbuffer[i*2]))/32768.f;
}
-
+
/* tell the library how much we actually submitted */
vorbis_analysis_wrote(&vd,i);
}
********************************************************************
function: basic codebook pack/unpack/code/decode operations
- last mod: $Id: codebook.c,v 1.28 2001/08/13 01:36:56 xiphmont Exp $
+ last mod: $Id: codebook.c,v 1.29 2001/08/13 11:33:39 xiphmont Exp $
********************************************************************/
}
long vorbis_book_decodev_add(codebook *book,float *a,oggpack_buffer *b,int n){
- int i,j=0,entry;
+ int i,j,entry;
float *t;
if(book->dim>8){
entry = vorbis_book_decode(book,b);
if(entry==-1)return(-1);
t = book->valuelist+entry*book->dim;
+ j=0;
switch(book->dim){
case 8:
a[i++]+=t[j++];
********************************************************************
function: floor backend 1 implementation
- last mod: $Id: floor1.c,v 1.11 2001/08/13 01:36:56 xiphmont Exp $
+ last mod: $Id: floor1.c,v 1.12 2001/08/13 11:33:39 xiphmont Exp $
********************************************************************/
{
FILE *of;
char buffer[80];
- sprintf(buffer,"line_%dx%d_class%d.vqd",
+ sprintf(buffer,"line_%ldx%ld_class%d.vqd",
vb->pcmend/2,posts-2,class);
of=fopen(buffer,"a");
fprintf(of,"%d\n",cval);
{
FILE *of;
char buffer[80];
- sprintf(buffer,"line_%dx%d_%dsub%d.vqd",
+ sprintf(buffer,"line_%ldx%ld_%dsub%d.vqd",
vb->pcmend/2,posts-2,class,bookas[k]);
of=fopen(buffer,"a");
fprintf(of,"%d\n",fit_valueB[j+k]);
********************************************************************
function: channel mapping 0 implementation
- last mod: $Id: mapping0.c,v 1.34 2001/08/13 01:36:57 xiphmont Exp $
+ last mod: $Id: mapping0.c,v 1.35 2001/08/13 11:33:39 xiphmont Exp $
********************************************************************/
res,
local_ampmax[i]);
- for(j=0;j<n/2;j++)
+ /*for(j=0;j<n/2;j++)
if(fabs(res[j])>1200){
analysis_noisy=1;
- /*fprintf(stderr,"%ld ",seq+i);*/
- }
+ fprintf(stderr,"%ld ",seq+i);
+ }*/
_analysis_output("res",seq+i,res,n/2,1,0);
_analysis_output("codedflr",seq+i,codedflr,n/2,1,1);
zerobundle[0]=alloca(sizeof(int)*vi->channels);
/* initial down-quantized coupling */
- _vp_quantize_couple(look->psy_look[blocktype],
- info,
- pcm,
- sofar,
- quantized,
- nonzero,
- 0);
+
+ if(info->coupling_steps==0){
+ /* this assumes all or nothing coupling right now. it should pass
+ through any channels left uncoupled, but it doesn't do that now */
+ for(i=0;i<vi->channels;i++){
+ float *lpcm=pcm[i];
+ float *lqua=quantized[i];
+ for(j=0;j<n/2;j++)
+ lqua[j]=lpcm[j];
+ }
+ }else{
+ _vp_quantize_couple(look->psy_look[blocktype],
+ info,
+ pcm,
+ sofar,
+ quantized,
+ nonzero,
+ 0);
+ }
for(i=0;i<vi->channels;i++)
_analysis_output("quant",seq+i,quantized[i],n/2,1,0);
if(!stopflag){
/* down-couple/down-quantize from perfect-'so-far' ->
new quantized vector */
- _vp_quantize_couple(look->psy_look[blocktype],
- info,
- pcm,
- sofar,
- quantized,
- nonzero,
- i);
+ if(info->coupling_steps==0){
+ /* this assumes all or nothing coupling right now. it should pass
+ through any channels left uncoupled, but it doesn't do that now */
+ for(i=0;i<vi->channels;i++){
+ float *lpcm=pcm[i];
+ float *lsof=sofar[i];
+ float *lqua=quantized[i];
+ for(j=0;j<n/2;j++)
+ lqua[j]=lpcm[j]-lsof[j];
+ }
+ }else{
+ _vp_quantize_couple(look->psy_look[blocktype],
+ info,
+ pcm,
+ sofar,
+ quantized,
+ nonzero,
+ i);
+ }
}
/* steady as she goes */
}
********************************************************************
function: residue backend 0, 1 and 2 implementation
- last mod: $Id: res0.c,v 1.34 2001/08/13 10:01:04 xiphmont Exp $
+ last mod: $Id: res0.c,v 1.35 2001/08/13 11:33:39 xiphmont Exp $
********************************************************************/
vorbis_look_residue0 *look=(vorbis_look_residue0 *)i;
- fprintf(stderr,"residue bit usage %f:%f (%f total)\n",
+ /*fprintf(stderr,"residue bit usage %f:%f (%f total)\n",
(float)look->phrasebits/look->frames,
(float)look->postbits/look->frames,
- (float)(look->postbits+look->phrasebits)/look->frames);
+ (float)(look->postbits+look->phrasebits)/look->frames);*/
/*vorbis_info_residue0 *info=look->info;
/* training hack */
if(val<look->phrasebook->entries)
ret=vorbis_book_encode(look->phrasebook,val,&vb->opb);
- else
- fprintf(stderr,"!");
+ /*else
+ fprintf(stderr,"!");*/
look->phrasebits+=ret;
}
}
- {
+ /*{
long total=0;
long totalbits=0;
fprintf(stderr,"%d :: ",vb->mode);
}
fprintf(stderr,":: %ld:%1.2g\n",total,(double)totalbits/total);
- }
+ }*/
return(0);
}
if(nonzero[i])
in[used++]=in[i];
if(used)
- return(_01class(vb,vl,in,used,_interleaved_testhack));
+ /*return(_01class(vb,vl,in,used,_interleaved_testhack));*/
+ return(_01class(vb,vl,in,used,_testhack));
else
return(0);
}
********************************************************************
function: simple programmatic interface for encoder mode setup
- last mod: $Id: vorbisenc.c,v 1.11 2001/08/13 08:39:30 xiphmont Exp $
+ last mod: $Id: vorbisenc.c,v 1.12 2001/08/13 11:33:40 xiphmont Exp $
********************************************************************/
break;
default:
-#if 0
- if(bpch<60000){
- /* mode AA */
- mode=&info_AA;
- }else if(bpch<75000){
- /* mode A */
- mode=&info_A;
+
+ if(bpch<40000){
+ mode=&info_44_Z;
+ }else if(bpch<50000){
+ mode=&info_44_Y;
+ }else if(bpch<70000){
+ mode=&info_44_X;
}else if(bpch<90000){
- /* mode B */
- mode=&info_B;
- }else if(bpch<110000){
- /* mode C */
- mode=&info_C;
- }else if(bpch<160000){
- /* mode D */
- mode=&info_D;
+ mode=&info_44_A;
+ }else if(bpch<120000){
+ mode=&info_44_B;
}else{
- /* mode E */
- mode=&info_E;
+ mode=&info_44_C;
}
-#endif
+ break;
}
/* now we have to deepcopy */