OSDN Git Service

fix a crash when a TS has no aspect ratio set in the video stream
authorjstebbins <jstebbins@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Tue, 14 Sep 2010 23:08:57 +0000 (23:08 +0000)
committerjstebbins <jstebbins@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Tue, 14 Sep 2010 23:08:57 +0000 (23:08 +0000)
git-svn-id: svn://localhost/HandBrake/trunk@3529 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/decavcodec.c
libhb/stream.c

index f5c4669..abf7ed1 100644 (file)
@@ -977,10 +977,11 @@ static int decavcodecvInfo( hb_work_object_t *w, hb_work_info_t *info )
         if ( info->pixel_aspect_width == 0 ||
              info->pixel_aspect_height == 0 )
         {
+            // There will not be an ffmpeg stream if the file is TS
             AVStream *st = hb_ffmpeg_avstream( w->codec_param );
-            info->pixel_aspect_width = st->sample_aspect_ratio.num ?
-                                        st->sample_aspect_ratio.num : 1;
-            info->pixel_aspect_height = st->sample_aspect_ratio.den ?
+            info->pixel_aspect_width = st && st->sample_aspect_ratio.num ?
+                                       st->sample_aspect_ratio.num : 1;
+            info->pixel_aspect_height = st && st->sample_aspect_ratio.den ?
                                         st->sample_aspect_ratio.den : 1;
         }
         /* ffmpeg returns the Pixel Aspect Ratio (PAR). Handbrake wants the
index 9166ace..58b2506 100644 (file)
@@ -2875,6 +2875,9 @@ static void ffmpeg_remap_stream( hb_stream_t *stream, hb_title_t *title )
 
 void *hb_ffmpeg_context( int codec_param )
 {
+    if ( ffmpeg_streams == NULL )
+        return NULL;
+
     int slot = codec_param & (ffmpeg_sl_size - 1);
     int stream_index = codec_param >> ffmpeg_sl_bits;
     return ffmpeg_streams[slot]->ffmpeg_ic->streams[stream_index]->codec;
@@ -2882,6 +2885,9 @@ void *hb_ffmpeg_context( int codec_param )
 
 void *hb_ffmpeg_avstream( int codec_param )
 {
+    if ( ffmpeg_streams == NULL )
+        return NULL;
+
     int slot = codec_param & (ffmpeg_sl_size - 1);
     int stream_index = codec_param >> ffmpeg_sl_bits;
     return ffmpeg_streams[slot]->ffmpeg_ic->streams[stream_index];