MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / decode_frame

Function decode_frame

libavcodec/flacdec.c:573–635  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

571}
572
573static int decode_frame(FLACContext *s)
574{
575 int i;
576 GetBitContext *gb = &s->gb;
577 FLACFrameInfo fi;
578
579 if (decode_frame_header(s->avctx, gb, &fi)) {
580 av_log(s->avctx, AV_LOG_ERROR, "invalid frame header\n");
581 return -1;
582 }
583
584 if (fi.channels != s->channels) {
585 av_log(s->avctx, AV_LOG_ERROR, "switching channel layout mid-stream "
586 "is not supported\n");
587 return -1;
588 }
589 s->ch_mode = fi.ch_mode;
590
591 if (fi.bps && fi.bps != s->bps) {
592 av_log(s->avctx, AV_LOG_ERROR, "switching bps mid-stream is not "
593 "supported\n");
594 return -1;
595 }
596 if (s->bps > 16) {
597 s->avctx->sample_fmt = SAMPLE_FMT_S32;
598 s->sample_shift = 32 - s->bps;
599 s->is32 = 1;
600 } else {
601 s->avctx->sample_fmt = SAMPLE_FMT_S16;
602 s->sample_shift = 16 - s->bps;
603 s->is32 = 0;
604 }
605
606 if (fi.blocksize > s->max_blocksize) {
607 av_log(s->avctx, AV_LOG_ERROR, "blocksize %d > %d\n", fi.blocksize,
608 s->max_blocksize);
609 return -1;
610 }
611 s->blocksize = fi.blocksize;
612
613 if (fi.samplerate == 0) {
614 fi.samplerate = s->samplerate;
615 } else if (fi.samplerate != s->samplerate) {
616 av_log(s->avctx, AV_LOG_WARNING, "sample rate changed from %d to %d\n",
617 s->samplerate, fi.samplerate);
618 }
619 s->samplerate = s->avctx->sample_rate = fi.samplerate;
620
621// dump_headers(s->avctx, (FLACStreaminfo *)s);
622
623 /* subframes */
624 for (i = 0; i < s->channels; i++) {
625 if (decode_subframe(s, i) < 0)
626 return -1;
627 }
628
629 align_get_bits(gb);
630

Callers 1

flac_decode_frameFunction · 0.70

Calls 5

av_logFunction · 0.85
align_get_bitsFunction · 0.85
skip_bitsFunction · 0.85
decode_frame_headerFunction · 0.70
decode_subframeFunction · 0.70

Tested by

no test coverage detected