~ubuntu-branches/ubuntu/wily/easytag/wily-proposed

« back to all changes in this revision

Viewing changes to src/libmpg123/layer1.c

  • Committer: Package Import Robot
  • Author(s): James Cowgill, James Cowgill, Alessio Treglia
  • Date: 2014-02-28 15:50:09 UTC
  • mfrom: (8.1.5 sid)
  • Revision ID: package-import@ubuntu.com-20140228155009-o7quqdw3qlldw98q
* Team upload.

[ James Cowgill ]
* New upstream release (Closes: #560813, #500051, #518955, #727811).
* Add myself to the list of uploaders.
* Use debhelper v9.
* debian/control:
  - Build depend on desktop-file-utils and yelp-tools.
  - Recommend on gnome-icon-theme, gvfs and yelp (thanks David King)
  - Update homepage location.
  - Bump standards to 3.9.5 (no changes required).
* debian/copyright:
  - Rewritten to use DEP-5
* debian/rules:
  - Enable all hardening flags.
  - Remove unnecessary dh overrides.
* debian/patches:
  - Remove 1001-c90_style.patch, applied upstream.
  - Add patch to remove appdata from buildsystem.
    Can't use until appdata-tools is introduced into Debian.

[ Alessio Treglia ]
* Improve package description (Closes: #691687)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
/* 
3
 
 * Mpeg Layer-1 audio decoder 
4
 
 * --------------------------
5
 
 * copyright (c) 1995 by Michael Hipp, All rights reserved. See also 'README'
6
 
 * near unoptimzed ...
7
 
 *
8
 
 * may have a few bugs after last optimization ... 
9
 
 *
10
 
 */
11
 
 
12
 
#include "mpg123.h"
13
 
#include "getbits.h"
14
 
 
15
 
/* Used by the getbits macros */
16
 
static unsigned long rval;
17
 
 
18
 
static void
19
 
I_step_one (unsigned int balloc[], unsigned int scale_index[2][SBLIMIT], struct frame *fr)
20
 
{
21
 
        unsigned int *ba = balloc;
22
 
        unsigned int *sca = (unsigned int *) scale_index;
23
 
 
24
 
        if (fr->stereo)
25
 
        {
26
 
                int i;
27
 
                int jsbound = fr->jsbound;
28
 
 
29
 
                for (i = 0; i < jsbound; i++)
30
 
                {
31
 
                        *ba++ = mpg123_getbits(4);
32
 
                        *ba++ = mpg123_getbits(4);
33
 
                }
34
 
                for (i = jsbound; i < SBLIMIT; i++)
35
 
                        *ba++ = mpg123_getbits(4);
36
 
 
37
 
                ba = balloc;
38
 
 
39
 
                for (i = 0; i < jsbound; i++)
40
 
                {
41
 
                        if ((*ba++))
42
 
                                *sca++ = mpg123_getbits(6);
43
 
                        if ((*ba++))
44
 
                                *sca++ = mpg123_getbits(6);
45
 
                }
46
 
                for (i = jsbound; i < SBLIMIT; i++)
47
 
                        if ((*ba++))
48
 
                        {
49
 
                                *sca++ = mpg123_getbits(6);
50
 
                                *sca++ = mpg123_getbits(6);
51
 
                        }
52
 
        }
53
 
        else
54
 
        {
55
 
                int i;
56
 
 
57
 
                for (i = 0; i < SBLIMIT; i++)
58
 
                        *ba++ = mpg123_getbits(4);
59
 
                ba = balloc;
60
 
                for (i = 0; i < SBLIMIT; i++)
61
 
                        if ((*ba++))
62
 
                                *sca++ = mpg123_getbits(6);
63
 
        }
64
 
}
65
 
 
66
 
static void
67
 
I_step_two (real fraction[2][SBLIMIT], unsigned int balloc[2 * SBLIMIT],
68
 
                unsigned int scale_index[2][SBLIMIT], struct frame *fr)
69
 
{
70
 
        int i, n;
71
 
        int smpb[2 * SBLIMIT];  /* values: 0-65535 */
72
 
        int *sample;
73
 
        register unsigned int *ba;
74
 
        register unsigned int *sca = (unsigned int *) scale_index;
75
 
 
76
 
        if (fr->stereo)
77
 
        {
78
 
                int jsbound = fr->jsbound;
79
 
                register real *f0 = fraction[0];
80
 
                register real *f1 = fraction[1];
81
 
 
82
 
                ba = balloc;
83
 
                for (sample = smpb, i = 0; i < jsbound; i++)
84
 
                {
85
 
                        if ((n = *ba++))
86
 
                                *sample++ = mpg123_getbits(n + 1);
87
 
                        if ((n = *ba++))
88
 
                                *sample++ = mpg123_getbits(n + 1);
89
 
                }
90
 
                for (i = jsbound; i < SBLIMIT; i++)
91
 
                        if ((n = *ba++))
92
 
                                *sample++ = mpg123_getbits(n + 1);
93
 
 
94
 
                ba = balloc;
95
 
                for (sample = smpb, i = 0; i < jsbound; i++)
96
 
                {
97
 
                        if ((n = *ba++))
98
 
                                *f0++ = (real) (((-1) << n) + (*sample++) + 1) * mpg123_muls[n + 1][*sca++];
99
 
                        else
100
 
                                *f0++ = 0.0;
101
 
                        if ((n = *ba++))
102
 
                                *f1++ = (real) (((-1) << n) + (*sample++) + 1) * mpg123_muls[n + 1][*sca++];
103
 
                        else
104
 
                                *f1++ = 0.0;
105
 
                }
106
 
                for (i = jsbound; i < SBLIMIT; i++)
107
 
                {
108
 
                        if ((n = *ba++))
109
 
                        {
110
 
                                real samp = (((-1) << n) + (*sample++) + 1);
111
 
 
112
 
                                *f0++ = samp * mpg123_muls[n + 1][*sca++];
113
 
                                *f1++ = samp * mpg123_muls[n + 1][*sca++];
114
 
                        }
115
 
                        else
116
 
                                *f0++ = *f1++ = 0.0;
117
 
                }
118
 
                for (i = fr->down_sample_sblimit; i < 32; i++)
119
 
                        fraction[0][i] = fraction[1][i] = 0.0;
120
 
        }
121
 
        else
122
 
        {
123
 
                register real *f0 = fraction[0];
124
 
 
125
 
                ba = balloc;
126
 
                for (sample = smpb, i = 0; i < SBLIMIT; i++)
127
 
                        if ((n = *ba++))
128
 
                                *sample++ = mpg123_getbits(n + 1);
129
 
                ba = balloc;
130
 
                for (sample = smpb, i = 0; i < SBLIMIT; i++)
131
 
                {
132
 
                        if ((n = *ba++))
133
 
                                *f0++ = (real) (((-1) << n) + (*sample++) + 1) * mpg123_muls[n + 1][*sca++];
134
 
                        else
135
 
                                *f0++ = 0.0;
136
 
                }
137
 
                for (i = fr->down_sample_sblimit; i < 32; i++)
138
 
                        fraction[0][i] = 0.0;
139
 
        }
140
 
}
141
 
 
142
 
int mpg123_do_layer1(struct frame *fr)
143
 
{
144
 
        int i, stereo = fr->stereo;
145
 
        unsigned int balloc[2 * SBLIMIT];
146
 
        unsigned int scale_index[2][SBLIMIT];
147
 
        real fraction[2][SBLIMIT];
148
 
        int single = fr->single;
149
 
 
150
 
        fr->jsbound = (fr->mode == MPG_MD_JOINT_STEREO) ? (fr->mode_ext << 2) + 4 : 32;
151
 
 
152
 
        if (stereo == 1 || single == 3)
153
 
                single = 0;
154
 
 
155
 
        I_step_one(balloc, scale_index, fr);
156
 
 
157
 
        for (i = 0; i < SCALE_BLOCK; i++)
158
 
        {
159
 
                I_step_two(fraction, balloc, scale_index, fr);
160
 
 
161
 
                if (single >= 0)
162
 
                {
163
 
                        (fr->synth_mono) ((real *) fraction[single], mpg123_pcm_sample, &mpg123_pcm_point);
164
 
                }
165
 
                else
166
 
                {
167
 
                        int p1 = mpg123_pcm_point;
168
 
 
169
 
                        (fr->synth) ((real *) fraction[0], 0, mpg123_pcm_sample, &p1);
170
 
                        (fr->synth) ((real *) fraction[1], 1, mpg123_pcm_sample, &mpg123_pcm_point);
171
 
                }
172
 
 
173
 
/***
174
 
                if (mpg123_info->output_audio)
175
 
                {
176
 
 
177
 
                        mpg123_ip.add_vis_pcm(mpg123_ip.output->written_time(), mpg123_cfg.resolution == 16 ? FMT_S16_NE : FMT_U8,
178
 
                                              mpg123_cfg.channels == 2 ? fr->stereo : 1, mpg123_pcm_point, mpg123_pcm_sample);
179
 
                        while (mpg123_ip.output->buffer_free() < mpg123_pcm_point && mpg123_info->going && mpg123_info->jump_to_time == -1)
180
 
                                xmms_usleep(10000);
181
 
                        if (mpg123_info->going && mpg123_info->jump_to_time == -1)
182
 
                                mpg123_ip.output->write_audio(mpg123_pcm_sample, mpg123_pcm_point);
183
 
                }
184
 
***/
185
 
                mpg123_pcm_point = 0;
186
 
        }
187
 
 
188
 
        return 1;
189
 
}