From 52d2419a149fd0ccf4f0baddd2b17dbc1c516fb0 Mon Sep 17 00:00:00 2001 From: jstebbins Date: Wed, 23 Dec 2009 00:05:05 +0000 Subject: [PATCH] LinGui: add point-to-point the user can now select between chapter, seconds, or frame start and end points for encoding. git-svn-id: svn://localhost/HandBrake/trunk@3041 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- gtk/src/callbacks.c | 346 +++++++++++++++++++++++++++++++++++------- gtk/src/ghb.ui | 293 ++++++++++++++++++----------------- gtk/src/hb-backend.c | 75 ++++++++- gtk/src/internal_defaults.xml | 8 +- gtk/src/presets.c | 24 +-- gtk/src/queuehandler.c | 23 ++- gtk/src/settings.h | 1 + gtk/src/widgetdeps.c | 7 +- 8 files changed, 554 insertions(+), 223 deletions(-) diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c index 087185dc..246f56b9 100644 --- a/gtk/src/callbacks.c +++ b/gtk/src/callbacks.c @@ -296,7 +296,7 @@ on_quit1_activate(GtkMenuItem *quit, signal_user_data_t *ud) { gint state = ghb_get_queue_state(); g_debug("on_quit1_activate ()"); - if (state & GHB_STATE_WORKING) + if (state & (GHB_STATE_WORKING|GHB_STATE_SEARCHING)) { if (ghb_cancel_encode2(ud, "Closing HandBrake will terminate encoding.\n")) { @@ -580,7 +580,8 @@ set_destination(signal_user_data_t *ud) title = ghb_settings_combo_int(ud->settings, "title"); g_string_append_printf(str, " - %d", title+1); } - if (ghb_settings_get_boolean( + if (ghb_settings_combo_int(ud->settings, "PtoPType") == 0 && + ghb_settings_get_boolean( ud->settings, "chapters_in_destination")) { gint start, end; @@ -590,8 +591,8 @@ set_destination(signal_user_data_t *ud) { g_string_append_printf(str, " -"); } - start = ghb_settings_get_int(ud->settings, "start_chapter"); - end = ghb_settings_get_int(ud->settings, "end_chapter"); + start = ghb_settings_get_int(ud->settings, "start_point"); + end = ghb_settings_get_int(ud->settings, "end_point"); if (start == end) g_string_append_printf(str, " Ch %d", start); else @@ -1259,7 +1260,7 @@ window_delete_event_cb(GtkWidget *widget, GdkEvent *event, signal_user_data_t *u { gint state = ghb_get_queue_state(); g_debug("window_delete_event_cb ()"); - if (state & GHB_STATE_WORKING) + if (state & (GHB_STATE_WORKING|GHB_STATE_SEARCHING)) { if (ghb_cancel_encode2(ud, "Closing HandBrake will terminate encoding.\n")) { @@ -1334,9 +1335,45 @@ update_title_duration(signal_user_data_t *ud) ti = ghb_settings_combo_int(ud->settings, "title"); widget = GHB_WIDGET (ud->builder, "title_duration"); - start = ghb_settings_get_int(ud->settings, "start_chapter"); - end = ghb_settings_get_int(ud->settings, "end_chapter"); - ghb_part_duration(ti, start, end, &hh, &mm, &ss); + if (ghb_settings_combo_int(ud->settings, "PtoPType") == 0) + { + start = ghb_settings_get_int(ud->settings, "start_point"); + end = ghb_settings_get_int(ud->settings, "end_point"); + ghb_part_duration(ti, start, end, &hh, &mm, &ss); + } + else if (ghb_settings_combo_int(ud->settings, "PtoPType") == 1) + { + gint duration; + + start = ghb_settings_get_int(ud->settings, "start_point"); + end = ghb_settings_get_int(ud->settings, "end_point"); + duration = end - start; + hh = duration / (60*60); + mm = (duration / 60) % 60; + ss = duration % 60; + } + else if (ghb_settings_combo_int(ud->settings, "PtoPType") == 2) + { + ghb_title_info_t tinfo; + + if (ghb_get_title_info (&tinfo, ti)) + { + gint64 frames; + gint duration; + + start = ghb_settings_get_int(ud->settings, "start_point"); + end = ghb_settings_get_int(ud->settings, "end_point"); + frames = end - start + 1; + duration = frames * tinfo.rate_base / tinfo.rate; + hh = duration / (60*60); + mm = (duration / 60) % 60; + ss = duration % 60; + } + else + { + hh = mm = ss = 0; + } + } text = g_strdup_printf("%02d:%02d:%02d", hh, mm, ss); gtk_label_set_text (GTK_LABEL(widget), text); g_free(text); @@ -1429,17 +1466,46 @@ show_title_info(signal_user_data_t *ud, ghb_title_info_t *tinfo) gtk_label_set_text (GTK_LABEL(widget), text); g_free(text); - g_debug("setting max end chapter %d", tinfo->num_chapters); - widget = GHB_WIDGET (ud->builder, "end_chapter"); - gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 1, tinfo->num_chapters); - gtk_spin_button_set_value (GTK_SPIN_BUTTON(widget), tinfo->num_chapters); - widget = GHB_WIDGET (ud->builder, "start_chapter"); - gtk_spin_button_set_value (GTK_SPIN_BUTTON(widget), 1); - gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 1, tinfo->num_chapters); + + gint duration = tinfo->duration / 90000; + + if (ghb_settings_combo_int(ud->settings, "PtoPType") == 0) + { + widget = GHB_WIDGET (ud->builder, "start_point"); + gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 1, tinfo->num_chapters); + gtk_spin_button_set_value (GTK_SPIN_BUTTON(widget), 1); + + widget = GHB_WIDGET (ud->builder, "end_point"); + gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 1, tinfo->num_chapters); + gtk_spin_button_set_value (GTK_SPIN_BUTTON(widget), tinfo->num_chapters); + } + else if (ghb_settings_combo_int(ud->settings, "PtoPType") == 1) + { + + widget = GHB_WIDGET (ud->builder, "start_point"); + gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 0, duration-1); + gtk_spin_button_set_value (GTK_SPIN_BUTTON(widget), 0); + + widget = GHB_WIDGET (ud->builder, "end_point"); + gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 1, duration); + gtk_spin_button_set_value (GTK_SPIN_BUTTON(widget), duration); + } + else if (ghb_settings_combo_int(ud->settings, "PtoPType") == 2) + { + gdouble max_frames = (gdouble)duration * tinfo->rate / tinfo->rate_base; + widget = GHB_WIDGET (ud->builder, "start_point"); + gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 1, max_frames); + gtk_spin_button_set_value (GTK_SPIN_BUTTON(widget), 1); + + widget = GHB_WIDGET (ud->builder, "end_point"); + gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 1, max_frames); + gtk_spin_button_set_value (GTK_SPIN_BUTTON(widget), max_frames); + } widget = GHB_WIDGET (ud->builder, "angle"); gtk_spin_button_set_value (GTK_SPIN_BUTTON(widget), 1); gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 1, tinfo->angle_count); + ghb_settings_set_int(ud->settings, "angle_count", tinfo->angle_count); ud->dont_clear_presets = FALSE; } @@ -1453,7 +1519,6 @@ title_changed_cb(GtkWidget *widget, signal_user_data_t *ud) g_debug("title_changed_cb ()"); ghb_widget_to_setting(ud->settings, widget); - ghb_check_dependency(ud, widget, NULL); titleindex = ghb_settings_combo_int(ud->settings, "title"); ghb_update_ui_combo_box (ud, "AudioTrack", titleindex, FALSE); @@ -1463,6 +1528,7 @@ title_changed_cb(GtkWidget *widget, signal_user_data_t *ud) { show_title_info(ud, &tinfo); } + ghb_check_dependency(ud, widget, NULL); update_chapter_list (ud); ghb_adjust_audio_rate_combos(ud); ghb_set_pref_audio(titleindex, ud); @@ -1494,7 +1560,7 @@ title_changed_cb(GtkWidget *widget, signal_user_data_t *ud) gint end; widget = GHB_WIDGET (ud->builder, "ChapterMarkers"); gtk_widget_set_sensitive(widget, TRUE); - end = ghb_settings_get_int(ud->settings, "end_chapter"); + end = ghb_settings_get_int(ud->settings, "end_point"); if (1 == end) { ud->dont_clear_presets = TRUE; @@ -1505,6 +1571,54 @@ title_changed_cb(GtkWidget *widget, signal_user_data_t *ud) } G_MODULE_EXPORT void +ptop_widget_changed_cb(GtkWidget *widget, signal_user_data_t *ud) +{ + gint ti; + ghb_title_info_t tinfo; + + ghb_widget_to_setting(ud->settings, widget); + ghb_check_dependency(ud, widget, NULL); + ghb_live_reset(ud); + + ti = ghb_settings_combo_int(ud->settings, "title"); + if (!ghb_get_title_info (&tinfo, ti)) + return; + + gint duration = tinfo.duration / 90000; + if (ghb_settings_combo_int(ud->settings, "PtoPType") == 0) + { + widget = GHB_WIDGET (ud->builder, "start_point"); + gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 1, tinfo.num_chapters); + gtk_spin_button_set_value (GTK_SPIN_BUTTON(widget), 1); + + widget = GHB_WIDGET (ud->builder, "end_point"); + gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 1, tinfo.num_chapters); + gtk_spin_button_set_value (GTK_SPIN_BUTTON(widget), tinfo.num_chapters); + } + else if (ghb_settings_combo_int(ud->settings, "PtoPType") == 1) + { + widget = GHB_WIDGET (ud->builder, "start_point"); + gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 0, duration-1); + gtk_spin_button_set_value (GTK_SPIN_BUTTON(widget), 0); + + widget = GHB_WIDGET (ud->builder, "end_point"); + gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 1, duration); + gtk_spin_button_set_value (GTK_SPIN_BUTTON(widget), duration); + } + else if (ghb_settings_combo_int(ud->settings, "PtoPType") == 2) + { + gdouble max_frames = (gdouble)duration * tinfo.rate / tinfo.rate_base; + widget = GHB_WIDGET (ud->builder, "start_point"); + gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 1, max_frames); + gtk_spin_button_set_value (GTK_SPIN_BUTTON(widget), 1); + + widget = GHB_WIDGET (ud->builder, "end_point"); + gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 1, max_frames); + gtk_spin_button_set_value (GTK_SPIN_BUTTON(widget), max_frames); + } +} + +G_MODULE_EXPORT void setting_widget_changed_cb(GtkWidget *widget, signal_user_data_t *ud) { ghb_widget_to_setting(ud->settings, widget); @@ -1596,65 +1710,107 @@ target_size_changed_cb(GtkWidget *widget, signal_user_data_t *ud) } G_MODULE_EXPORT void -start_chapter_changed_cb(GtkWidget *widget, signal_user_data_t *ud) +start_point_changed_cb(GtkWidget *widget, signal_user_data_t *ud) { gint start, end; const gchar *name = gtk_widget_get_name(widget); - g_debug("start_chapter_changed_cb () %s", name); + g_debug("start_point_changed_cb () %s", name); ghb_widget_to_setting(ud->settings, widget); - start = ghb_settings_get_int(ud->settings, "start_chapter"); - end = ghb_settings_get_int(ud->settings, "end_chapter"); - if (start > end) - ghb_ui_update(ud, "end_chapter", ghb_int_value(start)); - ghb_check_dependency(ud, widget, NULL); - if (ghb_settings_get_boolean(ud->settings, "chapters_in_destination")) + if (ghb_settings_combo_int(ud->settings, "PtoPType") == 0) + { + start = ghb_settings_get_int(ud->settings, "start_point"); + end = ghb_settings_get_int(ud->settings, "end_point"); + if (start > end) + ghb_ui_update(ud, "end_point", ghb_int_value(start)); + ghb_check_dependency(ud, widget, NULL); + if (ghb_settings_get_boolean(ud->settings, "chapters_in_destination")) + { + set_destination(ud); + } + widget = GHB_WIDGET (ud->builder, "ChapterMarkers"); + gtk_widget_set_sensitive(widget, TRUE); + // End may have been changed above, get it again + end = ghb_settings_get_int(ud->settings, "end_point"); + if (start == end) + { + ud->dont_clear_presets = TRUE; + ghb_ui_update(ud, "ChapterMarkers", ghb_boolean_value(FALSE)); + ud->dont_clear_presets = FALSE; + gtk_widget_set_sensitive(widget, FALSE); + } + update_title_duration(ud); + } + else if (ghb_settings_combo_int(ud->settings, "PtoPType") == 1) { - set_destination(ud); + start = ghb_settings_get_int(ud->settings, "start_point"); + end = ghb_settings_get_int(ud->settings, "end_point"); + if (start >= end) + ghb_ui_update(ud, "end_point", ghb_int_value(start+1)); + ghb_check_dependency(ud, widget, NULL); + update_title_duration(ud); } - widget = GHB_WIDGET (ud->builder, "ChapterMarkers"); - gtk_widget_set_sensitive(widget, TRUE); - // End may have been changed above, get it again - end = ghb_settings_get_int(ud->settings, "end_chapter"); - if (start == end) + else if (ghb_settings_combo_int(ud->settings, "PtoPType") == 2) { - ud->dont_clear_presets = TRUE; - ghb_ui_update(ud, "ChapterMarkers", ghb_boolean_value(FALSE)); - ud->dont_clear_presets = FALSE; - gtk_widget_set_sensitive(widget, FALSE); + start = ghb_settings_get_int(ud->settings, "start_point"); + end = ghb_settings_get_int(ud->settings, "end_point"); + if (start > end) + ghb_ui_update(ud, "end_point", ghb_int_value(start)); + ghb_check_dependency(ud, widget, NULL); + update_title_duration(ud); } - update_title_duration(ud); } G_MODULE_EXPORT void -end_chapter_changed_cb(GtkWidget *widget, signal_user_data_t *ud) +end_point_changed_cb(GtkWidget *widget, signal_user_data_t *ud) { gint start, end; const gchar *name = gtk_widget_get_name(widget); - g_debug("end_chapter_changed_cb () %s", name); + g_debug("end_point_changed_cb () %s", name); ghb_widget_to_setting(ud->settings, widget); - start = ghb_settings_get_int(ud->settings, "start_chapter"); - end = ghb_settings_get_int(ud->settings, "end_chapter"); - if (start > end) - ghb_ui_update(ud, "start_chapter", ghb_int_value(end)); - ghb_check_dependency(ud, widget, NULL); - if (ghb_settings_get_boolean(ud->settings, "chapters_in_destination")) + if (ghb_settings_combo_int(ud->settings, "PtoPType") == 0) + { + start = ghb_settings_get_int(ud->settings, "start_point"); + end = ghb_settings_get_int(ud->settings, "end_point"); + if (start > end) + ghb_ui_update(ud, "start_point", ghb_int_value(end)); + ghb_check_dependency(ud, widget, NULL); + if (ghb_settings_get_boolean(ud->settings, "chapters_in_destination")) + { + set_destination(ud); + } + widget = GHB_WIDGET (ud->builder, "ChapterMarkers"); + gtk_widget_set_sensitive(widget, TRUE); + // Start may have been changed above, get it again + start = ghb_settings_get_int(ud->settings, "start_point"); + if (start == end) + { + ud->dont_clear_presets = TRUE; + ghb_ui_update(ud, "ChapterMarkers", ghb_boolean_value(FALSE)); + ud->dont_clear_presets = FALSE; + gtk_widget_set_sensitive(widget, FALSE); + } + update_title_duration(ud); + } + else if (ghb_settings_combo_int(ud->settings, "PtoPType") == 1) { - set_destination(ud); + start = ghb_settings_get_int(ud->settings, "start_point"); + end = ghb_settings_get_int(ud->settings, "end_point"); + if (start >= end) + ghb_ui_update(ud, "start_point", ghb_int_value(end-1)); + ghb_check_dependency(ud, widget, NULL); + update_title_duration(ud); } - widget = GHB_WIDGET (ud->builder, "ChapterMarkers"); - gtk_widget_set_sensitive(widget, TRUE); - // Start may have been changed above, get it again - start = ghb_settings_get_int(ud->settings, "start_chapter"); - if (start == end) + else if (ghb_settings_combo_int(ud->settings, "PtoPType") == 2) { - ud->dont_clear_presets = TRUE; - ghb_ui_update(ud, "ChapterMarkers", ghb_boolean_value(FALSE)); - ud->dont_clear_presets = FALSE; - gtk_widget_set_sensitive(widget, FALSE); + start = ghb_settings_get_int(ud->settings, "start_point"); + end = ghb_settings_get_int(ud->settings, "end_point"); + if (start > end) + ghb_ui_update(ud, "start_point", ghb_int_value(end)); + ghb_check_dependency(ud, widget, NULL); + update_title_duration(ud); } - update_title_duration(ud); } G_MODULE_EXPORT void @@ -2388,6 +2544,46 @@ working_status_string(signal_user_data_t *ud, ghb_instance_status_t *status) return status_str; } +gchar* +searching_status_string(signal_user_data_t *ud, ghb_instance_status_t *status) +{ + gchar *task_str, *job_str, *status_str; + gint qcount; + gint index; + GValue *js; + + qcount = ghb_array_len(ud->queue); + index = find_queue_job(ud->queue, status->unique_id, &js); + if (qcount > 1) + { + job_str = g_strdup_printf("job %d of %d, ", index+1, qcount); + } + else + { + job_str = g_strdup(""); + } + task_str = g_strdup_printf("Searching for start time, "); + if(status->seconds > -1) + { + status_str= g_strdup_printf( + "Encoding: %s%s%.2f %%" + " (ETA %02dh%02dm%02ds)", + job_str, task_str, + 100.0 * status->progress, + status->hours, status->minutes, status->seconds ); + } + else + { + status_str= g_strdup_printf( + "Encoding: %s%s%.2f %%", + job_str, task_str, + 100.0 * status->progress ); + } + g_free(task_str); + g_free(job_str); + return status_str; +} + static void ghb_backend_events(signal_user_data_t *ud) { @@ -2526,6 +2722,44 @@ ghb_backend_events(signal_user_data_t *ud) { gtk_label_set_text (work_status, "Paused"); } + else if (status.queue.state & GHB_STATE_SEARCHING) + { + static gint working = 0; + + // This needs to be in scanning and working since scanning + // happens fast enough that it can be missed + index = find_queue_job(ud->queue, status.queue.unique_id, &js); + if (status.queue.unique_id != 0 && index >= 0) + { + gchar working_icon[] = "hb-working0"; + working_icon[10] = '0' + working; + working = (working+1) % 6; + treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "queue_list")); + store = GTK_TREE_STORE(gtk_tree_view_get_model(treeview)); + gchar *path = g_strdup_printf ("%d", index); + if (gtk_tree_model_get_iter_from_string( + GTK_TREE_MODEL(store), &iter, path)) + { + gtk_tree_store_set(store, &iter, 0, working_icon, -1); + } + g_free(path); + } + GtkLabel *label; + gchar *status_str; + + status_str = searching_status_string(ud, &status.queue); + label = GTK_LABEL(GHB_WIDGET(ud->builder, "queue_status")); + gtk_label_set_text (label, status_str); +#if !GTK_CHECK_VERSION(2, 16, 0) + GtkStatusIcon *si; + + si = GTK_STATUS_ICON(GHB_OBJECT(ud->builder, "hb_status")); + gtk_status_icon_set_tooltip(si, status_str); +#endif + gtk_label_set_text (work_status, status_str); + gtk_progress_bar_set_fraction (progress, status.queue.progress); + g_free(status_str); + } else if (status.queue.state & GHB_STATE_WORKING) { static gint working = 0; @@ -2693,6 +2927,8 @@ status_icon_query_tooltip_cb( ghb_get_status(&status); if (status.queue.state & GHB_STATE_WORKING) status_str = working_status_string(ud, &status.queue); + else if (status.queue.state & GHB_STATE_SEARCHING) + status_str = searching_status_string(ud, &status.queue); else if (status.queue.state & GHB_STATE_WORKDONE) status_str = g_strdup("Encode Complete"); else diff --git a/gtk/src/ghb.ui b/gtk/src/ghb.ui index 17490b7b..102214c0 100644 --- a/gtk/src/ghb.ui +++ b/gtk/src/ghb.ui @@ -249,6 +249,22 @@ 0 0 + + 99999 + 0 + 60 + 1 + 0 + 99999 + + + 99999 + 1 + 60 + 1 + 0 + 0 + 100 0 @@ -726,128 +742,62 @@ - + True - 6 - 6 + 2 + 2 + 5 - + True - 4 + 6 + 6 True - Title + 0.1 + Title: - - False - False - - - - - True - False - Set the title to encode. By default the longest title is chosen. This is often the feature title of a DVD. - - - - False - 1 - + + 0 + 1 + 0 + 1 + GTK_FILL + - - - False - 1 - - - - - True - 6 - 6 - + True - 4 + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + - + True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 0 0 - 0 - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - - - True - Chapters - - - False - False - - - - - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - Set the first chapter to encode. - adjustment1 - - - - False - 1 - - - - - True - through - - - False - False - 2 - - - - - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - Set the last chapter to encode. - adjustment2 - - - - False - 3 - - - - + 0 + + + True + False + Set the title to encode. By default the longest title is chosen. This is often the feature title of a DVD. + + + + - - False - 2 - + - + True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 + 1 0 - 8 + 0 True @@ -861,7 +811,7 @@ False False - 4 + 0 @@ -875,54 +825,111 @@ False - 5 + 1 - - False - 3 - + + + 1 + 2 + 0 + 1 + + + + + + True + 0 + 0 + 0 - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - 0 - 8 + 5 + - + True + Format to mux encoded tracks to. + + + + False + 0 + + + + + True + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 7 - - - True - 0.10000000149011612 - Duration: - - - False - False - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - hh:mm:ss - 8 - - - False - 1 - - + Set the first chapter to encode. + adjustment1 + + + + False + 1 + + + + + True + through + + + False + 2 + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Set the last chapter to encode. + adjustment2 + + + + False + 3 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 7 + + + True + 0.1 + Duration: + + False + 0 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + hh:mm:ss + 8 + + + False + 1 + @@ -930,12 +937,20 @@ 4 + + + + 1 + 2 + 1 + 2 + False - 2 + 1 @@ -958,7 +973,7 @@ True 12 - + True 2 2 diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c index 2a60fecc..b577a5b0 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -70,6 +70,18 @@ index_str_init(gint max_index) } } +static options_map_t d_point_to_point_opts[] = +{ + {"Chapters:", "chapter", 0, "0"}, + {"Seconds:", "time", 1, "1"}, + {"Frames:", "frame", 2, "2"}, +}; +combo_opts_t point_to_point_opts = +{ + sizeof(d_point_to_point_opts)/sizeof(options_map_t), + d_point_to_point_opts +}; + static options_map_t d_when_complete_opts[] = { {"Do Nothing", "nothing", 0, "0"}, @@ -359,6 +371,7 @@ typedef struct combo_name_map_t combo_name_map[] = { + {"PtoPType", &point_to_point_opts}, {"WhenComplete", &when_complete_opts}, {"PicturePAR", &par_opts}, {"PictureModulus", &alignment_opts}, @@ -2563,6 +2576,7 @@ ghb_update_ui_combo_box( audio_track_opts_set(ud->builder, "AudioTrack", user_data); subtitle_track_opts_set(ud->builder, "SubtitleTrack", user_data); generic_opts_set(ud->builder, "VideoQualityGranularity", &vqual_granularity_opts); + generic_opts_set(ud->builder, "PtoPType", &point_to_point_opts); generic_opts_set(ud->builder, "WhenComplete", &when_complete_opts); generic_opts_set(ud->builder, "PicturePAR", &par_opts); generic_opts_set(ud->builder, "PictureModulus", &alignment_opts); @@ -3078,6 +3092,22 @@ ghb_track_status() case HB_STATE_WORKING: hb_status.queue.state |= GHB_STATE_WORKING; hb_status.queue.state &= ~GHB_STATE_PAUSED; + hb_status.queue.state &= ~GHB_STATE_SEARCHING; + hb_status.queue.job_cur = p.job_cur; + hb_status.queue.job_count = p.job_count; + hb_status.queue.progress = p.progress; + hb_status.queue.rate_cur = p.rate_cur; + hb_status.queue.rate_avg = p.rate_avg; + hb_status.queue.hours = p.hours; + hb_status.queue.minutes = p.minutes; + hb_status.queue.seconds = p.seconds; + hb_status.queue.unique_id = p.sequence_id & 0xFFFFFF; + break; + + case HB_STATE_SEARCHING: + hb_status.queue.state |= GHB_STATE_SEARCHING; + hb_status.queue.state &= ~GHB_STATE_WORKING; + hb_status.queue.state &= ~GHB_STATE_PAUSED; hb_status.queue.job_cur = p.job_cur; hb_status.queue.job_count = p.job_count; hb_status.queue.progress = p.progress; @@ -4212,13 +4242,42 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex) } if (!job->start_at_preview) { - gint chapter_start, chapter_end; - chapter_start = ghb_settings_get_int(js, "start_chapter"); - chapter_end = ghb_settings_get_int(js, "end_chapter"); + gint start, end; gint num_chapters = hb_list_count(title->list_chapter); - job->chapter_start = MIN( num_chapters, chapter_start ); - job->chapter_end = MAX( job->chapter_start, chapter_end ); + gint duration = title->duration / 90000; + job->chapter_start = 1; + job->chapter_end = num_chapters; + if (ghb_settings_combo_int(js, "PtoPType") == 0) + { + start = ghb_settings_get_int(js, "start_point"); + end = ghb_settings_get_int(js, "end_point"); + job->chapter_start = MIN( num_chapters, start ); + job->chapter_end = MAX( job->chapter_start, end ); + + } + if (ghb_settings_combo_int(js, "PtoPType") == 1) + { + job->chapter_start = 1; + job->chapter_end = num_chapters; + start = ghb_settings_get_int(js, "start_point"); + end = ghb_settings_get_int(js, "end_point"); + job->pts_to_start = (int64_t)MIN(duration-1, start) * 90000; + job->pts_to_stop = (int64_t)MAX(start+1, end) * 90000 - + job->pts_to_start; + } + if (ghb_settings_combo_int(js, "PtoPType") == 2) + { + job->chapter_start = 1; + job->chapter_end = num_chapters; + start = ghb_settings_get_int(js, "start_point"); + end = ghb_settings_get_int(js, "end_point"); + gint64 max_frames; + max_frames = (gint64)duration * title->rate / title->rate_base; + job->frame_to_start = (int64_t)MIN(max_frames-1, start-1); + job->frame_to_stop = (int64_t)MAX(start, end-1) - + job->frame_to_start; + } job->chapter_markers = ghb_settings_get_boolean(js, "ChapterMarkers"); if (job->chapter_start == job->chapter_end) job->chapter_markers = 0; @@ -4228,14 +4287,14 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex) GValue *chapter; gint chap; gint count; - + chapters = ghb_settings_get_value(js, "chapter_list"); count = ghb_array_len(chapters); - for(chap = chapter_start; chap <= chapter_end; chap++) + for(chap = start; chap <= end; chap++) { hb_chapter_t * chapter_s; gchar *name; - + name = NULL; if (chap-1 < count) { diff --git a/gtk/src/internal_defaults.xml b/gtk/src/internal_defaults.xml index ec680241..3a67e42f 100644 --- a/gtk/src/internal_defaults.xml +++ b/gtk/src/internal_defaults.xml @@ -4,6 +4,8 @@ Initialization + angle_count + 1 angle 1 anamorphic @@ -14,7 +16,7 @@ dest_file new_video.mp4 - end_chapter + end_point 100 folder @@ -30,6 +32,8 @@ 720 PictureDisplayHeight 480 + PtoPType + chapter scale_height 0 scale_width @@ -42,7 +46,7 @@ single_title 1 - start_chapter + start_point 1 start_frame -1 diff --git a/gtk/src/presets.c b/gtk/src/presets.c index fca8c930..b59efca7 100644 --- a/gtk/src/presets.c +++ b/gtk/src/presets.c @@ -4087,16 +4087,20 @@ presets_list_selection_changed_cb(GtkTreeSelection *selection, signal_user_data_ g_debug("No selection??? Perhaps unselected."); gtk_widget_set_sensitive(widget, FALSE); } - gint start = ghb_settings_get_int(ud->settings, "start_chapter"); - gint end = ghb_settings_get_int(ud->settings, "end_chapter"); - widget = GHB_WIDGET (ud->builder, "ChapterMarkers"); - gtk_widget_set_sensitive(widget, TRUE); - if (start == end) - { - ud->dont_clear_presets = TRUE; - ghb_ui_update(ud, "ChapterMarkers", ghb_boolean_value(FALSE)); - ud->dont_clear_presets = FALSE; - gtk_widget_set_sensitive(widget, FALSE); + if (ghb_settings_combo_int(ud->settings, "PtoPType") == 0) + { + gint start, end; + start = ghb_settings_get_int(ud->settings, "start_point"); + end = ghb_settings_get_int(ud->settings, "end_point"); + widget = GHB_WIDGET (ud->builder, "ChapterMarkers"); + gtk_widget_set_sensitive(widget, TRUE); + if (start == end) + { + ud->dont_clear_presets = TRUE; + ghb_ui_update(ud, "ChapterMarkers", ghb_boolean_value(FALSE)); + ud->dont_clear_presets = FALSE; + gtk_widget_set_sensitive(widget, FALSE); + } } } diff --git a/gtk/src/queuehandler.c b/gtk/src/queuehandler.c index 4ba09571..24eded5d 100644 --- a/gtk/src/queuehandler.c +++ b/gtk/src/queuehandler.c @@ -70,7 +70,7 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter) gchar *dest, *preset, *vol_name, *basename; const gchar *vcodec, *container; gchar *fps, *vcodec_abbr; - gint title, start_chapter, end_chapter, width, height; + gint title, start_point, end_point, width, height; gint source_width, source_height; gboolean pass2 = FALSE, keep_aspect, vqtype, turbo; gint pic_par; @@ -84,8 +84,8 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter) tweaks = ghb_settings_get_boolean(settings, "allow_tweaks"); title = ghb_settings_get_int(settings, "titlenum"); - start_chapter = ghb_settings_get_int(settings, "start_chapter"); - end_chapter = ghb_settings_get_int(settings, "end_chapter"); + start_point = ghb_settings_get_int(settings, "start_point"); + end_point = ghb_settings_get_int(settings, "end_point"); vol_name = ghb_settings_get_string(settings, "volume_label"); dest = ghb_settings_get_string(settings, "destination"); basename = g_path_get_basename(dest); @@ -94,12 +94,19 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter) vqtype = ghb_settings_get_boolean(settings, "vquality_type_constant"); if (!vqtype) pass2 = ghb_settings_get_boolean(settings, "VideoTwoPass"); + const gchar *points; + if (ghb_settings_combo_int(settings, "PtoPType") == 0) + points = "Chapters"; + else if (ghb_settings_combo_int(settings, "PtoPType") == 1) + points = "Seconds"; + else if (ghb_settings_combo_int(settings, "PtoPType") == 2) + points = "Frames"; info = g_strdup_printf ( "%s " - "(Title %d, Chapters %d through %d, %d Video %s)" + "(Title %d, %s %d through %d, %d Video %s)" " --> %s", - vol_name, title, start_chapter, end_chapter, + vol_name, title, points, start_point, end_point, pass2 ? 2:1, pass2 ? "Passes":"Pass", escape ); g_free(basename); @@ -1044,7 +1051,8 @@ ghb_queue_buttons_grey(signal_user_data_t *ud) scan_state = ghb_get_scan_state(); show_stop = queue_state & - (GHB_STATE_WORKING | GHB_STATE_SCANNING | GHB_STATE_MUXING); + (GHB_STATE_WORKING | GHB_STATE_SEARCHING | + GHB_STATE_SCANNING | GHB_STATE_MUXING); show_start = !(scan_state & GHB_STATE_SCANNING) && (titleindex >= 0 || queue_count > 0); @@ -1205,7 +1213,8 @@ queue_start_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) gint state; state = ghb_get_queue_state(); - if (state & (GHB_STATE_WORKING | GHB_STATE_SCANNING | GHB_STATE_MUXING)) + if (state & (GHB_STATE_WORKING | GHB_STATE_SEARCHING | + GHB_STATE_SCANNING | GHB_STATE_MUXING)) { ghb_cancel_encode(ud, "You are currently encoding. " "What would you like to do?"); diff --git a/gtk/src/settings.h b/gtk/src/settings.h index c499da53..43fbdbfa 100644 --- a/gtk/src/settings.h +++ b/gtk/src/settings.h @@ -34,6 +34,7 @@ enum GHB_STATE_WORKDONE = 0x10, GHB_STATE_PAUSED = 0x20, GHB_STATE_MUXING = 0x40, + GHB_STATE_SEARCHING = 0x80, }; enum diff --git a/gtk/src/widgetdeps.c b/gtk/src/widgetdeps.c index 4e161fa5..71a54471 100644 --- a/gtk/src/widgetdeps.c +++ b/gtk/src/widgetdeps.c @@ -23,11 +23,14 @@ static dependency_t dep_map[] = {"title", "picture_tab", "none", TRUE, FALSE}, {"title", "chapters_label", "none", TRUE, FALSE}, {"title", "chapters_tab", "none", TRUE, FALSE}, - {"title", "start_chapter", "none", TRUE, FALSE}, - {"title", "end_chapter", "none", TRUE, FALSE}, + {"title", "start_point", "none", TRUE, FALSE}, + {"title", "end_point", "none", TRUE, FALSE}, {"title", "angle", "none", TRUE, FALSE}, + {"title", "angle_label", "1", TRUE, FALSE}, {"use_dvdnav", "angle", "FALSE", TRUE, TRUE}, {"use_dvdnav", "angle_label", "FALSE", TRUE, TRUE}, + {"angle_count", "angle", "1", TRUE, TRUE}, + {"angle_count", "angle_label", "1", TRUE, TRUE}, {"vquality_type_bitrate", "VideoAvgBitrate", "TRUE", FALSE, FALSE}, {"vquality_type_target", "VideoTargetSize", "TRUE", FALSE, FALSE}, {"vquality_type_constant", "VideoQualitySlider", "TRUE", FALSE, FALSE}, -- 2.11.0