1 /*
2 * FLAC common code
3 * Copyright (c) 2009 Justin Ruggles
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
30
32
42 };
43
45 {
49 }
50
53 {
54 int bs_code, sr_code, bps_code;
55
56 /* frame sync code */
57 if ((
get_bits(gb, 15) & 0x7FFF) != 0x7FFC) {
60 }
61
62 /* variable block size stream code */
64
65 /* block size and sample rate codes */
68
69 /* channels and decorrelation */
77 } else {
79 "invalid channel mode: %d\n", fi->
ch_mode);
81 }
82
83 /* bits per sample */
85 if (bps_code == 3) {
87 "invalid sample size code (%d)\n",
88 bps_code);
90 }
92
93 /* reserved bit */
96 "broken stream, invalid padding\n");
98 }
99
100 /* sample or frame count */
104 "sample/frame number invalid; utf8 fscked\n");
106 }
107
108 /* blocksize */
109 if (bs_code == 0) {
111 "reserved blocksize code: 0\n");
113 } else if (bs_code == 6) {
115 } else if (bs_code == 7) {
117 } else {
119 }
120
121 /* sample rate */
122 if (sr_code < 12) {
124 } else if (sr_code == 12) {
126 } else if (sr_code == 13) {
128 } else if (sr_code == 14) {
130 } else {
132 "illegal sample rate code %d\n",
133 sr_code);
135 }
136
137 /* header CRC-8 check */
142 "header crc mismatch\n");
144 }
145
146 return 0;
147 }
148
150 uint8_t **streaminfo_start)
151 {
154 return 0;
155 }
157 /* extradata contains STREAMINFO only */
161 }
163 } else {
166 return 0;
167 }
168 *streaminfo_start = &avctx->
extradata[8];
169 }
170 return 1;
171 }
172
174 {
177 return;
178
182 else
185 }
186
189 {
192
193 skip_bits(&gb, 16);
/* skip min blocksize */
198 s->max_blocksize = 16;
200 }
201
202 skip_bits(&gb, 24);
/* skip min frame size */
204
208
213 }
214
218
220
223
224 return 0;
225 }