comparison decoders/mpglib/decode_i386.c @ 279:52b9f37998db

Removed global state variable; should be thread safe now.
author Ryan C. Gordon <icculus@icculus.org>
date Thu, 14 Mar 2002 16:38:59 +0000
parents 9b6e82f7c853
children
comparison
equal deleted inserted replaced
278:dfe4a46f88f7 279:52b9f37998db
15 #include <string.h> 15 #include <string.h>
16 16
17 #include "mpg123_sdlsound.h" 17 #include "mpg123_sdlsound.h"
18 #include "mpglib_sdlsound.h" 18 #include "mpglib_sdlsound.h"
19 19
20 extern struct mpstr *gmp;
21
22 /* old WRITE_SAMPLE */ 20 /* old WRITE_SAMPLE */
23 #define WRITE_SAMPLE(samples,sum,clip) \ 21 #define WRITE_SAMPLE(samples,sum,clip) \
24 if( (sum) > 32767.0) { *(samples) = 0x7fff; (clip)++; } \ 22 if( (sum) > 32767.0) { *(samples) = 0x7fff; (clip)++; } \
25 else if( (sum) < -32768.0) { *(samples) = -0x8000; (clip)++; } \ 23 else if( (sum) < -32768.0) { *(samples) = -0x8000; (clip)++; } \
26 else { *(samples) = sum; } 24 else { *(samples) = sum; }
27 25
28 int synth_1to1_mono(real *bandPtr,unsigned char *samples,int *pnt) 26 int synth_1to1_mono(real *bandPtr,unsigned char *samples,
27 int *pnt, struct mpstr *mp)
29 { 28 {
30 short samples_tmp[64]; 29 short samples_tmp[64];
31 short *tmp1 = samples_tmp; 30 short *tmp1 = samples_tmp;
32 int i,ret; 31 int i,ret;
33 int pnt1 = 0; 32 int pnt1 = 0;
34 33
35 ret = synth_1to1(bandPtr,0,(unsigned char *) samples_tmp,&pnt1); 34 ret = synth_1to1(bandPtr,0,(unsigned char *) samples_tmp,&pnt1,mp);
36 samples += *pnt; 35 samples += *pnt;
37 36
38 for(i=0;i<32;i++) { 37 for(i=0;i<32;i++) {
39 *( (short *) samples) = *tmp1; 38 *( (short *) samples) = *tmp1;
40 samples += 2; 39 samples += 2;
44 43
45 return ret; 44 return ret;
46 } 45 }
47 46
48 47
49 int synth_1to1(real *bandPtr,int channel,unsigned char *out,int *pnt) 48 int synth_1to1(real *bandPtr,int channel,unsigned char *out,
49 int *pnt, struct mpstr *mp)
50 { 50 {
51 static const int step = 2; 51 static const int step = 2;
52 int bo; 52 int bo;
53 short *samples = (short *) (out + *pnt); 53 short *samples = (short *) (out + *pnt);
54 54
55 real *b0,(*buf)[0x110]; 55 real *b0,(*buf)[0x110];
56 int clip = 0; 56 int clip = 0;
57 int bo1; 57 int bo1;
58 58
59 bo = gmp->synth_bo; 59 bo = mp->synth_bo;
60 60
61 if(!channel) { 61 if(!channel) {
62 bo--; 62 bo--;
63 bo &= 0xf; 63 bo &= 0xf;
64 buf = gmp->synth_buffs[0]; 64 buf = mp->synth_buffs[0];
65 } 65 }
66 else { 66 else {
67 samples++; 67 samples++;
68 buf = gmp->synth_buffs[1]; 68 buf = mp->synth_buffs[1];
69 } 69 }
70 70
71 if(bo & 0x1) { 71 if(bo & 0x1) {
72 b0 = buf[0]; 72 b0 = buf[0];
73 bo1 = bo; 73 bo1 = bo;
77 b0 = buf[1]; 77 b0 = buf[1];
78 bo1 = bo+1; 78 bo1 = bo+1;
79 dct64(buf[0]+bo,buf[1]+bo+1,bandPtr); 79 dct64(buf[0]+bo,buf[1]+bo+1,bandPtr);
80 } 80 }
81 81
82 gmp->synth_bo = bo; 82 mp->synth_bo = bo;
83 83
84 { 84 {
85 register int j; 85 register int j;
86 real *window = decwin + 16 - bo1; 86 real *window = decwin + 16 - bo1;
87 87