summaryrefslogtreecommitdiffstats
path: root/mp3lib/decod386.c
diff options
context:
space:
mode:
authorarpi_esp <arpi_esp@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-02-24 20:28:24 +0000
committerarpi_esp <arpi_esp@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-02-24 20:28:24 +0000
commitd34041569e71fc9bd772354e94dc9d16061072a5 (patch)
tree8f481cae1c70f32d1756fbe5f39000577b73042d /mp3lib/decod386.c
parente95a95ece09bac96bdfd37322f96c6f57ef79ebc (diff)
downloadmpv-d34041569e71fc9bd772354e94dc9d16061072a5.tar.bz2
mpv-d34041569e71fc9bd772354e94dc9d16061072a5.tar.xz
Initial revision
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@2 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'mp3lib/decod386.c')
-rw-r--r--mp3lib/decod386.c194
1 files changed, 194 insertions, 0 deletions
diff --git a/mp3lib/decod386.c b/mp3lib/decod386.c
new file mode 100644
index 0000000000..f1a7e26b76
--- /dev/null
+++ b/mp3lib/decod386.c
@@ -0,0 +1,194 @@
+/*
+ * Mpeg Layer-1,2,3 audio decoder
+ * ------------------------------
+ * copyright (c) 1995,1996,1997 by Michael Hipp, All rights reserved.
+ * See also 'README'
+ *
+ * slighlty optimized for machines without autoincrement/decrement.
+ * The performance is highly compiler dependend. Maybe
+ * the decode.c version for 'normal' processor may be faster
+ * even for Intel processors.
+ */
+
+
+
+ /* new WRITE_SAMPLE */
+ /* sizeof(int) == 4 */
+#define WRITE_SAMPLE(samples,sum,clip) { \
+ double dtemp; long v; \
+ dtemp = ((((65536.0 * 65536.0 * 16)+(65536.0 * 0.5))* 65536.0)) + (sum);\
+ v = ((*(int *)&dtemp) - 0x80000000); \
+ if( v > 32767) { *(samples) = 0x7fff; (clip)++; } \
+ else if( v < -32768) { *(samples) = -0x8000; (clip)++; } \
+ else { *(samples) = v; } \
+}
+
+
+/*
+#define WRITE_SAMPLE(samples,sum,clip) { \
+ double dtemp; int v; \
+ dtemp = ((((65536.0 * 65536.0 * 16)+(65536.0 * 0.5))* 65536.0)) + (sum);\
+ v = ((*(int *)&dtemp) - 0x80000000); \
+ if( v > 32767) { *(samples) = 0x7fff; (clip)++; } \
+ else if( v < -32768) { *(samples) = -0x8000; (clip)++; } \
+ else { *(samples) = v; } \
+}
+*/
+
+static int synth_1to1_mono(real *bandPtr,unsigned char *samples,int *pnt)
+{
+ short samples_tmp[64];
+ short *tmp1 = samples_tmp;
+ int i,ret;
+ int pnt1 = 0;
+
+ ret = synth_1to1(bandPtr,0,(unsigned char *) samples_tmp,&pnt1);
+ samples += *pnt;
+
+ for(i=0;i<32;i++) {
+ *( (short *) samples) = *tmp1;
+ samples += 2;
+ tmp1 += 2;
+ }
+ *pnt += 64;
+
+ return ret;
+}
+
+
+static int synth_1to1_mono2stereo(real *bandPtr,unsigned char *samples,int *pnt)
+{
+ int i,ret;
+
+ ret = synth_1to1(bandPtr,0,samples,pnt);
+ samples = samples + *pnt - 128;
+
+ for(i=0;i<32;i++) {
+ ((short *)samples)[1] = ((short *)samples)[0];
+ samples+=4;
+ }
+
+ return ret;
+}
+
+
+static int synth_1to1(real *bandPtr,int channel,unsigned char *out,int *pnt)
+{
+ static real buffs[2][2][0x110];
+ static const int step = 2;
+ static int bo = 1;
+ short *samples = (short *) (out + *pnt);
+
+ real *b0,(*buf)[0x110];
+ int clip = 0;
+ int bo1;
+
+ #ifdef HAVE_3DNOW
+ if ( _3dnow )
+ {
+ int ret;
+ ret=synth_1to1_3dnow( bandPtr,channel,out+*pnt );
+ *pnt+=128;
+ return ret;
+ }
+ #endif
+ if ( _i586 )
+ {
+ int ret;
+ ret=synth_1to1_pent( bandPtr,channel,out+*pnt );
+ *pnt+=128;
+ return ret;
+ }
+
+ if(!channel) { /* channel=0 */
+ bo--;
+ bo &= 0xf;
+ buf = buffs[0];
+ }
+ else {
+ samples++;
+ buf = buffs[1];
+ }
+
+ if(bo & 0x1) {
+ b0 = buf[0];
+ bo1 = bo;
+ dct64(buf[1]+((bo+1)&0xf),buf[0]+bo,bandPtr);
+ }
+ else {
+ b0 = buf[1];
+ bo1 = bo+1;
+ dct64(buf[0]+bo,buf[1]+bo+1,bandPtr);
+ }
+
+ {
+ register int j;
+ real *window = decwin + 16 - bo1;
+
+ for (j=16;j;j--,b0+=0x10,window+=0x20,samples+=step)
+ {
+ real sum;
+ sum = window[0x0] * b0[0x0];
+ sum -= window[0x1] * b0[0x1];
+ sum += window[0x2] * b0[0x2];
+ sum -= window[0x3] * b0[0x3];
+ sum += window[0x4] * b0[0x4];
+ sum -= window[0x5] * b0[0x5];
+ sum += window[0x6] * b0[0x6];
+ sum -= window[0x7] * b0[0x7];
+ sum += window[0x8] * b0[0x8];
+ sum -= window[0x9] * b0[0x9];
+ sum += window[0xA] * b0[0xA];
+ sum -= window[0xB] * b0[0xB];
+ sum += window[0xC] * b0[0xC];
+ sum -= window[0xD] * b0[0xD];
+ sum += window[0xE] * b0[0xE];
+ sum -= window[0xF] * b0[0xF];
+
+ WRITE_SAMPLE(samples,sum,clip);
+ }
+
+ {
+ 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);
+ b0-=0x10,window-=0x20,samples+=step;
+ }
+ window += bo1<<1;
+
+ for (j=15;j;j--,b0-=0x10,window-=0x20,samples+=step)
+ {
+ real sum;
+ sum = -window[-0x1] * b0[0x0];
+ sum -= window[-0x2] * b0[0x1];
+ sum -= window[-0x3] * b0[0x2];
+ sum -= window[-0x4] * b0[0x3];
+ sum -= window[-0x5] * b0[0x4];
+ sum -= window[-0x6] * b0[0x5];
+ sum -= window[-0x7] * b0[0x6];
+ sum -= window[-0x8] * b0[0x7];
+ sum -= window[-0x9] * b0[0x8];
+ sum -= window[-0xA] * b0[0x9];
+ sum -= window[-0xB] * b0[0xA];
+ sum -= window[-0xC] * b0[0xB];
+ sum -= window[-0xD] * b0[0xC];
+ sum -= window[-0xE] * b0[0xD];
+ sum -= window[-0xF] * b0[0xE];
+ sum -= window[-0x0] * b0[0xF];
+
+ WRITE_SAMPLE(samples,sum,clip);
+ }
+ }
+ *pnt += 128;
+
+ return clip;
+
+}
+