74 int need32 = s->bps > 16;
78 if (need32 || want32) {
149 return ret < 0 ? ret : 0;
161 int metadata_type, metadata_size,
ret;
191 int metadata_last, metadata_size;
192 const uint8_t *buf_end = buf + buf_size;
196 if (buf_end - buf < 4)
200 if (buf_end - buf < metadata_size) {
204 buf += metadata_size;
205 }
while (!metadata_last);
207 return buf_size - (buf_end -
buf);
212 int i, tmp, partition, method_type, rice_order;
213 int rice_bits, rice_esc;
217 if (method_type > 1) {
226 if (samples << rice_order != s->
blocksize) {
232 if (pred_order > samples) {
234 pred_order, samples);
238 rice_bits = 4 + method_type;
239 rice_esc = (1 << rice_bits) - 1;
241 decoded += pred_order;
243 for (partition = 0; partition < (1 << rice_order); partition++) {
245 if (tmp == rice_esc) {
247 for (; i < samples; i++)
250 for (; i < samples; i++) {
261 int pred_order,
int bps)
268 for (i = 0; i < pred_order; i++) {
276 a = decoded[pred_order-1];
278 b =
a - decoded[pred_order-2];
280 c =
b - decoded[pred_order-2] + decoded[pred_order-3];
282 d =
c - decoded[pred_order-2] + 2*decoded[pred_order-3] - decoded[pred_order-4];
284 switch (pred_order) {
288 for (i = pred_order; i < blocksize; i++)
289 decoded[i] =
a += decoded[i];
292 for (i = pred_order; i < blocksize; i++)
293 decoded[i] =
a +=
b += decoded[i];
296 for (i = pred_order; i < blocksize; i++)
297 decoded[i] =
a +=
b +=
c += decoded[i];
300 for (i = pred_order; i < blocksize; i++)
301 decoded[i] =
a +=
b +=
c += d += decoded[i];
315 int coeff_prec, qlevel;
319 for (i = 0; i < pred_order; i++) {
324 if (coeff_prec == 16) {
335 for (i = 0; i < pred_order; i++) {
336 coeffs[pred_order - i - 1] =
get_sbits(&s->
gb, coeff_prec);
350 int type, wasted = 0;
374 "Invalid number of wasted bits > available bits (%d) - left=%d\n",
391 }
else if (type == 1) {
394 }
else if ((type >= 8) && (type <= 12)) {
397 }
else if (type >= 32) {
408 decoded[i] <<= wasted;
425 if (s->channels && fi.channels != s->channels && s->
got_streaminfo) {
437 if (!s->bps && !fi.bps) {
443 }
else if (s->bps && fi.bps != s->bps) {
454 if (!s->max_blocksize)
463 if (!s->samplerate && !fi.samplerate) {
465 " or frame header\n");
468 if (fi.samplerate == 0)
469 fi.samplerate = s->samplerate;
484 for (i = 0; i < s->channels; i++) {
498 int *got_frame_ptr,
AVPacket *avpkt)
503 int buf_size = avpkt->
size;
510 if (s->max_framesize == 0) {
516 if (buf_size > 5 && !memcmp(buf,
"\177FLAC", 5)) {
552 0, buf, bytes_read)) {
566 if (bytes_read > buf_size) {
570 if (bytes_read < buf_size) {
572 buf_size - bytes_read, buf_size);
586 if (s->max_blocksize)