Commit 0a3caa41 authored by bellard's avatar bellard

avoid too many false detections


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@1537 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent acfc0cbe
...@@ -405,28 +405,31 @@ static int mpeg_mux_end(AVFormatContext *ctx) ...@@ -405,28 +405,31 @@ static int mpeg_mux_end(AVFormatContext *ctx)
static int mpegps_probe(AVProbeData *p) static int mpegps_probe(AVProbeData *p)
{ {
int code, c, i; int code;
code = 0xff; const uint8_t *d;
/* we search the first start code. If it is a packet start code, /* we search the first start code. If it is a packet start code,
then we decide it is mpeg ps. We do not send highest value to then we decide it is mpeg ps. We do not send highest value to
give a chance to mpegts */ give a chance to mpegts */
for(i=0;i<p->buf_size;i++) { /* NOTE: the search range was restricted to avoid too many false
c = p->buf[i]; detections */
code = (code << 8) | c;
if ((code & 0xffffff00) == 0x100) { if (p->buf_size < 6)
if (code == PACK_START_CODE || return 0;
code == SYSTEM_HEADER_START_CODE || d = p->buf;
(code >= 0x1e0 && code <= 0x1ef) || code = (d[0] << 24) | (d[1] << 16) | (d[2] << 8) | (d[3]);
(code >= 0x1c0 && code <= 0x1df) || if ((code & 0xffffff00) == 0x100) {
code == PRIVATE_STREAM_2 || if (code == PACK_START_CODE ||
code == PROGRAM_STREAM_MAP || code == SYSTEM_HEADER_START_CODE ||
code == PRIVATE_STREAM_1 || (code >= 0x1e0 && code <= 0x1ef) ||
code == PADDING_STREAM) (code >= 0x1c0 && code <= 0x1df) ||
return AVPROBE_SCORE_MAX - 1; code == PRIVATE_STREAM_2 ||
else code == PROGRAM_STREAM_MAP ||
return 0; code == PRIVATE_STREAM_1 ||
} code == PADDING_STREAM)
return AVPROBE_SCORE_MAX - 1;
else
return 0;
} }
return 0; return 0;
} }
......
...@@ -153,23 +153,26 @@ static int video_read_header(AVFormatContext *s, ...@@ -153,23 +153,26 @@ static int video_read_header(AVFormatContext *s,
/* XXX: improve that by looking at several start codes */ /* XXX: improve that by looking at several start codes */
static int mpegvideo_probe(AVProbeData *p) static int mpegvideo_probe(AVProbeData *p)
{ {
int code, c, i; int code;
code = 0xff; const uint8_t *d;
/* we search the first start code. If it is a sequence, gop or /* we search the first start code. If it is a sequence, gop or
picture start code then we decide it is an mpeg video picture start code then we decide it is an mpeg video
stream. We do not send highest value to give a chance to mpegts */ stream. We do not send highest value to give a chance to mpegts */
for(i=0;i<p->buf_size;i++) { /* NOTE: the search range was restricted to avoid too many false
c = p->buf[i]; detections */
code = (code << 8) | c;
if ((code & 0xffffff00) == 0x100) { if (p->buf_size < 6)
if (code == SEQ_START_CODE || return 0;
code == GOP_START_CODE || d = p->buf;
code == PICTURE_START_CODE) code = (d[0] << 24) | (d[1] << 16) | (d[2] << 8) | (d[3]);
return 50 - 1; if ((code & 0xffffff00) == 0x100) {
else if (code == SEQ_START_CODE ||
return 0; code == GOP_START_CODE ||
} code == PICTURE_START_CODE)
return 50 - 1;
else
return 0;
} }
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment