static int matroska_parse_cluster_incremental(MatroskaDemuxContext *matroska)

{

    EbmlList *blocks_list;

    MatroskaBlock *blocks;

    int i, res;

    res = ebml_parse(matroska,

                     matroska_cluster_incremental_parsing,

                     &matroska->current_cluster);

    if (res == 1) {

        /* New Cluster */

        if (matroska->current_cluster_pos)

            ebml_level_end(matroska);

        ebml_free(matroska_cluster, &matroska->current_cluster);

        memset(&matroska->current_cluster, 0, sizeof(MatroskaCluster));

        matroska->current_cluster_num_blocks = 0;

        matroska->current_cluster_pos = avio_tell(matroska->ctx->pb);

        matroska->prev_pkt = NULL;

        /* sizeof the ID which was already read */

        if (matroska->current_id)

            matroska->current_cluster_pos -= 4;

        res = ebml_parse(matroska,

                         matroska_clusters_incremental,

                         &matroska->current_cluster);

        /* Try parsing the block again. */

        if (res == 1)

            res = ebml_parse(matroska,

                             matroska_cluster_incremental_parsing,

                             &matroska->current_cluster);

    }



    if (!res &&

        matroska->current_cluster_num_blocks <

            matroska->current_cluster.blocks.nb_elem) {

        blocks_list = &matroska->current_cluster.blocks;

        blocks = blocks_list->elem;



        matroska->current_cluster_num_blocks = blocks_list->nb_elem;

        i = blocks_list->nb_elem - 1;

        if (blocks[i].bin.size > 0 && blocks[i].bin.data) {

            int is_keyframe = blocks[i].non_simple ? !blocks[i].reference : -1;

            uint8_t* additional = blocks[i].additional.size > 0 ?

                                    blocks[i].additional.data : NULL;

            if (!blocks[i].non_simple)

                blocks[i].duration = 0;

            res = matroska_parse_block(matroska,

                                       blocks[i].bin.data, blocks[i].bin.size,

                                       blocks[i].bin.pos,

                                       matroska->current_cluster.timecode,

                                       blocks[i].duration, is_keyframe,

                                       additional, blocks[i].additional_id,

                                       blocks[i].additional.size,

                                       matroska->current_cluster_pos);

        }

    }



    if (res < 0)  matroska->done = 1;

    return res;

}

static int matroska_parse_cluster_incremental(MatroskaDemuxContext *matroska)

{

    EbmlList *blocks_list;

    MatroskaBlock *blocks;

    int i, res;

    res = ebml_parse(matroska,

                     matroska_cluster_incremental_parsing,

                     &matroska->current_cluster);

    if (res == 1) {

        

        if (matroska->current_cluster_pos)

            ebml_level_end(matroska);

        ebml_free(matroska_cluster, &matroska->current_cluster);

        memset(&matroska->current_cluster, 0, sizeof(MatroskaCluster));

        matroska->current_cluster_num_blocks = 0;

        matroska->current_cluster_pos = avio_tell(matroska->ctx->pb);

        matroska->prev_pkt = NULL;

        

        if (matroska->current_id)

            matroska->current_cluster_pos -= 4;

        res = ebml_parse(matroska,

                         matroska_clusters_incremental,

                         &matroska->current_cluster);

        

        if (res == 1)

            res = ebml_parse(matroska,

                             matroska_cluster_incremental_parsing,

                             &matroska->current_cluster);

    }



    if (!res &&

        matroska->current_cluster_num_blocks <

            matroska->current_cluster.blocks.nb_elem) {

        blocks_list = &matroska->current_cluster.blocks;

        blocks = blocks_list->elem;



        matroska->current_cluster_num_blocks = blocks_list->nb_elem;

        i = blocks_list->nb_elem - 1;

        if (blocks[i].bin.size > 0 && blocks[i].bin.data) {

            int is_keyframe = blocks[i].non_simple ? !blocks[i].reference : -1;

            uint8_t* additional = blocks[i].additional.size > 0 ?

                                    blocks[i].additional.data : NULL;

            if (!blocks[i].non_simple)

                blocks[i].duration = 0;

            res = matroska_parse_block(matroska,

                                       blocks[i].bin.data, blocks[i].bin.size,

                                       blocks[i].bin.pos,

                                       matroska->current_cluster.timecode,

                                       blocks[i].duration, is_keyframe,

                                       additional, blocks[i].additional_id,

                                       blocks[i].additional.size,

                                       matroska->current_cluster_pos);

        }

    }



    if (res < 0)  matroska->done = 1;

    return res;

}

    if (res < 0)  matroska->done = 1;
static int FUNC_0(MatroskaDemuxContext *VAR_0)

