-/* parse a master chunk, filling the SEQ table and other variables.
- * We assume the stream is currently pointing to it.
- */
-static void parse_master(AVFormatContext *s)
-{
- TYDemuxContext *ty = s->priv_data;
- unsigned map_size; /* size of bitmask, in bytes */
- unsigned i, j;
-
- /* Note that the entries in the SEQ table in the stream may have
- different sizes depending on the bits per entry. We store them
- all in the same size structure, so we have to parse them out one
- by one. If we had a dynamic structure, we could simply read the
- entire table directly from the stream into memory in place. */
-
- /* clear the SEQ table */
- av_freep(&ty->seq_table);
-
- /* parse header info */
-
- map_size = AV_RB32(ty->chunk + 20); /* size of bitmask, in bytes */
- i = AV_RB32(ty->chunk + 28); /* size of SEQ table, in bytes */
-
- ty->seq_table_size = i / (8LL + map_size);
-
- if (ty->seq_table_size == 0) {
- ty->seq_table = NULL;
- return;
- }
-
- /* parse all the entries */
- ty->seq_table = av_calloc(ty->seq_table_size, sizeof(TySeqTable));
- if (ty->seq_table == NULL) {
- ty->seq_table_size = 0;
- return;
- }
-
- ty->cur_chunk_pos = 32;
- for (j = 0; j < ty->seq_table_size; j++) {
- if (ty->cur_chunk_pos >= CHUNK_SIZE - 8)
- return;
- ty->seq_table[j].timestamp = AV_RB64(ty->chunk + ty->cur_chunk_pos);
- ty->cur_chunk_pos += 8;
- if (map_size > 8) {
- av_log(s, AV_LOG_ERROR, "Unsupported SEQ bitmap size in master chunk.\n");
- ty->cur_chunk_pos += map_size;
- } else {
- memcpy(ty->seq_table[j].chunk_bitmask, ty->chunk + ty->cur_chunk_pos, map_size);
- }
- }
-}
-