~ubuntu-branches/ubuntu/lucid/mpg123/lucid

« back to all changes in this revision

Viewing changes to src/decode_4to1.c

Tags: upstream-0.66
ImportĀ upstreamĀ versionĀ 0.66

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
        decode_4to1.c: ...with 4to1 downsampling / decoding of every 4th sample
3
3
 
4
4
        copyright 1995-2006 by the mpg123 project - free software under the terms of the LGPL 2.1
5
 
        see COPYING and AUTHORS files in distribution or http://mpg123.de
 
5
        see COPYING and AUTHORS files in distribution or http://mpg123.org
6
6
        initially written by Michael Hipp
7
7
 
8
8
        dunno why it sounds THIS annoying (maybe we should adapt the window?)
15
15
 
16
16
#include "config.h"
17
17
#include "mpg123.h"
18
 
 
19
 
#define WRITE_SAMPLE(samples,sum,clip) \
20
 
  if( (sum) > 32767.0) { *(samples) = 0x7fff; (clip)++; } \
21
 
  else if( (sum) < -32768.0) { *(samples) = -0x8000; (clip)++; } \
22
 
  else { *(samples) = sum; }
 
18
#include "decode.h"
23
19
 
24
20
int synth_4to1_8bit(real *bandPtr,int channel,unsigned char *samples,int *pnt)
25
21
{
26
 
  short samples_tmp[16];
27
 
  short *tmp1 = samples_tmp + channel;
 
22
  sample_t samples_tmp[16];
 
23
  sample_t *tmp1 = samples_tmp + channel;
28
24
  int i,ret;
29
25
  int pnt1 = 0;
30
26
 
32
28
  samples += channel + *pnt;
33
29
 
34
30
  for(i=0;i<8;i++) {
 
31
#ifdef FLOATOUT
 
32
    *samples = 0;
 
33
#else
35
34
    *samples = conv16to8[*tmp1>>AUSHIFT];
 
35
#endif
36
36
    samples += 2;
37
37
    tmp1 += 2;
38
38
  }
43
43
 
44
44
int synth_4to1_8bit_mono(real *bandPtr,unsigned char *samples,int *pnt)
45
45
{
46
 
  short samples_tmp[16];
47
 
  short *tmp1 = samples_tmp;
 
46
  sample_t samples_tmp[16];
 
47
  sample_t *tmp1 = samples_tmp;
48
48
  int i,ret;
49
49
  int pnt1 = 0;
50
50
 
52
52
  samples += *pnt;
53
53
 
54
54
  for(i=0;i<8;i++) {
 
55
#ifdef FLOATOUT
 
56
    *samples++ = 0;
 
57
#else
55
58
    *samples++ = conv16to8[*tmp1>>AUSHIFT];
 
59
#endif
56
60
    tmp1 += 2;
57
61
  }
58
62
  *pnt += 8;
63
67
 
64
68
int synth_4to1_8bit_mono2stereo(real *bandPtr,unsigned char *samples,int *pnt)
65
69
{
66
 
  short samples_tmp[16];
67
 
  short *tmp1 = samples_tmp;
 
70
  sample_t samples_tmp[16];
 
71
  sample_t *tmp1 = samples_tmp;
68
72
  int i,ret;
69
73
  int pnt1 = 0;
70
74
 
72
76
  samples += *pnt;
73
77
 
74
78
  for(i=0;i<8;i++) {
75
 
    *samples++ = conv16to8[*tmp1>>AUSHIFT];
76
 
    *samples++ = conv16to8[*tmp1>>AUSHIFT];
 
79
#ifdef FLOATOUT
 
80
    *samples++ = 0;
 
81
    *samples++ = 0;
 
82
#else
 
83
    *samples++ = conv16to8[*tmp1>>AUSHIFT];
 
84
    *samples++ = conv16to8[*tmp1>>AUSHIFT];
 
85
#endif
77
86
    tmp1 += 2;
78
87
  }
79
88
  *pnt += 16;
83
92
 
84
93
int synth_4to1_mono(real *bandPtr,unsigned char *samples,int *pnt)
85
94
{
86
 
  short samples_tmp[16];
87
 
  short *tmp1 = samples_tmp;
 
95
  sample_t samples_tmp[16];
 
96
  sample_t *tmp1 = samples_tmp;
88
97
  int i,ret;
89
98
  int pnt1 = 0;
90
99
 
92
101
  samples += *pnt;
93
102
 
94
103
  for(i=0;i<8;i++) {
95
 
    *( (short *)samples) = *tmp1;
96
 
    samples += 2;
 
104
    *( (sample_t *)samples) = *tmp1;
 
105
    samples += sizeof(sample_t);
97
106
    tmp1 += 2;
98
107
  }
99
 
  *pnt += 16;
 
108
  *pnt += 8*sizeof(sample_t);
100
109
 
101
110
  return ret;
102
111
}
106
115
  int i,ret;
107
116
 
108
117
  ret = synth_4to1(bandPtr,0,samples,pnt);
109
 
  samples = samples + *pnt - 32;
 
118
  samples = samples + *pnt - 16*sizeof(sample_t);
110
119
 
111
120
  for(i=0;i<8;i++) {
112
 
    ((short *)samples)[1] = ((short *)samples)[0];
113
 
    samples+=4;
 
121
    ((sample_t *)samples)[1] = ((sample_t *)samples)[0];
 
122
    samples+=2*sizeof(sample_t);
114
123
  }
115
124
 
116
125
  return ret;
121
130
  static real buffs[2][2][0x110];
122
131
  static const int step = 2;
123
132
  static int bo = 1;
124
 
  short *samples = (short *) (out + *pnt);
 
133
  sample_t *samples = (sample_t *) (out + *pnt);
125
134
 
126
135
  real *b0,(*buf)[0x110];
127
136
  int clip = 0; 
143
152
  if(bo & 0x1) {
144
153
    b0 = buf[0];
145
154
    bo1 = bo;
146
 
    dct64(buf[1]+((bo+1)&0xf),buf[0]+bo,bandPtr);
 
155
    opt_dct64(buf[1]+((bo+1)&0xf),buf[0]+bo,bandPtr);
147
156
  }
148
157
  else {
149
158
    b0 = buf[1];
150
159
    bo1 = bo+1;
151
 
    dct64(buf[0]+bo,buf[1]+bo+1,bandPtr);
 
160
    opt_dct64(buf[0]+bo,buf[1]+bo+1,bandPtr);
152
161
  }
153
162
 
154
163
  {
155
164
    register int j;
156
 
    real *window = decwin + 16 - bo1;
 
165
    real *window = opt_decwin + 16 - bo1;
157
166
 
158
167
    for (j=4;j;j--,b0+=0x30,window+=0x70)
159
168
    {
232
241
    }
233
242
  }
234
243
  
235
 
  *pnt += 32;
 
244
  *pnt += 16*sizeof(sample_t);
236
245
 
237
246
  return clip;
238
247
}