| 742 | } |
| 743 | |
| 744 | static int apply_cropping(AVCodecContext *avctx, AVFrame *frame) |
| 745 | { |
| 746 | /* make sure we are noisy about decoders returning invalid cropping data */ |
| 747 | if (frame->crop_left >= INT_MAX - frame->crop_right || |
| 748 | frame->crop_top >= INT_MAX - frame->crop_bottom || |
| 749 | (frame->crop_left + frame->crop_right) >= frame->width || |
| 750 | (frame->crop_top + frame->crop_bottom) >= frame->height) { |
| 751 | av_log(avctx, AV_LOG_WARNING, |
| 752 | "Invalid cropping information set by a decoder: " |
| 753 | "%zu/%zu/%zu/%zu (frame size %dx%d). " |
| 754 | "This is a bug, please report it\n", |
| 755 | frame->crop_left, frame->crop_right, frame->crop_top, frame->crop_bottom, |
| 756 | frame->width, frame->height); |
| 757 | frame->crop_left = 0; |
| 758 | frame->crop_right = 0; |
| 759 | frame->crop_top = 0; |
| 760 | frame->crop_bottom = 0; |
| 761 | return 0; |
| 762 | } |
| 763 | |
| 764 | if (!avctx->apply_cropping) |
| 765 | return 0; |
| 766 | |
| 767 | return av_frame_apply_cropping(frame, avctx->flags & AV_CODEC_FLAG_UNALIGNED ? |
| 768 | AV_FRAME_CROP_UNALIGNED : 0); |
| 769 | } |
| 770 | |
| 771 | // make sure frames returned to the caller are valid |
| 772 | static int frame_validate(AVCodecContext *avctx, AVFrame *frame) |
no test coverage detected