int ff_v4l2_m2m_codec_full_reinit(V4L2m2mContext *s)

{

    void *log_ctx = s->avctx;

    int ret;



    av_log(log_ctx, AV_LOG_DEBUG, "%s full reinit\n", s->devname);



    /* wait for pending buffer references */

    if (atomic_load(&s->refcount))

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



    /* close the driver */

    ff_v4l2_m2m_codec_end(s->avctx);



    /* start again now that we know the stream dimensions */

    s->draining = 0;

    s->reinit = 0;



    s->fd = open(s->devname, O_RDWR | O_NONBLOCK, 0);

    if (s->fd < 0)

        return AVERROR(errno);



    ret = v4l2_prepare_contexts(s);

    if (ret < 0)

        goto error;



    /* if a full re-init was requested - probe didn't run - we need to populate

     * the format for each context

     */

    ret = ff_v4l2_context_get_format(&s->output);

    if (ret) {

        av_log(log_ctx, AV_LOG_DEBUG, "v4l2 output format not supported\n");

        goto error;

    }



    ret = ff_v4l2_context_get_format(&s->capture);

    if (ret) {

        av_log(log_ctx, AV_LOG_DEBUG, "v4l2 capture format not supported\n");

        goto error;

    }



    ret = ff_v4l2_context_set_format(&s->output);

    if (ret) {

        av_log(log_ctx, AV_LOG_ERROR, "can't set v4l2 output format\n");

        goto error;

    }



    ret = ff_v4l2_context_set_format(&s->capture);

    if (ret) {

        av_log(log_ctx, AV_LOG_ERROR, "can't to set v4l2 capture format\n");

        goto error;

    }



    ret = ff_v4l2_context_init(&s->output);

    if (ret) {

        av_log(log_ctx, AV_LOG_ERROR, "no v4l2 output context's buffers\n");

        goto error;

    }



    /* decoder's buffers need to be updated at a later stage */

    if (!av_codec_is_decoder(s->avctx->codec)) {

        ret = ff_v4l2_context_init(&s->capture);

        if (ret) {

            av_log(log_ctx, AV_LOG_ERROR, "no v4l2 capture context's buffers\n");

            goto error;

        }

    }



    return 0;



error:

    if (close(s->fd) < 0) {

        ret = AVERROR(errno);

        av_log(log_ctx, AV_LOG_ERROR, "error closing %s (%s)\n",

            s->devname, av_err2str(AVERROR(errno)));

    }

    s->fd = -1;



    return ret;

}

int ff_v4l2_m2m_codec_full_reinit(V4L2m2mContext *s)

