summaryrefslogtreecommitdiffstats
path: root/gtk
diff options
context:
space:
mode:
authorJohn Stebbins <[email protected]>2019-07-31 10:59:25 -0700
committerJohn Stebbins <[email protected]>2019-08-11 15:36:40 -0700
commitcc33883b8a62e501d33c716f1e805601744d744f (patch)
treeebbec5d763cd5ccb693873d94ff12627eef9c2a2 /gtk
parent6125d196cacf967e90ab499327dbcb83588778c1 (diff)
libhb: make source audio track name available to frontends
It gets stored in new hb_audio_config_t.in.name field. It is available in the title dict read through hb_title_to_dict() or hb_title_to_json() in AudioList[].Name. When a job is initialized with hb_preset_job_init or hb_preset_job_init_json(), output audio tracks are initialized with the source track name. Also adds output track name initialization to LinGui.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/src/audiohandler.c64
-rw-r--r--gtk/src/audiohandler.h2
-rw-r--r--gtk/src/callbacks.c7
-rw-r--r--gtk/src/hb-backend.c8
-rw-r--r--gtk/src/hb-backend.h2
-rw-r--r--gtk/src/queuehandler.c14
-rw-r--r--gtk/src/titledict.c15
-rw-r--r--gtk/src/titledict.h2
8 files changed, 71 insertions, 43 deletions
diff --git a/gtk/src/audiohandler.c b/gtk/src/audiohandler.c
index cab1ff0ca..b1cb97c4a 100644
--- a/gtk/src/audiohandler.c
+++ b/gtk/src/audiohandler.c
@@ -27,6 +27,7 @@
#include "hb.h"
#include "settings.h"
#include "jobdict.h"
+#include "titledict.h"
#include "hb-backend.h"
#include "values.h"
#include "callbacks.h"
@@ -61,6 +62,7 @@ ghb_sanitize_audio_settings(GhbValue *settings, GhbValue *asettings)
// Sanitize codec
const char * mux_name;
int title_id, mux, acodec, fallback, copy_mask, track;
+ uint32_t in_codec = 0;
hb_audio_config_t * aconfig;
const hb_title_t * title;
@@ -75,7 +77,11 @@ ghb_sanitize_audio_settings(GhbValue *settings, GhbValue *asettings)
copy_mask = ghb_get_copy_mask(settings);
track = ghb_dict_get_int(asettings, "Track");
aconfig = ghb_get_audio_info(title, track);
- acodec = ghb_select_audio_codec(mux, aconfig, acodec,
+ if (aconfig != NULL)
+ {
+ in_codec = aconfig->in.codec;
+ }
+ acodec = ghb_select_audio_codec(mux, in_codec, acodec,
fallback, copy_mask);
ghb_dict_set_string(asettings, "Encoder",
hb_audio_encoder_get_short_name(acodec));
@@ -115,25 +121,24 @@ ghb_adjust_audio_rate_combos(signal_user_data_t *ud, GhbValue *asettings)
{
ghb_sanitize_audio_settings(ud->settings, asettings);
- int track, title_id, mix, acodec;
- const hb_title_t *title;
- hb_audio_config_t *aconfig;
+ int track, mix, acodec;
+ GhbValue * atrack;
+ uint64_t layout;
- title_id = ghb_dict_get_int(ud->settings, "title");
- title = ghb_lookup_title(title_id, NULL);
track = ghb_dict_get_int(asettings, "Track");
- aconfig = ghb_get_audio_info(title, track);
acodec = ghb_settings_audio_encoder_codec(asettings, "Encoder");
mix = ghb_settings_mixdown_mix(asettings, "Mixdown");
int low, high, sr;
sr = ghb_dict_get_int(asettings, "Samplerate");
- if (sr == 0 && aconfig != NULL)
+ atrack = ghb_get_title_audio_track(ud->settings, track);
+ if (sr == 0)
{
- sr = aconfig->in.samplerate;
+ sr = ghb_dict_get_int(atrack, "SampleRate");
}
- mix = ghb_get_best_mix(aconfig, acodec, mix);
+ layout = ghb_dict_get_int(atrack, "ChannelLayout");
+ mix = ghb_get_best_mix(layout, acodec, mix);
hb_audio_bitrate_get_limits(acodec, sr, mix, &low, &high);
GtkWidget *w = GHB_WIDGET(ud->builder, "AudioBitrate");
@@ -260,10 +265,8 @@ audio_deps(signal_user_data_t *ud, GhbValue *asettings, GtkWidget *widget)
}
gint
-ghb_select_audio_codec(gint mux, hb_audio_config_t *aconfig, gint acodec, gint fallback, gint copy_mask)
+ghb_select_audio_codec(gint mux, guint32 in_codec, gint acodec, gint fallback, gint copy_mask)
{
- guint32 in_codec = aconfig != NULL ? aconfig->in.codec : 0;
-
if (acodec == HB_ACODEC_AUTO_PASS)
{
return hb_autopassthru_get_encoder(in_codec, copy_mask, fallback, mux);
@@ -509,7 +512,6 @@ ghb_get_user_audio_lang(GhbValue *settings, const hb_title_t *title, gint track)
static GhbValue*
audio_add_track(
GhbValue *settings,
- const hb_title_t *title,
int track,
int encoder,
gdouble quality,
@@ -520,9 +522,8 @@ audio_add_track(
gdouble gain)
{
GhbValue *asettings;
- hb_audio_config_t *aconfig = NULL;
+ GhbValue *atrack;
- aconfig = ghb_get_audio_info(title, track);
asettings = ghb_dict_new();
ghb_dict_set_int(asettings, "Track", track);
@@ -532,9 +533,16 @@ audio_add_track(
ghb_dict_set_int(asettings, "Bitrate", bitrate);
ghb_dict_set_int(asettings, "Samplerate", samplerate);
- if (aconfig != NULL)
+ atrack = ghb_get_title_audio_track(settings, track);
+ if (atrack != NULL)
{
- mix = ghb_get_best_mix(aconfig, encoder, mix);
+ int layout = ghb_dict_get_int(atrack, "ChannelLayout");
+ const char * name = ghb_dict_get_string(atrack, "Name");
+ mix = ghb_get_best_mix(layout, encoder, mix);
+ if (name != NULL)
+ {
+ ghb_dict_set_string(asettings, "Name", name);
+ }
}
ghb_dict_set_string(asettings, "Mixdown", hb_mixdown_get_short_name(mix));
ghb_dict_set_double(asettings, "DRC", drc);
@@ -602,9 +610,9 @@ audio_select_and_add_track(
hb_audio_config_t *aconfig;
aconfig = hb_list_audio_config_item(title->list_audio, track);
select_acodec = ghb_select_audio_codec(
- mux->format, aconfig, acodec, fallback, copy_mask);
+ mux->format, aconfig->in.codec, acodec, fallback, copy_mask);
- asettings = audio_add_track(settings, title, track, select_acodec,
+ asettings = audio_add_track(settings, track, select_acodec,
quality, bitrate,
samplerate, mix, drc, gain);
}
@@ -978,14 +986,10 @@ audio_codec_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
{
// Transition from passthru to not, put some audio settings back to
// pref settings
- int title_id;
- const hb_title_t *title;
- gint titleindex;
gint track;
gint br, sr, mix;
-
- title_id = ghb_dict_get_int(ud->settings, "title");
- title = ghb_lookup_title(title_id, &titleindex);
+ uint64_t layout;
+ GhbValue * atrack;
if (asettings != NULL)
{
@@ -1008,13 +1012,13 @@ audio_codec_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
ghb_ui_update(ud, "AudioSamplerate",
ghb_string_value(ghb_audio_samplerate_get_short_name(sr)));
- hb_audio_config_t *aconfig;
- aconfig = ghb_get_audio_info(title, track);
+ atrack = ghb_get_title_audio_track(ud->settings, track);
if (sr == 0)
{
- sr = aconfig ? aconfig->in.samplerate : 48000;
+ sr = ghb_dict_get_int(atrack, "SampleRate");
}
- mix = ghb_get_best_mix( aconfig, acodec, mix);
+ layout = ghb_dict_get_int(atrack, "ChannelLayout");
+ mix = ghb_get_best_mix(layout, acodec, mix);
br = hb_audio_bitrate_get_best(acodec, br, sr, mix);
ghb_ui_update(ud, "AudioBitrate",
ghb_string_value(ghb_audio_bitrate_get_short_name(br)));
diff --git a/gtk/src/audiohandler.h b/gtk/src/audiohandler.h
index d31c5f000..33353ebaa 100644
--- a/gtk/src/audiohandler.h
+++ b/gtk/src/audiohandler.h
@@ -33,7 +33,7 @@ GhbValue *ghb_get_audio_list(GhbValue *settings);
void ghb_sanitize_audio_track_settings(GhbValue *settings);
const gchar* ghb_get_user_audio_lang(GhbValue *settings, const hb_title_t *title, gint track);
void ghb_audio_list_refresh_selected(signal_user_data_t *ud);
-gint ghb_select_audio_codec(gint mux, hb_audio_config_t *aconfig, gint acodec, gint fallback_acodec, gint copy_mask);
+gint ghb_select_audio_codec(gint mux, guint32 in_codec, gint acodec, gint fallback_acodec, gint copy_mask);
int ghb_select_fallback( GhbValue *settings, int acodec );
int ghb_get_copy_mask(GhbValue *settings);
void ghb_audio_list_refresh_all(signal_user_data_t *ud);
diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c
index 366e77460..1d1e64e60 100644
--- a/gtk/src/callbacks.c
+++ b/gtk/src/callbacks.c
@@ -2628,11 +2628,13 @@ ghb_set_title_settings(signal_user_data_t *ud, GhbValue *settings)
ghb_subtitle_set_pref_lang(settings);
if (title != NULL)
{
- GhbValue *job_dict;
+ GhbValue * job_dict, * title_dict;
char * label;
job_dict = hb_preset_job_init(ghb_scan_handle(), title_id, settings);
ghb_dict_set(settings, "Job", job_dict);
+ title_dict = hb_title_to_dict(ghb_scan_handle(), title_id);
+ ghb_dict_set(settings, "Title", title_dict);
gint num_chapters = hb_list_count(title->list_chapter);
@@ -2763,6 +2765,9 @@ load_all_titles(signal_user_data_t *ud, int titleindex)
settings_array = ghb_array_new();
+ // Start with a clean job
+ ghb_dict_remove(ud->settings, "Job");
+
preset = ghb_get_current_preset(ud);
if (preset != NULL)
{
diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c
index e5d4fe54a..9f842ee89 100644
--- a/gtk/src/hb-backend.c
+++ b/gtk/src/hb-backend.c
@@ -1268,19 +1268,17 @@ ghb_grey_combo_options(signal_user_data_t *ud)
acodec = ghb_settings_audio_encoder_codec(ud->settings, "AudioEncoder");
gint64 layout = aconfig != NULL ? aconfig->in.channel_layout : ~0;
+ guint32 in_codec = aconfig != NULL ? aconfig->in.codec : 0;
fallback = ghb_select_fallback(ud->settings, acodec);
gint copy_mask = ghb_get_copy_mask(ud->settings);
- acodec = ghb_select_audio_codec(mux->format, aconfig, acodec,
+ acodec = ghb_select_audio_codec(mux->format, in_codec, acodec,
fallback, copy_mask);
grey_mix_opts(ud, acodec, layout);
}
gint
-ghb_get_best_mix(hb_audio_config_t *aconfig, gint acodec, gint mix)
+ghb_get_best_mix(uint64_t layout, gint acodec, gint mix)
{
- gint layout;
- layout = aconfig ? aconfig->in.channel_layout : AV_CH_LAYOUT_5POINT1;
-
if (mix == HB_AMIXDOWN_NONE)
mix = HB_INVALID_AMIXDOWN;
diff --git a/gtk/src/hb-backend.h b/gtk/src/hb-backend.h
index 18d2f2199..bd9aabd16 100644
--- a/gtk/src/hb-backend.h
+++ b/gtk/src/hb-backend.h
@@ -133,7 +133,7 @@ gint64 ghb_get_chapter_duration(const hb_title_t *title, gint chap);
gint64 ghb_get_chapter_start(const hb_title_t *title, gint chap);
gint64 ghb_chapter_range_get_duration(const hb_title_t *title,
gint sc, gint ec);
-gint ghb_get_best_mix(hb_audio_config_t *aconfig, gint acodec, gint mix);
+gint ghb_get_best_mix(uint64_t layout, gint acodec, gint mix);
gboolean ghb_audio_is_passthru(gint acodec);
gboolean ghb_audio_can_passthru(gint acodec);
gint ghb_get_default_acodec(void);
diff --git a/gtk/src/queuehandler.c b/gtk/src/queuehandler.c
index 69f0b43b3..5cacf9a8c 100644
--- a/gtk/src/queuehandler.c
+++ b/gtk/src/queuehandler.c
@@ -29,6 +29,7 @@
#include "hb.h"
#include "settings.h"
#include "jobdict.h"
+#include "titledict.h"
#include "hb-backend.h"
#include "values.h"
#include "callbacks.h"
@@ -1915,16 +1916,17 @@ queue_add(signal_user_data_t *ud, GhbValue *settings, gint batch)
ghb_finalize_job(settings);
+ GhbValue *titleDict = ghb_get_title_settings(settings);
GhbValue *jobDict = ghb_get_job_settings(settings);
- GhbValue *sourceDict = ghb_get_job_source_settings(settings);
- GhbValue *queueDict = ghb_dict_new();
GhbValue *uiDict = ghb_value_dup(settings);
+
ghb_dict_remove(uiDict, "Job");
- int title_id = ghb_dict_get_int(sourceDict, "Title");
- GhbValue *titleDict = ghb_get_title_dict(title_id);
+ ghb_dict_remove(uiDict, "Title");
+
+ GhbValue *queueDict = ghb_dict_new();
ghb_dict_set(queueDict, "uiSettings", uiDict);
ghb_dict_set(queueDict, "Job", ghb_value_dup(jobDict));
- ghb_dict_set(queueDict, "Title", titleDict);
+ ghb_dict_set(queueDict, "Title", ghb_value_dup(titleDict));
// Copy current prefs into settings
// The job should run with the preferences that existed
@@ -2560,6 +2562,8 @@ queue_edit_action_cb(GSimpleAction *action, GVariant *param,
ghb_queue_edit_settings = ghb_value_dup(uiDict);
ghb_dict_set(ghb_queue_edit_settings,
"Job", ghb_value_dup(ghb_dict_get(queueDict, "Job")));
+ ghb_dict_set(ghb_queue_edit_settings,
+ "Title", ghb_value_dup(ghb_dict_get(queueDict, "Title")));
status = ghb_dict_get_int(uiDict, "job_status");
if (status == GHB_QUEUE_PENDING)
{
diff --git a/gtk/src/titledict.c b/gtk/src/titledict.c
index 7ad87e6ec..a4d65230c 100644
--- a/gtk/src/titledict.c
+++ b/gtk/src/titledict.c
@@ -39,9 +39,24 @@ GhbValue *ghb_get_title_audio_list(GhbValue *settings)
return audio_list;
}
+GhbValue *ghb_get_title_audio_track(GhbValue *settings, int track)
+{
+ GhbValue *audio_list = ghb_get_title_audio_list(settings);
+ GhbValue *audio_track = ghb_array_get(audio_list, track);
+ return audio_track;
+}
+
GhbValue *ghb_get_title_subtitle_list(GhbValue *settings)
{
GhbValue *title_dict = ghb_get_title_settings(settings);
GhbValue *subtitle_list = ghb_dict_get(title_dict, "SubtitleList");
return subtitle_list;
}
+
+GhbValue *ghb_get_title_subtitle_track(GhbValue *settings, int track)
+{
+ GhbValue *subtitle_list = ghb_get_title_subtitle_list(settings);
+ GhbValue *subtitle_track = ghb_array_get(subtitle_list, track);
+ return subtitle_track;
+}
+
diff --git a/gtk/src/titledict.h b/gtk/src/titledict.h
index 59b5c5506..4d2ed0c6e 100644
--- a/gtk/src/titledict.h
+++ b/gtk/src/titledict.h
@@ -28,6 +28,8 @@
GhbValue* ghb_get_title_settings(GhbValue *settings);
GhbValue* ghb_get_title_audio_list(GhbValue *settings);
+GhbValue *ghb_get_title_audio_track(GhbValue *settings, int track);
GhbValue* ghb_get_title_subtitle_list(GhbValue *settings);
+GhbValue *ghb_get_title_subtitle_track(GhbValue *settings, int track);
#endif // _TITLEDICT_H_