OSDN Git Service

- To reliably find audio in 720p or 1080i TS streams we need to search through first...
authorvan <van@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Mon, 18 Aug 2008 06:15:17 +0000 (06:15 +0000)
committervan <van@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Mon, 18 Aug 2008 06:15:17 +0000 (06:15 +0000)
 - When we're looking for a PES header for some PID, check both that the TS 'start' bit is set and that the first 3 data bytes are an MPEG start code (the start bit may get set by an error not caught by the CRC).
 - Print the substream id when we reject a PID as "not audio" so we'll be able to debug TS streams using non-standard PES encapsulations.

git-svn-id: svn://localhost/HandBrake/trunk@1642 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/stream.c

index 90b7ae3..930af30 100755 (executable)
@@ -727,7 +727,7 @@ static void skip_to_next_pack( hb_stream_t *src_stream )
  */
 static const uint8_t *hb_ts_stream_getPEStype(hb_stream_t *stream, uint32_t pid)
 {
-    int npack = 100000; // max packets to read
+    int npack = 300000; // max packets to read
 
     while (--npack >= 0)
     {
@@ -766,7 +766,11 @@ static const uint8_t *hb_ts_stream_getPEStype(hb_stream_t *stream, uint32_t pid)
                 udata += buf[4] + 1;
                 break;
         }
-        return &buf[udata];
+        /* PES hdr has to begin with an mpeg start code */
+        if (buf[udata+0] == 0x00 && buf[udata+1] == 0x00 && buf[udata+2] == 0x01)
+        {
+            return &buf[udata];
+        }
     }
 
     /* didn't find it */
@@ -1185,9 +1189,18 @@ static hb_audio_t *hb_ts_stream_set_audio_id_and_codec(hb_stream_t *stream,
     }
     else
     {
-        hb_log("transport stream pid 0x%x (type 0x%x) isn't audio",
-                stream->ts_audio_pids[aud_pid_index],
-                stream->ts_stream_type[1 + aud_pid_index]);
+        if ( buf )
+        {
+            hb_log("transport stream pid 0x%x (type 0x%x, substream 0x%x) "
+                    "isn't audio", stream->ts_audio_pids[aud_pid_index],
+                    stream->ts_stream_type[1 + aud_pid_index], buf[3]);
+        }
+        else
+        {
+            hb_log("transport stream pid 0x%x (type 0x%x) isn't audio",
+                    stream->ts_audio_pids[aud_pid_index],
+                    stream->ts_stream_type[1 + aud_pid_index]);
+        }
        }
     fseeko(stream->file_handle, cur_pos, SEEK_SET);
     return audio;