[FFmpeg-cvslog] r19769 - trunk/libavformat/ipmovie.c

reimar subversion
Sat Sep 5 17:41:32 CEST 2009


Author: reimar
Date: Sat Sep  5 17:41:32 2009
New Revision: 19769

Log:
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

Modified:
   trunk/libavformat/ipmovie.c

Modified: trunk/libavformat/ipmovie.c
==============================================================================
--- trunk/libavformat/ipmovie.c	Sat Sep  5 13:30:55 2009	(r19768)
+++ trunk/libavformat/ipmovie.c	Sat Sep  5 17:41:32 2009	(r19769)
@@ -501,10 +501,14 @@ static const char signature[] = "Interpl
 
 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(AVFormatC
     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)



More information about the ffmpeg-cvslog mailing list