summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-10-28 11:01:18 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-10-28 11:01:18 +0000
commite5d30923d1a60dd3155b713f453184e7de93ee1b (patch)
tree0b3b0737e07fa3f78c060f437d3d1857ef38719d
parent267ed8021e5ea0d7e4e81445365bc10483d960a8 (diff)
downloadmpv-e5d30923d1a60dd3155b713f453184e7de93ee1b.tar.bz2
mpv-e5d30923d1a60dd3155b713f453184e7de93ee1b.tar.xz
Cleanup/simplify nsv check_file function.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@20489 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r--libmpdemux/demux_nsv.c29
1 files changed, 7 insertions, 22 deletions
diff --git a/libmpdemux/demux_nsv.c b/libmpdemux/demux_nsv.c
index 6341abd7ca..0987aa29b9 100644
--- a/libmpdemux/demux_nsv.c
+++ b/libmpdemux/demux_nsv.c
@@ -285,36 +285,21 @@ static demuxer_t* demux_open_nsv ( demuxer_t* demuxer )
static int nsv_check_file ( demuxer_t* demuxer )
{
- unsigned char hdr;
+ uint32_t hdr = 0;
int i;
- /* Store original position */
-// off_t orig_pos = stream_tell(demuxer->stream);
-
mp_msg ( MSGT_DEMUX, MSGL_V, "Checking for Nullsoft Streaming Video\n" );
for (i = 0; i < HEADER_SEARCH_SIZE; i++) {
- if (stream_read_char(demuxer->stream) != 'N')
- continue;
- if(stream_eof(demuxer->stream))
- return 0;
-
- if (stream_read_char(demuxer->stream) != 'S')
- continue;
- if(stream_eof(demuxer->stream))
- return 0;
- if (stream_read_char(demuxer->stream) != 'V')
- continue;
- if(stream_eof(demuxer->stream))
- return 0;
-
- hdr = stream_read_char(demuxer->stream);
- if(stream_eof(demuxer->stream))
+ uint8_t c = stream_read_char(demuxer->stream);
+ if (stream_eof(demuxer->stream))
return 0;
- if((hdr == 'f') || (hdr == 's')) {
- stream_seek(demuxer->stream,stream_tell(demuxer->stream)-4);
+ if (hdr == mmioFOURCC('s', 'V', 'S', 'N') ||
+ (hdr == mmioFOURCC('f', 'V', 'S', 'N') && !c)) {
+ stream_seek(demuxer->stream,stream_tell(demuxer->stream)-5);
return DEMUXER_TYPE_NSV;
}
+ hdr = (hdr << 8) | c;
}
return 0;