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

Function frame_validate

libavcodec/decode.c:772–796  ·  view source on GitHub ↗

make sure frames returned to the caller are valid

Source from the content-addressed store, hash-verified

770
771// make sure frames returned to the caller are valid
772static int frame_validate(AVCodecContext *avctx, AVFrame *frame)
773{
774 if (!frame->buf[0] || frame->format < 0)
775 goto fail;
776
777 switch (avctx->codec_type) {
778 case AVMEDIA_TYPE_VIDEO:
779 if (frame->width <= 0 || frame->height <= 0)
780 goto fail;
781 break;
782 case AVMEDIA_TYPE_AUDIO:
783 if (!av_channel_layout_check(&frame->ch_layout) ||
784 frame->sample_rate <= 0)
785 goto fail;
786
787 break;
788 default: av_assert0(0);
789 }
790
791 return 0;
792fail:
793 av_log(avctx, AV_LOG_ERROR, "An invalid frame was output by a decoder. "
794 "This is a bug, please report it.\n");
795 return AVERROR_BUG;
796}
797
798int ff_decode_receive_frame(AVCodecContext *avctx, AVFrame *frame, unsigned flags)
799{

Callers 1

ff_decode_receive_frameFunction · 0.85

Calls 2

av_channel_layout_checkFunction · 0.85
av_logFunction · 0.85

Tested by

no test coverage detected