static int set_sps(HEVCContext *s, const HEVCSPS *sps)

{

    #define HWACCEL_MAX (CONFIG_HEVC_DXVA2_HWACCEL + CONFIG_HEVC_D3D11VA_HWACCEL)

    enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmt = pix_fmts;

    int ret;



    export_stream_params(s->avctx, &s->ps, sps);



    pic_arrays_free(s);

    ret = pic_arrays_init(s, sps);

    if (ret < 0)

        goto fail;



    if (sps->pix_fmt == AV_PIX_FMT_YUV420P || sps->pix_fmt == AV_PIX_FMT_YUVJ420P) {

#if CONFIG_HEVC_DXVA2_HWACCEL

        *fmt++ = AV_PIX_FMT_DXVA2_VLD;

#endif

#if CONFIG_HEVC_D3D11VA_HWACCEL

        *fmt++ = AV_PIX_FMT_D3D11VA_VLD;

#endif

    }



    *fmt++ = sps->pix_fmt;

    *fmt = AV_PIX_FMT_NONE;



    ret = ff_get_format(s->avctx, pix_fmts);

    if (ret < 0)

        goto fail;

    s->avctx->pix_fmt = ret;



    ff_hevc_pred_init(&s->hpc,     sps->bit_depth);

    ff_hevc_dsp_init (&s->hevcdsp, sps->bit_depth);

    ff_videodsp_init (&s->vdsp,    sps->bit_depth);



    if (sps->sao_enabled && !s->avctx->hwaccel) {

        av_frame_unref(s->tmp_frame);

        ret = ff_get_buffer(s->avctx, s->tmp_frame, AV_GET_BUFFER_FLAG_REF);

        if (ret < 0)

            goto fail;

        s->frame = s->tmp_frame;

    }



    s->ps.sps = sps;

    s->ps.vps = (HEVCVPS*) s->ps.vps_list[s->ps.sps->vps_id]->data;



    return 0;



fail:

    pic_arrays_free(s);

    s->ps.sps = NULL;

    return ret;

}

static int set_sps(HEVCContext *s, const HEVCSPS *sps)

{

    #define HWACCEL_MAX (CONFIG_HEVC_DXVA2_HWACCEL + CONFIG_HEVC_D3D11VA_HWACCEL)

    enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmt = pix_fmts;

    int ret;



    export_stream_params(s->avctx, &s->ps, sps);



    pic_arrays_free(s);

    ret = pic_arrays_init(s, sps);

    if (ret < 0)

        goto fail;



    if (sps->pix_fmt == AV_PIX_FMT_YUV420P || sps->pix_fmt == AV_PIX_FMT_YUVJ420P) {

#if CONFIG_HEVC_DXVA2_HWACCEL

        *fmt++ = AV_PIX_FMT_DXVA2_VLD;

#endif

#if CONFIG_HEVC_D3D11VA_HWACCEL

        *fmt++ = AV_PIX_FMT_D3D11VA_VLD;

#endif

    }



    *fmt++ = sps->pix_fmt;

    *fmt = AV_PIX_FMT_NONE;



    ret = ff_get_format(s->avctx, pix_fmts);

    if (ret < 0)

        goto fail;

    s->avctx->pix_fmt = ret;



    ff_hevc_pred_init(&s->hpc,     sps->bit_depth);

    ff_hevc_dsp_init (&s->hevcdsp, sps->bit_depth);

    ff_videodsp_init (&s->vdsp,    sps->bit_depth);



    if (sps->sao_enabled && !s->avctx->hwaccel) {

        av_frame_unref(s->tmp_frame);

        ret = ff_get_buffer(s->avctx, s->tmp_frame, AV_GET_BUFFER_FLAG_REF);

        if (ret < 0)

            goto fail;

        s->frame = s->tmp_frame;

    }



    s->ps.sps = sps;

    s->ps.vps = (HEVCVPS*) s->ps.vps_list[s->ps.sps->vps_id]->data;



    return 0;



fail:

    pic_arrays_free(s);

    s->ps.sps = NULL;

    return ret;

}

    export_stream_params(s->avctx, &s->ps, sps);
static int FUNC_0(HEVCContext *VAR_0, const HEVCSPS *VAR_1)

