74 int need32 = s->bps > 16;
78 if (need32 || want32) {
159 int metadata_type, metadata_size,
ret;
189 int metadata_last, metadata_size;
190 const uint8_t *buf_end = buf + buf_size;
194 if (buf_end - buf < 4)
198 if (buf_end - buf < metadata_size) {
202 buf += metadata_size;
203 }
while (!metadata_last);
205 return buf_size - (buf_end -
buf);
210 int i, tmp, partition, method_type, rice_order;
211 int rice_bits, rice_esc;
215 if (method_type > 1) {
224 if (samples << rice_order != s->
blocksize) {
230 if (pred_order > samples) {
232 pred_order, samples);
236 rice_bits = 4 + method_type;
237 rice_esc = (1 << rice_bits) - 1;
239 decoded += pred_order;
241 for (partition = 0; partition < (1 << rice_order); partition++) {
243 if (tmp == rice_esc) {
245 for (; i < samples; i++)
248 for (; i < samples; i++) {
259 int pred_order,
int bps)
266 for (i = 0; i < pred_order; i++) {
274 a = decoded[pred_order-1];
276 b =
a - decoded[pred_order-2];
278 c =
b - decoded[pred_order-2] + decoded[pred_order-3];
280 d =
c - decoded[pred_order-2] + 2*decoded[pred_order-3] - decoded[pred_order-4];
282 switch (pred_order) {
286 for (i = pred_order; i < blocksize; i++)
287 decoded[i] =
a += decoded[i];
290 for (i = pred_order; i < blocksize; i++)
291 decoded[i] =
a +=
b += decoded[i];
294 for (i = pred_order; i < blocksize; i++)
295 decoded[i] =
a +=
b +=
c += decoded[i];
298 for (i = pred_order; i < blocksize; i++)
299 decoded[i] =
a +=
b +=
c += d += decoded[i];
313 int coeff_prec, qlevel;
317 for (i = 0; i < pred_order; i++) {
322 if (coeff_prec == 16) {
333 for (i = 0; i < pred_order; i++) {
334 coeffs[pred_order - i - 1] =
get_sbits(&s->
gb, coeff_prec);
348 int type, wasted = 0;
372 "Invalid number of wasted bits > available bits (%d) - left=%d\n",
389 }
else if (type == 1) {
392 }
else if ((type >= 8) && (type <= 12)) {
395 }
else if (type >= 32) {
406 decoded[i] <<= wasted;
423 if (s->channels && fi.channels != s->channels && s->
got_streaminfo) {
435 if (!s->bps && !fi.bps) {
441 }
else if (s->bps && fi.bps != s->bps) {
452 if (!s->max_blocksize)
461 if (!s->samplerate && !fi.samplerate) {
463 " or frame header\n");
466 if (fi.samplerate == 0)
467 fi.samplerate = s->samplerate;
482 for (i = 0; i < s->channels; i++) {
496 int *got_frame_ptr,
AVPacket *avpkt)
501 int buf_size = avpkt->
size;
508 if (s->max_framesize == 0) {
514 if (buf_size > 5 && !memcmp(buf,
"\177FLAC", 5)) {
550 0, buf, bytes_read)) {
564 if (bytes_read > buf_size) {
568 if (bytes_read < buf_size) {
570 buf_size - bytes_read, buf_size);
584 if (s->max_blocksize)