diff options
author | Thierry Foucu <tfoucu@gmail.com> | 2011-05-11 16:36:39 -0700 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-05-12 14:37:50 +0200 |
commit | b7903ab16b7c17fa09497632a0472ab3157574ed (patch) | |
tree | 54c24618aa5b25531e06b5287d51f0373931caff | |
parent | 612122b187d711257eecd517e4049cef3bb0b7f0 (diff) | |
download | ffmpeg-b7903ab16b7c17fa09497632a0472ab3157574ed.tar.gz |
If a MP3 file contains the string NSVs, the NSV probe will think it is a NSV file instead of a MP3 file. Check for 0xBEEF after a Video/Audio chunck for more accuracy.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavformat/nsvdec.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/libavformat/nsvdec.c b/libavformat/nsvdec.c index 4b294d3591..300a8fd7f8 100644 --- a/libavformat/nsvdec.c +++ b/libavformat/nsvdec.c @@ -737,6 +737,9 @@ static int nsv_read_close(AVFormatContext *s) static int nsv_probe(AVProbeData *p) { int i; + int score; + int vsize, asize, auxcount; + score = 0; av_dlog(NULL, "nsv_probe(), buf_size %d\n", p->buf_size); /* check file header */ /* streamed files might not have any header */ @@ -749,14 +752,25 @@ static int nsv_probe(AVProbeData *p) /* 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') - return AVPROBE_SCORE_MAX-20; + p->buf[i+2] == 'V' && p->buf[i+3] == 's') { + 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; + } + } } /* so we'll have more luck on extension... */ if (av_match_ext(p->filename, "nsv")) return AVPROBE_SCORE_MAX/2; /* FIXME: add mime-type check */ - return 0; + return score; } AVInputFormat ff_nsv_demuxer = { |