{

    EbmlList *blocks_list;

    MatroskaBlock *blocks;

    int VAR_1, VAR_2;

    VAR_2 = ebml_parse(VAR_0,

                     matroska_cluster_incremental_parsing,

                     &VAR_0->current_cluster);

    if (VAR_2 == 1) {

        

        if (VAR_0->current_cluster_pos)

            ebml_level_end(VAR_0);

        ebml_free(matroska_cluster, &VAR_0->current_cluster);

        memset(&VAR_0->current_cluster, 0, sizeof(MatroskaCluster));

        VAR_0->current_cluster_num_blocks = 0;

        VAR_0->current_cluster_pos = avio_tell(VAR_0->ctx->pb);

        VAR_0->prev_pkt = NULL;

        

        if (VAR_0->current_id)

            VAR_0->current_cluster_pos -= 4;

        VAR_2 = ebml_parse(VAR_0,

                         matroska_clusters_incremental,

                         &VAR_0->current_cluster);

        

        if (VAR_2 == 1)

            VAR_2 = ebml_parse(VAR_0,

                             matroska_cluster_incremental_parsing,

                             &VAR_0->current_cluster);

    }



    if (!VAR_2 &&

        VAR_0->current_cluster_num_blocks <

            VAR_0->current_cluster.blocks.nb_elem) {

        blocks_list = &VAR_0->current_cluster.blocks;

        blocks = blocks_list->elem;



        VAR_0->current_cluster_num_blocks = blocks_list->nb_elem;

        VAR_1 = blocks_list->nb_elem - 1;

        if (blocks[VAR_1].bin.size > 0 && blocks[VAR_1].bin.data) {

            int VAR_3 = blocks[VAR_1].non_simple ? !blocks[VAR_1].reference : -1;

            uint8_t* additional = blocks[VAR_1].additional.size > 0 ?

                                    blocks[VAR_1].additional.data : NULL;

            if (!blocks[VAR_1].non_simple)

                blocks[VAR_1].duration = 0;

            VAR_2 = matroska_parse_block(VAR_0,

                                       blocks[VAR_1].bin.data, blocks[VAR_1].bin.size,

                                       blocks[VAR_1].bin.pos,

                                       VAR_0->current_cluster.timecode,

                                       blocks[VAR_1].duration, VAR_3,

                                       additional, blocks[VAR_1].additional_id,

                                       blocks[VAR_1].additional.size,

                                       VAR_0->current_cluster_pos);

        }

    }



    if (VAR_2 < 0)  VAR_0->done = 1;

    return VAR_2;

}

static int FUNC_0(MatroskaDemuxContext *VAR_0)
{ EbmlList *blocks_list; MatroskaBlock *blocks; int VAR_1, VAR_2; VAR_2 = ebml_parse(VAR_0,
matroska_cluster_incremental_parsing,
&VAR_0->current_cluster); if (VAR_2 == 1) { if (VAR_0->current_cluster_pos)
ebml_level_end(VAR_0); ebml_free(matroska_cluster, &VAR_0->current_cluster); memset(&VAR_0->current_cluster, 0, sizeof(MatroskaCluster)); VAR_0->current_cluster_num_blocks = 0; VAR_0->current_cluster_pos = avio_tell(VAR_0->ctx->pb); VAR_0->prev_pkt = NULL; if (VAR_0->current_id)
VAR_0->current_cluster_pos -= 4; VAR_2 = ebml_parse(VAR_0,
matroska_clusters_incremental,
&VAR_0->current_cluster); if (VAR_2 == 1)
VAR_2 = ebml_parse(VAR_0,
matroska_cluster_incremental_parsing,
&VAR_0->current_cluster); } if (!VAR_2 &&
VAR_0->current_cluster_num_blocks <
VAR_0->current_cluster.blocks.nb_elem) { blocks_list = &VAR_0->current_cluster.blocks; blocks = blocks_list->elem; VAR_0->current_cluster_num_blocks = blocks_list->nb_elem; VAR_1 = blocks_list->nb_elem - 1; if (blocks[VAR_1].bin.size > 0 && blocks[VAR_1].bin.data) { int VAR_3 = blocks[VAR_1].non_simple ? !blocks[VAR_1].reference : -1; uint8_t* additional = blocks[VAR_1].additional.size > 0 ?
blocks[VAR_1].additional.data : NULL; if (!blocks[VAR_1].non_simple)
blocks[VAR_1].duration = 0; VAR_2 = matroska_parse_block(VAR_0,
blocks[VAR_1].bin.data, blocks[VAR_1].bin.size,
blocks[VAR_1].bin.pos,
VAR_0->current_cluster.timecode,
blocks[VAR_1].duration, VAR_3,
additional, blocks[VAR_1].additional_id,
blocks[VAR_1].additional.size,
VAR_0->current_cluster_pos); } } if (VAR_2 < 0)  VAR_0->done = 1; return VAR_2; }