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

Function decode_header

libavcodec/ffv1dec.c:661–703  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

659}
660
661static int decode_header(AVCodecContext *avctx, RangeCoder *c,
662 uint8_t *buf, size_t buf_size)
663{
664 int ret;
665 FFV1Context *f = avctx->priv_data;
666
667 uint8_t keystate = 128;
668 ff_init_range_decoder(c, buf, buf_size);
669 ff_build_rac_states(c, 0.05 * (1LL << 32), 256 - 8);
670
671 if (get_rac(c, &keystate)) {
672 f->key_frame = AV_FRAME_FLAG_KEY;
673 f->key_frame_ok = 0;
674 if ((ret = read_header(f, c)) < 0)
675 return ret;
676 f->key_frame_ok = 1;
677 } else {
678 if (!f->key_frame_ok) {
679 av_log(avctx, AV_LOG_ERROR,
680 "Cannot decode non-keyframe without valid keyframe\n");
681 return AVERROR_INVALIDDATA;
682 }
683 f->key_frame = 0;
684 }
685
686 if (f->ac != AC_GOLOMB_RICE) {
687 if (buf_size < avctx->width * avctx->height / (128*8))
688 return AVERROR_INVALIDDATA;
689 } else {
690 int w = avctx->width;
691 int s = 1 + w / (1<<23);
692 int i;
693
694 w /= s;
695
696 for (i = 0; w > (1<<ff_log2_run[i]); i++)
697 w -= ff_log2_run[i];
698 if (buf_size < (avctx->height + i + 6) / 8 * s)
699 return AVERROR_INVALIDDATA;
700 }
701
702 return 0;
703}
704
705static int decode_slices(AVCodecContext *avctx, RangeCoder c,
706 AVPacket *avpkt)

Callers 1

decode_frameFunction · 0.70

Calls 5

ff_init_range_decoderFunction · 0.85
ff_build_rac_statesFunction · 0.85
get_racFunction · 0.85
av_logFunction · 0.85
read_headerFunction · 0.70

Tested by

no test coverage detected