Mercurial > libavformat.hg
changeset 5157:a74bea5a7084 libavformat
Search for ipmovie signature beyond the start of the file.
This allows to play directly files that combine player and movie into
a single executable like http://samples.mplayerhq.hu/game-formats/interplay-mve/DES3S.EXE
author | reimar |
---|---|
date | Sat, 05 Sep 2009 15:41:32 +0000 |
parents | 6c50f319725d |
children | 26ba0ebacbb2 |
files | ipmovie.c |
diffstat | 1 files changed, 16 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/ipmovie.c Sat Sep 05 11:30:55 2009 +0000 +++ b/ipmovie.c Sat Sep 05 15:41:32 2009 +0000 @@ -501,10 +501,14 @@ static int ipmovie_probe(AVProbeData *p) { - if (memcmp(p->buf, signature, sizeof(signature)) != 0) - return 0; + uint8_t *b = p->buf; + uint8_t *b_end = p->buf + p->buf_size - sizeof(signature); + do { + if (memcmp(b++, signature, sizeof(signature)) == 0) + return AVPROBE_SCORE_MAX; + } while (b < b_end); - return AVPROBE_SCORE_MAX; + return 0; } static int ipmovie_read_header(AVFormatContext *s, @@ -516,14 +520,22 @@ AVStream *st; unsigned char chunk_preamble[CHUNK_PREAMBLE_SIZE]; int chunk_type; + uint8_t signature_buffer[sizeof(signature)]; + get_buffer(pb, signature_buffer, sizeof(signature_buffer)); + while (memcmp(signature_buffer, signature, sizeof(signature))) { + memmove(signature_buffer, signature_buffer + 1, sizeof(signature_buffer) - 1); + signature_buffer[sizeof(signature_buffer) - 1] = get_byte(pb); + if (url_feof(pb)) + return AVERROR_EOF; + } /* initialize private context members */ ipmovie->video_pts = ipmovie->audio_frame_count = 0; ipmovie->audio_chunk_offset = ipmovie->video_chunk_offset = ipmovie->decode_map_chunk_offset = 0; /* on the first read, this will position the stream at the first chunk */ - ipmovie->next_chunk_offset = sizeof(signature) + 4; + ipmovie->next_chunk_offset = url_ftell(pb) + 4; /* process the first chunk which should be CHUNK_INIT_VIDEO */ if (process_ipmovie_chunk(ipmovie, pb, &pkt) != CHUNK_INIT_VIDEO)