static int get_buffer_internal(AVCodecContext *avctx, AVFrame *frame, int flags)
{
    const AVHWAccel *hwaccel = avctx->hwaccel;
    int override_dimensions = 1;
    int ret;
    if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
        if ((ret = av_image_check_size2(avctx->width, avctx->height, avctx->max_pixels, AV_PIX_FMT_NONE, 0, avctx)) < 0 || avctx->pix_fmt<0) {
            av_log(avctx, AV_LOG_ERROR, "video_get_buffer: image parameters invalid\n");
            return AVERROR(EINVAL);
        }
        if (frame->width <= 0 || frame->height <= 0) {
            frame->width  = FFMAX(avctx->width,  AV_CEIL_RSHIFT(avctx->coded_width,  avctx->lowres));
            frame->height = FFMAX(avctx->height, AV_CEIL_RSHIFT(avctx->coded_height, avctx->lowres));
            override_dimensions = 0;
        }
        if (frame->data[0] || frame->data[1] || frame->data[2] || frame->data[3]) {
            av_log(avctx, AV_LOG_ERROR, "pic->data[*]!=NULL in get_buffer_internal\n");
            return AVERROR(EINVAL);
        }
    }
    ret = ff_decode_frame_props(avctx, frame);
        return ret;
    if (hwaccel) {
        if (hwaccel->alloc_frame) {
            ret = hwaccel->alloc_frame(avctx, frame);
            goto end;
        }
    } else
        avctx->sw_pix_fmt = avctx->pix_fmt;
    ret = avctx->get_buffer2(avctx, frame, flags);
    if (ret >= 0)
        validate_avframe_allocation(avctx, frame);
end:
    if (avctx->codec_type == AVMEDIA_TYPE_VIDEO && !override_dimensions &&
        !(avctx->codec->caps_internal & FF_CODEC_CAP_EXPORTS_CROPPING)) {
        frame->width  = avctx->width;
        frame->height = avctx->height;
    }
    return ret;
}
static int get_buffer_internal(AVCodecContext *avctx, AVFrame *frame, int flags)
{
    const AVHWAccel *hwaccel = avctx->hwaccel;
    int override_dimensions = 1;
    int ret;
    if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
        if ((ret = av_image_check_size2(avctx->width, avctx->height, avctx->max_pixels, AV_PIX_FMT_NONE, 0, avctx)) < 0 || avctx->pix_fmt<0) {
            av_log(avctx, AV_LOG_ERROR, "video_get_buffer: image parameters invalid\n");
            return AVERROR(EINVAL);
        }
        if (frame->width <= 0 || frame->height <= 0) {
            frame->width  = FFMAX(avctx->width,  AV_CEIL_RSHIFT(avctx->coded_width,  avctx->lowres));
            frame->height = FFMAX(avctx->height, AV_CEIL_RSHIFT(avctx->coded_height, avctx->lowres));
            override_dimensions = 0;
        }
        if (frame->data[0] || frame->data[1] || frame->data[2] || frame->data[3]) {
            av_log(avctx, AV_LOG_ERROR, "pic->data[*]!=NULL in get_buffer_internal\n");
            return AVERROR(EINVAL);
        }
    }
    ret = ff_decode_frame_props(avctx, frame);
        return ret;
    if (hwaccel) {
        if (hwaccel->alloc_frame) {
            ret = hwaccel->alloc_frame(avctx, frame);
            goto end;
        }
    } else
        avctx->sw_pix_fmt = avctx->pix_fmt;
    ret = avctx->get_buffer2(avctx, frame, flags);
    if (ret >= 0)
        validate_avframe_allocation(avctx, frame);
