matroska_parse_cluster (MatroskaDemuxContext *matroska)

{

    int res = 0;

    uint32_t id;

    uint64_t cluster_time = 0;

    uint8_t *data;

    int64_t pos;

    int size;



    av_log(matroska->ctx, AV_LOG_DEBUG,

           "parsing cluster at %"PRId64"\n", url_ftell(&matroska->ctx->pb));



    while (res == 0) {

        if (!(id = ebml_peek_id(matroska, &matroska->level_up))) {

            res = AVERROR_IO;

            break;

        } else if (matroska->level_up) {

            matroska->level_up--;

            break;

        }



        switch (id) {

            /* cluster timecode */

            case MATROSKA_ID_CLUSTERTIMECODE: {

                uint64_t num;

                if ((res = ebml_read_uint(matroska, &id, &num)) < 0)

                    break;

                cluster_time = num;

                break;

            }



                /* a group of blocks inside a cluster */

            case MATROSKA_ID_BLOCKGROUP:

                if ((res = ebml_read_master(matroska, &id)) < 0)

                    break;

                res = matroska_parse_blockgroup(matroska, cluster_time);

                break;



            case MATROSKA_ID_SIMPLEBLOCK:

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

                res = ebml_read_binary(matroska, &id, &data, &size);

                if (res == 0)

                    res = matroska_parse_block(matroska, data, size, pos,

                                               cluster_time, -1, NULL, NULL);

                break;



            default:

                av_log(matroska->ctx, AV_LOG_INFO,

                       "Unknown entry 0x%x in cluster data\n", id);

                /* fall-through */



            case EBML_ID_VOID:

                res = ebml_read_skip(matroska);

                break;

        }



        if (matroska->level_up) {

            matroska->level_up--;

            break;

        }

    }



    return res;

}

matroska_parse_cluster (MatroskaDemuxContext *matroska)

{

    int res = 0;

    uint32_t id;

    uint64_t cluster_time = 0;

    uint8_t *data;

    int64_t pos;

    int size;



    av_log(matroska->ctx, AV_LOG_DEBUG,

           "parsing cluster at %"PRId64"\n", url_ftell(&matroska->ctx->pb));



    while (res == 0) {

        if (!(id = ebml_peek_id(matroska, &matroska->level_up))) {

            res = AVERROR_IO;

            break;

        } else if (matroska->level_up) {

            matroska->level_up--;

            break;

        }



        switch (id) {

            

            case MATROSKA_ID_CLUSTERTIMECODE: {

                uint64_t num;

                if ((res = ebml_read_uint(matroska, &id, &num)) < 0)

                    break;

                cluster_time = num;

                break;

            }



                

            case MATROSKA_ID_BLOCKGROUP:

                if ((res = ebml_read_master(matroska, &id)) < 0)

                    break;

                res = matroska_parse_blockgroup(matroska, cluster_time);

                break;



            case MATROSKA_ID_SIMPLEBLOCK:

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

                res = ebml_read_binary(matroska, &id, &data, &size);

                if (res == 0)

                    res = matroska_parse_block(matroska, data, size, pos,

                                               cluster_time, -1, NULL, NULL);

                break;



            default:

                av_log(matroska->ctx, AV_LOG_INFO,

                       "Unknown entry 0x%x in cluster data\n", id);

                



            case EBML_ID_VOID:

                res = ebml_read_skip(matroska);

                break;

        }



        if (matroska->level_up) {

            matroska->level_up--;

            break;

        }

    }



    return res;

}

FUNC_0 (MatroskaDemuxContext *VAR_0)

{

    int VAR_1 = 0;

    uint32_t id;

    uint64_t cluster_time = 0;

    uint8_t *data;

    int64_t pos;

    int VAR_2;



    av_log(VAR_0->ctx, AV_LOG_DEBUG,

           "parsing cluster at %"PRId64"\n", url_ftell(&VAR_0->ctx->pb));



    while (VAR_1 == 0) {

        if (!(id = ebml_peek_id(VAR_0, &VAR_0->level_up))) {

            VAR_1 = AVERROR_IO;

            break;

        } else if (VAR_0->level_up) {

            VAR_0->level_up--;

            break;

        }



        switch (id) {

            

            case MATROSKA_ID_CLUSTERTIMECODE: {

                uint64_t num;

                if ((VAR_1 = ebml_read_uint(VAR_0, &id, &num)) < 0)

                    break;

                cluster_time = num;

                break;

            }



                

            case MATROSKA_ID_BLOCKGROUP:

                if ((VAR_1 = ebml_read_master(VAR_0, &id)) < 0)

                    break;

                VAR_1 = matroska_parse_blockgroup(VAR_0, cluster_time);

                break;



            case MATROSKA_ID_SIMPLEBLOCK:

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

                VAR_1 = ebml_read_binary(VAR_0, &id, &data, &VAR_2);

                if (VAR_1 == 0)

                    VAR_1 = matroska_parse_block(VAR_0, data, VAR_2, pos,

                                               cluster_time, -1, NULL, NULL);

                break;



            default:

                av_log(VAR_0->ctx, AV_LOG_INFO,

                       "Unknown entry 0x%x in cluster data\n", id);

                



            case EBML_ID_VOID:

                VAR_1 = ebml_read_skip(VAR_0);

                break;

        }



        if (VAR_0->level_up) {

            VAR_0->level_up--;

            break;

        }

    }



    return VAR_1;

}

FUNC_0 (MatroskaDemuxContext *VAR_0)
{ int VAR_1 = 0; uint32_t id; uint64_t cluster_time = 0; uint8_t *data; int64_t pos; int VAR_2; av_log(VAR_0->ctx, AV_LOG_DEBUG,
"parsing cluster at %"PRId64"\n", url_ftell(&VAR_0->ctx->pb)); while (VAR_1 == 0) { if (!(id = ebml_peek_id(VAR_0, &VAR_0->level_up))) { VAR_1 = AVERROR_IO; break; } else if (VAR_0->level_up) { VAR_0->level_up--; break; } switch (id) { case MATROSKA_ID_CLUSTERTIMECODE: { uint64_t num; if ((VAR_1 = ebml_read_uint(VAR_0, &id, &num)) < 0)
break; cluster_time = num; break; } case MATROSKA_ID_BLOCKGROUP:
if ((VAR_1 = ebml_read_master(VAR_0, &id)) < 0)
break; VAR_1 = matroska_parse_blockgroup(VAR_0, cluster_time); break; case MATROSKA_ID_SIMPLEBLOCK:
pos = url_ftell(&VAR_0->ctx->pb); VAR_1 = ebml_read_binary(VAR_0, &id, &data, &VAR_2); if (VAR_1 == 0)
VAR_1 = matroska_parse_block(VAR_0, data, VAR_2, pos,
cluster_time, -1, NULL, NULL); break; default:
av_log(VAR_0->ctx, AV_LOG_INFO,
"Unknown entry 0x%x in cluster data\n", id); case EBML_ID_VOID:
VAR_1 = ebml_read_skip(VAR_0); break; } if (VAR_0->level_up) { VAR_0->level_up--; break; } } return VAR_1; }