static int matroska_parse_cluster(MatroskaDemuxContext *matroska)

{

    MatroskaCluster cluster = { 0 };

    EbmlList *blocks_list;

    MatroskaBlock *blocks;

    int i, res;

    int64_t pos = url_ftell(matroska->ctx->pb);

    matroska->prev_pkt = NULL;

    if (matroska->has_cluster_id){

        /* For the first cluster we parse, its ID was already read as

           part of matroska_read_header(), so don't read it again */

        res = ebml_parse_id(matroska, matroska_clusters,

                            MATROSKA_ID_CLUSTER, &cluster);

        pos -= 4;  /* sizeof the ID which was already read */

        matroska->has_cluster_id = 0;

    } else

        res = ebml_parse(matroska, matroska_clusters, &cluster);

    blocks_list = &cluster.blocks;

    blocks = blocks_list->elem;

    for (i=0; i<blocks_list->nb_elem; i++)

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

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

            res=matroska_parse_block(matroska,

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

                                     blocks[i].bin.pos,  cluster.timecode,

                                     blocks[i].duration, is_keyframe,

                                     pos);

        }

    ebml_free(matroska_cluster, &cluster);

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

    return res;

}

static int matroska_parse_cluster(MatroskaDemuxContext *matroska)

{

    MatroskaCluster cluster = { 0 };

    EbmlList *blocks_list;

    MatroskaBlock *blocks;

    int i, res;

    int64_t pos = url_ftell(matroska->ctx->pb);

    matroska->prev_pkt = NULL;

    if (matroska->has_cluster_id){

        



        res = ebml_parse_id(matroska, matroska_clusters,

                            MATROSKA_ID_CLUSTER, &cluster);

        pos -= 4;  

        matroska->has_cluster_id = 0;

    } else

        res = ebml_parse(matroska, matroska_clusters, &cluster);

    blocks_list = &cluster.blocks;

    blocks = blocks_list->elem;

    for (i=0; i<blocks_list->nb_elem; i++)

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

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

            res=matroska_parse_block(matroska,

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

                                     blocks[i].bin.pos,  cluster.timecode,

                                     blocks[i].duration, is_keyframe,

                                     pos);

        }

    ebml_free(matroska_cluster, &cluster);

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

    return res;

}

        if (blocks[i].bin.size > 0) {
static int FUNC_0(MatroskaDemuxContext *VAR_0)

{

    MatroskaCluster cluster = { 0 };

    EbmlList *blocks_list;

    MatroskaBlock *blocks;

    int VAR_1, VAR_2;

    int64_t pos = url_ftell(VAR_0->ctx->pb);

    VAR_0->prev_pkt = NULL;

    if (VAR_0->has_cluster_id){

        



        VAR_2 = ebml_parse_id(VAR_0, matroska_clusters,

                            MATROSKA_ID_CLUSTER, &cluster);

        pos -= 4;  

        VAR_0->has_cluster_id = 0;

    } else

        VAR_2 = ebml_parse(VAR_0, matroska_clusters, &cluster);

    blocks_list = &cluster.blocks;

    blocks = blocks_list->elem;

    for (VAR_1=0; VAR_1<blocks_list->nb_elem; VAR_1++)

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

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

            VAR_2=matroska_parse_block(VAR_0,

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

                                     blocks[VAR_1].bin.pos,  cluster.timecode,

                                     blocks[VAR_1].duration, is_keyframe,

                                     pos);

        }

    ebml_free(matroska_cluster, &cluster);

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

    return VAR_2;

}

static int FUNC_0(MatroskaDemuxContext *VAR_0)
{ MatroskaCluster cluster = { 0 }; EbmlList *blocks_list; MatroskaBlock *blocks; int VAR_1, VAR_2; int64_t pos = url_ftell(VAR_0->ctx->pb); VAR_0->prev_pkt = NULL; if (VAR_0->has_cluster_id){ VAR_2 = ebml_parse_id(VAR_0, matroska_clusters,
MATROSKA_ID_CLUSTER, &cluster); pos -= 4; VAR_0->has_cluster_id = 0; } else VAR_2 = ebml_parse(VAR_0, matroska_clusters, &cluster); blocks_list = &cluster.blocks; blocks = blocks_list->elem; for (VAR_1=0; VAR_1<blocks_list->nb_elem; VAR_1++) if (blocks[VAR_1].bin.size > 0) { int is_keyframe = blocks[VAR_1].non_simple ? !blocks[VAR_1].reference : -1; VAR_2=matroska_parse_block(VAR_0,
blocks[VAR_1].bin.data, blocks[VAR_1].bin.size,
blocks[VAR_1].bin.pos,  cluster.timecode,
blocks[VAR_1].duration, is_keyframe,
pos); } ebml_free(matroska_cluster, &cluster); if (VAR_2 < 0)  VAR_0->done = 1; return VAR_2; }