summaryrefslogtreecommitdiffstats
path: root/libhb
diff options
context:
space:
mode:
authorsaintdev <[email protected]>2007-07-06 03:14:08 +0000
committersaintdev <[email protected]>2007-07-06 03:14:08 +0000
commit57ccb9bd7ccd5431c2865de38862ac2ec8503059 (patch)
tree31be11d7af513fd7a341ed236db28e3624bae47e /libhb
parenta2c19bd698fc4d2af2ae4002daf73ed4d6d36295 (diff)
Fixes to the CLI for forced subtitles, and Turbo.
-Fixes a bug in the HB CLI whereby you can't use the native-language switch to enable subtitles when doing single pass. -Changes the threshold for enabling subtitles automatically during a subtitle scan from 20% to 10%. -Changes the turbo options to match what the GUI is doing. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@650 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rw-r--r--libhb/hb.c82
-rw-r--r--libhb/work.c5
2 files changed, 48 insertions, 39 deletions
diff --git a/libhb/hb.c b/libhb/hb.c
index 0550c3cac..0b0c515af 100644
--- a/libhb/hb.c
+++ b/libhb/hb.c
@@ -510,6 +510,7 @@ void hb_add( hb_handle_t * h, hb_job_t * job )
hb_audio_t * audio, * audio_copy;
hb_subtitle_t * subtitle, * subtitle_copy;
int i;
+ char audio_lang[4];
/* Copy the title */
title = job->title;
@@ -548,60 +549,39 @@ void hb_add( hb_handle_t * h, hb_job_t * job )
title_copy->list_subtitle = hb_list_init();
- if( job->pass != 1 )
- {
- /* Copy the subtitle we want (or not)
- */
- if( ( subtitle = hb_list_item( title->list_subtitle, job->subtitle ) ) )
- {
- subtitle_copy = malloc( sizeof( hb_subtitle_t ) );
- memcpy( subtitle_copy, subtitle, sizeof( hb_subtitle_t ) );
- hb_list_add( title_copy->list_subtitle, subtitle_copy );
- }
- } else {
- char audio_lang[4];
- memset( audio_lang, 0, sizeof( audio_lang ) );
+ memset( audio_lang, 0, sizeof( audio_lang ) );
+ if ( job->subtitle_scan || job->native_language ) {
+
/*
- * Pass 1, do we want to do a subtitle scan?
+ * Find the first audio language that is being encoded
*/
- if( job->subtitle_scan )
+ for( i = 0; i < 8; i++ )
{
- /*
- * Search for all occurances of the audio language in the
- * subtitles and add them all to the
- * title_copy->list_subtitle. First of all find the
- * language for the audio.
- */
- for( i = 0; i < 8; i++ )
+ if( job->audios[i] < 0 )
{
- if( job->audios[i] < 0 )
- {
- break;
- }
- if( ( audio = hb_list_item( title->list_audio, job->audios[i] ) ) )
- {
- strncpy(audio_lang, audio->iso639_2, sizeof(audio_lang));
- }
+ break;
+ }
+ if( ( audio = hb_list_item( title->list_audio, job->audios[i] ) ) )
+ {
+ strncpy(audio_lang, audio->iso639_2, sizeof(audio_lang));
+ break;
}
}
- /*
- * If we have a native language now is the time to see whether we want
- * to enable subtitles for it if it differs from the audio language.
- */
+
if( job->native_language )
{
if( strncasecmp( job->native_language, audio_lang,
sizeof( audio_lang ) ) != 0 )
{
-
+
hb_log( "Enabled subtitles in native language '%s', audio is in '%s'",
job->native_language, audio_lang);
/*
* The main audio track is not in our native language, so switch
- * the subtitle scan to use our native language instead.
+ * the subtitles to use our native language instead.
*/
strncpy( audio_lang, job->native_language, sizeof( audio_lang ) );
} else {
@@ -612,7 +592,13 @@ void hb_add( hb_handle_t * h, hb_job_t * job )
job->native_language = NULL;
}
}
-
+ }
+
+ if ( job->subtitle_scan || job->native_language )
+ {
+ /*
+ * Select subtitles that match the language we want
+ */
for( i=0; i < hb_list_count( title->list_subtitle ); i++ )
{
subtitle = hb_list_item( title->list_subtitle, i );
@@ -625,6 +611,28 @@ void hb_add( hb_handle_t * h, hb_job_t * job )
subtitle_copy = malloc( sizeof( hb_subtitle_t ) );
memcpy( subtitle_copy, subtitle, sizeof( hb_subtitle_t ) );
hb_list_add( title_copy->list_subtitle, subtitle_copy );
+ if ( !job->subtitle_scan ) {
+ /*
+ * With native language just select the
+ * first match in our langiage, not all of
+ * them.
+ */
+ break;
+ }
+ }
+ }
+ } else {
+ /*
+ * Manually selected subtitle, in which case only bother adding them
+ * for pass 0 or pass 2 of a two pass.
+ */
+ if( job->pass != 1 )
+ {
+ if( ( subtitle = hb_list_item( title->list_subtitle, job->subtitle ) ) )
+ {
+ subtitle_copy = malloc( sizeof( hb_subtitle_t ) );
+ memcpy( subtitle_copy, subtitle, sizeof( hb_subtitle_t ) );
+ hb_list_add( title_copy->list_subtitle, subtitle_copy );
}
}
}
diff --git a/libhb/work.c b/libhb/work.c
index b7d02cd5c..92707cc42 100644
--- a/libhb/work.c
+++ b/libhb/work.c
@@ -194,6 +194,7 @@ static void do_job( hb_job_t * job, int cpu_count )
w->fifo_in = job->fifo_render;
w->fifo_out = job->fifo_mpeg4;
w->config = &job->config;
+
hb_list_add( job->list_work, w );
if( job->select_subtitle && !job->subtitle_scan )
@@ -573,9 +574,9 @@ static void do_job( hb_job_t * job, int cpu_count )
* OK we have more than one, and the lowest is lower, but how much
* lower to qualify for turning it on by default?
*
- * Let's say 20% as a default.
+ * Let's say 10% as a default.
*/
- if( subtitle_lowest < ( subtitle_highest * 0.2 ) )
+ if( subtitle_lowest < ( subtitle_highest * 0.1 ) )
{
subtitle_hit = subtitle_lowest_id;
hb_log( "Found a subtitle candidate id 0x%x",