ogg_get_length (AVFormatContext * s)

{

    ogg_t *ogg = s->priv_data;

    int idx = -1, i;

    offset_t size, end;



    if(s->pb.is_streamed)

        return 0;



// already set

    if (s->duration != AV_NOPTS_VALUE)

        return 0;



    size = url_fsize(&s->pb);

    if(size < 0)

        return 0;

    end = size > MAX_PAGE_SIZE? size - MAX_PAGE_SIZE: size;



    ogg_save (s);

    url_fseek (&s->pb, end, SEEK_SET);



    while (!ogg_read_page (s, &i)){

        if (ogg->streams[i].granule != -1 && ogg->streams[i].granule != 0)

            idx = i;

    }



    if (idx != -1){

        s->streams[idx]->duration =

            ogg_gptopts (s, idx, ogg->streams[idx].granule);

    }



    ogg->size = size;

    ogg_restore (s, 0);

    ogg_save (s);

    while (!ogg_read_page (s, &i)) {

        if (i == idx && ogg->streams[i].granule != -1 && ogg->streams[i].granule != 0)

            break;

    }

    if (i == idx) {

        s->streams[idx]->start_time = ogg_gptopts (s, idx, ogg->streams[idx].granule);

        s->streams[idx]->duration -= s->streams[idx]->start_time;

    }

    ogg_restore (s, 0);



    return 0;

}

ogg_get_length (AVFormatContext * s)

{

    ogg_t *ogg = s->priv_data;

    int idx = -1, i;

    offset_t size, end;



    if(s->pb.is_streamed)

        return 0;





    if (s->duration != AV_NOPTS_VALUE)

        return 0;



    size = url_fsize(&s->pb);

    if(size < 0)

        return 0;

    end = size > MAX_PAGE_SIZE? size - MAX_PAGE_SIZE: size;



    ogg_save (s);

    url_fseek (&s->pb, end, SEEK_SET);



    while (!ogg_read_page (s, &i)){

        if (ogg->streams[i].granule != -1 && ogg->streams[i].granule != 0)

            idx = i;

    }



    if (idx != -1){

        s->streams[idx]->duration =

            ogg_gptopts (s, idx, ogg->streams[idx].granule);

    }



    ogg->size = size;

    ogg_restore (s, 0);

    ogg_save (s);

    while (!ogg_read_page (s, &i)) {

        if (i == idx && ogg->streams[i].granule != -1 && ogg->streams[i].granule != 0)

            break;

    }

    if (i == idx) {

        s->streams[idx]->start_time = ogg_gptopts (s, idx, ogg->streams[idx].granule);

        s->streams[idx]->duration -= s->streams[idx]->start_time;

    }

    ogg_restore (s, 0);



    return 0;

}

        if (ogg->streams[i].granule != -1 && ogg->streams[i].granule != 0)
FUNC_0 (AVFormatContext * VAR_0)

{

    ogg_t *ogg = VAR_0->priv_data;

    int VAR_1 = -1, VAR_2;

    offset_t size, end;



    if(VAR_0->pb.is_streamed)

        return 0;





    if (VAR_0->duration != AV_NOPTS_VALUE)

        return 0;



    size = url_fsize(&VAR_0->pb);

    if(size < 0)

        return 0;

    end = size > MAX_PAGE_SIZE? size - MAX_PAGE_SIZE: size;



    ogg_save (VAR_0);

    url_fseek (&VAR_0->pb, end, SEEK_SET);



    while (!ogg_read_page (VAR_0, &VAR_2)){

        if (ogg->streams[VAR_2].granule != -1 && ogg->streams[VAR_2].granule != 0)

            VAR_1 = VAR_2;

    }



    if (VAR_1 != -1){

        VAR_0->streams[VAR_1]->duration =

            ogg_gptopts (VAR_0, VAR_1, ogg->streams[VAR_1].granule);

    }



    ogg->size = size;

    ogg_restore (VAR_0, 0);

    ogg_save (VAR_0);

    while (!ogg_read_page (VAR_0, &VAR_2)) {

        if (VAR_2 == VAR_1 && ogg->streams[VAR_2].granule != -1 && ogg->streams[VAR_2].granule != 0)

            break;

    }

    if (VAR_2 == VAR_1) {

        VAR_0->streams[VAR_1]->start_time = ogg_gptopts (VAR_0, VAR_1, ogg->streams[VAR_1].granule);

        VAR_0->streams[VAR_1]->duration -= VAR_0->streams[VAR_1]->start_time;

    }

    ogg_restore (VAR_0, 0);



    return 0;

}

FUNC_0 (AVFormatContext * VAR_0)
{ ogg_t *ogg = VAR_0->priv_data; int VAR_1 = -1, VAR_2; offset_t size, end; if(VAR_0->pb.is_streamed)
return 0; if (VAR_0->duration != AV_NOPTS_VALUE)
return 0; size = url_fsize(&VAR_0->pb); if(size < 0)
return 0; end = size > MAX_PAGE_SIZE? size - MAX_PAGE_SIZE: size; ogg_save (VAR_0); url_fseek (&VAR_0->pb, end, SEEK_SET); while (!ogg_read_page (VAR_0, &VAR_2)){ if (ogg->streams[VAR_2].granule != -1 && ogg->streams[VAR_2].granule != 0)
VAR_1 = VAR_2; } if (VAR_1 != -1){ VAR_0->streams[VAR_1]->duration =
ogg_gptopts (VAR_0, VAR_1, ogg->streams[VAR_1].granule); } ogg->size = size; ogg_restore (VAR_0, 0); ogg_save (VAR_0); while (!ogg_read_page (VAR_0, &VAR_2)) { if (VAR_2 == VAR_1 && ogg->streams[VAR_2].granule != -1 && ogg->streams[VAR_2].granule != 0)
break; } if (VAR_2 == VAR_1) { VAR_0->streams[VAR_1]->start_time = ogg_gptopts (VAR_0, VAR_1, ogg->streams[VAR_1].granule); VAR_0->streams[VAR_1]->duration -= VAR_0->streams[VAR_1]->start_time; } ogg_restore (VAR_0, 0); return 0; }