summaryrefslogtreecommitdiffstats
path: root/gtk/src
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2009-09-09 22:30:15 +0000
committerjstebbins <[email protected]>2009-09-09 22:30:15 +0000
commit8d0214b7b44da8cb4c8a1c48ccef0bb3ecb441aa (patch)
tree71d9cf1517b79305942594a248399525583cdd82 /gtk/src
parent5e6d61bbaac7ffc9135c2132d6174bf7e078e912 (diff)
LinGui:
show the correct audio codec in the audio list when it has been changed because of incompatibility with source codec or output format git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2812 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'gtk/src')
-rw-r--r--gtk/src/audiohandler.c32
-rw-r--r--gtk/src/audiohandler.h1
-rw-r--r--gtk/src/callbacks.c1
-rw-r--r--gtk/src/hb-backend.c60
-rw-r--r--gtk/src/hb-backend.h2
5 files changed, 87 insertions, 9 deletions
diff --git a/gtk/src/audiohandler.c b/gtk/src/audiohandler.c
index d35979951..017a8b8d3 100644
--- a/gtk/src/audiohandler.c
+++ b/gtk/src/audiohandler.c
@@ -236,8 +236,8 @@ get_selected_asettings(signal_user_data_t *ud)
return asettings;
}
-static void
-audio_list_refresh_selected(signal_user_data_t *ud)
+void
+ghb_audio_list_refresh_selected(signal_user_data_t *ud)
{
GtkTreeView *treeview;
GtkTreePath *treepath;
@@ -249,13 +249,14 @@ audio_list_refresh_selected(signal_user_data_t *ud)
GValue *asettings = NULL;
const GValue *audio_list;
- g_debug("audio_list_refresh_selected ()");
+ g_debug("ghb_audio_list_refresh_selected ()");
treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "audio_list"));
selection = gtk_tree_view_get_selection (treeview);
if (gtk_tree_selection_get_selected(selection, &store, &iter))
{
const gchar *track, *codec, *br, *sr, *mix;
gchar *s_drc, *s_track, *s_codec, *s_br, *s_sr, *s_mix;
+ gint itrack, icodec;
gdouble drc;
// Get the row number
treepath = gtk_tree_model_get_path (store, &iter);
@@ -270,7 +271,9 @@ audio_list_refresh_selected(signal_user_data_t *ud)
asettings = ghb_array_get_nth(audio_list, row);
track = ghb_settings_combo_option(asettings, "AudioTrack");
+ itrack = ghb_settings_combo_int(asettings, "AudioTrack");
codec = ghb_settings_combo_option(asettings, "AudioEncoder");
+ icodec = ghb_settings_combo_int(asettings, "AudioEncoder");
br = ghb_settings_combo_option(asettings, "AudioBitrate");
sr = ghb_settings_combo_option(asettings, "AudioSamplerate");
mix = ghb_settings_combo_option(asettings, "AudioMixdown");
@@ -286,6 +289,11 @@ audio_list_refresh_selected(signal_user_data_t *ud)
else
s_drc = g_strdup_printf("%.1f", drc);
+ if (icodec == HB_ACODEC_MASK)
+ {
+ codec = ghb_select_audio_codec_str(ud, itrack);
+ }
+
gtk_list_store_set(GTK_LIST_STORE(store), &iter,
// These are displayed in list
0, track,
@@ -347,7 +355,7 @@ audio_codec_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
if (asettings != NULL)
{
ghb_widget_to_setting(asettings, widget);
- audio_list_refresh_selected(ud);
+ ghb_audio_list_refresh_selected(ud);
}
ghb_update_destination_extension(ud);
ghb_live_reset(ud);
@@ -368,7 +376,7 @@ audio_track_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
const gchar *track;
ghb_widget_to_setting(asettings, widget);
- audio_list_refresh_selected(ud);
+ ghb_audio_list_refresh_selected(ud);
track = ghb_settings_combo_option(asettings, "AudioTrack");
ghb_settings_set_string(asettings, "AudioTrackDescription", track);
}
@@ -387,7 +395,7 @@ audio_mix_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
if (asettings != NULL)
{
ghb_widget_to_setting(asettings, widget);
- audio_list_refresh_selected(ud);
+ ghb_audio_list_refresh_selected(ud);
}
ghb_live_reset(ud);
}
@@ -403,7 +411,7 @@ audio_widget_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
if (asettings != NULL)
{
ghb_widget_to_setting(asettings, widget);
- audio_list_refresh_selected(ud);
+ ghb_audio_list_refresh_selected(ud);
}
ghb_live_reset(ud);
}
@@ -429,7 +437,7 @@ drc_widget_changed_cb(GtkWidget *widget, gdouble val, signal_user_data_t *ud)
if (asettings != NULL)
{
ghb_widget_to_setting(asettings, widget);
- audio_list_refresh_selected(ud);
+ ghb_audio_list_refresh_selected(ud);
}
ghb_live_reset(ud);
}
@@ -478,6 +486,7 @@ add_to_audio_list(signal_user_data_t *ud, GValue *settings)
GtkTreeSelection *selection;
const gchar *track, *codec, *br, *sr, *mix;
gchar *s_drc, *s_track, *s_codec, *s_br, *s_sr, *s_mix;
+ gint icodec, itrack;
gdouble drc;
g_debug("add_to_audio_list ()");
@@ -486,7 +495,9 @@ add_to_audio_list(signal_user_data_t *ud, GValue *settings)
store = GTK_LIST_STORE(gtk_tree_view_get_model(treeview));
track = ghb_settings_combo_option(settings, "AudioTrack");
+ itrack = ghb_settings_combo_int(settings, "AudioTrack");
codec = ghb_settings_combo_option(settings, "AudioEncoder");
+ icodec = ghb_settings_combo_int(settings, "AudioEncoder");
br = ghb_settings_combo_option(settings, "AudioBitrate");
sr = ghb_settings_combo_option(settings, "AudioSamplerate");
mix = ghb_settings_combo_option(settings, "AudioMixdown");
@@ -502,6 +513,11 @@ add_to_audio_list(signal_user_data_t *ud, GValue *settings)
else
s_drc = g_strdup_printf("%.1f", drc);
+ if (icodec == HB_ACODEC_MASK)
+ {
+ codec = ghb_select_audio_codec_str(ud, itrack);
+ }
+
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter,
// These are displayed in list
diff --git a/gtk/src/audiohandler.h b/gtk/src/audiohandler.h
index b064ab2a3..a3b32344b 100644
--- a/gtk/src/audiohandler.h
+++ b/gtk/src/audiohandler.h
@@ -33,5 +33,6 @@ void ghb_clear_audio_list(signal_user_data_t *ud);
void ghb_set_audio(signal_user_data_t *ud, GValue *settings);
gchar* ghb_get_user_audio_lang(
signal_user_data_t *ud, gint titleindex, gint track);
+void ghb_audio_list_refresh_selected(signal_user_data_t *ud);
#endif // _AUDIOHANDLER_H_
diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c
index 521fa3d69..3168109fd 100644
--- a/gtk/src/callbacks.c
+++ b/gtk/src/callbacks.c
@@ -1276,6 +1276,7 @@ container_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
ghb_clear_presets_selection(ud);
ghb_live_reset(ud);
ghb_subtitle_prune(ud);
+ ghb_audio_list_refresh_selected(ud);
}
static gchar*
diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c
index dca551aa7..09023f69f 100644
--- a/gtk/src/hb-backend.c
+++ b/gtk/src/hb-backend.c
@@ -3667,6 +3667,63 @@ ghb_validate_subtitles(signal_user_data_t *ud)
return TRUE;
}
+gint
+ghb_select_audio_codec(signal_user_data_t *ud, gint track)
+{
+ hb_list_t * list;
+ hb_title_t * title;
+ hb_audio_config_t *audio;
+
+ if (h_scan == NULL) return -1;
+ list = hb_get_titles( h_scan );
+ if( !hb_list_count( list ) )
+ {
+ return -1;
+ }
+
+ gint titleindex;
+
+ titleindex = ghb_settings_combo_int(ud->settings, "title");
+ title = hb_list_item( list, titleindex );
+ if (title == NULL) return -1;
+
+ gint mux = ghb_settings_combo_int(ud->settings, "FileFormat");
+
+ if (track < 0 || track >= hb_list_count(title->list_audio))
+ return -1;
+
+ audio = (hb_audio_config_t *) hb_list_audio_config_item(
+ title->list_audio, track );
+ if (mux == HB_MUX_MP4)
+ {
+ if (audio->in.codec == HB_ACODEC_AC3)
+ return audio->in.codec;
+ else
+ return HB_ACODEC_FAAC;
+ }
+ else
+ {
+ if (audio->in.codec == HB_ACODEC_AC3 || audio->in.codec == HB_ACODEC_DCA)
+ return audio->in.codec;
+ else
+ return HB_ACODEC_LAME;
+ }
+}
+
+const gchar*
+ghb_select_audio_codec_str(signal_user_data_t *ud, gint track)
+{
+ gint acodec, ii;
+
+ acodec = ghb_select_audio_codec(ud, track);
+ for (ii = 0; ii < acodec_opts.count; ii++)
+ {
+ if (acodec_opts.map[ii].ivalue == acodec)
+ return acodec_opts.map[ii].option;
+ }
+ return "Unknown";
+}
+
gboolean
ghb_validate_audio(signal_user_data_t *ud)
{
@@ -4168,9 +4225,10 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex)
}
if ((job->mux == HB_MUX_MP4) &&
((audio.out.codec & HB_ACODEC_LAME) ||
+ (audio.out.codec & HB_ACODEC_DCA) ||
(audio.out.codec & HB_ACODEC_VORBIS)))
{
- // mp4/mp3|vorbis combination is not supported.
+ // mp4/mp3|dts|vorbis combination is not supported.
audio.out.codec = HB_ACODEC_FAAC;
}
audio.out.dynamic_range_compression =
diff --git a/gtk/src/hb-backend.h b/gtk/src/hb-backend.h
index f110528f0..86fd2e0aa 100644
--- a/gtk/src/hb-backend.h
+++ b/gtk/src/hb-backend.h
@@ -170,5 +170,7 @@ gdouble ghb_lookup_combo_double(const gchar *name, const GValue *gval);
const gchar* ghb_lookup_combo_option(const gchar *name, const GValue *gval);
const gchar* ghb_lookup_combo_string(const gchar *name, const GValue *gval);
gchar* ghb_get_tmp_dir();
+gint ghb_select_audio_codec(signal_user_data_t *ud, gint track);
+const gchar* ghb_select_audio_codec_str(signal_user_data_t *ud, gint track);
#endif // _HBBACKEND_H_