72 int need32 = s->bps > 16;
76 if (need32 || want32) {
157 int metadata_type, metadata_size,
ret;
187 int metadata_last, metadata_size;
188 const uint8_t *buf_end = buf + buf_size;
192 if (buf_end - buf < 4)
196 if (buf_end - buf < metadata_size) {
200 buf += metadata_size;
201 }
while (!metadata_last);
203 return buf_size - (buf_end -
buf);
208 int i, tmp, partition, method_type, rice_order;
209 int rice_bits, rice_esc;
213 if (method_type > 1) {
222 if (pred_order > samples) {
224 pred_order, samples);
228 rice_bits = 4 + method_type;
229 rice_esc = (1 << rice_bits) - 1;
231 decoded += pred_order;
233 for (partition = 0; partition < (1 << rice_order); partition++) {
235 if (tmp == rice_esc) {
237 for (; i < samples; i++)
240 for (; i < samples; i++) {
251 int pred_order,
int bps)
258 for (i = 0; i < pred_order; i++) {
266 a = decoded[pred_order-1];
268 b =
a - decoded[pred_order-2];
270 c =
b - decoded[pred_order-2] + decoded[pred_order-3];
272 d =
c - decoded[pred_order-2] + 2*decoded[pred_order-3] - decoded[pred_order-4];
274 switch (pred_order) {
278 for (i = pred_order; i < blocksize; i++)
279 decoded[i] =
a += decoded[i];
282 for (i = pred_order; i < blocksize; i++)
283 decoded[i] =
a +=
b += decoded[i];
286 for (i = pred_order; i < blocksize; i++)
287 decoded[i] =
a +=
b +=
c += decoded[i];
290 for (i = pred_order; i < blocksize; i++)
291 decoded[i] =
a +=
b +=
c += d += decoded[i];
305 int coeff_prec, qlevel;
309 for (i = 0; i < pred_order; i++) {
314 if (coeff_prec == 16) {
325 for (i = 0; i < pred_order; i++) {
326 coeffs[pred_order - i - 1] =
get_sbits(&s->
gb, coeff_prec);
340 int type, wasted = 0;
365 "Invalid number of wasted bits > available bits (%d) - left=%d\n",
383 }
else if (type == 1) {
386 }
else if ((type >= 8) && (type <= 12)) {
389 }
else if (type >= 32) {
400 decoded[i] <<= wasted;
417 if (s->channels && fi.channels != s->channels && s->
got_streaminfo) {
429 if (!s->bps && !fi.bps) {
435 }
else if (s->bps && fi.bps != s->bps) {
446 if (!s->max_blocksize)
455 if (!s->samplerate && !fi.samplerate) {
457 " or frame header\n");
460 if (fi.samplerate == 0)
461 fi.samplerate = s->samplerate;
476 for (i = 0; i < s->channels; i++) {
490 int *got_frame_ptr,
AVPacket *avpkt)
495 int buf_size = avpkt->
size;
502 if (s->max_framesize == 0) {
508 if (buf_size > 5 && !memcmp(buf,
"\177FLAC", 5)) {
544 0, buf, bytes_read)) {
558 if (bytes_read > buf_size) {
562 if (bytes_read < buf_size) {
564 buf_size - bytes_read, buf_size);
578 if (s->max_blocksize)