static int ogg_restore(AVFormatContext *s)

{

    struct ogg *ogg = s->priv_data;

    AVIOContext *bc = s->pb;

    struct ogg_state *ost = ogg->state;

    int i, err;



    if (!ost)

        return 0;



    ogg->state = ost->next;



        for (i = 0; i < ogg->nstreams; i++)

            av_freep(&ogg->streams[i].buf);



        avio_seek(bc, ost->pos, SEEK_SET);

        ogg->page_pos = -1;

        ogg->curidx   = ost->curidx;

        ogg->nstreams = ost->nstreams;

        if ((err = av_reallocp_array(&ogg->streams, ogg->nstreams,

                                     sizeof(*ogg->streams))) < 0) {

            ogg->nstreams = 0;

            return err;

        } else

            memcpy(ogg->streams, ost->streams,

                   ost->nstreams * sizeof(*ogg->streams));



    av_free(ost);



    return 0;

}

static int ogg_restore(AVFormatContext *s)

{

    struct ogg *ogg = s->priv_data;

    AVIOContext *bc = s->pb;

    struct ogg_state *ost = ogg->state;

    int i, err;



    if (!ost)

        return 0;



    ogg->state = ost->next;



        for (i = 0; i < ogg->nstreams; i++)

            av_freep(&ogg->streams[i].buf);



        avio_seek(bc, ost->pos, SEEK_SET);

        ogg->page_pos = -1;

        ogg->curidx   = ost->curidx;

        ogg->nstreams = ost->nstreams;

        if ((err = av_reallocp_array(&ogg->streams, ogg->nstreams,

                                     sizeof(*ogg->streams))) < 0) {

            ogg->nstreams = 0;

            return err;

        } else

            memcpy(ogg->streams, ost->streams,

                   ost->nstreams * sizeof(*ogg->streams));



    av_free(ost);



    return 0;

}

        for (i = 0; i < ogg->nstreams; i++)
static int FUNC_0(AVFormatContext *VAR_0)

{

    struct VAR_1 *VAR_1 = VAR_0->priv_data;

    AVIOContext *bc = VAR_0->pb;

    struct ogg_state *VAR_2 = VAR_1->state;

    int VAR_3, VAR_4;



    if (!VAR_2)

        return 0;



    VAR_1->state = VAR_2->next;



        for (VAR_3 = 0; VAR_3 < VAR_1->nstreams; VAR_3++)

            av_freep(&VAR_1->streams[VAR_3].buf);



        avio_seek(bc, VAR_2->pos, SEEK_SET);

        VAR_1->page_pos = -1;

        VAR_1->curidx   = VAR_2->curidx;

        VAR_1->nstreams = VAR_2->nstreams;

        if ((VAR_4 = av_reallocp_array(&VAR_1->streams, VAR_1->nstreams,

                                     sizeof(*VAR_1->streams))) < 0) {

            VAR_1->nstreams = 0;

            return VAR_4;

        } else

            memcpy(VAR_1->streams, VAR_2->streams,

                   VAR_2->nstreams * sizeof(*VAR_1->streams));



    av_free(VAR_2);



    return 0;

}

static int FUNC_0(AVFormatContext *VAR_0)
{ struct VAR_1 *VAR_1 = VAR_0->priv_data; AVIOContext *bc = VAR_0->pb; struct ogg_state *VAR_2 = VAR_1->state; int VAR_3, VAR_4; if (!VAR_2)
return 0; VAR_1->state = VAR_2->next; for (VAR_3 = 0; VAR_3 < VAR_1->nstreams; VAR_3++) av_freep(&VAR_1->streams[VAR_3].buf); avio_seek(bc, VAR_2->pos, SEEK_SET); VAR_1->page_pos = -1; VAR_1->curidx   = VAR_2->curidx; VAR_1->nstreams = VAR_2->nstreams; if ((VAR_4 = av_reallocp_array(&VAR_1->streams, VAR_1->nstreams,
sizeof(*VAR_1->streams))) < 0) { VAR_1->nstreams = 0; return VAR_4; } else memcpy(VAR_1->streams, VAR_2->streams,
VAR_2->nstreams * sizeof(*VAR_1->streams)); av_free(VAR_2); return 0; }