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

Side by Side Diff: src/libFLAC/crc.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/cpu.c ('k') | src/libFLAC/fixed.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) 2000,2001,2002,2003,2004,2005,2006,2007 Josh Coalson 2 * Copyright (C) 2000-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 "private/crc.h" 37 #include "private/crc.h"
37 38
38 /* CRC-8, poly = x^8 + x^2 + x^1 + x^0, init = 0 */ 39 /* CRC-8, poly = x^8 + x^2 + x^1 + x^0, init = 0 */
39 40
40 FLAC__byte const FLAC__crc8_table[256] = { 41 FLAC__byte const FLAC__crc8_table[256] = {
41 0x00, 0x07, 0x0E, 0x09, 0x1C, 0x1B, 0x12, 0x15, 42 0x00, 0x07, 0x0E, 0x09, 0x1C, 0x1B, 0x12, 0x15,
42 0x38, 0x3F, 0x36, 0x31, 0x24, 0x23, 0x2A, 0x2D, 43 0x38, 0x3F, 0x36, 0x31, 0x24, 0x23, 0x2A, 0x2D,
(...skipping 24 matching lines...) Expand all
67 0x3E, 0x39, 0x30, 0x37, 0x22, 0x25, 0x2C, 0x2B, 68 0x3E, 0x39, 0x30, 0x37, 0x22, 0x25, 0x2C, 0x2B,
68 0x06, 0x01, 0x08, 0x0F, 0x1A, 0x1D, 0x14, 0x13, 69 0x06, 0x01, 0x08, 0x0F, 0x1A, 0x1D, 0x14, 0x13,
69 0xAE, 0xA9, 0xA0, 0xA7, 0xB2, 0xB5, 0xBC, 0xBB, 70 0xAE, 0xA9, 0xA0, 0xA7, 0xB2, 0xB5, 0xBC, 0xBB,
70 0x96, 0x91, 0x98, 0x9F, 0x8A, 0x8D, 0x84, 0x83, 71 0x96, 0x91, 0x98, 0x9F, 0x8A, 0x8D, 0x84, 0x83,
71 0xDE, 0xD9, 0xD0, 0xD7, 0xC2, 0xC5, 0xCC, 0xCB, 72 0xDE, 0xD9, 0xD0, 0xD7, 0xC2, 0xC5, 0xCC, 0xCB,
72 0xE6, 0xE1, 0xE8, 0xEF, 0xFA, 0xFD, 0xF4, 0xF3 73 0xE6, 0xE1, 0xE8, 0xEF, 0xFA, 0xFD, 0xF4, 0xF3
73 }; 74 };
74 75
75 /* CRC-16, poly = x^16 + x^15 + x^2 + x^0, init = 0 */ 76 /* CRC-16, poly = x^16 + x^15 + x^2 + x^0, init = 0 */
76 77
77 unsigned FLAC__crc16_table[256] = { 78 unsigned const FLAC__crc16_table[256] = {
78 0x0000, 0x8005, 0x800f, 0x000a, 0x801b, 0x001e, 0x0014, 0x8011, 79 0x0000, 0x8005, 0x800f, 0x000a, 0x801b, 0x001e, 0x0014, 0x8011,
79 0x8033, 0x0036, 0x003c, 0x8039, 0x0028, 0x802d, 0x8027, 0x0022, 80 0x8033, 0x0036, 0x003c, 0x8039, 0x0028, 0x802d, 0x8027, 0x0022,
80 0x8063, 0x0066, 0x006c, 0x8069, 0x0078, 0x807d, 0x8077, 0x0072, 81 0x8063, 0x0066, 0x006c, 0x8069, 0x0078, 0x807d, 0x8077, 0x0072,
81 0x0050, 0x8055, 0x805f, 0x005a, 0x804b, 0x004e, 0x0044, 0x8041, 82 0x0050, 0x8055, 0x805f, 0x005a, 0x804b, 0x004e, 0x0044, 0x8041,
82 0x80c3, 0x00c6, 0x00cc, 0x80c9, 0x00d8, 0x80dd, 0x80d7, 0x00d2, 83 0x80c3, 0x00c6, 0x00cc, 0x80c9, 0x00d8, 0x80dd, 0x80d7, 0x00d2,
83 0x00f0, 0x80f5, 0x80ff, 0x00fa, 0x80eb, 0x00ee, 0x00e4, 0x80e1, 84 0x00f0, 0x80f5, 0x80ff, 0x00fa, 0x80eb, 0x00ee, 0x00e4, 0x80e1,
84 0x00a0, 0x80a5, 0x80af, 0x00aa, 0x80bb, 0x00be, 0x00b4, 0x80b1, 85 0x00a0, 0x80a5, 0x80af, 0x00aa, 0x80bb, 0x00be, 0x00b4, 0x80b1,
85 0x8093, 0x0096, 0x009c, 0x8099, 0x0088, 0x808d, 0x8087, 0x0082, 86 0x8093, 0x0096, 0x009c, 0x8099, 0x0088, 0x808d, 0x8087, 0x0082,
86 0x8183, 0x0186, 0x018c, 0x8189, 0x0198, 0x819d, 0x8197, 0x0192, 87 0x8183, 0x0186, 0x018c, 0x8189, 0x0198, 0x819d, 0x8197, 0x0192,
87 0x01b0, 0x81b5, 0x81bf, 0x01ba, 0x81ab, 0x01ae, 0x01a4, 0x81a1, 88 0x01b0, 0x81b5, 0x81bf, 0x01ba, 0x81ab, 0x01ae, 0x01a4, 0x81a1,
(...skipping 20 matching lines...) Expand all
108 0x0220, 0x8225, 0x822f, 0x022a, 0x823b, 0x023e, 0x0234, 0x8231, 109 0x0220, 0x8225, 0x822f, 0x022a, 0x823b, 0x023e, 0x0234, 0x8231,
109 0x8213, 0x0216, 0x021c, 0x8219, 0x0208, 0x820d, 0x8207, 0x0202 110 0x8213, 0x0216, 0x021c, 0x8219, 0x0208, 0x820d, 0x8207, 0x0202
110 }; 111 };
111 112
112 113
113 void FLAC__crc8_update(const FLAC__byte data, FLAC__uint8 *crc) 114 void FLAC__crc8_update(const FLAC__byte data, FLAC__uint8 *crc)
114 { 115 {
115 *crc = FLAC__crc8_table[*crc ^ data]; 116 *crc = FLAC__crc8_table[*crc ^ data];
116 } 117 }
117 118
118 void FLAC__crc8_update_block(const FLAC__byte *data, size_t len, FLAC__uint8 *cr c) 119 void FLAC__crc8_update_block(const FLAC__byte *data, unsigned len, FLAC__uint8 * crc)
119 { 120 {
120 while(len--) 121 while(len--)
121 *crc = FLAC__crc8_table[*crc ^ *data++]; 122 *crc = FLAC__crc8_table[*crc ^ *data++];
122 } 123 }
123 124
124 FLAC__uint8 FLAC__crc8(const FLAC__byte *data, size_t len) 125 FLAC__uint8 FLAC__crc8(const FLAC__byte *data, unsigned len)
125 { 126 {
126 FLAC__uint8 crc = 0; 127 FLAC__uint8 crc = 0;
127 128
128 while(len--) 129 while(len--)
129 crc = FLAC__crc8_table[crc ^ *data++]; 130 crc = FLAC__crc8_table[crc ^ *data++];
130 131
131 return crc; 132 return crc;
132 } 133 }
133 134
134 unsigned FLAC__crc16(const FLAC__byte *data, size_t len) 135 unsigned FLAC__crc16(const FLAC__byte *data, unsigned len)
135 { 136 {
136 unsigned crc = 0; 137 unsigned crc = 0;
137 138
138 while(len--) 139 while(len--)
139 crc = ((crc<<8) ^ FLAC__crc16_table[(crc>>8) ^ *data++]) & 0xfff f; 140 crc = ((crc<<8) ^ FLAC__crc16_table[(crc>>8) ^ *data++]) & 0xfff f;
140 141
141 return crc; 142 return crc;
142 } 143 }
OLDNEW
« no previous file with comments | « src/libFLAC/cpu.c ('k') | src/libFLAC/fixed.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698