Mercurial > libavformat.hg
comparison matroska.c @ 2014:de75a5a81f28 libavformat
add support for seeking to a keyframe instead of a random frame
author | aurel |
---|---|
date | Mon, 09 Apr 2007 17:03:20 +0000 |
parents | fc0b19650faa |
children | a698d9aa78f2 |
comparison
equal
deleted
inserted
replaced
2013:fc0b19650faa | 2014:de75a5a81f28 |
---|---|
341 done; | 341 done; |
342 | 342 |
343 /* The index for seeking. */ | 343 /* The index for seeking. */ |
344 int num_indexes; | 344 int num_indexes; |
345 MatroskaDemuxIndex *index; | 345 MatroskaDemuxIndex *index; |
346 | |
347 /* What to skip before effectively reading a packet. */ | |
348 int skip_to_keyframe; | |
349 AVStream *skip_to_stream; | |
346 } MatroskaDemuxContext; | 350 } MatroskaDemuxContext; |
347 | 351 |
348 /* | 352 /* |
349 * The first few functions handle EBML file parsing. The rest | 353 * The first few functions handle EBML file parsing. The rest |
350 * is the document interpretation. Matroska really just is a | 354 * is the document interpretation. Matroska really just is a |
2434 flags = *data; | 2438 flags = *data; |
2435 data += 1; | 2439 data += 1; |
2436 size -= 1; | 2440 size -= 1; |
2437 if (is_keyframe == -1) | 2441 if (is_keyframe == -1) |
2438 is_keyframe = flags & 1 ? PKT_FLAG_KEY : 0; | 2442 is_keyframe = flags & 1 ? PKT_FLAG_KEY : 0; |
2443 | |
2444 if (matroska->skip_to_keyframe) { | |
2445 if (!is_keyframe || st != matroska->skip_to_stream) | |
2446 return res; | |
2447 matroska->skip_to_keyframe = 0; | |
2448 } | |
2449 | |
2439 switch ((flags & 0x06) >> 1) { | 2450 switch ((flags & 0x06) >> 1) { |
2440 case 0x0: /* no lacing */ | 2451 case 0x0: /* no lacing */ |
2441 laces = 1; | 2452 laces = 1; |
2442 lace_size = av_mallocz(sizeof(int)); | 2453 lace_size = av_mallocz(sizeof(int)); |
2443 lace_size[0] = size; | 2454 lace_size[0] = size; |
2780 if (index < 0) | 2791 if (index < 0) |
2781 return 0; | 2792 return 0; |
2782 | 2793 |
2783 /* do the seek */ | 2794 /* do the seek */ |
2784 url_fseek(&s->pb, st->index_entries[index].pos, SEEK_SET); | 2795 url_fseek(&s->pb, st->index_entries[index].pos, SEEK_SET); |
2796 matroska->skip_to_keyframe = !(flags & AVSEEK_FLAG_ANY); | |
2797 matroska->skip_to_stream = st; | |
2785 matroska->num_packets = 0; | 2798 matroska->num_packets = 0; |
2786 matroska->peek_id = 0; | 2799 matroska->peek_id = 0; |
2787 return 0; | 2800 return 0; |
2788 } | 2801 } |
2789 | 2802 |