void ff_qsv_decode_reset(AVCodecContext *avctx, QSVContext *q)

{

    QSVFrame *cur;

    AVPacket pkt;

    int ret = 0;

    mfxVideoParam param = { { 0 } };



    if (q->reinit_pending) {

        close_decoder(q);

    } else if (q->engine_ready) {

        ret = MFXVideoDECODE_GetVideoParam(q->session, &param);

        if (ret < 0) {

            av_log(avctx, AV_LOG_ERROR, "MFX decode get param error %d\n", ret);

        }



        ret = MFXVideoDECODE_Reset(q->session, &param);

        if (ret < 0) {

            av_log(avctx, AV_LOG_ERROR, "MFX decode reset error %d\n", ret);

        }



        /* Free all frames*/

        cur = q->work_frames;

        while (cur) {

            q->work_frames = cur->next;

            av_frame_free(&cur->frame);

            av_freep(&cur);

            cur = q->work_frames;

        }

    }



    /* Reset output surfaces */

    av_fifo_reset(q->async_fifo);



    /* Reset input packets fifo */

    while (av_fifo_size(q->pkt_fifo)) {

        av_fifo_generic_read(q->pkt_fifo, &pkt, sizeof(pkt), NULL);

        av_packet_unref(&pkt);

    }



    /* Reset input bitstream fifo */

    av_fifo_reset(q->input_fifo);

}

void ff_qsv_decode_reset(AVCodecContext *avctx, QSVContext *q)

{

    QSVFrame *cur;

    AVPacket pkt;

    int ret = 0;

    mfxVideoParam param = { { 0 } };



    if (q->reinit_pending) {

        close_decoder(q);

    } else if (q->engine_ready) {

        ret = MFXVideoDECODE_GetVideoParam(q->session, &param);

        if (ret < 0) {

            av_log(avctx, AV_LOG_ERROR, "MFX decode get param error %d\n", ret);

        }



        ret = MFXVideoDECODE_Reset(q->session, &param);

        if (ret < 0) {

            av_log(avctx, AV_LOG_ERROR, "MFX decode reset error %d\n", ret);

        }



        

        cur = q->work_frames;

        while (cur) {

            q->work_frames = cur->next;

            av_frame_free(&cur->frame);

            av_freep(&cur);

            cur = q->work_frames;

        }

    }



    

    av_fifo_reset(q->async_fifo);



    

    while (av_fifo_size(q->pkt_fifo)) {

        av_fifo_generic_read(q->pkt_fifo, &pkt, sizeof(pkt), NULL);

        av_packet_unref(&pkt);

    }



    

    av_fifo_reset(q->input_fifo);

}

    av_fifo_reset(q->async_fifo);     while (av_fifo_size(q->pkt_fifo)) {     av_fifo_reset(q->input_fifo);
void FUNC_0(AVCodecContext *VAR_0, QSVContext *VAR_1)

{

    QSVFrame *cur;

    AVPacket pkt;

    int VAR_2 = 0;

    mfxVideoParam param = { { 0 } };



    if (VAR_1->reinit_pending) {

        close_decoder(VAR_1);

    } else if (VAR_1->engine_ready) {

        VAR_2 = MFXVideoDECODE_GetVideoParam(VAR_1->session, &param);

        if (VAR_2 < 0) {

            av_log(VAR_0, AV_LOG_ERROR, "MFX decode get param error %d\n", VAR_2);

        }



        VAR_2 = MFXVideoDECODE_Reset(VAR_1->session, &param);

        if (VAR_2 < 0) {

            av_log(VAR_0, AV_LOG_ERROR, "MFX decode reset error %d\n", VAR_2);

        }



        

        cur = VAR_1->work_frames;

        while (cur) {

            VAR_1->work_frames = cur->next;

            av_frame_free(&cur->frame);

            av_freep(&cur);

            cur = VAR_1->work_frames;

        }

    }



    

    av_fifo_reset(VAR_1->async_fifo);



    

    while (av_fifo_size(VAR_1->pkt_fifo)) {

        av_fifo_generic_read(VAR_1->pkt_fifo, &pkt, sizeof(pkt), NULL);

        av_packet_unref(&pkt);

    }



    

    av_fifo_reset(VAR_1->input_fifo);

}

void FUNC_0(AVCodecContext *VAR_0, QSVContext *VAR_1)
{ QSVFrame *cur; AVPacket pkt; int VAR_2 = 0; mfxVideoParam param = { { 0 } }; if (VAR_1->reinit_pending) { close_decoder(VAR_1); } else if (VAR_1->engine_ready) { VAR_2 = MFXVideoDECODE_GetVideoParam(VAR_1->session, &param); if (VAR_2 < 0) { av_log(VAR_0, AV_LOG_ERROR, "MFX decode get param error %d\n", VAR_2); } VAR_2 = MFXVideoDECODE_Reset(VAR_1->session, &param); if (VAR_2 < 0) { av_log(VAR_0, AV_LOG_ERROR, "MFX decode reset error %d\n", VAR_2); } cur = VAR_1->work_frames; while (cur) { VAR_1->work_frames = cur->next; av_frame_free(&cur->frame); av_freep(&cur); cur = VAR_1->work_frames; } } av_fifo_reset(VAR_1->async_fifo); while (av_fifo_size(VAR_1->pkt_fifo)) { av_fifo_generic_read(VAR_1->pkt_fifo, &pkt, sizeof(pkt), NULL); av_packet_unref(&pkt); } av_fifo_reset(VAR_1->input_fifo); }