summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2009-06-02 15:32:01 +0000
committerjstebbins <[email protected]>2009-06-02 15:32:01 +0000
commitb1fcb3154f5c09a81e0cf712fad9d22f4e8e89bc (patch)
tree263ef770c5316bd112024f2a688c272c69f5b528
parent8868e9649a2ff1c60a3334e00418bba92eb67f70 (diff)
softsubtitles:
- when doing an indepth scan, do not scan CC tracks - separate subtitle configureation attributes into separate hb_subtitle_config_t. Add an instance of this to hb_job_t for setting the attributes of the subtitle found through an indepth scan - Add a default_track flag to hb_subtitle_config_t that tells the muxer that the track should be flaged as the default. muxmkv uses this. - When an indepth scan is complete, check to see if the autoselected subtitle matchces (by id) one of the manually selected subtitles. If a match is found, the autoselected subtitle with all the attributes the user assigned to it replaces the manually selected subtitle. - LinGui: Add "Default" column to subtitle tab. This is a radio that lets the user choose which subtitle should be displayed by default. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2468 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r--gtk/src/hb-backend.c62
-rw-r--r--gtk/src/internal_defaults.xml2
-rw-r--r--gtk/src/main.c19
-rw-r--r--gtk/src/presets.c2
-rw-r--r--gtk/src/subtitlehandler.c104
-rw-r--r--libhb/common.h22
-rw-r--r--libhb/decmpeg2.c2
-rw-r--r--libhb/decvobsub.c4
-rw-r--r--libhb/dvd.c2
-rw-r--r--libhb/dvdnav.c2
-rw-r--r--libhb/hb.c66
-rw-r--r--libhb/muxcommon.c2
-rw-r--r--libhb/muxmkv.c6
-rw-r--r--libhb/muxmp4.c2
-rw-r--r--libhb/reader.c2
-rw-r--r--libhb/sync.c8
-rw-r--r--libhb/work.c97
-rw-r--r--macosx/Controller.mm4
-rw-r--r--test/test.c6
19 files changed, 286 insertions, 128 deletions
diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c
index 3fbc03ad3..fa38a20ce 100644
--- a/gtk/src/hb-backend.c
+++ b/gtk/src/hb-backend.c
@@ -1992,6 +1992,7 @@ ghb_add_all_subtitles(signal_user_data_t *ud, gint titleindex)
ghb_settings_set_int(subdict, "SubtitleTrack", -1);
ghb_settings_set_boolean(subdict, "SubtitleForced", FALSE);
ghb_settings_set_boolean(subdict, "SubtitleBurned", FALSE);
+ ghb_settings_set_boolean(subdict, "SubtitleDefaultTrack", FALSE);
ghb_settings_set_string(subdict, "SubtitleLanguage", "auto");
ghb_add_subtitle(ud, subdict, FALSE);
@@ -2004,6 +2005,7 @@ ghb_add_all_subtitles(signal_user_data_t *ud, gint titleindex)
ghb_settings_set_int(subdict, "SubtitleTrack", ii);
ghb_settings_set_boolean(subdict, "SubtitleForced", FALSE);
ghb_settings_set_boolean(subdict, "SubtitleBurned", FALSE);
+ ghb_settings_set_boolean(subdict, "SubtitleDefaultTrack", FALSE);
ghb_settings_set_string(subdict, "SubtitleLanguage",
subtitle->iso639_2);
ghb_add_subtitle(ud, subdict, FALSE);
@@ -3913,18 +3915,8 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex)
job->cfr = 1;
}
- // First remove any audios that are already in the list
- // This happens if you are encoding the same title a second time.
- gint num_audio_tracks = hb_list_count(job->list_audio);
- gint ii;
- for(ii = 0; ii < num_audio_tracks; ii++)
- {
- hb_audio_t *audio = (hb_audio_t*)hb_list_item(job->list_audio, 0);
- hb_list_rem(job->list_audio, audio);
- }
-
const GValue *audio_list;
- gint count;
+ gint count, ii;
gint tcount = 0;
audio_list = ghb_settings_get_value(js, "audio_list");
@@ -4043,12 +4035,13 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex)
const GValue *subtitle_list;
gint subtitle;
+ job->select_subtitle = NULL;
subtitle_list = ghb_settings_get_value(js, "subtitle_list");
count = ghb_array_len(subtitle_list);
for (ii = 0; ii < count; ii++)
{
GValue *ssettings;
- gboolean burned, enabled, one_burned = FALSE;
+ gboolean enabled, force, burned, def, one_burned = FALSE;
ssettings = ghb_array_get_nth(subtitle_list, ii);
@@ -4058,11 +4051,33 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex)
continue;
subtitle = ghb_settings_get_int(ssettings, "SubtitleTrack");
+ force = ghb_settings_get_boolean(ssettings, "SubtitleForced");
burned = ghb_settings_get_boolean(ssettings, "SubtitleBurned");
+ def = ghb_settings_get_boolean(ssettings, "SubtitleDefaultTrack");
if (subtitle == -1)
{
+ if (!burned && job->mux == HB_MUX_MKV)
+ {
+ job->select_subtitle_config.dest = PASSTHRUSUB;
+ }
+ else if (!burned && job->mux == HB_MUX_MP4)
+ {
+ // Skip any non-burned vobsubs when output is mp4
+ continue;
+ }
+ else
+ {
+ // Only allow one subtitle to be burned into the video
+ if (one_burned)
+ continue;
+ one_burned = TRUE;
+ }
+ job->select_subtitle_config.force = force;
+ job->select_subtitle_config.default_track = def;
job->indepth_scan = 1;
+ job->select_subtitle = malloc(sizeof(hb_subtitle_t*));
+ *job->select_subtitle = NULL;
}
else if (subtitle >= 0)
{
@@ -4074,7 +4089,7 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex)
if (!burned && job->mux == HB_MUX_MKV &&
subt->format == PICTURESUB)
{
- subt->dest = PASSTHRUSUB;
+ subt->config.dest = PASSTHRUSUB;
}
else if (!burned && job->mux == HB_MUX_MP4 &&
subt->format == PICTURESUB)
@@ -4089,7 +4104,8 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex)
continue;
one_burned = TRUE;
}
- subt->force = ghb_settings_get_boolean(ssettings, "SubtitleForced");
+ subt->config.force = force;
+ subt->config.default_track = def;
hb_list_add(job->list_subtitle, subt);
}
}
@@ -4110,8 +4126,6 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex)
x264opts_tmp = job->x264opts;
job->x264opts = NULL;
- job->select_subtitle = malloc(sizeof(hb_subtitle_t*));
- *(job->select_subtitle) = NULL;
/*
* Add the pre-scan job
@@ -4123,10 +4137,7 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex)
job->x264opts = x264opts_tmp;
}
- else
- {
- job->select_subtitle = NULL;
- }
+
if( ghb_settings_get_boolean(js, "VideoTwoPass") &&
!ghb_settings_get_boolean(js, "vquality_type_constant"))
{
@@ -4198,6 +4209,17 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex)
//if (job->x264opts != NULL)
// g_free(job->x264opts);
}
+
+ // First remove any audios that are already in the list
+ // This happens if you are encoding the same title a second time.
+ gint num_audio_tracks = hb_list_count(job->list_audio);
+ for(ii = 0; ii < num_audio_tracks; ii++)
+ {
+ hb_audio_t *audio = (hb_audio_t*)hb_list_item(job->list_audio, 0);
+ hb_list_rem(job->list_audio, audio);
+ free(audio);
+ }
+
if (detel_str) g_free(detel_str);
if (decomb_str) g_free(decomb_str);
if (deint_str) g_free(deint_str);
diff --git a/gtk/src/internal_defaults.xml b/gtk/src/internal_defaults.xml
index 3349c30c6..a216f73aa 100644
--- a/gtk/src/internal_defaults.xml
+++ b/gtk/src/internal_defaults.xml
@@ -277,6 +277,8 @@
<true />
<key>SubtitleBurned</key>
<true />
+ <key>SubtitleDefaultTrack</key>
+ <false />
</dict>
</array>
<key>VideoTurboTwoPass</key>
diff --git a/gtk/src/main.c b/gtk/src/main.c
index ef0dc18c2..7331c0b7e 100644
--- a/gtk/src/main.c
+++ b/gtk/src/main.c
@@ -384,6 +384,7 @@ extern G_MODULE_EXPORT void subtitle_list_selection_changed_cb(void);
extern G_MODULE_EXPORT void subtitle_enable_toggled_cb(void);
extern G_MODULE_EXPORT void subtitle_forced_toggled_cb(void);
extern G_MODULE_EXPORT void subtitle_burned_toggled_cb(void);
+extern G_MODULE_EXPORT void subtitle_default_toggled_cb(void);
extern G_MODULE_EXPORT void subtitle_track_changed_cb(void);
// Create and bind the tree model to the tree view for the subtitle track list
@@ -403,16 +404,17 @@ bind_subtitle_tree_model (signal_user_data_t *ud)
selection = gtk_tree_view_get_selection (treeview);
// 6 columns in model. 4 are visible, the other 2 is for storing
// values that I need
- treestore = gtk_list_store_new(7,
+ // Enable, Track, force, burn, default, type, track short, can delete
+ treestore = gtk_list_store_new(8,
G_TYPE_BOOLEAN, G_TYPE_STRING,
G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
- G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_BOOLEAN);
+ G_TYPE_BOOLEAN, G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_BOOLEAN);
gtk_tree_view_set_model(treeview, GTK_TREE_MODEL(treestore));
cell = gtk_cell_renderer_toggle_new();
column = gtk_tree_view_column_new_with_attributes(
- _("On"), cell, "active", 0, NULL);
+ _("Enable"), cell, "active", 0, NULL);
gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column));
g_signal_connect(cell, "toggled", subtitle_enable_toggled_cb, ud);
@@ -438,9 +440,16 @@ bind_subtitle_tree_model (signal_user_data_t *ud)
gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column));
g_signal_connect(cell, "toggled", subtitle_burned_toggled_cb, ud);
+ cell = gtk_cell_renderer_toggle_new();
+ gtk_cell_renderer_toggle_set_radio(GTK_CELL_RENDERER_TOGGLE(cell), TRUE);
+ column = gtk_tree_view_column_new_with_attributes(
+ _("Default"), cell, "active", 4, NULL);
+ gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column));
+ g_signal_connect(cell, "toggled", subtitle_default_toggled_cb, ud);
+
cell = gtk_cell_renderer_text_new();
column = gtk_tree_view_column_new_with_attributes(
- _("Type"), cell, "text", 4, NULL);
+ _("Type"), cell, "text", 5, NULL);
gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column));
diff --git a/gtk/src/presets.c b/gtk/src/presets.c
index be028f6bc..505ce023e 100644
--- a/gtk/src/presets.c
+++ b/gtk/src/presets.c
@@ -2274,6 +2274,8 @@ import_value_xlat(GValue *dict)
}
ghb_dict_insert(sdict, g_strdup("SubtitleBurned"),
ghb_boolean_value_new(TRUE));
+ ghb_dict_insert(sdict, g_strdup("SubtitleDefaultTrack"),
+ ghb_boolean_value_new(FALSE));
}
else
{
diff --git a/gtk/src/subtitlehandler.c b/gtk/src/subtitlehandler.c
index 255da4744..c40e880e7 100644
--- a/gtk/src/subtitlehandler.c
+++ b/gtk/src/subtitlehandler.c
@@ -245,6 +245,40 @@ ghb_subtitle_exclusive_burn(signal_user_data_t *ud, gint track)
}
}
+void
+ghb_subtitle_exclusive_default(signal_user_data_t *ud, gint track)
+{
+ GValue *subtitle_list;
+ GValue *settings;
+ gint ii, count, tt;
+ GtkTreeView *tv;
+ GtkTreeModel *tm;
+ GtkTreeIter ti;
+ gboolean def;
+
+ g_debug("ghb_subtitle_exclusive_default");
+ subtitle_list = ghb_settings_get_value(ud->settings, "subtitle_list");
+ count = ghb_array_len(subtitle_list);
+ for (ii = 0; ii < count; ii++)
+ {
+ settings = ghb_array_get_nth(subtitle_list, ii);
+ tt = ghb_settings_combo_int(settings, "SubtitleTrack");
+ def = ghb_settings_get_boolean(settings, "SubtitleDefaultTrack");
+
+ tv = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "subtitle_list"));
+ g_return_if_fail(tv != NULL);
+ tm = gtk_tree_view_get_model(tv);
+ gtk_tree_model_iter_nth_child(tm, &ti, NULL, ii);
+ if (def && tt != track)
+ {
+
+ ghb_settings_set_boolean(settings, "SubtitleDefaultTrack", FALSE);
+ def = FALSE;
+ gtk_list_store_set(GTK_LIST_STORE(tm), &ti, 4, FALSE, -1);
+ }
+ }
+}
+
G_MODULE_EXPORT void
subtitle_enable_toggled_cb(
GtkCellRendererToggle *cell,
@@ -395,6 +429,53 @@ subtitle_burned_toggled_cb(
ghb_subtitle_exclusive_burn(ud, track);
}
+G_MODULE_EXPORT void
+subtitle_default_toggled_cb(
+ GtkCellRendererToggle *cell,
+ gchar *path,
+ signal_user_data_t *ud)
+{
+ GtkTreeView *tv;
+ GtkTreeModel *tm;
+ GtkTreeIter ti;
+ GtkTreePath *tp;
+ gboolean active;
+ gint row;
+ gint *indices;
+ GValue *subtitle_list;
+ gint count, track;
+ GValue *settings;
+
+ g_debug("default toggled");
+ tp = gtk_tree_path_new_from_string (path);
+ tv = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "subtitle_list"));
+ g_return_if_fail(tv != NULL);
+ tm = gtk_tree_view_get_model(tv);
+ g_return_if_fail(tm != NULL);
+ gtk_tree_model_get_iter(tm, &ti, tp);
+ gtk_tree_model_get(tm, &ti, 4, &active, -1);
+ active ^= 1;
+
+ // Get the row number
+ indices = gtk_tree_path_get_indices (tp);
+ row = indices[0];
+ gtk_tree_path_free(tp);
+
+ subtitle_list = ghb_settings_get_value(ud->settings, "subtitle_list");
+ count = ghb_array_len(subtitle_list);
+ if (row < 0 || row >= count)
+ return;
+
+ settings = ghb_array_get_nth(subtitle_list, row);
+ track = ghb_settings_combo_int(settings, "SubtitleTrack");
+
+ ghb_settings_set_boolean(settings, "SubtitleDefaultTrack", active);
+
+ gtk_list_store_set(GTK_LIST_STORE(tm), &ti, 4, active, -1);
+ // allow only one default
+ ghb_subtitle_exclusive_default(ud, track);
+}
+
static gboolean
trackUsed(signal_user_data_t *ud, gint track)
{
@@ -484,9 +565,9 @@ subtitle_track_changed_cb(
// These are displayed in list
1, track,
3, burned,
- 4, source,
+ 5, source,
// These are used to set combo values when a list item is selected
- 5, s_track,
+ 6, s_track,
-1);
g_free(s_track);
ghb_live_reset(ud);
@@ -586,7 +667,7 @@ add_to_subtitle_list(
GtkListStore *store;
GtkTreeSelection *selection;
const gchar *track, *source;
- gboolean forced, burned, enabled;
+ gboolean forced, burned, enabled, def;
gchar *s_track;
gint i_track;
@@ -599,6 +680,7 @@ add_to_subtitle_list(
enabled = ghb_settings_get_boolean(settings, "SubtitleEnabled");
forced = ghb_settings_get_boolean(settings, "SubtitleForced");
burned = ghb_settings_get_boolean(settings, "SubtitleBurned");
+ def = ghb_settings_get_boolean(settings, "SubtitleDefaultTrack");
s_track = ghb_settings_get_string(settings, "SubtitleTrack");
i_track = ghb_settings_get_int(settings, "SubtitleTrack");
@@ -611,10 +693,11 @@ add_to_subtitle_list(
1, track,
2, forced,
3, burned,
- 4, source,
+ 4, def,
+ 5, source,
// These are used to set combo box values when a list item is selected
- 5, s_track,
- 6, can_delete,
+ 6, s_track,
+ 7, can_delete,
-1);
gtk_tree_selection_select_iter(selection, &iter);
g_free(s_track);
@@ -635,7 +718,7 @@ subtitle_list_selection_changed_cb(GtkTreeSelection *selection, signal_user_data
const gchar *track;
gboolean can_delete;
- gtk_tree_model_get(store, &iter, 5, &track, 6, &can_delete, -1);
+ gtk_tree_model_get(store, &iter, 6, &track, 7, &can_delete, -1);
ghb_settings_set_string(ud->settings, "SubtitleTrack", track);
if (can_delete)
@@ -749,7 +832,7 @@ ghb_set_subtitle(signal_user_data_t *ud, gint track, GValue *settings)
GValue *slist;
GValue *subtitle;
gint count, ii, tt;
- gboolean forced, burned, enabled;
+ gboolean enabled, forced, burned, def;
g_debug("ghb_set_subtitle");
slist = ghb_settings_get_value(ud->settings, "subtitle_list");
@@ -765,6 +848,7 @@ ghb_set_subtitle(signal_user_data_t *ud, gint track, GValue *settings)
enabled = ghb_settings_get_boolean(settings, "SubtitleEnabled");
forced = ghb_settings_get_boolean(settings, "SubtitleForced");
burned = ghb_settings_get_boolean(settings, "SubtitleBurned");
+ def = ghb_settings_get_boolean(settings, "SubtitleDefaultTrack");
tv = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "subtitle_list"));
g_return_if_fail(tv != NULL);
@@ -774,11 +858,13 @@ ghb_set_subtitle(signal_user_data_t *ud, gint track, GValue *settings)
ghb_settings_set_boolean(subtitle, "SubtitleEnabled", enabled);
ghb_settings_set_boolean(subtitle, "SubtitleForced", forced);
ghb_settings_set_boolean(subtitle, "SubtitleBurned", burned);
+ ghb_settings_set_boolean(subtitle, "SubtitleDefaultTrack", def);
gtk_list_store_set(GTK_LIST_STORE(tm), &ti,
0, enabled,
2, forced,
3, burned,
- 6, FALSE,
+ 4, def,
+ 7, FALSE,
-1);
break;
}
diff --git a/libhb/common.h b/libhb/common.h
index 83460653a..b9e26682e 100644
--- a/libhb/common.h
+++ b/libhb/common.h
@@ -55,6 +55,7 @@ typedef struct hb_chapter_s hb_chapter_t;
typedef struct hb_audio_s hb_audio_t;
typedef struct hb_audio_config_s hb_audio_config_t;
typedef struct hb_subtitle_s hb_subtitle_t;
+typedef struct hb_subtitle_config_s hb_subtitle_config_t;
typedef struct hb_metadata_s hb_metadata_t;
typedef struct hb_state_s hb_state_t;
typedef union hb_esconfig_u hb_esconfig_t;
@@ -108,6 +109,13 @@ struct hb_mixdown_s
int amixdown;
};
+struct hb_subtitle_config_s
+{
+ enum subdest { RENDERSUB, PASSTHRUSUB } dest;
+ int force;
+ int default_track;
+};
+
#define HB_VIDEO_RATE_BASE 27000000
extern hb_rate_t hb_video_rates[];
@@ -235,9 +243,10 @@ struct hb_job_s
int mp4_optimize;
int ipod_atom;
- int indepth_scan;
- hb_subtitle_t ** select_subtitle;
- char * native_language;
+ int indepth_scan;
+ hb_subtitle_config_t select_subtitle_config;
+ hb_subtitle_t ** select_subtitle;
+ char * native_language;
int angle; // dvd angle to encode
int frame_to_stop; // declare eof when we hit this frame
@@ -439,12 +448,13 @@ struct hb_chapter_s
struct hb_subtitle_s
{
- int track;
int id;
+ int track;
+
+ hb_subtitle_config_t config;
+
enum subtype { PICTURESUB, TEXTSUB } format;
enum subsource { VOBSUB, SRTSUB, CC608SUB, CC708SUB } source;
- enum subdest { RENDERSUB, PASSTHRUSUB } dest;
- int force;
char lang[1024];
char iso639_2[4];
uint8_t type; /* Closed Caption, Childrens, Directors etc */
diff --git a/libhb/decmpeg2.c b/libhb/decmpeg2.c
index b719370e8..cd3c5a324 100644
--- a/libhb/decmpeg2.c
+++ b/libhb/decmpeg2.c
@@ -472,7 +472,7 @@ static int hb_libmpeg2_decode( hb_libmpeg2_t * m, hb_buffer_t * buf_es,
}
subtitle->format = TEXTSUB;
subtitle->source = CC608SUB;
- subtitle->dest = PASSTHRUSUB;
+ subtitle->config.dest = PASSTHRUSUB;
subtitle->type = 5;
hb_list_add( m->title->list_subtitle, subtitle );
diff --git a/libhb/decvobsub.c b/libhb/decvobsub.c
index e5633d54d..2a5ccab01 100644
--- a/libhb/decvobsub.c
+++ b/libhb/decvobsub.c
@@ -484,7 +484,7 @@ static hb_buffer_t * Decode( hb_work_object_t * w )
/* Get infos about the subtitle */
ParseControls( w );
- if( job->indepth_scan || ( w->subtitle->force && pv->pts_forced == 0 ) )
+ if( job->indepth_scan || ( w->subtitle->config.force && pv->pts_forced == 0 ) )
{
/*
* Don't encode subtitles when doing a scan.
@@ -495,7 +495,7 @@ static hb_buffer_t * Decode( hb_work_object_t * w )
return NULL;
}
- if (w->subtitle->dest == PASSTHRUSUB)
+ if (w->subtitle->config.dest == PASSTHRUSUB)
{
pv->buf->start = pv->pts_start;
pv->buf->stop = pv->pts_stop;
diff --git a/libhb/dvd.c b/libhb/dvd.c
index fc267778e..d07ccc61f 100644
--- a/libhb/dvd.c
+++ b/libhb/dvd.c
@@ -471,7 +471,7 @@ static hb_title_t * hb_dvdread_title_scan( hb_dvd_t * e, int t )
lang->iso639_2);
subtitle->format = PICTURESUB;
subtitle->source = VOBSUB;
- subtitle->dest = RENDERSUB; // By default render (burn-in) the VOBSUB.
+ subtitle->config.dest = RENDERSUB; // By default render (burn-in) the VOBSUB.
subtitle->type = lang_extension;
diff --git a/libhb/dvdnav.c b/libhb/dvdnav.c
index 589c9160e..2236f6d10 100644
--- a/libhb/dvdnav.c
+++ b/libhb/dvdnav.c
@@ -638,7 +638,7 @@ static hb_title_t * hb_dvdnav_title_scan( hb_dvd_t * e, int t )
lang->iso639_2);
subtitle->format = PICTURESUB;
subtitle->source = VOBSUB;
- subtitle->dest = RENDERSUB; // By default render (burn-in) the VOBSUB.
+ subtitle->config.dest = RENDERSUB; // By default render (burn-in) the VOBSUB.
subtitle->type = lang_extension;
diff --git a/libhb/hb.c b/libhb/hb.c
index c4045170c..9fdfe90f4 100644
--- a/libhb/hb.c
+++ b/libhb/hb.c
@@ -1066,7 +1066,8 @@ void hb_add( hb_handle_t * h, hb_job_t * job )
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 )
+ if( strcmp( subtitle->iso639_2, audio_lang ) == 0 &&
+ subtitle->source == VOBSUB )
{
/*
* Matched subtitle language with audio language, so
@@ -1093,56 +1094,45 @@ 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->select_subtitle )
+ if( job->pass != 1 && job->native_language )
{
/*
- * Don't add subtitles here, we'll add them via select_subtitle
- * at the end of the subtitle_scan.
+ * 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.
*/
+ 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 )
+ {
+ /*
+ * 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 {
/*
- * Definitely not doing a subtitle scan.
+ * Manually selected subtitles, in which case only
+ * bother adding them for pass 0 or pass 2 of a two
+ * 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/muxcommon.c b/libhb/muxcommon.c
index a404911af..da390c500 100644
--- a/libhb/muxcommon.c
+++ b/libhb/muxcommon.c
@@ -262,7 +262,7 @@ static void MuxerFunc( void * _mux )
{
hb_subtitle_t *subtitle = hb_list_item( title->list_subtitle, i );
- if (subtitle->dest != PASSTHRUSUB)
+ if (subtitle->config.dest != PASSTHRUSUB)
continue;
add_mux_track( mux, subtitle->fifo_out, subtitle->mux_data, 0 );
}
diff --git a/libhb/muxmkv.c b/libhb/muxmkv.c
index ace68f454..2e8814ca9 100644
--- a/libhb/muxmkv.c
+++ b/libhb/muxmkv.c
@@ -287,7 +287,7 @@ static int MKVInit( hb_mux_object_t * m )
int len;
subtitle = hb_list_item( title->list_subtitle, i );
- if (subtitle->dest != PASSTHRUSUB)
+ if (subtitle->config.dest != PASSTHRUSUB)
continue;
memset(track, 0, sizeof(mk_TrackConfig));
@@ -313,6 +313,10 @@ static int MKVInit( hb_mux_object_t * m )
default:
continue;
}
+ if ( subtitle->config.default_track )
+ {
+ track->flagDefault = 1;
+ }
mux_data = calloc(1, sizeof( hb_mux_data_t ) );
subtitle->mux_data = mux_data;
diff --git a/libhb/muxmp4.c b/libhb/muxmp4.c
index 1511713b3..cdb9ce7ae 100644
--- a/libhb/muxmp4.c
+++ b/libhb/muxmp4.c
@@ -408,7 +408,7 @@ static int MP4Init( hb_mux_object_t * m )
hb_subtitle_t *subtitle = hb_list_item( job->list_subtitle, i );
if( subtitle && subtitle->format == TEXTSUB &&
- subtitle->dest == PASSTHRUSUB )
+ subtitle->config.dest == PASSTHRUSUB )
{
uint64_t width, height = 60;
if( job->anamorphic.mode )
diff --git a/libhb/reader.c b/libhb/reader.c
index c865ea85f..9ac515c4e 100644
--- a/libhb/reader.c
+++ b/libhb/reader.c
@@ -527,7 +527,7 @@ static hb_fifo_t ** GetFifoForId( hb_job_t * job, int id )
subtitle = hb_list_item( title->list_subtitle, i );
if (id == subtitle->id) {
subtitle->hits++;
- if( !job->indepth_scan || subtitle->force )
+ if( !job->indepth_scan || subtitle->config.force )
{
/*
* Pass the subtitles to be processed if we are not scanning, or if
diff --git a/libhb/sync.c b/libhb/sync.c
index c4ef6d6df..8ae1b78e8 100644
--- a/libhb/sync.c
+++ b/libhb/sync.c
@@ -303,7 +303,7 @@ static void SyncVideo( hb_work_object_t * w )
for( i = 0; i < hb_list_count( job->list_subtitle ); i++)
{
subtitle = hb_list_item( job->list_subtitle, i );
- if( subtitle->dest == PASSTHRUSUB )
+ if( subtitle->config.dest == PASSTHRUSUB )
{
hb_fifo_push( subtitle->fifo_out, hb_buffer_init( 0 ) );
}
@@ -336,7 +336,7 @@ static void SyncVideo( hb_work_object_t * w )
for( i = 0; i < hb_list_count( job->list_subtitle ); i++)
{
subtitle = hb_list_item( job->list_subtitle, i );
- if( subtitle->dest == PASSTHRUSUB )
+ if( subtitle->config.dest == PASSTHRUSUB )
{
hb_fifo_push( subtitle->fifo_out, hb_buffer_init( 0 ) );
}
@@ -627,7 +627,7 @@ static void SyncVideo( hb_work_object_t * w )
{
if( sub->size > 0 )
{
- if( subtitle->dest == RENDERSUB )
+ if( subtitle->config.dest == RENDERSUB )
{
if ( cur->sub == NULL )
{
@@ -660,7 +660,7 @@ static void SyncVideo( hb_work_object_t * w )
/*
* EOF - consume for rendered, else pass through
*/
- if( subtitle->dest == RENDERSUB )
+ if( subtitle->config.dest == RENDERSUB )
{
sub = hb_fifo_get( subtitle->fifo_raw );
hb_buffer_close( &sub );
diff --git a/libhb/work.c b/libhb/work.c
index 848c798e4..5be4bdf9f 100644
--- a/libhb/work.c
+++ b/libhb/work.c
@@ -280,7 +280,7 @@ void hb_display_job_info( hb_job_t * job )
subtitle->source == VOBSUB ? "VOBSUB" :
((subtitle->source == CC608SUB ||
subtitle->source == CC708SUB) ? "CC" : "SRT"),
- subtitle->dest == RENDERSUB ? "Render/Burn in" : "Pass-Through");
+ subtitle->config.dest == RENDERSUB ? "Render/Burn in" : "Pass-Through");
}
}
@@ -466,18 +466,64 @@ static void do_job( hb_job_t * job, int cpu_count )
hb_list_add( job->list_work, w );
}
- if( job->select_subtitle && !job->indepth_scan )
+ /*
+ * Look for the scanned subtitle in the existing subtitle list
+ */
+ if ( !job->indepth_scan && job->select_subtitle && *(job->select_subtitle) )
{
/*
- * Must be second pass of a two pass with subtitle scan enabled, so
- * add the subtitle that we found on the first pass for use in this
- * pass.
+ * Disable forced subtitles if we didn't find any in the scan
+ * so that we display normal subtitles instead.
+ *
+ * select_subtitle implies that we did a scan.
*/
- if (*(job->select_subtitle))
+ if( (*job->select_subtitle)->config.force &&
+ (*job->select_subtitle)->forced_hits == 0 )
{
- hb_list_add( title->list_subtitle, *( job->select_subtitle ) );
+ (*job->select_subtitle)->config.force = 0;
+ }
+ for( i=0; i < hb_list_count(title->list_subtitle); i++ )
+ {
+ subtitle = hb_list_item( title->list_subtitle, i );
+
+ if( subtitle )
+ {
+ /*
+ * Disable forced subtitles if we didn't find any in the scan
+ * so that we display normal subtitles instead.
+ *
+ * select_subtitle implies that we did a scan.
+ */
+ if( (*job->select_subtitle)->id == subtitle->id )
+ {
+ *subtitle = *(*job->select_subtitle);
+ free( *job->select_subtitle );
+ free( job->select_subtitle );
+ job->select_subtitle = NULL;
+ }
+ }
+ }
+
+ if( job->select_subtitle )
+ {
+ /*
+ * Its not in the existing list
+ *
+ * Must be second pass of a two pass with subtitle scan enabled, so
+ * add the subtitle that we found on the first pass for use in this
+ * pass.
+ */
+ hb_list_add( title->list_subtitle, *job->select_subtitle );
+ free( job->select_subtitle );
+ job->select_subtitle = NULL;
}
}
+ else if ( !job->indepth_scan && job->select_subtitle )
+ {
+ free( job->select_subtitle );
+ job->select_subtitle = NULL;
+ }
+
for( i=0; i < hb_list_count(title->list_subtitle); i++ )
{
@@ -490,22 +536,7 @@ static void do_job( hb_job_t * job, int cpu_count )
subtitle->fifo_sync = hb_fifo_init( FIFO_CPU_MULT * cpu_count );
subtitle->fifo_out = hb_fifo_init( FIFO_CPU_MULT * cpu_count );
- /*
- * Disable forced subtitles if we didn't find any in the scan
- * so that we display normal subtitles instead.
- *
- * select_subtitle implies that we did a scan.
- */
- if( !job->indepth_scan && subtitle->force &&
- job->select_subtitle )
- {
- if( subtitle->forced_hits == 0 )
- {
- subtitle->force = 0;
- }
- }
-
- if( (!job->indepth_scan || subtitle->force) &&
+ if( (!job->indepth_scan || subtitle->config.force) &&
subtitle->source == VOBSUB ) {
/*
* Don't add threads for subtitles when we are scanning, unless
@@ -528,7 +559,7 @@ static void do_job( hb_job_t * job, int cpu_count )
if( !job->indepth_scan &&
subtitle->format == PICTURESUB
- && subtitle->dest == PASSTHRUSUB )
+ && subtitle->config.dest == PASSTHRUSUB )
{
/*
* Passing through a subtitle picture, this will have to
@@ -910,9 +941,14 @@ cleanup:
for( i=0; i < hb_list_count( title->list_subtitle ); i++ )
{
subtitle = hb_list_item( title->list_subtitle, i );
+
hb_log( "Subtitle stream 0x%x '%s': %d hits (%d forced)",
subtitle->id, subtitle->lang, subtitle->hits,
subtitle->forced_hits );
+
+ if( subtitle->hits == 0 )
+ continue;
+
if( subtitle->hits > subtitle_highest )
{
subtitle_highest = subtitle->hits;
@@ -982,19 +1018,12 @@ cleanup:
subtitle = hb_list_item( title->list_subtitle, i );
if( subtitle->id == subtitle_hit )
{
+ subtitle->config = job->select_subtitle_config;
hb_list_rem( title->list_subtitle, subtitle );
- *( job->select_subtitle ) = subtitle;
+ *job->select_subtitle = subtitle;
+ break;
}
}
- } else {
- /*
- * Must be the end of pass 0 or 2 - we don't need this anymore.
- *
- * Have to put the subtitle list back together in the title though
- * or the GUI will have a hissy fit.
- */
- free( job->select_subtitle );
- job->select_subtitle = NULL;
}
}
diff --git a/macosx/Controller.mm b/macosx/Controller.mm
index 7c64e2a3e..150d23381 100644
--- a/macosx/Controller.mm
+++ b/macosx/Controller.mm
@@ -3230,9 +3230,9 @@ fWorkingCount = 0;
hb_subtitle_t *subtitle = (hb_subtitle_t *) hb_list_item( title->list_subtitle,
[[queueToApply objectForKey:@"JobSubtitlesIndex"] intValue] - 2 );
if( [[queueToApply objectForKey:@"SubtitlesForced"] intValue] == 1 )
- subtitle->force = 1;
+ subtitle->config.force = 1;
else
- subtitle->force = 0;
+ subtitle->config.force = 0;
hb_list_add( job->list_subtitle, subtitle );
break;
}
diff --git a/test/test.c b/test/test.c
index ab08750e2..fc915d45e 100644
--- a/test/test.c
+++ b/test/test.c
@@ -1656,7 +1656,7 @@ static int HandleEvents( hb_handle_t * h )
subtitle = hb_list_item( title->list_subtitle, sub-1 );
if( subtitle ) {
if( subtitle_force ) {
- subtitle->force = subtitle_force;
+ subtitle->config.force = subtitle_force;
}
hb_list_add( job->list_subtitle, subtitle );
} else {
@@ -1750,6 +1750,10 @@ static int HandleEvents( hb_handle_t * h )
job->select_subtitle = malloc(sizeof(hb_subtitle_t*));
*(job->select_subtitle) = NULL;
+ job->select_subtitle_config.dest = RENDERSUB;
+ job->select_subtitle_config.default_track = 0;
+ job->select_subtitle_config.force = subtitle_force;
+
/*
* Add the pre-scan job
*/