[FFmpeg-devel] [PATCH 1/2] nsv: simplify probe function
Aurelien Jacobs
aurel at gnuage.org
Sun May 15 23:04:58 CEST 2011
---
libavformat/nsvdec.c | 24 +++++++++---------------
1 files changed, 9 insertions(+), 15 deletions(-)
diff --git a/libavformat/nsvdec.c b/libavformat/nsvdec.c
index 300a8fd..dacfd1f 100644
--- a/libavformat/nsvdec.c
+++ b/libavformat/nsvdec.c
@@ -20,6 +20,7 @@
*/
#include "avformat.h"
#include "riff.h"
+#include "libavutil/intreadwrite.h"
//#define DEBUG
//#define DEBUG_DUMP_INDEX // XXX dumbdriving-271.nsv breaks with it commented!!
@@ -736,10 +737,8 @@ static int nsv_read_close(AVFormatContext *s)
static int nsv_probe(AVProbeData *p)
{
- int i;
- int score;
- int vsize, asize, auxcount;
- score = 0;
+ int i, vsize, asize, score = 0;
+
av_dlog(NULL, "nsv_probe(), buf_size %d\n", p->buf_size);
/* check file header */
/* streamed files might not have any header */
@@ -751,19 +750,14 @@ static int nsv_probe(AVProbeData *p)
/* seems the servers don't bother starting clean chunks... */
/* sometimes even the first header is at 9KB or something :^) */
for (i = 1; i < p->buf_size - 3; i++) {
- if (p->buf[i+0] == 'N' && p->buf[i+1] == 'S' &&
- p->buf[i+2] == 'V' && p->buf[i+3] == 's') {
+ if (AV_RL32(p->buf + i) == AV_RL32("NSVs")) {
score = AVPROBE_SCORE_MAX/5;
/* Get the chunk size and check if at the end we are getting 0xBEEF */
- auxcount = p->buf[i+19];
- vsize = p->buf[i+20] | p->buf[i+21] << 8;
- asize = p->buf[i+22] | p->buf[i+23] << 8;
- vsize = (vsize << 4) | (auxcount >> 4);
- if ((asize + vsize + i + 23) < p->buf_size - 2) {
- if (p->buf[i+23+asize+vsize+1] == 0xEF &&
- p->buf[i+23+asize+vsize+2] == 0xBE)
- return AVPROBE_SCORE_MAX-20;
- }
+ vsize = AV_RL24(p->buf+i+19) >> 4;
+ asize = AV_RL16(p->buf+i+22);
+ if ((asize + vsize + i + 23) < p->buf_size - 2
+ && AV_RL16(p->buf+i+23+asize+vsize+1) == 0xBEEF)
+ return 4*AVPROBE_SCORE_MAX/5;
}
}
/* so we'll have more luck on extension... */
--
1.7.5.1
More information about the ffmpeg-devel
mailing list