24 #include "../vorbis/codec.h"
43 256, {26.f,26.f,26.f,30.f}, {-90.f,-90.f,-90.f,-90.f}, -90.f,
52 static vp_part _vp_part0[]={
53 { 1,9e10f, 9e10f, 1.f,9999.f},
54 { 9999, .75f, 9e10f, .5f,9999.f},
56 { 18,9e10f, 9e10f, .5f, 30.f},
57 { 9999,9e10f, 9e10f, .5f, 30.f}
60 static vp_couple _vp_couple0[]={
61 { 1, {9e10f,9e10f,0}, { 0.f, 0.f,0}, { 0.f, 0.f,0}, {0.f,0.f,0}},
62 { 18, {9e10f,9e10f,0}, { 0.f, 0.f,0}, { 0.f, 0.f,0}, {0.f,0.f,0}},
63 { 9999, {9e10f,9e10f,0}, { 0.f, 9e10f,0}, { 0.f,22.f,1}, {0.f,0.f,0}}
67 ATH_Bark_dB_lineaggressive,
80 {-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f},
81 {-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f},
82 {-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f},
84 {-30.f,-30.f,-35.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f},
85 {-30.f,-30.f,-35.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f},
86 {-30.f,-30.f,-35.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f},
87 {-30.f,-30.f,-35.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f},
88 {-30.f,-30.f,-35.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f},
89 {-30.f,-30.f,-35.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f},
90 {-30.f,-30.f,-35.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f},
91 {-40.f,-40.f,-40.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f},
92 {-40.f,-40.f,-40.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f},
93 {-40.f,-40.f,-40.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f},
95 {-30.f,-35.f,-35.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f},
97 {-30.f,-30.f,-33.f,-35.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f},
98 {-30.f,-30.f,-33.f,-35.f,-40.f,-45.f,-50.f,-60.f,-70.f,-85.f,-100.f},
99 {-24.f,-24.f,-26.f,-32.f,-32.f,-42.f,-50.f,-60.f,-70.f,-85.f,-100.f},
104 {{-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-40.f,-40.f,-40.f,-40.f,-40.f},
105 {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-40.f,-40.f,-40.f,-40.f,-40.f},
106 {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-40.f,-40.f,-40.f,-40.f,-40.f},
107 {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-40.f,-40.f,-40.f,-40.f,-40.f},
108 {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-40.f,-40.f,-40.f,-40.f,-40.f},
109 {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-40.f,-40.f,-40.f,-40.f,-40.f},
110 {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-40.f,-40.f,-40.f,-40.f,-40.f},
111 {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-40.f,-40.f,-40.f,-40.f,-40.f},
112 {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-40.f,-40.f,-40.f,-40.f,-40.f},
113 {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-40.f,-40.f,-40.f,-40.f,-40.f},
114 {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-40.f,-40.f,-40.f,-40.f,-40.f},
115 {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-40.f,-40.f,-40.f,-40.f,-40.f},
116 {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-40.f,-40.f,-40.f,-40.f,-40.f},
117 {-10.f,-12.f,-14.f,-16.f,-16.f,-20.f,-24.f,-30.f,-32.f,-40.f,-40.f},
118 {-10.f,-12.f,-14.f,-16.f,-16.f,-20.f,-24.f,-30.f,-32.f,-40.f,-40.f},
119 {-10.f,-10.f,-10.f,-12.f,-14.f,-18.f,-22.f,-28.f,-32.f,-40.f,-40.f},
120 {-10.f,-10.f,-10.f,-12.f,-14.f,-18.f,-22.f,-28.f,-32.f,-40.f,-40.f},
154 _vp_part0,_vp_couple0
172 6,3,10, 22,18,26, 41,36,47,
173 69,61,78, 112,99,126, 185,162,211,
174 329,282,387, 672,553,825
201 sprintf(buffer,
"%s_%d.m",base,i);
202 of=fopen(buffer,
"w");
209 fprintf(of,
"%g ",
toBARK(22050.
f*j/n));
211 fprintf(of,
"%g ",(
float)j);
214 fprintf(of,
"%g\n",todB(v+j));
216 fprintf(of,
"%g\n",v[j]);
228 int main(
int argc,
char *argv[]){
233 float ampmax=-9999,newmax;
234 float local_ampmax[2];
237 float ampmax_att_per_sec=-6.;
239 float *pcm[2],*out[2],*
window,*flr[2],*
mask[2],*work[2];
240 signed char *
buffer,*buffer2;
266 framesize=atoi(argv[0]);
282 buffer2=buffer+framesize*2;
283 window=_vorbis_window_create(0,framesize,framesize/2,framesize/2);
286 _vp_psy_init(&p_look,&_psy_set0,&_psy_set0G,framesize/2,44100);
293 fread(buffer,1,44,stdin);
294 fwrite(buffer,1,44,stdout);
295 memset(buffer,0,framesize*2);
297 analysis(
"window",0,window,framesize,0,0);
299 fprintf(stderr,
"Processing for frame size %d...\n",framesize);
302 long bytes=
fread(buffer2,1,framesize*2,stdin);
303 if(bytes<framesize*2)
304 memset(buffer2+bytes,0,framesize*2-bytes);
310 for(i=0;i<framesize;i++){
311 pcm[0][
i]=((buffer[i*4+1]<<8)|
312 (0x00ff&(
int)buffer[i*4]))/32768.f;
313 pcm[1][
i]=((buffer[i*4+3]<<8)|
314 (0x00ff&(
int)buffer[i*4+2]))/32768.f;
318 float secs=framesize/44100.;
320 ampmax+=secs*ampmax_att_per_sec;
321 if(ampmax<-9999)ampmax=-9999;
325 float scale=4.f/framesize;
328 float *logmdct=mdct+framesize/2;
333 for(j=0;j<framesize;j++)
334 fft[j]=pcm[i][j]*=window[j];
338 local_ampmax[
i]=-9999.f;
341 for(j=1;j<framesize-1;j+=2){
343 temp=fft[(j+1)>>1]=todB(&temp);
344 if(temp>local_ampmax[i])local_ampmax[
i]=temp;
346 if(local_ampmax[i]>ampmax)ampmax=local_ampmax[
i];
349 for(j=0;j<framesize/2;j++)
350 logmdct[j]=todB(mdct+j);
361 float *logmdct=mdct+framesize/2;
362 float *mask=fft+framesize/2;
365 _vp_compute_mask(&p_look,
380 memset(&vd,0,
sizeof(vd));
386 nonzero[
i]=
_floor_P[1]->forward(&vb,floor_look,
403 for(j=0;j<framesize/2;j++)
404 if(fabs(pcm[i][j])>1500)
405 fprintf(stderr,
"%ld ",
frameno+i);
412 _vp_partition_prequant(&p_look,
435 for(j=0;j<framesize/2;j++){
464 for(j=0;j<framesize/2;j++)
465 pcm[i][j]*=flr[i][j];
472 for(j=0;j<framesize/2;j++)
473 out[i][j]+=pcm[i][j]*window[j];
482 char *ptr=buffer+i*2;
485 for(j=0;j<framesize/2;j++){
486 int val=mono[
j]*32767.;
489 if(!flag)fprintf(stderr,
"clipping in frame %ld ",
frameno+i);
494 if(!flag)fprintf(stderr,
"clipping in frame %ld ",
frameno+i);
499 ptr[1]=(val>>8)&0xff;
505 fwrite(buffer,1,framesize*2,stdout);
506 memmove(buffer,buffer2,framesize*2);
509 for(j=0,k=framesize/2;j<framesize/2;j++,k++)
510 out[i][j]=pcm[i][k]*window[k];
516 fprintf(stderr,
"average raw bits of entropy: %.03g/sample\n",acc/tot);
517 fprintf(stderr,
"average nonzero samples: %.03g/%d\n",nonz/tot*framesize/2,
519 fprintf(stderr,
"Done\n\n");
void analysis(char *base, int i, float *v, int n, int bark, int dB)
vorbis_look_floor *(* look)(vorbis_dsp_state *, vorbis_info_floor *)
GLenum GLenum GLenum GLenum GLenum scale
void mdct_init(mdct_lookup *lookup, int n)
void mdct_forward(mdct_lookup *init, DATA_TYPE *in, DATA_TYPE *out)
int main(int argc, char *argv[])
void drft_init(drft_lookup *l, int n)
vorbis_look_psy_global * _vp_global_look(vorbis_info *vi)
void mdct_backward(mdct_lookup *init, DATA_TYPE *in, DATA_TYPE *out)
void _vp_remove_floor(vorbis_look_psy *p, float *mdct, int *codedflr, float *residue, int sliding_lowpass)
void _vp_psy_init(vorbis_look_psy *p, vorbis_info_psy *vi, vorbis_info_psy_global *gi, int n, long rate)
vorbis_func_floor * _floor_P[]
void _vp_couple(int blobno, vorbis_info_psy_global *g, vorbis_look_psy *p, vorbis_info_mapping0 *vi, float **res, float **mag_memo, int **mag_sort, int **ifloor, int *nonzero, int sliding_lowpass)
int sprintf(idStr &string, const char *fmt,...)
void drft_forward(drft_lookup *l, float *data)