X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=lib%2Fpsytune.c;h=a7e101058b7a50809a87fc0d03dbd75803d53f7f;hb=f02bae4c215247ff4bf910f4381a7bb1af1d36fa;hp=8027e778b83314cf946374cea3b10aeca3dd03c9;hpb=61084771be7bd5769cd2ca40b42a649811f201bd;p=platform%2Fupstream%2Flibvorbis.git diff --git a/lib/psytune.c b/lib/psytune.c index 8027e77..a7e1010 100644 --- a/lib/psytune.c +++ b/lib/psytune.c @@ -1,117 +1,202 @@ /******************************************************************** * * - * THIS FILE IS PART OF THE Ogg Vorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY * - * THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE. * - * PLEASE READ THESE TERMS DISTRIBUTING. * + * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * * - * THE OggSQUISH SOURCE CODE IS (C) COPYRIGHT 1994-2000 * - * by Monty and The XIPHOPHORUS Company * - * http://www.xiph.org/ * + * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * + * by the Xiph.Org Foundation http://www.xiph.org/ * * * ******************************************************************** function: simple utility that runs audio through the psychoacoustics without encoding - last mod: $Id: psytune.c,v 1.5 2000/08/15 09:09:43 xiphmont Exp $ + last mod: $Id$ ********************************************************************/ +/* NB: this is dead code, retained purely for doc and reference value + don't try to compile it */ + #include #include #include #include #include "vorbis/codec.h" +#include "codec_internal.h" #include "os.h" +#include "misc.h" #include "psy.h" #include "mdct.h" +#include "smallft.h" #include "window.h" #include "scales.h" #include "lpc.h" +#include "lsp.h" +#include "masking.h" +#include "registry.h" -static vorbis_info_psy _psy_set0={ - 1,/*athp*/ - 1,/*decayp*/ - 1,/*smoothp*/ - 0,.2, +static vorbis_info_psy_global _psy_set0G={ + 0, /* decaydBpms */ + 8, /* lines per eighth octave */ + + /* thresh sample period, preecho clamp trigger threshhold, range, minenergy */ + 256, {26.f,26.f,26.f,30.f}, {-90.f,-90.f,-90.f,-90.f}, -90.f, + -6.f, + + 0, + + 0., + 0., +}; - -100., - -140., +static vp_part _vp_part0[]={ + { 1,9e10f, 9e10f, 1.f,9999.f}, + { 9999, .75f, 9e10f, .5f,9999.f}, +/*{ 9999, 1.5f, 9e10f, .5f,9999.f},*/ + { 18,9e10f, 9e10f, .5f, 30.f}, + { 9999,9e10f, 9e10f, .5f, 30.f} +}; + +static vp_couple _vp_couple0[]={ + { 1, {9e10f,9e10f,0}, { 0.f, 0.f,0}, { 0.f, 0.f,0}, {0.f,0.f,0}}, + { 18, {9e10f,9e10f,0}, { 0.f, 0.f,0}, { 0.f, 0.f,0}, {0.f,0.f,0}}, + { 9999, {9e10f,9e10f,0}, { 0.f, 9e10f,0}, { 0.f,22.f,1}, {0.f,0.f,0}} +}; + +static vorbis_info_psy _psy_set0={ + ATH_Bark_dB_lineaggressive, + + -100.f, + -140.f, + 6.f, /* floor master att */ /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 */ /* x: 63 88 125 175 250 350 500 700 1k 1.4k 2k 2.8k 4k 5.6k 8k 11.5k 16k Hz */ /* y: 0 10 20 30 40 50 60 70 80 90 100 dB */ - - 1,/* tonemaskp */ + 1, /* tonemaskp */ + 0.f, /* tone master att */ /* 0 10 20 30 40 50 60 70 80 90 100 */ - {{-40.,-40.,-40.,-40.,-40.,-50.,-60.,-70.,-80.,-90.,-100.}, /*63*/ - {-40.,-40.,-40.,-40.,-40.,-50.,-60.,-70.,-80.,-90.,-100.}, /*88*/ - {-40.,-40.,-40.,-40.,-40.,-50.,-60.,-70.,-80.,-90.,-100.}, /*125*/ - {-40.,-40.,-40.,-40.,-40.,-50.,-60.,-70.,-80.,-90.,-100.}, /*175*/ - {-40.,-40.,-40.,-40.,-40.,-50.,-60.,-70.,-80.,-90.,-100.}, /*250*/ - {-40.,-40.,-40.,-40.,-40.,-50.,-60.,-70.,-80.,-90.,-100.}, /*350*/ - {-40.,-40.,-40.,-40.,-40.,-50.,-60.,-70.,-80.,-90.,-100.}, /*500*/ - {-40.,-40.,-40.,-40.,-40.,-50.,-60.,-70.,-80.,-90.,-100.}, /*700*/ - {-40.,-40.,-40.,-40.,-40.,-50.,-60.,-70.,-80.,-90.,-100.}, /*1000*/ - {-40.,-40.,-40.,-40.,-40.,-50.,-60.,-70.,-80.,-90.,-100.}, /*1400*/ - {-40.,-40.,-40.,-40.,-40.,-50.,-60.,-70.,-80.,-90.,-100.}, /*2000*/ - {-40.,-40.,-40.,-40.,-40.,-50.,-60.,-70.,-80.,-90.,-100.}, /*2800*/ - {-40.,-40.,-40.,-40.,-40.,-50.,-60.,-70.,-80.,-90.,-100.}, /*4000*/ - {-40.,-40.,-40.,-40.,-40.,-50.,-60.,-70.,-80.,-90.,-100.}, /*5600*/ - {-40.,-40.,-40.,-40.,-40.,-50.,-60.,-70.,-80.,-90.,-100.}, /*8000*/ - {-40.,-40.,-40.,-40.,-40.,-50.,-60.,-70.,-80.,-90.,-100.}, /*11500*/ - {-40.,-40.,-40.,-40.,-40.,-50.,-60.,-70.,-80.,-90.,-100.}, /*16000*/ + { + {-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f}, /*63*/ + {-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f}, /*88*/ + {-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f}, /*125*/ + + {-30.f,-30.f,-35.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*175*/ + {-30.f,-30.f,-35.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*250*/ + {-30.f,-30.f,-35.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*350*/ + {-30.f,-30.f,-35.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*500*/ + {-30.f,-30.f,-35.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*700*/ + {-30.f,-30.f,-35.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*1000*/ + {-30.f,-30.f,-35.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*1400*/ + {-40.f,-40.f,-40.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*2000*/ + {-40.f,-40.f,-40.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*2800*/ + {-40.f,-40.f,-40.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*4000*/ + + {-30.f,-35.f,-35.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*5600*/ + + {-30.f,-30.f,-33.f,-35.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*8000*/ + {-30.f,-30.f,-33.f,-35.f,-40.f,-45.f,-50.f,-60.f,-70.f,-85.f,-100.f}, /*11500*/ + {-24.f,-24.f,-26.f,-32.f,-32.f,-42.f,-50.f,-60.f,-70.f,-85.f,-100.f}, /*16000*/ + }, 1,/* peakattp */ - {{-14.,-16.,-18.,-19.,-20.,-21.,-22.,-22.,-22.,-22.,-22.}, /*63*/ - {-14.,-16.,-18.,-19.,-20.,-21.,-22.,-22.,-22.,-22.,-22.}, /*88*/ - {-14.,-16.,-18.,-19.,-20.,-21.,-22.,-22.,-22.,-22.,-22.}, /*125*/ - { -7., -8., -9.,-10.,-10.,-11.,-12.,-13.,-15.,-18.,-20.}, /*8000*/ - { -7., -8., -9.,-10.,-10.,-11.,-12.,-13.,-15.,-18.,-20.}, /*8000*/ - { -7., -8., -9.,-10.,-10.,-11.,-12.,-13.,-15.,-18.,-20.}, /*8000*/ - { -7., -8., -9.,-10.,-10.,-11.,-12.,-13.,-15.,-18.,-20.}, /*8000*/ - { -7., -8., -9.,-10.,-10.,-11.,-12.,-13.,-15.,-18.,-20.}, /*8000*/ - { -7., -8., -9.,-10.,-10.,-11.,-12.,-13.,-15.,-18.,-20.}, /*8000*/ - { -7., -8., -9.,-10.,-10.,-11.,-12.,-13.,-15.,-18.,-20.}, /*8000*/ - { -7., -8., -9.,-10.,-10.,-11.,-12.,-13.,-15.,-18.,-20.}, /*8000*/ - { -7., -8., -9.,-10.,-10.,-11.,-12.,-13.,-15.,-18.,-20.}, /*8000*/ - { -7., -8., -9.,-10.,-10.,-11.,-12.,-13.,-15.,-18.,-20.}, /*8000*/ - { -7., -8., -9.,-10.,-10.,-11.,-12.,-13.,-15.,-18.,-20.}, /*8000*/ - { -7., -8., -9.,-10.,-10.,-11.,-12.,-13.,-15.,-16.,-17.}, /*8000*/ - { -6., -7., -9., -9., -9., -9.,-10.,-11.,-12.,-13.,-14.}, /*11500*/ - { -6., -6., -9., -9., -9., -9., -9., -9.,-10.,-11.,-12.}, /*16000*/ + {{-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-40.f,-40.f,-40.f,-40.f,-40.f},/*63*/ + {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-40.f,-40.f,-40.f,-40.f,-40.f},/*88*/ + {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-40.f,-40.f,-40.f,-40.f,-40.f},/*125*/ + {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-40.f,-40.f,-40.f,-40.f,-40.f},/*175*/ + {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-40.f,-40.f,-40.f,-40.f,-40.f},/*250*/ + {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-40.f,-40.f,-40.f,-40.f,-40.f},/*350*/ + {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-40.f,-40.f,-40.f,-40.f,-40.f},/*500*/ + {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-40.f,-40.f,-40.f,-40.f,-40.f},/*700*/ + {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-40.f,-40.f,-40.f,-40.f,-40.f},/*1000*/ + {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-40.f,-40.f,-40.f,-40.f,-40.f},/*1400*/ + {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-40.f,-40.f,-40.f,-40.f,-40.f},/*2000*/ + {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-40.f,-40.f,-40.f,-40.f,-40.f},/*2800*/ + {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-40.f,-40.f,-40.f,-40.f,-40.f},/*4000*/ + {-10.f,-12.f,-14.f,-16.f,-16.f,-20.f,-24.f,-30.f,-32.f,-40.f,-40.f},/*5600*/ + {-10.f,-12.f,-14.f,-16.f,-16.f,-20.f,-24.f,-30.f,-32.f,-40.f,-40.f},/*8000*/ + {-10.f,-10.f,-10.f,-12.f,-14.f,-18.f,-22.f,-28.f,-32.f,-40.f,-40.f},/*11500*/ + {-10.f,-10.f,-10.f,-12.f,-14.f,-18.f,-22.f,-28.f,-32.f,-40.f,-40.f},/*16000*/ }, 1,/*noisemaskp */ - /* 0 10 20 30 40 50 60 70 80 90 100 */ - {{-99.,-99.,-99.,-99.,-99.,-99.,-99.,-199.,-199.,-199.,-199.}, /*63*/ - {-99.,-99.,-99.,-99.,-99.,-99.,-99.,-199.,-199.,-199.,-199.}, /*88*/ - {-99.,-99.,-99.,-99.,-99.,-99.,-99.,-199.,-199.,-199.,-199.}, /*125*/ - {-99.,-99.,-99.,-99.,-99.,-99.,-99.,-199.,-199.,-199.,-199.}, /*175*/ - {-99.,-99.,-99.,-99.,-99.,-99.,-99.,-199.,-199.,-199.,-199.}, /*250*/ - {-99.,-99.,-99.,-99.,-99.,-99.,-99.,-199.,-199.,-199.,-199.}, /*350*/ - {-99.,-99.,-99.,-99.,-99.,-99.,-99.,-199.,-199.,-199.,-199.}, /*350*/ - {-99.,-99.,-99.,-99.,-99.,-99.,-99.,-199.,-199.,-199.,-199.}, /*350*/ - { -6., -6., -6., -6., -6., -6., -6., -6., -6., -6., -6.}, /*2000*/ - { -6., -6., -6., -6., -6., -6., -6., -6., -6., -6., -6.}, /*2000*/ - { -6., -6., -6., -6., -6., -6., -6., -6., -6., -6., -6.}, /*2000*/ - { -6., -6., -6., -6., -6., -6., -6., -6., -6., -6., -6.}, /*2800*/ - { -0., -0., -0., -0., -0., -0., -0., -0., -0., -0., -0.}, /*4000*/ - { 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.}, /*5600*/ - { 4., 4., 4., 4., 4., 4., 4., 4., 4., 4., 4.}, /*8000*/ - { 4., 4., 4., 4., 4., 4., 4., 4., 4., 4., 4.}, /*11500*/ - { 4., 4., 4., 4., 4., 4., 4., 4., 4., 4., 4.}, /*16000*/ + -10.f, /* suppress any noise curve over maxspec+n */ + .5f, /* low window */ + .5f, /* high window */ + 10, + 10, + 25, + {.000f, 0.f, /*63*/ + .000f, 0.f, /*88*/ + .000f, 0.f, /*125*/ + .000f, 0.f, /*175*/ + .000f, 0.f, /*250*/ + .000f, 0.f, /*350*/ + .000f, 0.f, /*500*/ + .000f, 0.f, /*700*/ + .000f, 0.f, /*1000*/ + .300f, 0.f, /*1400*/ + .300f, 0.f, /*2000*/ + .300f, 0.f, /*2800*/ + .500f, 0.f, /*4000*/ + .700f, 0.f, /*5600*/ + .850f, 0.f, /*8000*/ + .900f, 0.f, /*11500*/ + .900f, 1.f, /*16000*/ }, + + 95.f, /* even decade + 5 is important; saves an rint() later in a + tight loop) */ + -44., - 110., - - -0, -.005, /* attack/decay control */ + 32, + _vp_part0,_vp_couple0 }; +static vorbis_info_floor1 _floor_set0={1, + {0}, + + {32}, + {0}, + {0}, + {{-1}}, + + 2, + {0,1024, + + 88,31,243, + + 14,54,143,460, + + 6,3,10, 22,18,26, 41,36,47, + 69,61,78, 112,99,126, 185,162,211, + 329,282,387, 672,553,825 + }, + + 60,30,400, + 20,8,1,18., + 20,600, + 960}; + + +static vorbis_info_mapping0 mapping_info={1,{0,1},{0},{0},{0},0, 1, {0},{1}}; +static codec_setup_info codec_setup0={ {0,0}, + 1,1,1,1,1,0,1, + {NULL}, + {0},{&mapping_info}, + {0},{NULL}, + {1},{&_floor_set0}, + {2},{NULL}, + {NULL}, + {&_psy_set0}, + &_psy_set0G}; + static int noisy=0; -void analysis(char *base,int i,double *v,int n,int bark,int dB){ +void analysis(char *base,int i,float *v,int n,int bark,int dB){ if(noisy){ int j; FILE *of; @@ -121,78 +206,49 @@ void analysis(char *base,int i,double *v,int n,int bark,int dB){ for(j=0;jm=m; - look->n=n; - look->ln=ln; - lpc_init(&look->lpclook,look->ln,look->m); - - scale=look->ln/toBARK(22050.); - - look->linearmap=malloc(look->n*sizeof(int)); - for(j=0;jn;j++){ - int val=floor( toBARK(22050./n*j) *scale); - if(val>look->ln)val=look->ln; - look->linearmap[j]=val; - } -} +/****************************************************************/ int main(int argc,char *argv[]){ int eos=0; - double nonz=0.; - double acc=0.; - double tot=0.; + float nonz=0.f; + float acc=0.f; + float tot=0.f; + float ampmax=-9999,newmax; + float local_ampmax[2]; int framesize=2048; - int order=32; - int map=256; + float ampmax_att_per_sec=-6.; - double *pcm[2],*out[2],*window,*decay[2],*lpc,*floor; + float *pcm[2],*out[2],*window,*flr[2],*mask[2],*work[2]; signed char *buffer,*buffer2; mdct_lookup m_look; + drft_lookup f_look; vorbis_look_psy p_look; + vorbis_look_psy_global *pg_look; + vorbis_look_floor *floor_look; + vorbis_info vi; long i,j,k; - vorbis_look_floor0 floorlook; - int ath=0; int decayp=0; @@ -201,57 +257,38 @@ int main(int argc,char *argv[]){ if(*argv[0]=='-'){ /* option */ if(argv[0][1]=='v'){ - noisy=0; - } - if(argv[0][1]=='A'){ - ath=0; - } - if(argv[0][1]=='D'){ - decayp=0; - } - if(argv[0][1]=='X'){ - ath=0; - decayp=0; + noisy=0; } }else if(*argv[0]=='+'){ - /* option */ - if(argv[0][1]=='v'){ - noisy=1; - } - if(argv[0][1]=='A'){ - ath=1; - } - if(argv[0][1]=='D'){ - decayp=1; - } - if(argv[0][1]=='X'){ - ath=1; - decayp=1; - } + /* option */ + if(argv[0][1]=='v'){ + noisy=1; + } }else - framesize=atoi(argv[0]); + framesize=atoi(argv[0]); argv++; } - pcm[0]=malloc(framesize*sizeof(double)); - pcm[1]=malloc(framesize*sizeof(double)); - out[0]=calloc(framesize/2,sizeof(double)); - out[1]=calloc(framesize/2,sizeof(double)); - decay[0]=calloc(framesize/2,sizeof(double)); - decay[1]=calloc(framesize/2,sizeof(double)); - floor=malloc(framesize*sizeof(double)); - lpc=malloc(order*sizeof(double)); - buffer=malloc(framesize*4); + vi.channels=2; + vi.codec_setup=&codec_setup0; + + pcm[0]=_ogg_malloc(framesize*sizeof(float)); + pcm[1]=_ogg_malloc(framesize*sizeof(float)); + out[0]=_ogg_calloc(framesize/2,sizeof(float)); + out[1]=_ogg_calloc(framesize/2,sizeof(float)); + work[0]=_ogg_calloc(framesize,sizeof(float)); + work[1]=_ogg_calloc(framesize,sizeof(float)); + flr[0]=_ogg_calloc(framesize/2,sizeof(float)); + flr[1]=_ogg_calloc(framesize/2,sizeof(float)); + buffer=_ogg_malloc(framesize*4); buffer2=buffer+framesize*2; - window=_vorbis_window(0,framesize,framesize/2,framesize/2); + window=_vorbis_window_create(0,framesize,framesize/2,framesize/2); mdct_init(&m_look,framesize); - _vp_psy_init(&p_look,&_psy_set0,framesize/2,44100); - floorinit(&floorlook,framesize/2,order,map); - - for(i=0;ilook(NULL,NULL,&_floor_set0); /* we cheat on the WAV header; we just bypass 44 bytes and never verify that it matches 16bit/stereo/44.1kHz. */ @@ -270,81 +307,201 @@ int main(int argc,char *argv[]){ memset(buffer2+bytes,0,framesize*2-bytes); if(bytes!=0){ + int nonzero[2]; /* uninterleave samples */ for(i=0;i>1]=todB(&temp); + if(temp>local_ampmax[i])local_ampmax[i]=temp; + } + if(local_ampmax[i]>ampmax)ampmax=local_ampmax[i]; + + mdct_forward(&m_look,pcm[i],mdct); + for(j=0;jforward(&vb,floor_look, + mdct, + logmdct, + mask, + logmax, + + flr[i]); + } + + _vp_remove_floor(&p_look, + pg_look, + logmdct, + mdct, + flr[i], + pcm[i], + local_ampmax[i]); + + for(j=0;j1500) + fprintf(stderr,"%ld ",frameno+i); + + analysis("res",frameno+i,pcm[i],framesize/2,1,0); + analysis("codedflr",frameno+i,flr[i],framesize/2,1,1); + } + + /* residue prequantization */ + _vp_partition_prequant(&p_look, + &vi, + pcm, + nonzero); + + for(i=0;i<2;i++) + analysis("quant",frameno+i,pcm[i],framesize/2,1,0); + + /* channel coupling / stereo quantization */ + + _vp_couple(&p_look, + &mapping_info, + pcm, + nonzero); + + for(i=0;i<2;i++) + analysis("coupled",frameno+i,pcm[i],framesize/2,1,0); + + /* decoupling */ + for(i=mapping_info.coupling_steps-1;i>=0;i--){ + float *pcmM=pcm[mapping_info.coupling_mag[i]]; + float *pcmA=pcm[mapping_info.coupling_ang[i]]; + + for(j=0;j0) + if(ang>0){ + pcmM[j]=mag; + pcmA[j]=mag-ang; + }else{ + pcmA[j]=mag; + pcmM[j]=mag+ang; + } + else + if(ang>0){ + pcmM[j]=mag; + pcmA[j]=mag+ang; + }else{ + pcmA[j]=mag; + pcmM[j]=mag-ang; + } + } + } + + for(i=0;i<2;i++) + analysis("decoupled",frameno+i,pcm[i],framesize/2,1,0); + for(i=0;i<2;i++){ - double amp; - - analysis("pre",frameno,pcm[i],framesize,0,0); - - /* do the psychacoustics */ - for(j=0;j32767)val=32767; - if(val<-32768)val=-32768; - ptr[0]=val&0xff; - ptr[1]=(val>>8)&0xff; - ptr+=4; - } + char *ptr=buffer+i*2; + float *mono=out[i]; + int flag=0; + for(j=0;j32767){ + if(!flag)fprintf(stderr,"clipping in frame %ld ",frameno+i); + flag=1; + val=32767; + } + if(val<-32768){ + if(!flag)fprintf(stderr,"clipping in frame %ld ",frameno+i); + flag=1; + val=-32768; + } + ptr[0]=val&0xff; + ptr[1]=(val>>8)&0xff; + ptr+=4; + } } fprintf(stderr,"*"); @@ -352,15 +509,16 @@ int main(int argc,char *argv[]){ memmove(buffer,buffer2,framesize*2); for(i=0;i<2;i++){ - for(j=0,k=framesize/2;j