int dxva2_init(AVCodecContext *s)

{

    InputStream *ist = s->opaque;

    int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR;

    DXVA2Context *ctx;

    int ret;



    if (!ist->hwaccel_ctx) {

        ret = dxva2_alloc(s);

        if (ret < 0)

            return ret;

    }

    ctx = ist->hwaccel_ctx;



    if (s->codec_id == AV_CODEC_ID_H264 &&

        (s->profile & ~FF_PROFILE_H264_CONSTRAINED) > FF_PROFILE_H264_HIGH) {

        av_log(NULL, loglevel, "Unsupported H.264 profile for DXVA2 HWAccel: %d\n", s->profile);

        return AVERROR(EINVAL);

    }



    if (s->codec_id == AV_CODEC_ID_HEVC &&

        s->profile != FF_PROFILE_HEVC_MAIN && s->profile != FF_PROFILE_HEVC_MAIN_10) {

        av_log(NULL, loglevel, "Unsupported HEVC profile for DXVA2 HWAccel: %d\n", s->profile);

        return AVERROR(EINVAL);

    }



    av_buffer_unref(&ctx->hw_frames_ctx);



    ret = dxva2_create_decoder(s);

    if (ret < 0) {

        av_log(NULL, loglevel, "Error creating the DXVA2 decoder\n");

        return ret;

    }



    return 0;

}

int dxva2_init(AVCodecContext *s)

{

    InputStream *ist = s->opaque;

    int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR;

    DXVA2Context *ctx;

    int ret;



    if (!ist->hwaccel_ctx) {

        ret = dxva2_alloc(s);

        if (ret < 0)

            return ret;

    }

    ctx = ist->hwaccel_ctx;



    if (s->codec_id == AV_CODEC_ID_H264 &&

        (s->profile & ~FF_PROFILE_H264_CONSTRAINED) > FF_PROFILE_H264_HIGH) {

        av_log(NULL, loglevel, "Unsupported H.264 profile for DXVA2 HWAccel: %d\n", s->profile);

        return AVERROR(EINVAL);

    }



    if (s->codec_id == AV_CODEC_ID_HEVC &&

        s->profile != FF_PROFILE_HEVC_MAIN && s->profile != FF_PROFILE_HEVC_MAIN_10) {

        av_log(NULL, loglevel, "Unsupported HEVC profile for DXVA2 HWAccel: %d\n", s->profile);

        return AVERROR(EINVAL);

    }



    av_buffer_unref(&ctx->hw_frames_ctx);



    ret = dxva2_create_decoder(s);

    if (ret < 0) {

        av_log(NULL, loglevel, "Error creating the DXVA2 decoder\n");

        return ret;

    }



    return 0;

}

int FUNC_0(AVCodecContext *VAR_0)

{

    InputStream *ist = VAR_0->opaque;

    int VAR_1 = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR;

    DXVA2Context *ctx;

    int VAR_2;



    if (!ist->hwaccel_ctx) {

        VAR_2 = dxva2_alloc(VAR_0);

        if (VAR_2 < 0)

            return VAR_2;

    }

    ctx = ist->hwaccel_ctx;



    if (VAR_0->codec_id == AV_CODEC_ID_H264 &&

        (VAR_0->profile & ~FF_PROFILE_H264_CONSTRAINED) > FF_PROFILE_H264_HIGH) {

        av_log(NULL, VAR_1, "Unsupported H.264 profile for DXVA2 HWAccel: %d\n", VAR_0->profile);

        return AVERROR(EINVAL);

    }



    if (VAR_0->codec_id == AV_CODEC_ID_HEVC &&

        VAR_0->profile != FF_PROFILE_HEVC_MAIN && VAR_0->profile != FF_PROFILE_HEVC_MAIN_10) {

        av_log(NULL, VAR_1, "Unsupported HEVC profile for DXVA2 HWAccel: %d\n", VAR_0->profile);

        return AVERROR(EINVAL);

    }



    av_buffer_unref(&ctx->hw_frames_ctx);



    VAR_2 = dxva2_create_decoder(VAR_0);

    if (VAR_2 < 0) {

        av_log(NULL, VAR_1, "Error creating the DXVA2 decoder\n");

        return VAR_2;

    }



    return 0;

}

int FUNC_0(AVCodecContext *VAR_0)
{ InputStream *ist = VAR_0->opaque; int VAR_1 = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR; DXVA2Context *ctx; int VAR_2; if (!ist->hwaccel_ctx) { VAR_2 = dxva2_alloc(VAR_0); if (VAR_2 < 0)
return VAR_2; } ctx = ist->hwaccel_ctx; if (VAR_0->codec_id == AV_CODEC_ID_H264 &&
(VAR_0->profile & ~FF_PROFILE_H264_CONSTRAINED) > FF_PROFILE_H264_HIGH) { av_log(NULL, VAR_1, "Unsupported H.264 profile for DXVA2 HWAccel: %d\n", VAR_0->profile); return AVERROR(EINVAL); } if (VAR_0->codec_id == AV_CODEC_ID_HEVC &&
VAR_0->profile != FF_PROFILE_HEVC_MAIN && VAR_0->profile != FF_PROFILE_HEVC_MAIN_10) { av_log(NULL, VAR_1, "Unsupported HEVC profile for DXVA2 HWAccel: %d\n", VAR_0->profile); return AVERROR(EINVAL); } av_buffer_unref(&ctx->hw_frames_ctx); VAR_2 = dxva2_create_decoder(VAR_0); if (VAR_2 < 0) { av_log(NULL, VAR_1, "Error creating the DXVA2 decoder\n"); return VAR_2; } return 0; }