Commit 61e8efd3 authored by Reimar Döffinger's avatar Reimar Döffinger

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
parent 78bfe6c3
......@@ -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 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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment