comparison libmpdemux/demux_nsv.c @ 20473:6ebbcbeae8c1

Cleanup/simplify nsv check_file function.
author reimar
date Sat, 28 Oct 2006 11:01:18 +0000
parents 054516eecb9b
children 4d81dbdf46b9
comparison
equal deleted inserted replaced
20472:e7474c33f072 20473:6ebbcbeae8c1
283 return demuxer; 283 return demuxer;
284 } 284 }
285 285
286 static int nsv_check_file ( demuxer_t* demuxer ) 286 static int nsv_check_file ( demuxer_t* demuxer )
287 { 287 {
288 unsigned char hdr; 288 uint32_t hdr = 0;
289 int i; 289 int i;
290
291 /* Store original position */
292 // off_t orig_pos = stream_tell(demuxer->stream);
293 290
294 mp_msg ( MSGT_DEMUX, MSGL_V, "Checking for Nullsoft Streaming Video\n" ); 291 mp_msg ( MSGT_DEMUX, MSGL_V, "Checking for Nullsoft Streaming Video\n" );
295 292
296 for (i = 0; i < HEADER_SEARCH_SIZE; i++) { 293 for (i = 0; i < HEADER_SEARCH_SIZE; i++) {
297 if (stream_read_char(demuxer->stream) != 'N') 294 uint8_t c = stream_read_char(demuxer->stream);
298 continue; 295 if (stream_eof(demuxer->stream))
299 if(stream_eof(demuxer->stream))
300 return 0; 296 return 0;
301 297 if (hdr == mmioFOURCC('s', 'V', 'S', 'N') ||
302 if (stream_read_char(demuxer->stream) != 'S') 298 (hdr == mmioFOURCC('f', 'V', 'S', 'N') && !c)) {
303 continue; 299 stream_seek(demuxer->stream,stream_tell(demuxer->stream)-5);
304 if(stream_eof(demuxer->stream))
305 return 0;
306 if (stream_read_char(demuxer->stream) != 'V')
307 continue;
308 if(stream_eof(demuxer->stream))
309 return 0;
310
311 hdr = stream_read_char(demuxer->stream);
312 if(stream_eof(demuxer->stream))
313 return 0;
314 if((hdr == 'f') || (hdr == 's')) {
315 stream_seek(demuxer->stream,stream_tell(demuxer->stream)-4);
316 return DEMUXER_TYPE_NSV; 300 return DEMUXER_TYPE_NSV;
317 } 301 }
302 hdr = (hdr << 8) | c;
318 } 303 }
319 304
320 return 0; 305 return 0;
321 } 306 }
322 307