int ff_nvdec_frame_params(AVCodecContext *avctx,

                          AVBufferRef *hw_frames_ctx,

                          int dpb_size)

{

    AVHWFramesContext *frames_ctx = (AVHWFramesContext*)hw_frames_ctx->data;

    const AVPixFmtDescriptor *sw_desc;

    int cuvid_codec_type, cuvid_chroma_format;



    sw_desc = av_pix_fmt_desc_get(avctx->sw_pix_fmt);

    if (!sw_desc)

        return AVERROR_BUG;



    cuvid_codec_type = map_avcodec_id(avctx->codec_id);

    if (cuvid_codec_type < 0) {

        av_log(avctx, AV_LOG_ERROR, "Unsupported codec ID\n");

        return AVERROR_BUG;

    }



    cuvid_chroma_format = map_chroma_format(avctx->sw_pix_fmt);

    if (cuvid_chroma_format < 0) {

        av_log(avctx, AV_LOG_VERBOSE, "Unsupported chroma format\n");

        return AVERROR(EINVAL);

    }



    if (avctx->thread_type & FF_THREAD_FRAME)

        dpb_size += avctx->thread_count;



    frames_ctx->format            = AV_PIX_FMT_CUDA;

    frames_ctx->width             = avctx->coded_width;

    frames_ctx->height            = avctx->coded_height;

    frames_ctx->sw_format         = sw_desc->comp[0].depth > 8 ?

                                    AV_PIX_FMT_P010 : AV_PIX_FMT_NV12;

    frames_ctx->initial_pool_size = dpb_size;



    return 0;

}

int ff_nvdec_frame_params(AVCodecContext *avctx,

                          AVBufferRef *hw_frames_ctx,

                          int dpb_size)

{

    AVHWFramesContext *frames_ctx = (AVHWFramesContext*)hw_frames_ctx->data;

    const AVPixFmtDescriptor *sw_desc;

    int cuvid_codec_type, cuvid_chroma_format;



    sw_desc = av_pix_fmt_desc_get(avctx->sw_pix_fmt);

    if (!sw_desc)

        return AVERROR_BUG;



    cuvid_codec_type = map_avcodec_id(avctx->codec_id);

    if (cuvid_codec_type < 0) {

        av_log(avctx, AV_LOG_ERROR, "Unsupported codec ID\n");

        return AVERROR_BUG;

    }



    cuvid_chroma_format = map_chroma_format(avctx->sw_pix_fmt);

    if (cuvid_chroma_format < 0) {

        av_log(avctx, AV_LOG_VERBOSE, "Unsupported chroma format\n");

        return AVERROR(EINVAL);

    }



    if (avctx->thread_type & FF_THREAD_FRAME)

        dpb_size += avctx->thread_count;



    frames_ctx->format            = AV_PIX_FMT_CUDA;

    frames_ctx->width             = avctx->coded_width;

    frames_ctx->height            = avctx->coded_height;

    frames_ctx->sw_format         = sw_desc->comp[0].depth > 8 ?

                                    AV_PIX_FMT_P010 : AV_PIX_FMT_NV12;

    frames_ctx->initial_pool_size = dpb_size;



    return 0;

}

int FUNC_0(AVCodecContext *VAR_0,

                          AVBufferRef *VAR_1,

                          int VAR_2)

{

    AVHWFramesContext *frames_ctx = (AVHWFramesContext*)VAR_1->data;

    const AVPixFmtDescriptor *VAR_3;

    int VAR_4, VAR_5;



    VAR_3 = av_pix_fmt_desc_get(VAR_0->sw_pix_fmt);

    if (!VAR_3)

        return AVERROR_BUG;



    VAR_4 = map_avcodec_id(VAR_0->codec_id);

    if (VAR_4 < 0) {

        av_log(VAR_0, AV_LOG_ERROR, "Unsupported codec ID\n");

        return AVERROR_BUG;

    }



    VAR_5 = map_chroma_format(VAR_0->sw_pix_fmt);

    if (VAR_5 < 0) {

        av_log(VAR_0, AV_LOG_VERBOSE, "Unsupported chroma format\n");

        return AVERROR(EINVAL);

    }



    if (VAR_0->thread_type & FF_THREAD_FRAME)

        VAR_2 += VAR_0->thread_count;



    frames_ctx->format            = AV_PIX_FMT_CUDA;

    frames_ctx->width             = VAR_0->coded_width;

    frames_ctx->height            = VAR_0->coded_height;

    frames_ctx->sw_format         = VAR_3->comp[0].depth > 8 ?

                                    AV_PIX_FMT_P010 : AV_PIX_FMT_NV12;

    frames_ctx->initial_pool_size = VAR_2;



    return 0;

}

int FUNC_0(AVCodecContext *VAR_0,
AVBufferRef *VAR_1,
int VAR_2)
{ AVHWFramesContext *frames_ctx = (AVHWFramesContext*)VAR_1->data; const AVPixFmtDescriptor *VAR_3; int VAR_4, VAR_5; VAR_3 = av_pix_fmt_desc_get(VAR_0->sw_pix_fmt); if (!VAR_3)
return AVERROR_BUG; VAR_4 = map_avcodec_id(VAR_0->codec_id); if (VAR_4 < 0) { av_log(VAR_0, AV_LOG_ERROR, "Unsupported codec ID\n"); return AVERROR_BUG; } VAR_5 = map_chroma_format(VAR_0->sw_pix_fmt); if (VAR_5 < 0) { av_log(VAR_0, AV_LOG_VERBOSE, "Unsupported chroma format\n"); return AVERROR(EINVAL); } if (VAR_0->thread_type & FF_THREAD_FRAME)
VAR_2 += VAR_0->thread_count; frames_ctx->format            = AV_PIX_FMT_CUDA; frames_ctx->width             = VAR_0->coded_width; frames_ctx->height            = VAR_0->coded_height; frames_ctx->sw_format         = VAR_3->comp[0].depth > 8 ?
AV_PIX_FMT_P010 : AV_PIX_FMT_NV12; frames_ctx->initial_pool_size = VAR_2; return 0; }