static int writer_open(WriterContext **wctx, const Writer *writer, const char *args,

                       const struct section *sections, int nb_sections)

{

    int i, ret = 0;



    if (!(*wctx = av_malloc(sizeof(WriterContext)))) {

        ret = AVERROR(ENOMEM);

        goto fail;

    }



    if (!((*wctx)->priv = av_mallocz(writer->priv_size))) {

        ret = AVERROR(ENOMEM);

        goto fail;

    }



    (*wctx)->class = &writer_class;

    (*wctx)->writer = writer;

    (*wctx)->level = -1;

    (*wctx)->sections = sections;

    (*wctx)->nb_sections = nb_sections;



    if (writer->priv_class) {

        void *priv_ctx = (*wctx)->priv;

        *((const AVClass **)priv_ctx) = writer->priv_class;

        av_opt_set_defaults(priv_ctx);



        if (args &&

            (ret = av_set_options_string(priv_ctx, args, "=", ":")) < 0)

            goto fail;

    }



    for (i = 0; i < SECTION_MAX_NB_LEVELS; i++)

        av_bprint_init(&(*wctx)->section_pbuf[i], 1, AV_BPRINT_SIZE_UNLIMITED);



    if ((*wctx)->writer->init)

        ret = (*wctx)->writer->init(*wctx);

    if (ret < 0)

        goto fail;



    return 0;



fail:

    writer_close(wctx);

    return ret;

}

static int writer_open(WriterContext **wctx, const Writer *writer, const char *args,

                       const struct section *sections, int nb_sections)

{

    int i, ret = 0;



    if (!(*wctx = av_malloc(sizeof(WriterContext)))) {

        ret = AVERROR(ENOMEM);

        goto fail;

    }



    if (!((*wctx)->priv = av_mallocz(writer->priv_size))) {

        ret = AVERROR(ENOMEM);

        goto fail;

    }



    (*wctx)->class = &writer_class;

    (*wctx)->writer = writer;

    (*wctx)->level = -1;

    (*wctx)->sections = sections;

    (*wctx)->nb_sections = nb_sections;



    if (writer->priv_class) {

        void *priv_ctx = (*wctx)->priv;

        *((const AVClass **)priv_ctx) = writer->priv_class;

        av_opt_set_defaults(priv_ctx);



        if (args &&

            (ret = av_set_options_string(priv_ctx, args, "=", ":")) < 0)

            goto fail;

    }



    for (i = 0; i < SECTION_MAX_NB_LEVELS; i++)

        av_bprint_init(&(*wctx)->section_pbuf[i], 1, AV_BPRINT_SIZE_UNLIMITED);



    if ((*wctx)->writer->init)

        ret = (*wctx)->writer->init(*wctx);

    if (ret < 0)

        goto fail;



    return 0;



fail:

    writer_close(wctx);

    return ret;

}

    if (!(*wctx = av_malloc(sizeof(WriterContext)))) {
static int FUNC_0(WriterContext **VAR_0, const Writer *VAR_1, const char *VAR_2,

                       const struct section *VAR_3, int VAR_4)

{

    int VAR_5, VAR_6 = 0;



    if (!(*VAR_0 = av_malloc(sizeof(WriterContext)))) {

        VAR_6 = AVERROR(ENOMEM);

        goto fail;

    }



    if (!((*VAR_0)->priv = av_mallocz(VAR_1->priv_size))) {

        VAR_6 = AVERROR(ENOMEM);

        goto fail;

    }



    (*VAR_0)->class = &writer_class;

    (*VAR_0)->VAR_1 = VAR_1;

    (*VAR_0)->level = -1;

    (*VAR_0)->VAR_3 = VAR_3;

    (*VAR_0)->VAR_4 = VAR_4;



    if (VAR_1->priv_class) {

        void *VAR_7 = (*VAR_0)->priv;

        *((const AVClass **)VAR_7) = VAR_1->priv_class;

        av_opt_set_defaults(VAR_7);



        if (VAR_2 &&

            (VAR_6 = av_set_options_string(VAR_7, VAR_2, "=", ":")) < 0)

            goto fail;

    }



    for (VAR_5 = 0; VAR_5 < SECTION_MAX_NB_LEVELS; VAR_5++)

        av_bprint_init(&(*VAR_0)->section_pbuf[VAR_5], 1, AV_BPRINT_SIZE_UNLIMITED);



    if ((*VAR_0)->VAR_1->init)

        VAR_6 = (*VAR_0)->VAR_1->init(*VAR_0);

    if (VAR_6 < 0)

        goto fail;



    return 0;



fail:

    writer_close(VAR_0);

    return VAR_6;

}

static int FUNC_0(WriterContext **VAR_0, const Writer *VAR_1, const char *VAR_2,
const struct section *VAR_3, int VAR_4)
{ int VAR_5, VAR_6 = 0; if (!(*VAR_0 = av_malloc(sizeof(WriterContext)))) { VAR_6 = AVERROR(ENOMEM); goto fail; } if (!((*VAR_0)->priv = av_mallocz(VAR_1->priv_size))) { VAR_6 = AVERROR(ENOMEM); goto fail; } (*VAR_0)->class = &writer_class; (*VAR_0)->VAR_1 = VAR_1; (*VAR_0)->level = -1; (*VAR_0)->VAR_3 = VAR_3; (*VAR_0)->VAR_4 = VAR_4; if (VAR_1->priv_class) { void *VAR_7 = (*VAR_0)->priv; *((const AVClass **)VAR_7) = VAR_1->priv_class; av_opt_set_defaults(VAR_7); if (VAR_2 &&
(VAR_6 = av_set_options_string(VAR_7, VAR_2, "=", ":")) < 0)
goto fail; } for (VAR_5 = 0; VAR_5 < SECTION_MAX_NB_LEVELS; VAR_5++) av_bprint_init(&(*VAR_0)->section_pbuf[VAR_5], 1, AV_BPRINT_SIZE_UNLIMITED); if ((*VAR_0)->VAR_1->init)
VAR_6 = (*VAR_0)->VAR_1->init(*VAR_0); if (VAR_6 < 0)
goto fail; return 0; fail:
writer_close(VAR_0); return VAR_6; }