diff options
author | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2009-09-05 19:41:32 +0400 |
---|---|---|
committer | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2009-09-05 19:41:32 +0400 |
commit | 61e8efd35eb3045300003ded688accd0f1207028 (patch) | |
tree | 6ead8b7fd08f7f7e6f29066d03f8a80c26ef151b | |
parent | 78bfe6c3c1708f9ef1ef74596f88015c194784fa (diff) |
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
Originally committed as revision 19769 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavformat/ipmovie.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/libavformat/ipmovie.c b/libavformat/ipmovie.c index 0552605a5d..c9b506a3ef 100644 --- a/libavformat/ipmovie.c +++ b/libavformat/ipmovie.c @@ -501,10 +501,14 @@ static const char signature[] = "Interplay MVE File\x1A\0\x1A"; 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 @@ static int ipmovie_read_header(AVFormatContext *s, 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) |