diff options
author | Fabrice Bellard <fabrice@bellard.org> | 2003-02-02 20:04:03 +0000 |
---|---|---|
committer | Fabrice Bellard <fabrice@bellard.org> | 2003-02-02 20:04:03 +0000 |
commit | fa7773216ad6091edbabfc2d3d2a3ef4f6128094 (patch) | |
tree | 40d174b439383a35af8bf9ab15040523d6df27b8 /libavformat/raw.c | |
parent | 4c7e86192937f9477532cd593b6a27f1f2fe9566 (diff) | |
download | ffmpeg-fa7773216ad6091edbabfc2d3d2a3ef4f6128094.tar.gz |
avoid too many false detections
Originally committed as revision 1537 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/raw.c')
-rw-r--r-- | libavformat/raw.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/libavformat/raw.c b/libavformat/raw.c index 70185f8e42..e5cae2ff67 100644 --- a/libavformat/raw.c +++ b/libavformat/raw.c @@ -153,23 +153,26 @@ static int video_read_header(AVFormatContext *s, /* XXX: improve that by looking at several start codes */ static int mpegvideo_probe(AVProbeData *p) { - int code, c, i; - code = 0xff; + int code; + const uint8_t *d; /* we search the first start code. If it is a sequence, gop or picture start code then we decide it is an mpeg video stream. We do not send highest value to give a chance to mpegts */ - for(i=0;i<p->buf_size;i++) { - c = p->buf[i]; - code = (code << 8) | c; - if ((code & 0xffffff00) == 0x100) { - if (code == SEQ_START_CODE || - code == GOP_START_CODE || - code == PICTURE_START_CODE) - return 50 - 1; - else - return 0; - } + /* NOTE: the search range was restricted to avoid too many false + detections */ + + if (p->buf_size < 6) + return 0; + d = p->buf; + code = (d[0] << 24) | (d[1] << 16) | (d[2] << 8) | (d[3]); + if ((code & 0xffffff00) == 0x100) { + if (code == SEQ_START_CODE || + code == GOP_START_CODE || + code == PICTURE_START_CODE) + return 50 - 1; + else + return 0; } return 0; } |