Mercurial > libavformat.hg
comparison matroska.c @ 1456:34d0d965a0d0 libavformat
Add support for block duration.
Patch by Steve Lhomme % slhomme A divxcorp P com %
Original thread:
Date: Mon, 06 Nov 2006 19:22:14 +0100
Subject: [Ffmpeg-devel] [PATCH] Matroska block duration support
author | aurel |
---|---|
date | Mon, 06 Nov 2006 23:52:10 +0000 |
parents | e0e7ac1b8601 |
children | 5ea71a7f06fc |
comparison
equal
deleted
inserted
replaced
1455:e0e7ac1b8601 | 1456:34d0d965a0d0 |
---|---|
2275 matroska_parse_blockgroup (MatroskaDemuxContext *matroska, | 2275 matroska_parse_blockgroup (MatroskaDemuxContext *matroska, |
2276 uint64_t cluster_time) | 2276 uint64_t cluster_time) |
2277 { | 2277 { |
2278 int res = 0; | 2278 int res = 0; |
2279 uint32_t id; | 2279 uint32_t id; |
2280 AVPacket *pkt; | 2280 AVPacket *pkt = NULL; |
2281 int is_keyframe = PKT_FLAG_KEY, last_num_packets = matroska->num_packets; | 2281 int is_keyframe = PKT_FLAG_KEY, last_num_packets = matroska->num_packets; |
2282 uint64_t duration = AV_NOPTS_VALUE; | |
2283 int track = -1; | |
2282 | 2284 |
2283 av_log(matroska->ctx, AV_LOG_DEBUG, "parsing blockgroup...\n"); | 2285 av_log(matroska->ctx, AV_LOG_DEBUG, "parsing blockgroup...\n"); |
2284 | 2286 |
2285 while (res == 0) { | 2287 while (res == 0) { |
2286 if (!(id = ebml_peek_id(matroska, &matroska->level_up))) { | 2288 if (!(id = ebml_peek_id(matroska, &matroska->level_up))) { |
2298 case MATROSKA_ID_BLOCK: { | 2300 case MATROSKA_ID_BLOCK: { |
2299 uint8_t *data, *origdata; | 2301 uint8_t *data, *origdata; |
2300 int size; | 2302 int size; |
2301 int16_t block_time; | 2303 int16_t block_time; |
2302 uint32_t *lace_size = NULL; | 2304 uint32_t *lace_size = NULL; |
2303 int n, track, flags, laces = 0; | 2305 int n, flags, laces = 0; |
2304 uint64_t num; | 2306 uint64_t num; |
2305 int64_t pos= url_ftell(&matroska->ctx->pb); | 2307 int64_t pos= url_ftell(&matroska->ctx->pb); |
2306 | 2308 |
2307 if ((res = ebml_read_binary(matroska, &id, &data, &size)) < 0) | 2309 if ((res = ebml_read_binary(matroska, &id, &data, &size)) < 0) |
2308 break; | 2310 break; |
2452 av_free(origdata); | 2454 av_free(origdata); |
2453 break; | 2455 break; |
2454 } | 2456 } |
2455 | 2457 |
2456 case MATROSKA_ID_BLOCKDURATION: { | 2458 case MATROSKA_ID_BLOCKDURATION: { |
2457 uint64_t num; | 2459 if ((res = ebml_read_uint(matroska, &id, &duration)) < 0) |
2458 if ((res = ebml_read_uint(matroska, &id, &num)) < 0) | 2460 break; |
2459 break; | |
2460 av_log(matroska->ctx, AV_LOG_INFO, | |
2461 "FIXME: implement support for BlockDuration\n"); | |
2462 break; | 2461 break; |
2463 } | 2462 } |
2464 | 2463 |
2465 case MATROSKA_ID_BLOCKREFERENCE: | 2464 case MATROSKA_ID_BLOCKREFERENCE: |
2466 /* We've found a reference, so not even the first frame in | 2465 /* We've found a reference, so not even the first frame in |
2483 | 2482 |
2484 if (matroska->level_up) { | 2483 if (matroska->level_up) { |
2485 matroska->level_up--; | 2484 matroska->level_up--; |
2486 break; | 2485 break; |
2487 } | 2486 } |
2487 } | |
2488 | |
2489 if (pkt) | |
2490 { | |
2491 if (duration != AV_NOPTS_VALUE) | |
2492 pkt->duration = duration; | |
2493 else if (track >= 0 && track < matroska->num_tracks) | |
2494 pkt->duration = matroska->tracks[track]->default_duration / matroska->time_scale; | |
2488 } | 2495 } |
2489 | 2496 |
2490 return res; | 2497 return res; |
2491 } | 2498 } |
2492 | 2499 |