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

Function decode_frame

libavcodec/snowdec.c:590–810  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

588}
589
590static int decode_frame(AVCodecContext *avctx, AVFrame *picture,
591 int *got_frame, AVPacket *avpkt)
592{
593 const uint8_t *buf = avpkt->data;
594 int buf_size = avpkt->size;
595 SnowContext *s = avctx->priv_data;
596 RangeCoder * const c= &s->c;
597 int bytes_read;
598 int level, orientation, plane_index;
599 int res;
600
601 ff_init_range_decoder(c, buf, buf_size);
602 ff_build_rac_states(c, 0.05*(1LL<<32), 256-8);
603
604 s->current_picture->pict_type= AV_PICTURE_TYPE_I; //FIXME I vs. P
605 if ((res = decode_header(s)) < 0)
606 return res;
607
608 if (avctx->debug & 2048) {
609 av_frame_unref(s->mconly_picture);
610 res = ff_get_buffer(avctx, s->mconly_picture, AV_GET_BUFFER_FLAG_REF);
611 if (res < 0)
612 return res;
613 }
614
615 if (s->current_picture->data[0] && s->current_picture->format != avctx->pix_fmt) {
616 av_log(avctx, AV_LOG_ERROR, "pixel format changed\n");
617 return AVERROR_PATCHWELCOME;
618 }
619
620 if ((res=ff_snow_common_init_after_header(avctx)) < 0)
621 return res;
622
623 // realloc slice buffer for the case that spatial_decomposition_count changed
624 ff_slice_buffer_destroy(&s->sb);
625 if ((res = ff_slice_buffer_init(&s->sb, s->plane[0].height,
626 (MB_SIZE >> s->block_max_depth) +
627 s->spatial_decomposition_count * 11 + 1,
628 s->plane[0].width,
629 s->spatial_idwt_buffer)) < 0)
630 return res;
631
632 for(plane_index=0; plane_index < s->nb_planes; plane_index++){
633 Plane *p= &s->plane[plane_index];
634 p->fast_mc= p->diag_mc && p->htaps==6 && p->hcoeff[0]==40
635 && p->hcoeff[1]==-10
636 && p->hcoeff[2]==2;
637 }
638
639 ff_snow_alloc_blocks(s);
640
641 if ((res = ff_snow_frames_prepare(s)) < 0)
642 return res;
643
644 s->current_picture->width = s->avctx->width;
645 s->current_picture->height = s->avctx->height;
646 res = ff_get_buffer(s->avctx, s->current_picture, AV_GET_BUFFER_FLAG_REF);
647 if (res < 0)

Callers

nothing calls this directly

Calls 15

ff_init_range_decoderFunction · 0.85
ff_build_rac_statesFunction · 0.85
av_frame_unrefFunction · 0.85
ff_get_bufferFunction · 0.85
av_logFunction · 0.85
ff_slice_buffer_destroyFunction · 0.85
ff_slice_buffer_initFunction · 0.85
ff_snow_alloc_blocksFunction · 0.85
ff_snow_frames_prepareFunction · 0.85
av_size_multFunction · 0.85
av_fast_mallocFunction · 0.85

Tested by

no test coverage detected