{

    void *log_ctx = s->avctx;

    int ret;



    av_log(log_ctx, AV_LOG_DEBUG, "%s full reinit\n", s->devname);



    

    if (atomic_load(&s->refcount))

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



    

    ff_v4l2_m2m_codec_end(s->avctx);



    

    s->draining = 0;

    s->reinit = 0;



    s->fd = open(s->devname, O_RDWR | O_NONBLOCK, 0);

    if (s->fd < 0)

        return AVERROR(errno);



    ret = v4l2_prepare_contexts(s);

    if (ret < 0)

        goto error;



    





    ret = ff_v4l2_context_get_format(&s->output);

    if (ret) {

        av_log(log_ctx, AV_LOG_DEBUG, "v4l2 output format not supported\n");

        goto error;

    }



    ret = ff_v4l2_context_get_format(&s->capture);

    if (ret) {

        av_log(log_ctx, AV_LOG_DEBUG, "v4l2 capture format not supported\n");

        goto error;

    }



    ret = ff_v4l2_context_set_format(&s->output);

    if (ret) {

        av_log(log_ctx, AV_LOG_ERROR, "can't set v4l2 output format\n");

        goto error;

    }



    ret = ff_v4l2_context_set_format(&s->capture);

    if (ret) {

        av_log(log_ctx, AV_LOG_ERROR, "can't to set v4l2 capture format\n");

        goto error;

    }



    ret = ff_v4l2_context_init(&s->output);

    if (ret) {

        av_log(log_ctx, AV_LOG_ERROR, "no v4l2 output context's buffers\n");

        goto error;

    }



    

    if (!av_codec_is_decoder(s->avctx->codec)) {

        ret = ff_v4l2_context_init(&s->capture);

        if (ret) {

            av_log(log_ctx, AV_LOG_ERROR, "no v4l2 capture context's buffers\n");

            goto error;

        }

    }



    return 0;



error:

    if (close(s->fd) < 0) {

        ret = AVERROR(errno);

        av_log(log_ctx, AV_LOG_ERROR, "error closing %s (%s)\n",

            s->devname, av_err2str(AVERROR(errno)));

    }

    s->fd = -1;



    return ret;

}

    ff_v4l2_m2m_codec_end(s->avctx);     s->fd = open(s->devname, O_RDWR | O_NONBLOCK, 0);     if (s->fd < 0)         return AVERROR(errno);     ret = v4l2_prepare_contexts(s);     if (ret < 0)         goto error;     if (close(s->fd) < 0) {         ret = AVERROR(errno);         av_log(log_ctx, AV_LOG_ERROR, "error closing %s (%s)\n",             s->devname, av_err2str(AVERROR(errno)));     s->fd = -1;     if (atomic_load(&s->refcount))     s->fd = -1;
int FUNC_0(V4L2m2mContext *VAR_0)

{

    void *VAR_1 = VAR_0->avctx;

    int VAR_2;



    av_log(VAR_1, AV_LOG_DEBUG, "%VAR_0 full reinit\n", VAR_0->devname);



    

    if (atomic_load(&VAR_0->refcount))

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



    

    ff_v4l2_m2m_codec_end(VAR_0->avctx);



    

    VAR_0->draining = 0;

    VAR_0->reinit = 0;



    VAR_0->fd = open(VAR_0->devname, O_RDWR | O_NONBLOCK, 0);

    if (VAR_0->fd < 0)

        return AVERROR(errno);



    VAR_2 = v4l2_prepare_contexts(VAR_0);

    if (VAR_2 < 0)

        goto error;



    





    VAR_2 = ff_v4l2_context_get_format(&VAR_0->output);

    if (VAR_2) {

        av_log(VAR_1, AV_LOG_DEBUG, "v4l2 output format not supported\n");

        goto error;

    }



    VAR_2 = ff_v4l2_context_get_format(&VAR_0->capture);

    if (VAR_2) {

        av_log(VAR_1, AV_LOG_DEBUG, "v4l2 capture format not supported\n");

        goto error;

    }



    VAR_2 = ff_v4l2_context_set_format(&VAR_0->output);

    if (VAR_2) {

        av_log(VAR_1, AV_LOG_ERROR, "can't set v4l2 output format\n");

        goto error;

    }



    VAR_2 = ff_v4l2_context_set_format(&VAR_0->capture);

    if (VAR_2) {

        av_log(VAR_1, AV_LOG_ERROR, "can't to set v4l2 capture format\n");

        goto error;

    }



    VAR_2 = ff_v4l2_context_init(&VAR_0->output);

    if (VAR_2) {

        av_log(VAR_1, AV_LOG_ERROR, "no v4l2 output context'VAR_0 buffers\n");

        goto error;

    }



    

    if (!av_codec_is_decoder(VAR_0->avctx->codec)) {

        VAR_2 = ff_v4l2_context_init(&VAR_0->capture);

        if (VAR_2) {

            av_log(VAR_1, AV_LOG_ERROR, "no v4l2 capture context'VAR_0 buffers\n");

            goto error;

        }

    }



    return 0;



error:

    if (close(VAR_0->fd) < 0) {

        VAR_2 = AVERROR(errno);

        av_log(VAR_1, AV_LOG_ERROR, "error closing %VAR_0 (%VAR_0)\n",

            VAR_0->devname, av_err2str(AVERROR(errno)));

    }

    VAR_0->fd = -1;



    return VAR_2;

}

int FUNC_0(V4L2m2mContext *VAR_0)
{ void *VAR_1 = VAR_0->avctx; int VAR_2; av_log(VAR_1, AV_LOG_DEBUG, "%VAR_0 full reinit\n", VAR_0->devname); if (atomic_load(&VAR_0->refcount))
while(sem_wait(&VAR_0->refsync) == -1 && errno == EINTR); ff_v4l2_m2m_codec_end(VAR_0->avctx); VAR_0->draining = 0; VAR_0->reinit = 0; VAR_0->fd = open(VAR_0->devname, O_RDWR | O_NONBLOCK, 0); if (VAR_0->fd < 0)
return AVERROR(errno); VAR_2 = v4l2_prepare_contexts(VAR_0); if (VAR_2 < 0)
goto error; VAR_2 = ff_v4l2_context_get_format(&VAR_0->output); if (VAR_2) { av_log(VAR_1, AV_LOG_DEBUG, "v4l2 output format not supported\n"); goto error; } VAR_2 = ff_v4l2_context_get_format(&VAR_0->capture); if (VAR_2) { av_log(VAR_1, AV_LOG_DEBUG, "v4l2 capture format not supported\n"); goto error; } VAR_2 = ff_v4l2_context_set_format(&VAR_0->output); if (VAR_2) { av_log(VAR_1, AV_LOG_ERROR, "can't set v4l2 output format\n"); goto error; } VAR_2 = ff_v4l2_context_set_format(&VAR_0->capture); if (VAR_2) { av_log(VAR_1, AV_LOG_ERROR, "can't to set v4l2 capture format\n"); goto error; } VAR_2 = ff_v4l2_context_init(&VAR_0->output); if (VAR_2) { av_log(VAR_1, AV_LOG_ERROR, "no v4l2 output context'VAR_0 buffers\n"); goto error; } if (!av_codec_is_decoder(VAR_0->avctx->codec)) { VAR_2 = ff_v4l2_context_init(&VAR_0->capture); if (VAR_2) { av_log(VAR_1, AV_LOG_ERROR, "no v4l2 capture context'VAR_0 buffers\n"); goto error; } } return 0; error:
if (close(VAR_0->fd) < 0) { VAR_2 = AVERROR(errno); av_log(VAR_1, AV_LOG_ERROR, "error closing %VAR_0 (%VAR_0)\n",
VAR_0->devname, av_err2str(AVERROR(errno))); } VAR_0->fd = -1; return VAR_2; }