summaryrefslogtreecommitdiff
path: root/libavformat/mpeg.c
diff options
context:
space:
mode:
authorAlex Converse <alex.converse@gmail.com>2011-09-28 15:43:24 -0700
committerAlex Converse <alex.converse@gmail.com>2011-09-29 09:45:57 -0700
commitfe21f78d2bf1ac5b5400570a8a4031be3493aa7d (patch)
tree63d1a63a184240d2a904a766181af88ef29499f6 /libavformat/mpeg.c
parentbf00a73ace9b1aba790b75dcb26d43adfceb769f (diff)
mpeg probe: check the 2/4-bit synchronization value found after a pack_start_code.
Diffstat (limited to 'libavformat/mpeg.c')
-rw-r--r--libavformat/mpeg.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
index f797da7e27..ef683b1a05 100644
--- a/libavformat/mpeg.c
+++ b/libavformat/mpeg.c
@@ -49,6 +49,10 @@ static int check_pes(uint8_t *p, uint8_t *end){
return pes1||pes2;
}
+static int check_pack_header(const uint8_t *buf) {
+ return (buf[1] & 0xC0) == 0x40 || (buf[1] & 0xF0) == 0x20;
+}
+
static int mpegps_probe(AVProbeData *p)
{
uint32_t code= -1;
@@ -61,9 +65,10 @@ static int mpegps_probe(AVProbeData *p)
if ((code & 0xffffff00) == 0x100) {
int len= p->buf[i+1] << 8 | p->buf[i+2];
int pes= check_pes(p->buf+i, p->buf+p->buf_size);
+ int pack = check_pack_header(p->buf+i);
if(code == SYSTEM_HEADER_START_CODE) sys++;
- else if(code == PACK_START_CODE) pspack++;
+ else if(code == PACK_START_CODE && pack) pspack++;
else if((code & 0xf0) == VIDEO_ID && pes) vid++;
// skip pes payload to avoid start code emulation for private
// and audio streams