+ }
+ else if (def_val != NULL)
+ {
+ ret = g_strdup(def_val);
+ }
+ return ret;
+}
+
+gint
+ghb_lookup_badapt(gchar *options)
+{
+ gint ret = 0;
+ gchar *result;
+ gchar **split;
+
+ if (options == NULL)
+ options = "";
+
+ split = g_strsplit(options, ":", -1);
+
+ result = x264_lookup_value(split, x264_badapt_syns);
+ g_strfreev(split);
+ if (result != NULL)
+ {
+ ret = g_strtod(result, NULL);
+ g_free(result);
+ }
+ return ret;
+}
+
+// Construct the x264 options string
+// The result is allocated, so someone must free it at some point.
+static gchar*
+sanitize_x264opts(signal_user_data_t *ud, const gchar *options)
+{
+ GString *x264opts = g_string_new("");
+ gchar **split = g_strsplit(options, ":", -1);
+ gint ii;
+
+ // Fix up option dependencies
+ gint subme = ghb_settings_combo_int(ud->settings, "x264_subme");
+ if (subme < 6)
+ {
+ x264_remove_opt(split, x264_psy_syns);
+ }
+ gint trell = ghb_settings_combo_int(ud->settings, "x264_trellis");
+ if (trell < 1)
+ {
+ gint psy;
+ gdouble psy_rd = 0., psy_trell;
+
+ psy = x264_find_opt(split, x264_psy_syns);
+ if (psy >= 0)