# HG changeset patch # User rfelker # Date 1042486732 0 # Node ID 1c8e98dba92f429f72efcd251fd55f200a5fcbc8 # Parent 9821db5b213f9092d50ce02d1ba277f12a69a52d don't waste time on rg_scale nonsense if not necessary. diff -r 9821db5b213f -r 1c8e98dba92f libmpcodecs/ad_libvorbis.c --- a/libmpcodecs/ad_libvorbis.c Mon Jan 13 19:18:26 2003 +0000 +++ b/libmpcodecs/ad_libvorbis.c Mon Jan 13 19:38:52 2003 +0000 @@ -187,6 +187,7 @@ int len = 0; int samples; float **pcm; + float scale; ogg_packet op; struct ov_struct_st *ov = sh->context; op.b_o_s = op.e_o_s = 0; @@ -206,18 +207,14 @@ /* convert floats to 16 bit signed ints (host order) and interleave */ +#ifdef TREMOR + if (ov->rg_scale_int == 64) { for(i=0;ivi.channels;i++){ ogg_int16_t *convbuffer=(ogg_int16_t *)(&buf[len]); ogg_int16_t *ptr=convbuffer+i; -#ifdef TREMOR ogg_int32_t *mono=pcm[i]; for(j=0;jrg_scale_int)>>(9+6); -#else - float *mono=pcm[i]; - for(j=0;jrg_scale; -#endif /* TREMOR */ + int val=mono[j]>>9; /* might as well guard against clipping */ if(val>32767){ val=32767; @@ -231,6 +228,38 @@ ptr+=ov->vi.channels; } } + } else +#endif /* TREMOR */ + { +#ifndef TREMOR + scale = 32767.f * ov->rg_scale; +#endif + for(i=0;ivi.channels;i++){ + ogg_int16_t *convbuffer=(ogg_int16_t *)(&buf[len]); + ogg_int16_t *ptr=convbuffer+i; +#ifdef TREMOR + ogg_int32_t *mono=pcm[i]; + for(j=0;jrg_scale_int)>>(9+6); +#else + float *mono=pcm[i]; + for(j=0;j32767){ + val=32767; + clipflag=1; + } + if(val<-32768){ + val=-32768; + clipflag=1; + } +#endif /* TREMOR */ + *ptr=val; + ptr+=ov->vi.channels; + } + } + } if(clipflag) mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"Clipping in frame %ld\n",(long)(ov->vd.sequence));