OSDN Git Service

Don't reject MPEG PS files just because they're missing a SYS header (clips won't...
authorvan <van@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Thu, 11 Dec 2008 01:06:43 +0000 (01:06 +0000)
committervan <van@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Thu, 11 Dec 2008 01:06:43 +0000 (01:06 +0000)
git-svn-id: svn://localhost/HandBrake/trunk@2018 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/stream.c

index 8e66c85..abe827e 100755 (executable)
@@ -301,14 +301,13 @@ static int check_ps_sync(const uint8_t *buf)
            (buf[2] == 0x01) && (buf[3] == 0xba);
 }
 
-static int check_ps_sys(const uint8_t *buf)
+static int check_ps_sc(const uint8_t *buf)
 {
     // a legal MPEG program stream must start with a Pack followed by a
-    // SYS. If we've already verified the pack, this skips over it and checks
-    // for the sys header.
+    // some other start code. If we've already verified the pack, this skip
+    // it and checks for a start code prefix.
     int pos = 14 + ( buf[13] & 0x7 );   // skip over the PACK
-    return (buf[pos+0] == 0x00) && (buf[pos+1] == 0x00) &&
-           (buf[pos+2] == 0x01) && (buf[pos+3] == 0xbb);
+    return (buf[pos+0] == 0x00) && (buf[pos+1] == 0x00) && (buf[pos+2] == 0x01);
 }
 
 static int check_ts_sync(const uint8_t *buf)
@@ -348,8 +347,9 @@ static int hb_stream_check_for_ts(const uint8_t *buf)
 
 static int hb_stream_check_for_ps(const uint8_t *buf)
 {
-    // program streams should start with a PACK then a SYS header.
-    return check_ps_sync(buf) && check_ps_sys(buf);
+    // program streams should start with a PACK then some other mpeg start
+    // code (usually a SYS but that might be missing if we only have a clip).
+    return check_ps_sync(buf) && check_ps_sc(buf);
 }
 
 static int hb_stream_check_for_dvd_ps(const uint8_t *buf)