Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Side by Side Diff: src/libFLAC/float.c

Issue 1961133002: Update FLAC to 1.3.1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/flac.git@master
Patch Set: build config tweaks for Windows Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/libFLAC/fixed_intrin_ssse3.c ('k') | src/libFLAC/format.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* libFLAC - Free Lossless Audio Codec library 1 /* libFLAC - Free Lossless Audio Codec library
2 * Copyright (C) 2004,2005,2006,2007 Josh Coalson 2 * Copyright (C) 2004-2009 Josh Coalson
3 * Copyright (C) 2011-2014 Xiph.Org Foundation
3 * 4 *
4 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
6 * are met: 7 * are met:
7 * 8 *
8 * - Redistributions of source code must retain the above copyright 9 * - Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
10 * 11 *
11 * - Redistributions in binary form must reproduce the above copyright 12 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
14 * 15 *
15 * - Neither the name of the Xiph.org Foundation nor the names of its 16 * - Neither the name of the Xiph.org Foundation nor the names of its
16 * contributors may be used to endorse or promote products derived from 17 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission. 18 * this software without specific prior written permission.
18 * 19 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 28 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */ 31 */
31 32
32 #if HAVE_CONFIG_H 33 #ifdef HAVE_CONFIG_H
33 # include <config.h> 34 # include <config.h>
34 #endif 35 #endif
35 36
36 #include "FLAC/assert.h" 37 #include "FLAC/assert.h"
37 38 #include "share/compat.h"
38 #include "private/float.h" 39 #include "private/float.h"
39 40
40 #ifdef FLAC__INTEGER_ONLY_LIBRARY 41 #ifdef FLAC__INTEGER_ONLY_LIBRARY
41 42
42 /* adjust for compilers that can't understand using LLU suffix for uint64_t lite rals */
43 #ifdef _MSC_VER
44 #define FLAC__U64L(x) x
45 #else
46 #define FLAC__U64L(x) x##LLU
47 #endif
48
49 const FLAC__fixedpoint FLAC__FP_ZERO = 0; 43 const FLAC__fixedpoint FLAC__FP_ZERO = 0;
50 const FLAC__fixedpoint FLAC__FP_ONE_HALF = 0x00008000; 44 const FLAC__fixedpoint FLAC__FP_ONE_HALF = 0x00008000;
51 const FLAC__fixedpoint FLAC__FP_ONE = 0x00010000; 45 const FLAC__fixedpoint FLAC__FP_ONE = 0x00010000;
52 const FLAC__fixedpoint FLAC__FP_LN2 = 45426; 46 const FLAC__fixedpoint FLAC__FP_LN2 = 45426;
53 const FLAC__fixedpoint FLAC__FP_E = 178145; 47 const FLAC__fixedpoint FLAC__FP_E = 178145;
54 48
55 /* Lookup tables for Knuth's logarithm algorithm */ 49 /* Lookup tables for Knuth's logarithm algorithm */
56 #define LOG2_LOOKUP_PRECISION 16 50 #define LOG2_LOOKUP_PRECISION 16
57 static const FLAC__uint32 log2_lookup[][LOG2_LOOKUP_PRECISION] = { 51 static const FLAC__uint32 log2_lookup[][LOG2_LOOKUP_PRECISION] = {
58 { 52 {
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 FLAC__uint32 FLAC__fixedpoint_log2(FLAC__uint32 x, unsigned fracbits, unsigned p recision) 269 FLAC__uint32 FLAC__fixedpoint_log2(FLAC__uint32 x, unsigned fracbits, unsigned p recision)
276 { 270 {
277 const FLAC__uint32 ONE = (1u << fracbits); 271 const FLAC__uint32 ONE = (1u << fracbits);
278 const FLAC__uint32 *table = log2_lookup[fracbits >> 2]; 272 const FLAC__uint32 *table = log2_lookup[fracbits >> 2];
279 273
280 FLAC__ASSERT(fracbits < 32); 274 FLAC__ASSERT(fracbits < 32);
281 FLAC__ASSERT((fracbits & 0x3) == 0); 275 FLAC__ASSERT((fracbits & 0x3) == 0);
282 276
283 if(x < ONE) 277 if(x < ONE)
284 return 0; 278 return 0;
285 » 279
286 if(precision > LOG2_LOOKUP_PRECISION) 280 if(precision > LOG2_LOOKUP_PRECISION)
287 precision = LOG2_LOOKUP_PRECISION; 281 precision = LOG2_LOOKUP_PRECISION;
288 282
289 /* Knuth's algorithm for computing logarithms, optimized for base-2 with lookup tables */ 283 /* Knuth's algorithm for computing logarithms, optimized for base-2 with lookup tables */
290 { 284 {
291 FLAC__uint32 y = 0; 285 FLAC__uint32 y = 0;
292 FLAC__uint32 z = x >> 1, k = 1; 286 FLAC__uint32 z = x >> 1, k = 1;
293 while (x > ONE && k < precision) { 287 while (x > ONE && k < precision) {
294 if (x - z >= ONE) { 288 if (x - z >= ONE) {
295 x -= z; 289 x -= z;
296 z = x >> k; 290 z = x >> k;
297 y += table[k]; 291 y += table[k];
298 } 292 }
299 else { 293 else {
300 z >>= 1; 294 z >>= 1;
301 k++; 295 k++;
302 } 296 }
303 } 297 }
304 return y; 298 return y;
305 } 299 }
306 } 300 }
307 301
308 #endif /* defined FLAC__INTEGER_ONLY_LIBRARY */ 302 #endif /* defined FLAC__INTEGER_ONLY_LIBRARY */
OLDNEW
« no previous file with comments | « src/libFLAC/fixed_intrin_ssse3.c ('k') | src/libFLAC/format.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698