int ff_v4l2_m2m_codec_reinit(V4L2m2mContext* s)

{

    int ret;



    av_log(s->avctx, AV_LOG_DEBUG, "reinit context\n");



    /* 1. streamoff */

    ret = ff_v4l2_context_set_status(&s->capture, VIDIOC_STREAMOFF);

    if (ret)

        av_log(s->avctx, AV_LOG_ERROR, "capture VIDIOC_STREAMOFF\n");



    /* 2. unmap the capture buffers (v4l2 and ffmpeg):

     *    we must wait for all references to be released before being allowed

     *    to queue new buffers.

     */

    av_log(s->avctx, AV_LOG_DEBUG, "waiting for user to release AVBufferRefs\n");

    if (atomic_load(&s->refcount))

        while(sem_wait(&s->refsync) == -1 && errno == EINTR);



    ff_v4l2_context_release(&s->capture);



    /* 3. get the new capture format */

    ret = ff_v4l2_context_get_format(&s->capture);

    if (ret) {

        av_log(s->avctx, AV_LOG_ERROR, "query the new capture format\n");

        return ret;

    }



    /* 4. set the capture format */

    ret = ff_v4l2_context_set_format(&s->capture);

    if (ret) {

        av_log(s->avctx, AV_LOG_ERROR, "setting capture format\n");

        return ret;

    }



    /* 5. complete reinit */

    sem_destroy(&s->refsync);

    sem_init(&s->refsync, 0, 0);

    s->draining = 0;

    s->reinit = 0;



    return 0;

}

int ff_v4l2_m2m_codec_reinit(V4L2m2mContext* s)

{

    int ret;



    av_log(s->avctx, AV_LOG_DEBUG, "reinit context\n");



    

    ret = ff_v4l2_context_set_status(&s->capture, VIDIOC_STREAMOFF);

    if (ret)

        av_log(s->avctx, AV_LOG_ERROR, "capture VIDIOC_STREAMOFF\n");



    







    av_log(s->avctx, AV_LOG_DEBUG, "waiting for user to release AVBufferRefs\n");

    if (atomic_load(&s->refcount))

        while(sem_wait(&s->refsync) == -1 && errno == EINTR);



    ff_v4l2_context_release(&s->capture);



    

    ret = ff_v4l2_context_get_format(&s->capture);

    if (ret) {

        av_log(s->avctx, AV_LOG_ERROR, "query the new capture format\n");

        return ret;

    }



    

    ret = ff_v4l2_context_set_format(&s->capture);

    if (ret) {

        av_log(s->avctx, AV_LOG_ERROR, "setting capture format\n");

        return ret;

    }



    

    sem_destroy(&s->refsync);

    sem_init(&s->refsync, 0, 0);

    s->draining = 0;

    s->reinit = 0;



    return 0;

}

    sem_destroy(&s->refsync);     sem_init(&s->refsync, 0, 0);     if (atomic_load(&s->refcount))     ff_v4l2_context_release(&s->capture);     sem_destroy(&s->refsync);
int FUNC_0(V4L2m2mContext* VAR_0)

{

    int VAR_1;



    av_log(VAR_0->avctx, AV_LOG_DEBUG, "reinit context\n");



    

    VAR_1 = ff_v4l2_context_set_status(&VAR_0->capture, VIDIOC_STREAMOFF);

    if (VAR_1)

        av_log(VAR_0->avctx, AV_LOG_ERROR, "capture VIDIOC_STREAMOFF\n");



    







    av_log(VAR_0->avctx, AV_LOG_DEBUG, "waiting for user to release AVBufferRefs\n");

    if (atomic_load(&VAR_0->refcount))

        while(sem_wait(&VAR_0->refsync) == -1 && errno == EINTR);



    ff_v4l2_context_release(&VAR_0->capture);



    

    VAR_1 = ff_v4l2_context_get_format(&VAR_0->capture);

    if (VAR_1) {

        av_log(VAR_0->avctx, AV_LOG_ERROR, "query the new capture format\n");

        return VAR_1;

    }



    

    VAR_1 = ff_v4l2_context_set_format(&VAR_0->capture);

    if (VAR_1) {

        av_log(VAR_0->avctx, AV_LOG_ERROR, "setting capture format\n");

        return VAR_1;

    }



    

    sem_destroy(&VAR_0->refsync);

    sem_init(&VAR_0->refsync, 0, 0);

    VAR_0->draining = 0;

    VAR_0->reinit = 0;



    return 0;

}

int FUNC_0(V4L2m2mContext* VAR_0)
{ int VAR_1; av_log(VAR_0->avctx, AV_LOG_DEBUG, "reinit context\n"); VAR_1 = ff_v4l2_context_set_status(&VAR_0->capture, VIDIOC_STREAMOFF); if (VAR_1)
av_log(VAR_0->avctx, AV_LOG_ERROR, "capture VIDIOC_STREAMOFF\n"); av_log(VAR_0->avctx, AV_LOG_DEBUG, "waiting for user to release AVBufferRefs\n"); if (atomic_load(&VAR_0->refcount))
while(sem_wait(&VAR_0->refsync) == -1 && errno == EINTR); ff_v4l2_context_release(&VAR_0->capture); VAR_1 = ff_v4l2_context_get_format(&VAR_0->capture); if (VAR_1) { av_log(VAR_0->avctx, AV_LOG_ERROR, "query the new capture format\n"); return VAR_1; } VAR_1 = ff_v4l2_context_set_format(&VAR_0->capture); if (VAR_1) { av_log(VAR_0->avctx, AV_LOG_ERROR, "setting capture format\n"); return VAR_1; } sem_destroy(&VAR_0->refsync); sem_init(&VAR_0->refsync, 0, 0); VAR_0->draining = 0; VAR_0->reinit = 0; return 0; }