Skip to content
Snippets Groups Projects
Commit 45faf7fc authored by Thierry Foucu's avatar Thierry Foucu Committed by Diego Biurrun
Browse files

nsv: Fix misdetection of MP3 files as NSV.


If an MP3 file contains the string NSVs, the NSV probe will confuse it for an
NSV file. Check for 0xBEEF after a Video/Audio chunk to achieve more accuracy.

Signed-off-by: default avatarDiego Biurrun <diego@biurrun.de>
parent b3bbc6fd
No related branches found
No related tags found
No related merge requests found
...@@ -737,6 +737,9 @@ static int nsv_read_close(AVFormatContext *s) ...@@ -737,6 +737,9 @@ static int nsv_read_close(AVFormatContext *s)
static int nsv_probe(AVProbeData *p) static int nsv_probe(AVProbeData *p)
{ {
int i; int i;
int score;
int vsize, asize, auxcount;
score = 0;
av_dlog(NULL, "nsv_probe(), buf_size %d\n", p->buf_size); av_dlog(NULL, "nsv_probe(), buf_size %d\n", p->buf_size);
/* check file header */ /* check file header */
/* streamed files might not have any header */ /* streamed files might not have any header */
...@@ -749,14 +752,25 @@ static int nsv_probe(AVProbeData *p) ...@@ -749,14 +752,25 @@ static int nsv_probe(AVProbeData *p)
/* sometimes even the first header is at 9KB or something :^) */ /* sometimes even the first header is at 9KB or something :^) */
for (i = 1; i < p->buf_size - 3; i++) { for (i = 1; i < p->buf_size - 3; i++) {
if (p->buf[i+0] == 'N' && p->buf[i+1] == 'S' && if (p->buf[i+0] == 'N' && p->buf[i+1] == 'S' &&
p->buf[i+2] == 'V' && p->buf[i+3] == 's') p->buf[i+2] == 'V' && p->buf[i+3] == 's') {
return AVPROBE_SCORE_MAX-20; 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... */ /* so we'll have more luck on extension... */
if (av_match_ext(p->filename, "nsv")) if (av_match_ext(p->filename, "nsv"))
return AVPROBE_SCORE_MAX/2; return AVPROBE_SCORE_MAX/2;
/* FIXME: add mime-type check */ /* FIXME: add mime-type check */
return 0; return score;
} }
AVInputFormat ff_nsv_demuxer = { AVInputFormat ff_nsv_demuxer = {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment