* hb-backend.c
*
* Fri Mar 28 10:38:44 2008
- * Copyright 2008 John Stebbins
+ * Copyright 2008-2011 John Stebbins
* <john at stebbins dot name>
****************************************************************************/
{
{"Do Nothing", "nothing", 0, "0"},
{"Show Notification", "notify", 1, "1"},
+ {"Quit Handbrake", "quit", 4, "4"},
{"Put Computer To Sleep", "sleep", 2, "2"},
{"Shutdown Computer", "shutdown", 3, "3"},
};
return result;
}
+hb_rate_t *ghb_audio_bitrates;
+int ghb_audio_bitrates_count;
+
static gint
lookup_audio_bitrate_int(const GValue *rate)
{
// Coincidentally, the string "source" will return 0
// which is our flag to use "same as source"
gchar *str = ghb_value_string(rate);
- for (ii = 0; ii < hb_audio_bitrates_count; ii++)
+ for (ii = 0; ii < ghb_audio_bitrates_count; ii++)
{
- if (strcmp(hb_audio_bitrates[ii].string, str) == 0)
+ if (strcmp(ghb_audio_bitrates[ii].string, str) == 0)
{
- result = hb_audio_bitrates[ii].rate;
+ result = ghb_audio_bitrates[ii].rate;
break;
}
}
G_VALUE_TYPE(rate) == G_TYPE_DOUBLE)
{
gint val = ghb_value_int(rate);
- for (ii = 0; ii < hb_audio_bitrates_count; ii++)
+ for (ii = 0; ii < ghb_audio_bitrates_count; ii++)
{
- if (hb_audio_bitrates[ii].rate == val)
+ if (ghb_audio_bitrates[ii].rate == val)
{
- result = hb_audio_bitrates[ii].rate;
+ result = ghb_audio_bitrates[ii].rate;
break;
}
}
// Coincidentally, the string "source" will return 0
// which is our flag to use "same as source"
gchar *str = ghb_value_string(rate);
- for (ii = 0; ii < hb_audio_bitrates_count; ii++)
+ for (ii = 0; ii < ghb_audio_bitrates_count; ii++)
{
- if (strcmp(hb_audio_bitrates[ii].string, str) == 0)
+ if (strcmp(ghb_audio_bitrates[ii].string, str) == 0)
{
- result = hb_audio_bitrates[ii].string;
+ result = ghb_audio_bitrates[ii].string;
break;
}
}
G_VALUE_TYPE(rate) == G_TYPE_DOUBLE)
{
gint val = ghb_value_int(rate);
- for (ii = 0; ii < hb_audio_bitrates_count; ii++)
+ for (ii = 0; ii < ghb_audio_bitrates_count; ii++)
{
- if (hb_audio_bitrates[ii].rate == val)
+ if (ghb_audio_bitrates[ii].rate == val)
{
- result = hb_audio_bitrates[ii].string;
+ result = ghb_audio_bitrates[ii].string;
break;
}
}
allow_6ch = acodec & ~HB_ACODEC_LAME;
if (aconfig)
{
- gint layout = aconfig->in.channel_layout & HB_INPUT_CH_LAYOUT_DISCRETE_NO_LFE_MASK;
- allow_stereo =
- ((layout == HB_INPUT_CH_LAYOUT_MONO && !allow_mono) || layout >= HB_INPUT_CH_LAYOUT_STEREO);
- allow_dolby =
- (layout == HB_INPUT_CH_LAYOUT_3F1R) ||
- (layout == HB_INPUT_CH_LAYOUT_3F2R) ||
- (layout == HB_INPUT_CH_LAYOUT_DOLBY);
- allow_dpl2 = (layout == HB_INPUT_CH_LAYOUT_3F2R);
- allow_6ch = allow_6ch &&
- (layout == HB_INPUT_CH_LAYOUT_3F2R) &&
- (aconfig->in.channel_layout & HB_INPUT_CH_LAYOUT_HAS_LFE);
+ gint best = hb_get_best_mixdown(acodec, aconfig->in.channel_layout, 0);
+
+ allow_stereo = best >= HB_AMIXDOWN_STEREO;
+ allow_dolby = best >= HB_AMIXDOWN_DOLBY;
+ allow_dpl2 = best >= HB_AMIXDOWN_DOLBYPLII;
+ allow_6ch = best >= HB_AMIXDOWN_6CH;
}
grey_combo_box_item(builder, "AudioMixdown", HB_AMIXDOWN_MONO, !allow_mono);
grey_combo_box_item(builder, "AudioMixdown", HB_AMIXDOWN_STEREO, !allow_stereo);
gint
ghb_get_best_mix(hb_audio_config_t *aconfig, gint acodec, gint mix)
{
- gboolean allow_mono = TRUE;
- gboolean allow_stereo = TRUE;
- gboolean allow_dolby = TRUE;
- gboolean allow_dpl2 = TRUE;
- gboolean allow_6ch = TRUE;
-
- if (acodec & HB_ACODEC_PASS_FLAG)
- {
- // Audio codec pass-thru. No mixdown
- return 0;
- }
- if (aconfig)
- {
- allow_mono = TRUE;
- gint layout = aconfig->in.channel_layout & HB_INPUT_CH_LAYOUT_DISCRETE_NO_LFE_MASK;
- allow_stereo =
- ((layout == HB_INPUT_CH_LAYOUT_MONO && !allow_mono) || layout >= HB_INPUT_CH_LAYOUT_STEREO);
- allow_dolby =
- (layout == HB_INPUT_CH_LAYOUT_3F1R) ||
- (layout == HB_INPUT_CH_LAYOUT_3F2R) ||
- (layout == HB_INPUT_CH_LAYOUT_DOLBY);
- allow_dpl2 = (layout == HB_INPUT_CH_LAYOUT_3F2R);
- allow_6ch =
- (acodec & ~HB_ACODEC_LAME) &&
- (layout == HB_INPUT_CH_LAYOUT_3F2R) &&
- (aconfig->in.channel_layout & HB_INPUT_CH_LAYOUT_HAS_LFE);
- }
- gboolean greater = FALSE;
- if (mix == 0)
- {
- // If no mix is specified, select the best available.
- mix = HB_AMIXDOWN_6CH;
- }
- if (mix == HB_AMIXDOWN_6CH)
- {
- greater = TRUE;
- if (allow_6ch) return HB_AMIXDOWN_6CH;
- }
- if (mix == HB_AMIXDOWN_DOLBYPLII || greater)
- {
- greater = TRUE;
- if (allow_dpl2) return HB_AMIXDOWN_DOLBYPLII;
- }
- if (mix == HB_AMIXDOWN_DOLBY || greater)
- {
- greater = TRUE;
- if (allow_dolby) return HB_AMIXDOWN_DOLBY;
- }
- if (mix == HB_AMIXDOWN_STEREO || greater)
- {
- greater = TRUE;
- if (allow_stereo) return HB_AMIXDOWN_STEREO;
- }
- if (mix == HB_AMIXDOWN_MONO || greater)
- {
- greater = TRUE;
- if (allow_mono) return HB_AMIXDOWN_MONO;
- }
- if (allow_stereo) return HB_AMIXDOWN_STEREO;
- if (allow_dolby) return HB_AMIXDOWN_DOLBY;
- if (allow_dpl2) return HB_AMIXDOWN_DOLBYPLII;
- if (allow_6ch) return HB_AMIXDOWN_6CH;
- return 0;
+ int layout;
+ layout = aconfig ? aconfig->in.channel_layout :
+ HB_INPUT_CH_LAYOUT_3F2R | HB_INPUT_CH_LAYOUT_HAS_LFE;
+ return hb_get_best_mixdown( acodec, layout, mix );
}
// Set up the model for the combo box
{
audio = (hb_audio_config_t*)hb_list_audio_config_item(
title->list_audio, ii );
- passthru_acodec = acodec & audio->in.codec;
+ passthru_acodec = HB_ACODEC_PASS_MASK & acodec & audio->in.codec;
// Is the source track use a passthru capable codec?
if (passthru_acodec == 0)
continue;
{
audio = (hb_audio_config_t*)hb_list_audio_config_item(
title->list_audio, ii );
- passthru_acodec = HB_ACODEC_PASS_MASK & audio->in.codec;
+ passthru_acodec = HB_ACODEC_PASS_MASK & acodec & audio->in.codec;
// Is the source track use a passthru capable codec?
if (passthru_acodec == 0)
continue;
if (rate < 8) return;
+ if (ghb_audio_bitrates[hb_audio_bitrates_count].string)
+ {
+ g_free(ghb_audio_bitrates[hb_audio_bitrates_count].string);
+ }
+ ghb_audio_bitrates[hb_audio_bitrates_count].rate = rate;
+ ghb_audio_bitrates[hb_audio_bitrates_count].string =
+ g_strdup_printf("%d", rate);
+ ghb_audio_bitrates_count = hb_audio_bitrates_count + 1;
+
store = get_combo_box_store(builder, name);
if (!find_combo_item_by_int(GTK_TREE_MODEL(store), rate, &iter))
{
gtk_list_store_set(store, &iter,
0, str,
1, TRUE,
- 2, str,
+ 2, ghb_audio_bitrates[hb_audio_bitrates_count].string,
3, (gdouble)rate,
- 4, str,
+ 4, ghb_audio_bitrates[hb_audio_bitrates_count].string,
-1);
g_free(str);
}
guint last = (guint)last_rate;
guint first = (guint)first_rate;
+ ghb_audio_bitrates_count = hb_audio_bitrates_count;
+
g_debug("audio_bitrate_opts_clean ()\n");
store = get_combo_box_store(builder, name);
if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL(store), &iter))
{
gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, 3, &ivalue, -1);
if (search_rates(
- hb_audio_bitrates, ivalue, hb_audio_bitrates_count) < 0)
+ ghb_audio_bitrates, ivalue, ghb_audio_bitrates_count) < 0)
{
done = !gtk_list_store_remove(store, &iter);
}
gint ii;
gchar *str;
+ ghb_audio_bitrates_count = hb_audio_bitrates_count;
+ ghb_audio_bitrates = calloc(hb_audio_bitrates_count+1, sizeof(hb_rate_t));
+
+ for (ii = 0; ii < hb_audio_bitrates_count; ii++)
+ {
+ ghb_audio_bitrates[ii] = hb_audio_bitrates[ii];
+ }
+
g_debug("audio_bitrate_opts_set ()\n");
store = get_combo_box_store(builder, name);
gtk_list_store_clear(store);
- for (ii = 0; ii < hb_audio_bitrates_count; ii++)
+ for (ii = 0; ii < ghb_audio_bitrates_count; ii++)
{
gtk_list_store_append(store, &iter);
str = g_strdup_printf ("<small>%s</small>",
- hb_audio_bitrates[ii].string);
+ ghb_audio_bitrates[ii].string);
gtk_list_store_set(store, &iter,
0, str,
1, TRUE,
- 2, hb_audio_bitrates[ii].string,
- 3, (gdouble)hb_audio_bitrates[ii].rate,
- 4, hb_audio_bitrates[ii].string,
+ 2, ghb_audio_bitrates[ii].string,
+ 3, (gdouble)ghb_audio_bitrates[ii].rate,
+ 4, ghb_audio_bitrates[ii].string,
-1);
g_free(str);
}
{
return HB_ACODEC_AC3;
}
+ else if (acodec & HB_ACODEC_LAME)
+ {
+ return HB_ACODEC_LAME;
+ }
else if (acodec & HB_ACODEC_FAAC)
{
return HB_ACODEC_FAAC;
value = ghb_lookup_acodec_value(codec);
ghb_settings_take_value(asettings, "AudioEncoder", value);
}
+
gint mix = ghb_settings_combo_int (asettings, "AudioMixdown");
gboolean allow_mono = TRUE;
gboolean allow_stereo = TRUE;
gboolean allow_dpl2 = TRUE;
gboolean allow_6ch = TRUE;
allow_mono = TRUE;
- gint layout = aconfig->in.channel_layout & HB_INPUT_CH_LAYOUT_DISCRETE_NO_LFE_MASK;
- allow_stereo =
- ((layout == HB_INPUT_CH_LAYOUT_MONO && !allow_mono) || layout >= HB_INPUT_CH_LAYOUT_STEREO);
- allow_dolby =
- (layout == HB_INPUT_CH_LAYOUT_3F1R) ||
- (layout == HB_INPUT_CH_LAYOUT_3F2R) ||
- (layout == HB_INPUT_CH_LAYOUT_DOLBY);
- allow_dpl2 = (layout == HB_INPUT_CH_LAYOUT_3F2R);
- allow_6ch =
- (codec & ~HB_ACODEC_LAME) &&
- (layout == HB_INPUT_CH_LAYOUT_3F2R) &&
- (aconfig->in.channel_layout & HB_INPUT_CH_LAYOUT_HAS_LFE);
+
+ gint best = hb_get_best_mixdown(codec, aconfig->in.channel_layout, 0);
+
+ allow_stereo = best >= HB_AMIXDOWN_STEREO;
+ allow_dolby = best >= HB_AMIXDOWN_DOLBY;
+ allow_dpl2 = best >= HB_AMIXDOWN_DOLBYPLII;
+ allow_6ch = best >= HB_AMIXDOWN_6CH;
gchar *mix_unsup = NULL;
if (mix == HB_AMIXDOWN_MONO && !allow_mono)
max = 62;
} break;
}
- if (vquality < min || vquality > max)
+ if (vcodec == HB_VCODEC_X264 && vquality == 0.0)
+ {
+ message = g_strdup_printf(
+ "Warning: lossless h.264 selected\n\n"
+ "Lossless h.264 is not well supported by\n"
+ "many players and editors.\n\n"
+ "It will produce enormous output files.\n\n"
+ "Are you sure you wish to use this setting?",
+ (gint)vquality, min, max);
+ if (!ghb_message_dialog(GTK_MESSAGE_QUESTION, message,
+ "Cancel", "Continue"))
+ {
+ g_free(message);
+ return FALSE;
+ }
+ g_free(message);
+ }
+ else if (vquality < min || vquality > max)
{
message = g_strdup_printf(
- "Interesting video quality choise: %d\n\n"
- "Typical values range from %d to %d.\n"
+ "Interesting video quality choice: %d\n\n"
+ "Typical values range from %d to %d.\n\n"
"Are you sure you wish to use this setting?",
(gint)vquality, min, max);
if (!ghb_message_dialog(GTK_MESSAGE_QUESTION, message,
sub_config.offset = ghb_settings_get_int(ssettings, "SrtOffset");
lang = ghb_settings_get_string(ssettings, "SrtLanguage");
code = ghb_settings_get_string(ssettings, "SrtCodeset");
- strncpy(sub_config.src_filename, filename, 128);
- strncpy(sub_config.src_codeset, code, 40);
+ strncpy(sub_config.src_filename, filename, 255);
+ sub_config.src_filename[255] = 0;
+ strncpy(sub_config.src_codeset, code, 39);
+ sub_config.src_codeset[39] = 0;
sub_config.force = 0;
sub_config.dest = PASSTHRUSUB;
sub_config.default_track = def;