summaryrefslogtreecommitdiffstats
path: root/libhb
diff options
context:
space:
mode:
authoreddyg <eddyg.hb@myreflection.org>2009-06-21 22:12:36 +0000
committereddyg <eddyg.hb@myreflection.org>2009-06-21 22:12:36 +0000
commit63d590ca6b884e309bc6af1379af7882281d25e4 (patch)
tree9a424d2b72c854b0fbf3be3b2fce3d2c163979dc /libhb
parent56314be38d30d4784aac574b25d0248d3593b052 (diff)
Moved --native-langauge processing from libhb to the CLI. Added --native-dub option to allow the user to request dubbing instead of subtitles when the audio does not match the users native language.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2594 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rw-r--r--libhb/common.h1
-rw-r--r--libhb/hb.c82
-rw-r--r--libhb/work.c55
3 files changed, 29 insertions, 109 deletions
diff --git a/libhb/common.h b/libhb/common.h
index ccd065c15..488004f7a 100644
--- a/libhb/common.h
+++ b/libhb/common.h
@@ -248,7 +248,6 @@ struct hb_job_s
int indepth_scan;
hb_subtitle_config_t select_subtitle_config;
- char * native_language;
int angle; // dvd angle to encode
int frame_to_stop; // declare eof when we hit this frame
diff --git a/libhb/hb.c b/libhb/hb.c
index e554a4d2c..df04aea3e 100644
--- a/libhb/hb.c
+++ b/libhb/hb.c
@@ -1014,7 +1014,7 @@ void hb_add( hb_handle_t * h, hb_job_t * job )
title_copy->list_subtitle = hb_list_init();
/*
- * The following code is confusing, there are three ways in which
+ * The following code is confusing, there are two ways in which
* we select subtitles and it depends on whether this is single or
* two pass mode.
*
@@ -1022,17 +1022,13 @@ void hb_add( hb_handle_t * h, hb_job_t * job )
* scans all subtitles of that language. The second pass does not
* select any because they are set at the end of the first pass.
*
- * native_language may have a preferred language, in which case we
- * may be switching the language we want for the subtitles in the
- * first pass of a single pass, or the second pass of a two pass.
- *
* We may have manually selected a subtitle, in which case that is
* selected in the first pass of a single pass, or the second of a
* two pass.
*/
memset( audio_lang, 0, sizeof( audio_lang ) );
- if ( job->indepth_scan || job->native_language ) {
+ if ( job->indepth_scan ) {
/*
* Find the first audio language that is being encoded
@@ -1045,35 +1041,6 @@ void hb_add( hb_handle_t * h, hb_job_t * job )
break;
}
}
-
- /*
- * In all cases switch the language if we need to to our native
- * language.
- */
- if( job->native_language )
- {
- if( strncasecmp( job->native_language, audio_lang,
- sizeof( audio_lang ) ) != 0 )
- {
-
- if( job->pass != 2 )
- {
- 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 subtitles to use our native language instead.
- */
- strncpy( audio_lang, job->native_language, sizeof( audio_lang ) );
- } else {
- /*
- * native language is irrelevent, free it.
- */
- free( job->native_language );
- job->native_language = NULL;
- }
- }
}
/*
@@ -1098,14 +1065,6 @@ 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->native_language ) {
- /*
- * With native language just select the
- * first match in our langiage, not all of
- * them. Subsequent ones are likely to be commentary
- */
- break;
- }
}
}
} else {
@@ -1113,46 +1072,17 @@ void hb_add( hb_handle_t * h, hb_job_t * job )
* Not doing a subtitle scan in this pass, but maybe we are in the
* first pass?
*/
- if( job->pass != 1 && job->native_language )
+ if( job->pass != 1 )
{
/*
- * We are not doing a subtitle scan but do want the
- * native langauge subtitle selected, so select it
- * for pass 0 or pass 2 of a two pass.
+ * Copy all of them from the input job, to the title_copy/job_copy.
*/
- for( i=0; i < hb_list_count( title->list_subtitle ); i++ )
- {
- subtitle = hb_list_item( title->list_subtitle, i );
- if( strcmp( subtitle->iso639_2, audio_lang ) == 0 )
+ for( i = 0; i < hb_list_count(job->list_subtitle); i++ ) {
+ if( ( subtitle = hb_list_item( job->list_subtitle, i ) ) )
{
- /*
- * Matched subtitle language with audio language, so
- * add this to our list to scan.
- */
subtitle_copy = malloc( sizeof( hb_subtitle_t ) );
memcpy( subtitle_copy, subtitle, sizeof( hb_subtitle_t ) );
hb_list_add( title_copy->list_subtitle, subtitle_copy );
- break;
- }
- }
- } else {
- /*
- * Manually selected subtitles, in which case only
- * bother adding them for pass 0 or pass 2 of a two
- * pass.
- */
- if( job->pass != 1 )
- {
- /*
- * Copy all of them from the input job, to the title_copy/job_copy.
- */
- for( i = 0; i < hb_list_count(job->list_subtitle); i++ ) {
- if( ( subtitle = hb_list_item( job->list_subtitle, i ) ) )
- {
- 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 55ce36fc0..486b8a305 100644
--- a/libhb/work.c
+++ b/libhb/work.c
@@ -1002,41 +1002,32 @@ cleanup:
}
}
- if( job->native_language ) {
+
+ if( subtitle_forced_id )
+ {
/*
- * We still have a native_language, so the audio and subtitles are
- * different, so in this case it is a foreign film and we want to
- * select the subtitle with the highest hits in our language.
+ * If there are any subtitle streams with forced subtitles
+ * then select it in preference to the lowest.
*/
- subtitle_hit = subtitle_highest_id;
- hb_log( "Found a native-language subtitle id 0x%x", subtitle_hit);
- } else {
- if( subtitle_forced_id )
- {
- /*
- * If there are any subtitle streams with forced subtitles
- * then select it in preference to the lowest.
- */
- subtitle_hit = subtitle_forced_id;
- hb_log("Found a subtitle candidate id 0x%x (contains forced subs)",
- subtitle_hit);
- } else if( subtitle_lowest < subtitle_highest )
+ subtitle_hit = subtitle_forced_id;
+ hb_log("Found a subtitle candidate id 0x%x (contains forced subs)",
+ subtitle_hit);
+ } else if( subtitle_lowest < subtitle_highest )
+ {
+ /*
+ * 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 10% as a default.
+ */
+ if( subtitle_lowest < ( subtitle_highest * 0.1 ) )
{
- /*
- * 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 10% as a default.
- */
- if( subtitle_lowest < ( subtitle_highest * 0.1 ) )
- {
- subtitle_hit = subtitle_lowest_id;
- hb_log( "Found a subtitle candidate id 0x%x",
- subtitle_hit );
- } else {
- hb_log( "No candidate subtitle detected during subtitle-scan");
- }
+ subtitle_hit = subtitle_lowest_id;
+ hb_log( "Found a subtitle candidate id 0x%x",
+ subtitle_hit );
+ } else {
+ hb_log( "No candidate subtitle detected during subtitle-scan");
}
}
}