end:
    if (avctx->codec_type == AVMEDIA_TYPE_VIDEO && !override_dimensions &&
        !(avctx->codec->caps_internal & FF_CODEC_CAP_EXPORTS_CROPPING)) {
        frame->width  = avctx->width;
        frame->height = avctx->height;
    }
    return ret;
}
static int FUNC_0(AVCodecContext *VAR_0, AVFrame *VAR_1, int VAR_2)
{
    const AVHWAccel *VAR_3 = VAR_0->VAR_3;
    int VAR_4 = 1;
    int VAR_5;
    if (VAR_0->codec_type == AVMEDIA_TYPE_VIDEO) {
        if ((VAR_5 = av_image_check_size2(VAR_0->width, VAR_0->height, VAR_0->max_pixels, AV_PIX_FMT_NONE, 0, VAR_0)) < 0 || VAR_0->pix_fmt<0) {
            av_log(VAR_0, AV_LOG_ERROR, "video_get_buffer: image parameters invalid\n");
            return AVERROR(EINVAL);
        }
        if (VAR_1->width <= 0 || VAR_1->height <= 0) {
            VAR_1->width  = FFMAX(VAR_0->width,  AV_CEIL_RSHIFT(VAR_0->coded_width,  VAR_0->lowres));
            VAR_1->height = FFMAX(VAR_0->height, AV_CEIL_RSHIFT(VAR_0->coded_height, VAR_0->lowres));
            VAR_4 = 0;
        }
        if (VAR_1->data[0] || VAR_1->data[1] || VAR_1->data[2] || VAR_1->data[3]) {
            av_log(VAR_0, AV_LOG_ERROR, "pic->data[*]!=NULL in FUNC_0\n");
            return AVERROR(EINVAL);
        }
    }
    VAR_5 = ff_decode_frame_props(VAR_0, VAR_1);
        return VAR_5;
    if (VAR_3) {
        if (VAR_3->alloc_frame) {
            VAR_5 = VAR_3->alloc_frame(VAR_0, VAR_1);
            goto end;
        }
    } else
        VAR_0->sw_pix_fmt = VAR_0->pix_fmt;
    VAR_5 = VAR_0->get_buffer2(VAR_0, VAR_1, VAR_2);
    if (VAR_5 >= 0)
        validate_avframe_allocation(VAR_0, VAR_1);
end:
    if (VAR_0->codec_type == AVMEDIA_TYPE_VIDEO && !VAR_4 &&
        !(VAR_0->codec->caps_internal & FF_CODEC_CAP_EXPORTS_CROPPING)) {
        VAR_1->width  = VAR_0->width;
        VAR_1->height = VAR_0->height;
    }
    return VAR_5;
}
static int FUNC_0(AVCodecContext *VAR_0, AVFrame *VAR_1, int VAR_2)
{ const AVHWAccel *VAR_3 = VAR_0->VAR_3; int VAR_4 = 1; int VAR_5; if (VAR_0->codec_type == AVMEDIA_TYPE_VIDEO) { if ((VAR_5 = av_image_check_size2(VAR_0->width, VAR_0->height, VAR_0->max_pixels, AV_PIX_FMT_NONE, 0, VAR_0)) < 0 || VAR_0->pix_fmt<0) { av_log(VAR_0, AV_LOG_ERROR, "video_get_buffer: image parameters invalid\n"); return AVERROR(EINVAL); } if (VAR_1->width <= 0 || VAR_1->height <= 0) { VAR_1->width  = FFMAX(VAR_0->width,  AV_CEIL_RSHIFT(VAR_0->coded_width,  VAR_0->lowres)); VAR_1->height = FFMAX(VAR_0->height, AV_CEIL_RSHIFT(VAR_0->coded_height, VAR_0->lowres)); VAR_4 = 0; } if (VAR_1->data[0] || VAR_1->data[1] || VAR_1->data[2] || VAR_1->data[3]) { av_log(VAR_0, AV_LOG_ERROR, "pic->data[*]!=NULL in FUNC_0\n"); return AVERROR(EINVAL); } } VAR_5 = ff_decode_frame_props(VAR_0, VAR_1); return VAR_5; if (VAR_3) { if (VAR_3->alloc_frame) { VAR_5 = VAR_3->alloc_frame(VAR_0, VAR_1); goto end; } } else VAR_0->sw_pix_fmt = VAR_0->pix_fmt; VAR_5 = VAR_0->get_buffer2(VAR_0, VAR_1, VAR_2); if (VAR_5 >= 0)
validate_avframe_allocation(VAR_0, VAR_1); end:
if (VAR_0->codec_type == AVMEDIA_TYPE_VIDEO && !VAR_4 &&
!(VAR_0->codec->caps_internal & FF_CODEC_CAP_EXPORTS_CROPPING)) { VAR_1->width  = VAR_0->width; VAR_1->height = VAR_0->height; } return VAR_5; }