Bug Summary

File:libs/libsndfile/src/ALAC/matrix_enc.c
Location:line 193, column 5
Description:Value stored to 'l' is never read

Annotated Source Code

1/*
2 * Copyright (c) 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2012 Erik de Castro Lopo <erikd@mega-nerd.com>
4 *
5 * @APPLE_APACHE_LICENSE_HEADER_START@
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 * @APPLE_APACHE_LICENSE_HEADER_END@
20 */
21
22/*
23 File: matrix_enc.c
24
25 Contains: ALAC mixing/matrixing encode routines.
26
27 Copyright: (c) 2004-2011 Apple, Inc.
28*/
29
30#include "matrixlib.h"
31#include "ALACAudioTypes.h"
32
33/*
34 There is no plain middle-side option; instead there are various mixing
35 modes including middle-side, each lossless, as embodied in the mix()
36 and unmix() functions. These functions exploit a generalized middle-side
37 transformation:
38
39 u := [(rL + (m-r)R)/m];
40 v := L - R;
41
42 where [ ] denotes integer floor. The (lossless) inverse is
43
44 L = u + v - [rV/m];
45 R = L - v;
46*/
47
48// 16-bit routines
49
50void mix16( int32_t * in, uint32_t stride, int32_t * u, int32_t * v, int32_t numSamples, int32_t mixbits, int32_t mixres )
51{
52 int32_t j;
53
54 if ( mixres != 0 )
55 {
56 int32_t mod = 1 << mixbits;
57 int32_t m2;
58
59 /* matrixed stereo */
60 m2 = mod - mixres;
61 for ( j = 0; j < numSamples; j++ )
62 {
63 int32_t l, r;
64
65 l = in[0] >> 16;
66 r = in[1] >> 16;
67 in += stride;
68 u[j] = (mixres * l + m2 * r) >> mixbits;
69 v[j] = l - r;
70 }
71 }
72 else
73 {
74 /* Conventional separated stereo. */
75 for ( j = 0; j < numSamples; j++ )
76 {
77 u[j] = in[0] >> 16;
78 v[j] = in[1] >> 16;
79 in += stride;
80 }
81 }
82}
83
84// 20-bit routines
85// - the 20 bits of data are left-justified in 3 bytes of storage but right-aligned for input/output predictor buffers
86
87void mix20( int32_t * in, uint32_t stride, int32_t * u, int32_t * v, int32_t numSamples, int32_t mixbits, int32_t mixres )
88{
89 int32_t l, r;
90 int32_t j;
91
92 if ( mixres != 0 )
93 {
94 /* matrixed stereo */
95 int32_t mod = 1 << mixbits;
96 int32_t m2 = mod - mixres;
97
98 for ( j = 0; j < numSamples; j++ )
99 {
100 l = in[0] >> 12;
101 r = in[1] >> 12;
102 in += stride;
103
104 u[j] = (mixres * l + m2 * r) >> mixbits;
105 v[j] = l - r;
106 }
107 }
108 else
109 {
110 /* Conventional separated stereo. */
111 for ( j = 0; j < numSamples; j++ )
112 {
113 u[j] = in[0] >> 12;
114 v[j] = in[1] >> 12;
115 in += stride;
116 }
117 }
118}
119
120// 24-bit routines
121// - the 24 bits of data are right-justified in the input/output predictor buffers
122
123void mix24( int32_t * in, uint32_t stride, int32_t * u, int32_t * v, int32_t numSamples,
124 int32_t mixbits, int32_t mixres, uint16_t * shiftUV, int32_t bytesShifted )
125{
126 int32_t l, r;
127 int32_t shift = bytesShifted * 8;
128 uint32_t mask = (1ul << shift) - 1;
129 int32_t j, k;
130
131 if ( mixres != 0 )
132 {
133 /* matrixed stereo */
134 int32_t mod = 1 << mixbits;
135 int32_t m2 = mod - mixres;
136
137 if ( bytesShifted != 0 )
138 {
139 for ( j = 0, k = 0; j < numSamples; j++, k += 2 )
140 {
141 l = in[0] >> 8;
142 r = in[1] >> 8;
143 in += stride;
144
145 shiftUV[k + 0] = (uint16_t)(l & mask);
146 shiftUV[k + 1] = (uint16_t)(r & mask);
147
148 l >>= shift;
149 r >>= shift;
150
151 u[j] = (mixres * l + m2 * r) >> mixbits;
152 v[j] = l - r;
153 }
154 }
155 else
156 {
157 for ( j = 0; j < numSamples; j++ )
158 {
159 l = in[0] >> 8;
160 r = in[1] >> 8;
161 in += stride;
162
163 u[j] = (mixres * l + m2 * r) >> mixbits;
164 v[j] = l - r;
165 }
166 }
167 }
168 else
169 {
170 /* Conventional separated stereo. */
171 if ( bytesShifted != 0 )
172 {
173 for ( j = 0, k = 0; j < numSamples; j++, k += 2 )
174 {
175 l = in[0] >> 8;
176 r = in[1] >> 8;
177 in += stride;
178
179 shiftUV[k + 0] = (uint16_t)(l & mask);
180 shiftUV[k + 1] = (uint16_t)(r & mask);
181
182 l >>= shift;
183 r >>= shift;
184
185 u[j] = l;
186 v[j] = r;
187 }
188 }
189 else
190 {
191 for ( j = 0; j < numSamples; j++ )
192 {
193 l = in[0] >> 8;
Value stored to 'l' is never read
194 r = in[1] >> 8;
195 in += stride;
196 }
197 }
198 }
199}
200
201// 32-bit routines
202// - note that these really expect the internal data width to be < 32 but the arrays are 32-bit
203// - otherwise, the calculations might overflow into the 33rd bit and be lost
204// - therefore, these routines deal with the specified "unused lower" bytes in the "shift" buffers
205
206void mix32( int32_t * in, uint32_t stride, int32_t * u, int32_t * v, int32_t numSamples,
207 int32_t mixbits, int32_t mixres, uint16_t * shiftUV, int32_t bytesShifted )
208{
209 int32_t shift = bytesShifted * 8;
210 uint32_t mask = (1ul << shift) - 1;
211 int32_t l, r;
212 int32_t j, k;
213
214 if ( mixres != 0 )
215 {
216 int32_t mod = 1 << mixbits;
217 int32_t m2;
218
219 //Assert( bytesShifted != 0 );
220
221 /* matrixed stereo with shift */
222 m2 = mod - mixres;
223 for ( j = 0, k = 0; j < numSamples; j++, k += 2 )
224 {
225 l = in[0];
226 r = in[1];
227 in += stride;
228
229 shiftUV[k + 0] = (uint16_t)(l & mask);
230 shiftUV[k + 1] = (uint16_t)(r & mask);
231
232 l >>= shift;
233 r >>= shift;
234
235 u[j] = (mixres * l + m2 * r) >> mixbits;
236 v[j] = l - r;
237 }
238 }
239 else
240 {
241 if ( bytesShifted == 0 )
242 {
243 /* de-interleaving w/o shift */
244 for ( j = 0; j < numSamples; j++ )
245 {
246 u[j] = in[0];
247 v[j] = in[1];
248 in += stride;
249 }
250 }
251 else
252 {
253 /* de-interleaving with shift */
254 for ( j = 0, k = 0; j < numSamples; j++, k += 2 )
255 {
256 l = in[0];
257 r = in[1];
258 in += stride;
259
260 shiftUV[k + 0] = (uint16_t)(l & mask);
261 shiftUV[k + 1] = (uint16_t)(r & mask);
262
263 l >>= shift;
264 r >>= shift;
265
266 u[j] = l;
267 v[j] = r;
268 }
269 }
270 }
271}
272