make sure frames returned to the caller are valid
| 770 | |
| 771 | // make sure frames returned to the caller are valid |
| 772 | static 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; |
| 792 | fail: |
| 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 | |
| 798 | int ff_decode_receive_frame(AVCodecContext *avctx, AVFrame *frame, unsigned flags) |
| 799 | { |
no test coverage detected