{

    #define HWACCEL_MAX (CONFIG_HEVC_DXVA2_HWACCEL + CONFIG_HEVC_D3D11VA_HWACCEL)

    enum AVPixelFormat VAR_2[HWACCEL_MAX + 2], *fmt = VAR_2;

    int VAR_3;



    export_stream_params(VAR_0->avctx, &VAR_0->ps, VAR_1);



    pic_arrays_free(VAR_0);

    VAR_3 = pic_arrays_init(VAR_0, VAR_1);

    if (VAR_3 < 0)

        goto fail;



    if (VAR_1->pix_fmt == AV_PIX_FMT_YUV420P || VAR_1->pix_fmt == AV_PIX_FMT_YUVJ420P) {

#if CONFIG_HEVC_DXVA2_HWACCEL

        *fmt++ = AV_PIX_FMT_DXVA2_VLD;

#endif

#if CONFIG_HEVC_D3D11VA_HWACCEL

        *fmt++ = AV_PIX_FMT_D3D11VA_VLD;

#endif

    }



    *fmt++ = VAR_1->pix_fmt;

    *fmt = AV_PIX_FMT_NONE;



    VAR_3 = ff_get_format(VAR_0->avctx, VAR_2);

    if (VAR_3 < 0)

        goto fail;

    VAR_0->avctx->pix_fmt = VAR_3;



    ff_hevc_pred_init(&VAR_0->hpc,     VAR_1->bit_depth);

    ff_hevc_dsp_init (&VAR_0->hevcdsp, VAR_1->bit_depth);

    ff_videodsp_init (&VAR_0->vdsp,    VAR_1->bit_depth);



    if (VAR_1->sao_enabled && !VAR_0->avctx->hwaccel) {

        av_frame_unref(VAR_0->tmp_frame);

        VAR_3 = ff_get_buffer(VAR_0->avctx, VAR_0->tmp_frame, AV_GET_BUFFER_FLAG_REF);

        if (VAR_3 < 0)

            goto fail;

        VAR_0->frame = VAR_0->tmp_frame;

    }



    VAR_0->ps.VAR_1 = VAR_1;

    VAR_0->ps.vps = (HEVCVPS*) VAR_0->ps.vps_list[VAR_0->ps.VAR_1->vps_id]->data;



    return 0;



fail:

    pic_arrays_free(VAR_0);

    VAR_0->ps.VAR_1 = NULL;

    return VAR_3;

}

static int FUNC_0(HEVCContext *VAR_0, const HEVCSPS *VAR_1)
{ #define HWACCEL_MAX (CONFIG_HEVC_DXVA2_HWACCEL + CONFIG_HEVC_D3D11VA_HWACCEL)
enum AVPixelFormat VAR_2[HWACCEL_MAX + 2], *fmt = VAR_2; int VAR_3; export_stream_params(VAR_0->avctx, &VAR_0->ps, VAR_1); pic_arrays_free(VAR_0); VAR_3 = pic_arrays_init(VAR_0, VAR_1); if (VAR_3 < 0)
goto fail; if (VAR_1->pix_fmt == AV_PIX_FMT_YUV420P || VAR_1->pix_fmt == AV_PIX_FMT_YUVJ420P) { #if CONFIG_HEVC_DXVA2_HWACCEL
*fmt++ = AV_PIX_FMT_DXVA2_VLD; #endif
#if CONFIG_HEVC_D3D11VA_HWACCEL
*fmt++ = AV_PIX_FMT_D3D11VA_VLD; #endif
} *fmt++ = VAR_1->pix_fmt; *fmt = AV_PIX_FMT_NONE; VAR_3 = ff_get_format(VAR_0->avctx, VAR_2); if (VAR_3 < 0)
goto fail; VAR_0->avctx->pix_fmt = VAR_3; ff_hevc_pred_init(&VAR_0->hpc,     VAR_1->bit_depth); ff_hevc_dsp_init (&VAR_0->hevcdsp, VAR_1->bit_depth); ff_videodsp_init (&VAR_0->vdsp,    VAR_1->bit_depth); if (VAR_1->sao_enabled && !VAR_0->avctx->hwaccel) { av_frame_unref(VAR_0->tmp_frame); VAR_3 = ff_get_buffer(VAR_0->avctx, VAR_0->tmp_frame, AV_GET_BUFFER_FLAG_REF); if (VAR_3 < 0)
goto fail; VAR_0->frame = VAR_0->tmp_frame; } VAR_0->ps.VAR_1 = VAR_1; VAR_0->ps.vps = (HEVCVPS*) VAR_0->ps.vps_list[VAR_0->ps.VAR_1->vps_id]->data; return 0; fail:
pic_arrays_free(VAR_0); VAR_0->ps.VAR_1 = NULL; return VAR_3; }