OSDN Git Service

LinGui: make Help->Guide work on windows/mingw
[handbrake-jp/handbrake-jp-git.git] / libhb / scan.c
index 1ae5de0..68188a2 100644 (file)
@@ -30,7 +30,7 @@ typedef struct
 
 static void ScanFunc( void * );
 static int  DecodePreviews( hb_scan_t *, hb_title_t * title );
-static int LookForAudio( hb_title_t * title, hb_buffer_t * b );
+static void LookForAudio( hb_title_t * title, hb_buffer_t * b );
 static int  AllAudioOK( hb_title_t * title );
 
 static const char *aspect_to_string( double aspect )
@@ -69,6 +69,7 @@ static void ScanFunc( void * _data )
     hb_scan_t  * data = (hb_scan_t *) _data;
     hb_title_t * title;
     int          i;
+    int          feature = 0;
 
        data->dvd = NULL;
        data->stream = NULL;
@@ -93,6 +94,7 @@ static void ScanFunc( void * _data )
                 hb_list_add( data->list_title,
                              hb_dvd_title_scan( data->dvd, i + 1 ) );
             }
+            feature = hb_dvd_main_feature( data->dvd, data->list_title );
         }
     }
     else if ( ( data->batch = hb_batch_init( data->path ) ) )
@@ -171,6 +173,22 @@ static void ScanFunc( void * _data )
             j++;
         }
 
+        if ( data->dvd )
+        {
+            // The subtitle width and height needs to be set to the 
+            // title widht and height for DVDs.  title width and
+            // height don't get set until we decode previews, so
+            // we can't set subtitle width/height till we get here.
+            for( j = 0; j < hb_list_count( title->list_subtitle ); j++ )
+            {
+                hb_subtitle_t *subtitle = hb_list_item( title->list_subtitle, j );
+                if ( subtitle->source == VOBSUB )
+                {
+                    subtitle->width = title->width;
+                    subtitle->height = title->height;
+                }
+            }
+        }
         i++;
     }
 
@@ -184,6 +202,7 @@ static void ScanFunc( void * _data )
         title->job = job;
 
         job->title = title;
+        job->feature = feature;
 
         /* Set defaults settings */
         job->chapter_start = 1;
@@ -518,11 +537,10 @@ static int DecodePreviews( hb_scan_t * data, hb_title_t * title )
                         vid_buf = NULL;
                     }
                 }
-                else 
+                else if( ! AllAudioOK( title ) ) 
                 {
-                    if( ! AllAudioOK( title ) )
-                        if ( !LookForAudio( title, buf_es ) )
-                            buf_es = NULL;
+                    LookForAudio( title, buf_es );
+                    buf_es = NULL;
                 }
                 if ( buf_es )
                     hb_buffer_close( &buf_es );
@@ -825,7 +843,7 @@ skip_preview:
  * aren't (e.g., some European DVD Teletext streams use the same IDs as US ATSC
  * AC-3 audio).
  */
-static int LookForAudio( hb_title_t * title, hb_buffer_t * b )
+static void LookForAudio( hb_title_t * title, hb_buffer_t * b )
 {
     int i;
 
@@ -846,7 +864,8 @@ static int LookForAudio( hb_title_t * title, hb_buffer_t * b )
     if( !audio || audio->config.in.bitrate != 0 )
     {
         /* not found or already done */
-        return 1;
+        hb_buffer_close( &b );
+        return;
     }
 
     if ( audio->priv.scan_cache == NULL )
@@ -884,7 +903,7 @@ static int LookForAudio( hb_title_t * title, hb_buffer_t * b )
     if ( !info.bitrate )
     {
         /* didn't find any info */
-        return 0;
+        return;
     }
     hb_fifo_flush( audio->priv.scan_cache );
     hb_fifo_close( &audio->priv.scan_cache );
@@ -917,7 +936,7 @@ static int LookForAudio( hb_title_t * title, hb_buffer_t * b )
             audio->config.lang.description );
  
     free( w );
-    return 1;
+    return;
 
     // We get here if there's no hope of finding info on an audio bitstream,
     // either because we don't have a decoder (or a decoder with a bitstream
@@ -932,7 +951,7 @@ static int LookForAudio( hb_title_t * title, hb_buffer_t * b )
     hb_fifo_flush( audio->priv.scan_cache );
     hb_fifo_close( &audio->priv.scan_cache );
     hb_list_rem( title->list_audio, audio );
-    return -1;
+    return;
 }
 
 /*