]> granicus.if.org Git - handbrake/commitdiff
merge fix for TS streams that have no PAT or PMT to bug fix branch
authorjstebbins <jstebbins.hb@gmail.com>
Fri, 30 Mar 2012 18:32:03 +0000 (18:32 +0000)
committerjstebbins <jstebbins.hb@gmail.com>
Fri, 30 Mar 2012 18:32:03 +0000 (18:32 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/branches/0.9.x@4561 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/stream.c

index bf9a76ff8108f12d8d2610c0d60042e776720ee1..a60b0d3cdbad318523fb66fd4a80f9aa15e999b3 100644 (file)
@@ -250,10 +250,10 @@ static void hb_stream_duration(hb_stream_t *stream, hb_title_t *inTitle);
 static off_t align_to_next_packet(hb_stream_t *stream);
 static int64_t pes_timestamp( const uint8_t *pes );
 
-static void hb_ts_stream_init(hb_stream_t *stream);
+static int hb_ts_stream_init(hb_stream_t *stream);
 static hb_buffer_t * hb_ts_stream_decode(hb_stream_t *stream);
 static void hb_init_audio_list(hb_stream_t *stream, hb_title_t *title);
-static void hb_ts_stream_find_pids(hb_stream_t *stream);
+static int hb_ts_stream_find_pids(hb_stream_t *stream);
 
 static void hb_ps_stream_init(hb_stream_t *stream);
 static hb_buffer_t * hb_ps_stream_decode(hb_stream_t *stream);
@@ -614,10 +614,10 @@ static int hb_stream_get_type(hb_stream_t *stream)
                    " offset %d bytes", psize, offset);
             stream->packetsize = psize;
             stream->hb_stream_type = transport;
-            hb_ts_stream_init(stream);
-            return 1;
+            if (hb_ts_stream_init(stream) == 0)
+                return 1;
         }
-        if ( hb_stream_check_for_ps(stream) != 0 )
+        else if ( hb_stream_check_for_ps(stream) != 0 )
         {
             hb_log("file is MPEG Program Stream");
             stream->hb_stream_type = program;
@@ -2133,7 +2133,7 @@ static void hb_init_audio_list(hb_stream_t *stream, hb_title_t *title)
  *
  **********************************************************************/
 
-static void hb_ts_stream_init(hb_stream_t *stream)
+static int hb_ts_stream_init(hb_stream_t *stream)
 {
     int i;
 
@@ -2161,7 +2161,10 @@ static void hb_ts_stream_init(hb_stream_t *stream)
     stream->ts.packet = malloc( stream->packetsize );
 
     // Find the audio and video pids in the stream
-    hb_ts_stream_find_pids(stream);
+    if (hb_ts_stream_find_pids(stream) < 0)
+    {
+        return -1;
+    }
 
     // hb_ts_resolve_pid_types reads some data, so the TS buffers
     // are needed here.
@@ -2229,6 +2232,7 @@ static void hb_ts_stream_init(hb_stream_t *stream)
                 hb_stream_delete_ts_entry(stream, i);
         }
     }
+    return 0;
 }
 
 static void hb_ps_stream_init(hb_stream_t *stream)
@@ -3831,7 +3835,6 @@ static void hb_ps_stream_find_streams(hb_stream_t *stream)
         }
         hb_stream_seek( stream, 0.2 );
     }
-done:
     hb_buffer_close( &buf );
 }
 
@@ -4260,7 +4263,7 @@ static void hb_ps_resolve_stream_types(hb_stream_t *stream)
 }
 
 
-static void hb_ts_stream_find_pids(hb_stream_t *stream)
+static int hb_ts_stream_find_pids(hb_stream_t *stream)
 {
     // To be different from every other broadcaster in the world, New Zealand TV
     // changes PMTs (and thus video & audio PIDs) when 'programs' change. Since
@@ -4289,8 +4292,8 @@ static void hb_ts_stream_find_pids(hb_stream_t *stream)
 
         if ((pid == 0x0000) && (stream->ts_number_pat_entries == 0))
         {
-          decode_PAT(buf, stream);
-          continue;
+            decode_PAT(buf, stream);
+            continue;
         }
 
         int pat_index = 0;
@@ -4315,16 +4318,21 @@ static void hb_ts_stream_find_pids(hb_stream_t *stream)
             if (stream->pat_info[pat_index].program_number != 0 &&
                 pid == stream->pat_info[pat_index].program_map_PID)
             {
-              if (build_program_map(buf, stream) > 0)
-                break;
+                if (build_program_map(buf, stream) > 0)
+                {
+                    break;
+                }
             }
         }
         // Keep going  until we have a complete set of PIDs
         if ( ts_index_of_video( stream ) >= 0 )
           break;
     }
+    if ( ts_index_of_video( stream ) < 0 )
+        return -1;
     update_ts_streams( stream, stream->pmt_info.PCR_PID, 0, -1, P, NULL );
- }
+    return 0;
+}
 
 
 // convert a PES PTS or DTS to an int64