Mercurial > audlegacy
changeset 1335:109698f652b9 trunk
[svn] - dynamic resampler with interpolation, no special GUI options for it yet though (this replaces the mpg123 "way" of doing it)
author | nenolod |
---|---|
date | Tue, 27 Jun 2006 19:39:52 -0700 |
parents | fe42b588cb53 |
children | 9b6f9e20d8c2 |
files | ChangeLog Plugins/Input/mpg123/Makefile.in Plugins/Input/mpg123/decode_2to1.c Plugins/Input/mpg123/decode_4to1.c Plugins/Input/mpg123/decode_ntom.c Plugins/Input/mpg123/mpg123.c Plugins/Input/mpg123/mpg123.h Plugins/Input/mpg123/resample.c |
diffstat | 8 files changed, 336 insertions(+), 772 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Tue Jun 27 03:00:41 2006 -0700 +++ b/ChangeLog Tue Jun 27 19:39:52 2006 -0700 @@ -1,3 +1,11 @@ +2006-06-27 10:00:41 +0000 Tony Vroon <chainsaw@gentoo.org> + revision [1580] + Update translation credits for German (hansmi) & Polish (vojcek). + + Changes: Modified: + +2 -0 trunk/audacious/credits.c + + 2006-06-27 09:47:29 +0000 Tony Vroon <chainsaw@gentoo.org> revision [1578] Updated Polish translation by Wojciech Myrda <vojcek@tlen.pl>.
--- a/Plugins/Input/mpg123/Makefile.in Tue Jun 27 03:00:41 2006 -0700 +++ b/Plugins/Input/mpg123/Makefile.in Tue Jun 27 19:39:52 2006 -0700 @@ -6,7 +6,7 @@ LIBDIR = $(plugindir)/$(INPUT_PLUGIN_DIR) SOURCES = mpg123.c configure.c fileinfo.c common.c \ - decode_2to1.c decode_4to1.c \ + resample.c \ layer1.c layer2.c layer3.c \ tabinit.c http.c \ dxhead.c decode.c dct64.c paranoia.c interface.c
--- a/Plugins/Input/mpg123/decode_2to1.c Tue Jun 27 03:00:41 2006 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,228 +0,0 @@ -/* - * Mpeg Layer-1,2,3 audio decoder - * ------------------------------ - * copyright (c) 1995 by Michael Hipp, All rights reserved. See also 'README' - * version for slower machines .. decodes only every second sample - * sounds like 24000,22050 or 16000 kHz .. (depending on original sample freq.) - * - */ - -#include <stdlib.h> -#include <math.h> -#include <string.h> - -#include "mpg123.h" - -#define WRITE_SAMPLE(samples,sum,clip) \ - if( (sum) > 32767.0) { *(samples) = 0x7fff; (clip)++; } \ - else if( (sum) < -32768.0) { *(samples) = -0x8000; (clip)++; } \ - else { *(samples) = sum; } - -int mpgdec_synth_2to1_8bit(mpgdec_real *bandPtr,int channel,unsigned char *samples,int *pnt) -{ - short samples_tmp[32]; - short *tmp1 = samples_tmp + channel; - int i,ret; - int pnt1 = 0; - - ret = mpgdec_synth_2to1(bandPtr,channel,(unsigned char *) samples_tmp,&pnt1); - samples += channel + *pnt; - - for(i=0;i<16;i++) { - *samples = mpgdec_conv16to8[*tmp1>>AUSHIFT]; - samples += 2; - tmp1 += 2; - } - *pnt += 32; - - return ret; -} - -int mpgdec_synth_2to1_8bit_mono(mpgdec_real *bandPtr,unsigned char *samples,int *pnt) -{ - short samples_tmp[32]; - short *tmp1 = samples_tmp; - int i,ret; - int pnt1 = 0; - - ret = mpgdec_synth_2to1(bandPtr,0,(unsigned char *) samples_tmp,&pnt1); - samples += *pnt; - - for(i=0;i<16;i++) { - *samples++ = mpgdec_conv16to8[*tmp1>>AUSHIFT]; - tmp1 += 2; - } - *pnt += 16; - - return ret; -} - - -int mpgdec_synth_2to1_8bit_mono2stereo(mpgdec_real *bandPtr,unsigned char *samples,int *pnt) -{ - short samples_tmp[32]; - short *tmp1 = samples_tmp; - int i,ret; - int pnt1 = 0; - - ret = mpgdec_synth_2to1(bandPtr,0,(unsigned char *) samples_tmp,&pnt1); - samples += *pnt; - - for(i=0;i<16;i++) { - *samples++ = mpgdec_conv16to8[*tmp1>>AUSHIFT]; - *samples++ = mpgdec_conv16to8[*tmp1>>AUSHIFT]; - tmp1 += 2; - } - *pnt += 32; - - return ret; -} - -int mpgdec_synth_2to1_mono(mpgdec_real *bandPtr,unsigned char *samples,int *pnt) -{ - short samples_tmp[32]; - short *tmp1 = samples_tmp; - int i,ret; - int pnt1=0; - - ret = mpgdec_synth_2to1(bandPtr,0,(unsigned char *) samples_tmp,&pnt1); - samples += *pnt; - - for(i=0;i<16;i++) { - *( (short *) samples) = *tmp1; - samples += 2; - tmp1 += 2; - } - *pnt += 32; - - return ret; -} - -int mpgdec_synth_2to1_mono2stereo(mpgdec_real *bandPtr,unsigned char *samples,int *pnt) -{ - int i,ret; - - ret = mpgdec_synth_2to1(bandPtr,0,samples,pnt); - samples = samples + *pnt - 64; - - for(i=0;i<16;i++) { - ((short *)samples)[1] = ((short *)samples)[0]; - samples+=4; - } - - return ret; -} - -int mpgdec_synth_2to1(mpgdec_real *bandPtr,int channel,unsigned char *out,int *pnt) -{ - static mpgdec_real buffs[2][2][0x110]; - static const int step = 2; - static int bo = 1; - short *samples = (short *) (out + *pnt); - - mpgdec_real *b0,(*buf)[0x110]; - int clip = 0; - int bo1; - - if(!channel) { - bo--; - bo &= 0xf; - buf = buffs[0]; - } - else { - samples++; - buf = buffs[1]; - } - - if(bo & 0x1) { - b0 = buf[0]; - bo1 = bo; - mpgdec_dct64(buf[1]+((bo+1)&0xf),buf[0]+bo,bandPtr); - } - else { - b0 = buf[1]; - bo1 = bo+1; - mpgdec_dct64(buf[0]+bo,buf[1]+bo+1,bandPtr); - } - - { - register int j; - mpgdec_real *window = mpgdec_decwin + 16 - bo1; - - for (j=8;j;j--,b0+=0x10,window+=0x30) - { - mpgdec_real sum; - sum = *window++ * *b0++; - sum -= *window++ * *b0++; - sum += *window++ * *b0++; - sum -= *window++ * *b0++; - sum += *window++ * *b0++; - sum -= *window++ * *b0++; - sum += *window++ * *b0++; - sum -= *window++ * *b0++; - sum += *window++ * *b0++; - sum -= *window++ * *b0++; - sum += *window++ * *b0++; - sum -= *window++ * *b0++; - sum += *window++ * *b0++; - sum -= *window++ * *b0++; - sum += *window++ * *b0++; - sum -= *window++ * *b0++; - - WRITE_SAMPLE(samples,sum,clip); samples += step; -#if 0 - WRITE_SAMPLE(samples,sum,clip); samples += step; -#endif - } - - { - mpgdec_real sum; - sum = window[0x0] * b0[0x0]; - sum += window[0x2] * b0[0x2]; - sum += window[0x4] * b0[0x4]; - sum += window[0x6] * b0[0x6]; - sum += window[0x8] * b0[0x8]; - sum += window[0xA] * b0[0xA]; - sum += window[0xC] * b0[0xC]; - sum += window[0xE] * b0[0xE]; - WRITE_SAMPLE(samples,sum,clip); samples += step; -#if 0 - WRITE_SAMPLE(samples,sum,clip); samples += step; -#endif - b0-=0x20,window-=0x40; - } - window += bo1<<1; - - for (j=7;j;j--,b0-=0x30,window-=0x30) - { - mpgdec_real sum; - sum = -*(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - - WRITE_SAMPLE(samples,sum,clip); samples += step; -#if 0 - WRITE_SAMPLE(samples,sum,clip); samples += step; -#endif - } - } - - *pnt += 64; - - return clip; -} - -
--- a/Plugins/Input/mpg123/decode_4to1.c Tue Jun 27 03:00:41 2006 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,235 +0,0 @@ -/* - * Mpeg Layer-1,2,3 audio decoder - * ------------------------------ - * copyright (c) 1995,1996,1997 by Michael Hipp, All rights reserved. - * See also 'README' - * version for slower machines .. decodes only every fourth sample - * dunno why it sounds THIS annoying (maybe we should adapt the window?) - * absolutely not optimized for this operation - */ - -#include <stdlib.h> -#include <math.h> -#include <string.h> - -#include "mpg123.h" - -#define WRITE_SAMPLE(samples,sum,clip) \ - if( (sum) > 32767.0) { *(samples) = 0x7fff; (clip)++; } \ - else if( (sum) < -32768.0) { *(samples) = -0x8000; (clip)++; } \ - else { *(samples) = sum; } - -int mpgdec_synth_4to1_8bit(mpgdec_real *bandPtr,int channel,unsigned char *samples,int *pnt) -{ - short samples_tmp[16]; - short *tmp1 = samples_tmp + channel; - int i,ret; - int pnt1 = 0; - - ret = mpgdec_synth_4to1(bandPtr,channel,(unsigned char *) samples_tmp,&pnt1); - samples += channel + *pnt; - - for(i=0;i<8;i++) { - *samples = mpgdec_conv16to8[*tmp1>>AUSHIFT]; - samples += 2; - tmp1 += 2; - } - *pnt += 16; - - return ret; -} - -int mpgdec_synth_4to1_8bit_mono(mpgdec_real *bandPtr,unsigned char *samples,int *pnt) -{ - short samples_tmp[16]; - short *tmp1 = samples_tmp; - int i,ret; - int pnt1 = 0; - - ret = mpgdec_synth_4to1(bandPtr,0,(unsigned char *) samples_tmp,&pnt1); - samples += *pnt; - - for(i=0;i<8;i++) { - *samples++ = mpgdec_conv16to8[*tmp1>>AUSHIFT]; - tmp1 += 2; - } - *pnt += 8; - - return ret; -} - - -int mpgdec_synth_4to1_8bit_mono2stereo(mpgdec_real *bandPtr,unsigned char *samples,int *pnt) -{ - short samples_tmp[16]; - short *tmp1 = samples_tmp; - int i,ret; - int pnt1 = 0; - - ret = mpgdec_synth_4to1(bandPtr,0,(unsigned char *) samples_tmp,&pnt1); - samples += *pnt; - - for(i=0;i<8;i++) { - *samples++ = mpgdec_conv16to8[*tmp1>>AUSHIFT]; - *samples++ = mpgdec_conv16to8[*tmp1>>AUSHIFT]; - tmp1 += 2; - } - *pnt += 16; - - return ret; -} - -int mpgdec_synth_4to1_mono(mpgdec_real *bandPtr,unsigned char *samples,int *pnt) -{ - short samples_tmp[16]; - short *tmp1 = samples_tmp; - int i,ret; - int pnt1 = 0; - - ret = mpgdec_synth_4to1(bandPtr,0,(unsigned char *) samples_tmp,&pnt1); - samples += *pnt; - - for(i=0;i<8;i++) { - *( (short *)samples) = *tmp1; - samples += 2; - tmp1 += 2; - } - *pnt += 16; - - return ret; -} - -int mpgdec_synth_4to1_mono2stereo(mpgdec_real *bandPtr,unsigned char *samples,int *pnt) -{ - int i,ret; - - ret = mpgdec_synth_4to1(bandPtr,0,samples,pnt); - samples = samples + *pnt - 32; - - for(i=0;i<8;i++) { - ((short *)samples)[1] = ((short *)samples)[0]; - samples+=4; - } - - return ret; -} - -int mpgdec_synth_4to1(mpgdec_real *bandPtr,int channel,unsigned char *out,int *pnt) -{ - static mpgdec_real buffs[2][2][0x110]; - static const int step = 2; - static int bo = 1; - short *samples = (short *) (out + *pnt); - - mpgdec_real *b0,(*buf)[0x110]; - int clip = 0; - int bo1; - - if(!channel) { - bo--; - bo &= 0xf; - buf = buffs[0]; - } - else { - samples++; - buf = buffs[1]; - } - - if(bo & 0x1) { - b0 = buf[0]; - bo1 = bo; - mpgdec_dct64(buf[1]+((bo+1)&0xf),buf[0]+bo,bandPtr); - } - else { - b0 = buf[1]; - bo1 = bo+1; - mpgdec_dct64(buf[0]+bo,buf[1]+bo+1,bandPtr); - } - - { - register int j; - mpgdec_real *window = mpgdec_decwin + 16 - bo1; - - for (j=4;j;j--,b0+=0x30,window+=0x70) - { - mpgdec_real sum; - sum = *window++ * *b0++; - sum -= *window++ * *b0++; - sum += *window++ * *b0++; - sum -= *window++ * *b0++; - sum += *window++ * *b0++; - sum -= *window++ * *b0++; - sum += *window++ * *b0++; - sum -= *window++ * *b0++; - sum += *window++ * *b0++; - sum -= *window++ * *b0++; - sum += *window++ * *b0++; - sum -= *window++ * *b0++; - sum += *window++ * *b0++; - sum -= *window++ * *b0++; - sum += *window++ * *b0++; - sum -= *window++ * *b0++; - - WRITE_SAMPLE(samples,sum,clip); samples += step; -#if 0 - WRITE_SAMPLE(samples,sum,clip); samples += step; - WRITE_SAMPLE(samples,sum,clip); samples += step; - WRITE_SAMPLE(samples,sum,clip); samples += step; -#endif - } - - { - mpgdec_real sum; - sum = window[0x0] * b0[0x0]; - sum += window[0x2] * b0[0x2]; - sum += window[0x4] * b0[0x4]; - sum += window[0x6] * b0[0x6]; - sum += window[0x8] * b0[0x8]; - sum += window[0xA] * b0[0xA]; - sum += window[0xC] * b0[0xC]; - sum += window[0xE] * b0[0xE]; - WRITE_SAMPLE(samples,sum,clip); samples += step; -#if 0 - WRITE_SAMPLE(samples,sum,clip); samples += step; - WRITE_SAMPLE(samples,sum,clip); samples += step; - WRITE_SAMPLE(samples,sum,clip); samples += step; -#endif - b0-=0x40,window-=0x80; - } - window += bo1<<1; - - for (j=3;j;j--,b0-=0x50,window-=0x70) - { - mpgdec_real sum; - sum = -*(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - - WRITE_SAMPLE(samples,sum,clip); samples += step; -#if 0 - WRITE_SAMPLE(samples,sum,clip); samples += step; - WRITE_SAMPLE(samples,sum,clip); samples += step; - WRITE_SAMPLE(samples,sum,clip); samples += step; -#endif - } - } - - *pnt += 32; - - return clip; -} - -
--- a/Plugins/Input/mpg123/decode_ntom.c Tue Jun 27 03:00:41 2006 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,282 +0,0 @@ -/* - * Mpeg Layer-1,2,3 audio decoder - * ------------------------------ - * copyright (c) 1995,1996,1997 by Michael Hipp, All rights reserved. - * See also 'README' - * - * N->M down/up sampling. Not optimized for speed. - */ - -#include <stdlib.h> -#include <math.h> -#include <string.h> - -#include "mpg123.h" - -#define WRITE_SAMPLE(samples,sum,clip) \ - if( (sum) > 32767.0) { *(samples) = 0x7fff; (clip)++; } \ - else if( (sum) < -32768.0) { *(samples) = -0x8000; (clip)++; } \ - else { *(samples) = sum; } - -#define NTOM_MUL (32768) -static unsigned long ntom_val[2] = { NTOM_MUL>>1,NTOM_MUL>>1 }; -static unsigned long ntom_step = NTOM_MUL; - - -void mpgdec_synth_ntom_set_step(long m,long n) -{ - if(n >= 96000 || m >= 96000 || m == 0 || n == 0) { - fprintf(stderr,"NtoM converter: illegal rates\n"); - exit(1); - } - - n *= NTOM_MUL; - ntom_step = n / m; - - if(ntom_step > 8*NTOM_MUL) { - fprintf(stderr,"max. 1:8 conversion allowed!\n"); - exit(1); - } - - ntom_val[0] = ntom_val[1] = NTOM_MUL>>1; -} - -int mpgdec_synth_ntom_8bit(mpgdec_real *bandPtr,int channel,unsigned char *samples,int *pnt) -{ - short samples_tmp[8*64]; - short *tmp1 = samples_tmp + channel; - int i,ret; - int pnt1 = 0; - - ret = mpgdec_synth_ntom(bandPtr,channel,(unsigned char *) samples_tmp,&pnt1); - samples += channel + *pnt; - - for(i=0;i<(pnt1>>2);i++) { - *samples = mpgdec_conv16to8[*tmp1>>AUSHIFT]; - samples += 2; - tmp1 += 2; - } - *pnt += pnt1>>1; - - return ret; -} - -int mpgdec_synth_ntom_8bit_mono(mpgdec_real *bandPtr,unsigned char *samples,int *pnt) -{ - short samples_tmp[8*64]; - short *tmp1 = samples_tmp; - int i,ret; - int pnt1 = 0; - - ret = mpgdec_synth_ntom(bandPtr,0,(unsigned char *) samples_tmp,&pnt1); - samples += *pnt; - - for(i=0;i<(pnt1>>2);i++) { - *samples++ = mpgdec_conv16to8[*tmp1>>AUSHIFT]; - tmp1 += 2; - } - *pnt += pnt1 >> 2; - - return ret; -} - -int mpgdec_synth_ntom_8bit_mono2stereo(mpgdec_real *bandPtr,unsigned char *samples,int *pnt) -{ - short samples_tmp[8*64]; - short *tmp1 = samples_tmp; - int i,ret; - int pnt1 = 0; - - ret = mpgdec_synth_ntom(bandPtr,0,(unsigned char *) samples_tmp,&pnt1); - samples += *pnt; - - for(i=0;i<(pnt1>>2);i++) { - *samples++ = mpgdec_conv16to8[*tmp1>>AUSHIFT]; - *samples++ = mpgdec_conv16to8[*tmp1>>AUSHIFT]; - tmp1 += 2; - } - *pnt += pnt1 >> 1; - - return ret; -} - -int mpgdec_synth_ntom_mono(mpgdec_real *bandPtr,unsigned char *samples,int *pnt) -{ - short samples_tmp[8*64]; - short *tmp1 = samples_tmp; - int i,ret; - int pnt1 = 0; - - ret = mpgdec_synth_ntom(bandPtr,0,(unsigned char *) samples_tmp,&pnt1); - samples += *pnt; - - for(i=0;i<(pnt1>>2);i++) { - *( (short *)samples) = *tmp1; - samples += 2; - tmp1 += 2; - } - *pnt += pnt1 >> 1; - - return ret; -} - - -int mpgdec_synth_ntom_mono2stereo(mpgdec_real *bandPtr,unsigned char *samples,int *pnt) -{ - int i,ret; - int pnt1 = *pnt; - - ret = mpgdec_synth_ntom(bandPtr,0,samples,pnt); - samples += pnt1; - - for(i=0;i<((*pnt-pnt1)>>2);i++) { - ((short *)samples)[1] = ((short *)samples)[0]; - samples+=4; - } - - return ret; -} - - -int mpgdec_synth_ntom(mpgdec_real *bandPtr,int channel,unsigned char *out,int *pnt) -{ - static mpgdec_real buffs[2][2][0x110]; - static const int step = 2; - static int bo = 1; - short *samples = (short *) (out + *pnt); - - mpgdec_real *b0,(*buf)[0x110]; - int clip = 0; - int bo1; - int ntom; - - if(!channel) { - bo--; - bo &= 0xf; - buf = buffs[0]; - ntom = ntom_val[1] = ntom_val[0]; - } - else { - samples++; - out += 2; /* to compute the right *pnt value */ - buf = buffs[1]; - ntom = ntom_val[1]; - } - - if(bo & 0x1) { - b0 = buf[0]; - bo1 = bo; - mpgdec_dct64(buf[1]+((bo+1)&0xf),buf[0]+bo,bandPtr); - } - else { - b0 = buf[1]; - bo1 = bo+1; - mpgdec_dct64(buf[0]+bo,buf[1]+bo+1,bandPtr); - } - - - { - register int j; - mpgdec_real *window = decwin + 16 - bo1; - - for (j=16;j;j--,window+=0x10) - { - mpgdec_real sum; - - ntom += ntom_step; - if(ntom < NTOM_MUL) { - window += 16; - b0 += 16; - continue; - } - - sum = *window++ * *b0++; - sum -= *window++ * *b0++; - sum += *window++ * *b0++; - sum -= *window++ * *b0++; - sum += *window++ * *b0++; - sum -= *window++ * *b0++; - sum += *window++ * *b0++; - sum -= *window++ * *b0++; - sum += *window++ * *b0++; - sum -= *window++ * *b0++; - sum += *window++ * *b0++; - sum -= *window++ * *b0++; - sum += *window++ * *b0++; - sum -= *window++ * *b0++; - sum += *window++ * *b0++; - sum -= *window++ * *b0++; - - while(ntom >= NTOM_MUL) { - WRITE_SAMPLE(samples,sum,clip); - samples += step; - ntom -= NTOM_MUL; - } - } - - ntom += ntom_step; - if(ntom >= NTOM_MUL) - { - mpgdec_real sum; - sum = window[0x0] * b0[0x0]; - sum += window[0x2] * b0[0x2]; - sum += window[0x4] * b0[0x4]; - sum += window[0x6] * b0[0x6]; - sum += window[0x8] * b0[0x8]; - sum += window[0xA] * b0[0xA]; - sum += window[0xC] * b0[0xC]; - sum += window[0xE] * b0[0xE]; - - while(ntom >= NTOM_MUL) { - WRITE_SAMPLE(samples,sum,clip); - samples += step; - ntom -= NTOM_MUL; - } - } - - b0-=0x10,window-=0x20; - window += bo1<<1; - - for (j=15;j;j--,b0-=0x20,window-=0x10) - { - mpgdec_real sum; - - ntom += ntom_step; - if(ntom < NTOM_MUL) { - window -= 16; - b0 += 16; - continue; - } - - sum = -*(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - sum -= *(--window) * *b0++; - - while(ntom >= NTOM_MUL) { - WRITE_SAMPLE(samples,sum,clip); - samples += step; - ntom -= NTOM_MUL; - } - } - } - - ntom_val[channel] = ntom; - *pnt = ((unsigned char *) samples - out); - - return clip; -} - -
--- a/Plugins/Input/mpg123/mpg123.c Tue Jun 27 03:00:41 2006 -0700 +++ b/Plugins/Input/mpg123/mpg123.c Tue Jun 27 19:39:52 2006 -0700 @@ -116,24 +116,24 @@ int ds = fr->down_sample; int p8 = 0; - static func funcs[][3] = { + static func funcs[2][2] = { {mpgdec_synth_1to1, - mpgdec_synth_2to1, - mpgdec_synth_4to1}, + mpgdec_synth_ntom}, {mpgdec_synth_1to1_8bit, - mpgdec_synth_2to1_8bit, - mpgdec_synth_4to1_8bit}, + mpgdec_synth_ntom_8bit} }; - static func_mono funcs_mono[2][4] = { + static func_mono funcs_mono[2][2] = { {mpgdec_synth_1to1_mono, - mpgdec_synth_2to1_mono, - mpgdec_synth_4to1_mono}, + mpgdec_synth_ntom_mono}, {mpgdec_synth_1to1_8bit_mono, - mpgdec_synth_2to1_8bit_mono, - mpgdec_synth_4to1_8bit_mono} + mpgdec_synth_ntom_8bit_mono} }; + /* Compatibility with older configs. */ + if (ds > 1) + ds = 1; + if (mpgdec_cfg.resolution == 8) p8 = 1; fr->synth = funcs[p8][ds]; @@ -627,7 +627,8 @@ { int r; AFormat fmt = mpgdec_cfg.resolution == 16 ? FMT_S16_NE : FMT_U8; - int freq = mpgdec_freqs[fr.sampling_frequency] >> mpgdec_cfg.downsample; +/* int freq = mpgdec_freqs[fr.sampling_frequency] >> mpgdec_cfg.downsample; */ + int freq = mpgdec_frequency; int channels = mpgdec_cfg.channels == 2 ? fr.stereo : 1; r = mpgdec_ip.output->open_audio(fmt, freq, channels); @@ -696,7 +697,6 @@ fr.down_sample = mpgdec_cfg.downsample; fr.down_sample_sblimit = SBLIMIT >> mpgdec_cfg.downsample; set_synth_functions(&fr); - mpgdec_init_layer3(fr.down_sample_sblimit); mpgdec_info->tpf = mpgdec_compute_tpf(&fr); if (strncasecmp(filename, "http://", 7)) { @@ -734,6 +734,16 @@ mpgdec_mpeg25 = fr.mpeg25; mpgdec_mode = fr.mode; + if (fr.down_sample) + { + long n = mpgdec_freqs[fr.sampling_frequency]; + long m = n / fr.down_sample; + + mpgdec_synth_ntom_set_step(n, m); + + mpgdec_frequency = (gint) m; + } + if (strncasecmp(filename, "http://", 7)) { mpgdec_length = mpgdec_info->num_frames * mpgdec_info->tpf * 1000; if (!mpgdec_title) @@ -745,6 +755,9 @@ mpgdec_length = -1; } + set_synth_functions(&fr); + mpgdec_init_layer3(fr.down_sample_sblimit); + mpgdec_ip.set_info(mpgdec_title, mpgdec_length, mpgdec_bitrate * 1000, mpgdec_freqs[fr.sampling_frequency], fr.stereo);
--- a/Plugins/Input/mpg123/mpg123.h Tue Jun 27 03:00:41 2006 -0700 +++ b/Plugins/Input/mpg123/mpg123.h Tue Jun 27 19:39:52 2006 -0700 @@ -293,20 +293,12 @@ extern int mpgdec_synth_1to1_8bit_mono2stereo(mpgdec_real *, unsigned char *, int *); -extern int mpgdec_synth_2to1(mpgdec_real *, int, unsigned char *, int *); -extern int mpgdec_synth_2to1_8bit(mpgdec_real *, int, unsigned char *, int *); -extern int mpgdec_synth_2to1_mono(mpgdec_real *, unsigned char *, int *); -extern int mpgdec_synth_2to1_mono2stereo(mpgdec_real *, unsigned char *, int *); -extern int mpgdec_synth_2to1_8bit_mono(mpgdec_real *, unsigned char *, int *); -extern int mpgdec_synth_2to1_8bit_mono2stereo(mpgdec_real *, unsigned char *, - int *); - -extern int mpgdec_synth_4to1(mpgdec_real *, int, unsigned char *, int *); -extern int mpgdec_synth_4to1_8bit(mpgdec_real *, int, unsigned char *, int *); -extern int mpgdec_synth_4to1_mono(mpgdec_real *, unsigned char *, int *); -extern int mpgdec_synth_4to1_mono2stereo(mpgdec_real *, unsigned char *, int *); -extern int mpgdec_synth_4to1_8bit_mono(mpgdec_real *, unsigned char *, int *); -extern int mpgdec_synth_4to1_8bit_mono2stereo(mpgdec_real *, unsigned char *, +extern int mpgdec_synth_ntom(mpgdec_real *, int, unsigned char *, int *); +extern int mpgdec_synth_ntom_8bit(mpgdec_real *, int, unsigned char *, int *); +extern int mpgdec_synth_ntom_mono(mpgdec_real *, unsigned char *, int *); +extern int mpgdec_synth_ntom_mono2stereo(mpgdec_real *, unsigned char *, int *); +extern int mpgdec_synth_ntom_8bit_mono(mpgdec_real *, unsigned char *, int *); +extern int mpgdec_synth_ntom_8bit_mono2stereo(mpgdec_real *, unsigned char *, int *); extern void mpgdec_rewindNbits(int bits);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Plugins/Input/mpg123/resample.c Tue Jun 27 19:39:52 2006 -0700 @@ -0,0 +1,296 @@ +/* libmpgdec: An advanced MPEG layer 1/2/3 decoder. + * resample.c: A dynamic resampler. + * + * Copyright (C) 2005-2006 William Pitcock <nenolod@nenolod.net> + * Portions copyright (C) 1995-1999 Michael Hipp + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <stdlib.h> +#include <math.h> +#include <string.h> + +#include "mpg123.h" + +#define WRITE_SAMPLE(samples,sum,clip) \ + if( (sum) > 32767.0) { *(samples) = 0x7fff; (clip)++; } \ + else if( (sum) < -32768.0) { *(samples) = -0x8000; (clip)++; } \ + else { *(samples) = sum; } + +#define NTOM_MUL (32768) +static unsigned long ntom_val[2] = { NTOM_MUL>>1,NTOM_MUL>>1 }; +static unsigned long ntom_step = NTOM_MUL; + + +void mpgdec_synth_ntom_set_step(long m,long n) +{ + if(n >= 96000 || m >= 96000 || m == 0 || n == 0) { + fprintf(stderr,"resampler: illegal rates\n"); + exit(1); + } + + n *= NTOM_MUL; + ntom_step = n / m; + + printf("mpgdec_synth_to_ntom_set_step: calculated step: %ld skip-samples\n", ntom_step); + + if(ntom_step > 8*NTOM_MUL) { + fprintf(stderr,"max. 1:8 conversion allowed!\n"); + exit(1); + } + + ntom_val[0] = ntom_val[1] = NTOM_MUL>>1; +} + +int mpgdec_synth_ntom_8bit(mpgdec_real *bandPtr,int channel,unsigned char *samples,int *pnt) +{ + short samples_tmp[8*64]; + short *tmp1 = samples_tmp + channel; + int i,ret; + int pnt1 = 0; + + ret = mpgdec_synth_ntom(bandPtr,channel,(unsigned char *) samples_tmp,&pnt1); + samples += channel + *pnt; + + for(i=0;i<(pnt1>>2);i++) { + *samples = mpgdec_conv16to8[*tmp1>>AUSHIFT]; + samples += 2; + tmp1 += 2; + } + *pnt += pnt1>>1; + + return ret; +} + +int mpgdec_synth_ntom_8bit_mono(mpgdec_real *bandPtr,unsigned char *samples,int *pnt) +{ + short samples_tmp[8*64]; + short *tmp1 = samples_tmp; + int i,ret; + int pnt1 = 0; + + ret = mpgdec_synth_ntom(bandPtr,0,(unsigned char *) samples_tmp,&pnt1); + samples += *pnt; + + for(i=0;i<(pnt1>>2);i++) { + *samples++ = mpgdec_conv16to8[*tmp1>>AUSHIFT]; + tmp1 += 2; + } + *pnt += pnt1 >> 2; + + return ret; +} + +int mpgdec_synth_ntom_8bit_mono2stereo(mpgdec_real *bandPtr,unsigned char *samples,int *pnt) +{ + short samples_tmp[8*64]; + short *tmp1 = samples_tmp; + int i,ret; + int pnt1 = 0; + + ret = mpgdec_synth_ntom(bandPtr,0,(unsigned char *) samples_tmp,&pnt1); + samples += *pnt; + + for(i=0;i<(pnt1>>2);i++) { + *samples++ = mpgdec_conv16to8[*tmp1>>AUSHIFT]; + *samples++ = mpgdec_conv16to8[*tmp1>>AUSHIFT]; + tmp1 += 2; + } + *pnt += pnt1 >> 1; + + return ret; +} + +int mpgdec_synth_ntom_mono(mpgdec_real *bandPtr,unsigned char *samples,int *pnt) +{ + short samples_tmp[8*64]; + short *tmp1 = samples_tmp; + int i,ret; + int pnt1 = 0; + + ret = mpgdec_synth_ntom(bandPtr,0,(unsigned char *) samples_tmp,&pnt1); + samples += *pnt; + + for(i=0;i<(pnt1>>2);i++) { + *( (short *)samples) = *tmp1; + samples += 2; + tmp1 += 2; + } + *pnt += pnt1 >> 1; + + return ret; +} + + +int mpgdec_synth_ntom_mono2stereo(mpgdec_real *bandPtr,unsigned char *samples,int *pnt) +{ + int i,ret; + int pnt1 = *pnt; + + ret = mpgdec_synth_ntom(bandPtr,0,samples,pnt); + samples += pnt1; + + for(i=0;i<((*pnt-pnt1)>>2);i++) { + ((short *)samples)[1] = ((short *)samples)[0]; + samples+=4; + } + + return ret; +} + + +int mpgdec_synth_ntom(mpgdec_real *bandPtr,int channel,unsigned char *out,int *pnt) +{ + static mpgdec_real buffs[2][2][0x110]; + static const int step = 2; + static int bo = 1; + short *samples = (short *) (out + *pnt); + + mpgdec_real *b0,(*buf)[0x110]; + int clip = 0; + int bo1; + int ntom; + + if(!channel) { + bo--; + bo &= 0xf; + buf = buffs[0]; + ntom = ntom_val[1] = ntom_val[0]; + } + else { + samples++; + out += 2; /* to compute the right *pnt value */ + buf = buffs[1]; + ntom = ntom_val[1]; + } + + if(bo & 0x1) { + b0 = buf[0]; + bo1 = bo; + mpgdec_dct64(buf[1]+((bo+1)&0xf),buf[0]+bo,bandPtr); + } + else { + b0 = buf[1]; + bo1 = bo+1; + mpgdec_dct64(buf[0]+bo,buf[1]+bo+1,bandPtr); + } + + + { + register int j; + mpgdec_real *window = mpgdec_decwin + 16 - bo1; + + for (j=16;j;j--,window+=0x10) + { + mpgdec_real sum; + + ntom += ntom_step; + if(ntom < NTOM_MUL) { + window += 16; + b0 += 16; + continue; + } + + sum = *window++ * *b0++; + sum -= *window++ * *b0++; + sum += *window++ * *b0++; + sum -= *window++ * *b0++; + sum += *window++ * *b0++; + sum -= *window++ * *b0++; + sum += *window++ * *b0++; + sum -= *window++ * *b0++; + sum += *window++ * *b0++; + sum -= *window++ * *b0++; + sum += *window++ * *b0++; + sum -= *window++ * *b0++; + sum += *window++ * *b0++; + sum -= *window++ * *b0++; + sum += *window++ * *b0++; + sum -= *window++ * *b0++; + + while(ntom >= NTOM_MUL) { + WRITE_SAMPLE(samples,sum,clip); + samples += step; + ntom -= NTOM_MUL; + } + } + + ntom += ntom_step; + if(ntom >= NTOM_MUL) + { + mpgdec_real sum; + sum = window[0x0] * b0[0x0]; + sum += window[0x2] * b0[0x2]; + sum += window[0x4] * b0[0x4]; + sum += window[0x6] * b0[0x6]; + sum += window[0x8] * b0[0x8]; + sum += window[0xA] * b0[0xA]; + sum += window[0xC] * b0[0xC]; + sum += window[0xE] * b0[0xE]; + + while(ntom >= NTOM_MUL) { + WRITE_SAMPLE(samples,sum,clip); + samples += step; + ntom -= NTOM_MUL; + } + } + + b0-=0x10,window-=0x20; + window += bo1<<1; + + for (j=15;j;j--,b0-=0x20,window-=0x10) + { + mpgdec_real sum; + + ntom += ntom_step; + if(ntom < NTOM_MUL) { + window -= 16; + b0 += 16; + continue; + } + + sum = -*(--window) * *b0++; + sum -= *(--window) * *b0++; + sum -= *(--window) * *b0++; + sum -= *(--window) * *b0++; + sum -= *(--window) * *b0++; + sum -= *(--window) * *b0++; + sum -= *(--window) * *b0++; + sum -= *(--window) * *b0++; + sum -= *(--window) * *b0++; + sum -= *(--window) * *b0++; + sum -= *(--window) * *b0++; + sum -= *(--window) * *b0++; + sum -= *(--window) * *b0++; + sum -= *(--window) * *b0++; + sum -= *(--window) * *b0++; + sum -= *(--window) * *b0++; + + while(ntom >= NTOM_MUL) { + WRITE_SAMPLE(samples,sum,clip); + samples += step; + ntom -= NTOM_MUL; + } + } + } + + ntom_val[channel] = ntom; + *pnt = ((unsigned char *) samples - out); + + return clip; +} + +