diff options
-rw-r--r-- | gtk/src/callbacks.c | 8 | ||||
-rw-r--r-- | gtk/src/hb-backend.c | 29 | ||||
-rw-r--r-- | gtk/src/hb-backend.h | 2 |
3 files changed, 24 insertions, 15 deletions
diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c index 0bdb9c08b..b399090ab 100644 --- a/gtk/src/callbacks.c +++ b/gtk/src/callbacks.c @@ -2674,7 +2674,8 @@ ghb_update_summary_info(signal_user_data_t *ud) gtk_label_set_text(GTK_LABEL(widget), text); g_free(text); - int width, height, display_width, display_height, par_width, par_height; + double display_width; + int width, height, display_height, par_width, par_height; char * display_aspect; width = ghb_dict_get_int(ud->settings, "scale_width"); @@ -2684,12 +2685,15 @@ ghb_update_summary_info(signal_user_data_t *ud) par_width = ghb_dict_get_int(ud->settings, "PicturePARWidth"); par_height = ghb_dict_get_int(ud->settings, "PicturePARHeight"); + display_width = (double)width * par_width / par_height; display_aspect = ghb_get_display_aspect_string(display_width, display_height); + + display_width = ghb_dict_get_int(ud->settings, "PictureDisplayWidth"); text = g_strdup_printf("%dx%d storage, %dx%d display\n" "%d:%d Pixel Aspect Ratio\n" "%s Display Aspect Ratio", - width, height, display_width, display_height, + width, height, (int)display_width, display_height, par_width, par_height, display_aspect); widget = GHB_WIDGET(ud->builder, "dimensions_summary"); gtk_label_set_text(GTK_LABEL(widget), text); diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c index a3f5aa58a..3d947c8c1 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -3792,27 +3792,27 @@ ghb_set_scale_settings(GhbValue *settings, gint mode) } char * -ghb_get_display_aspect_string(int disp_width, int disp_height) +ghb_get_display_aspect_string(double disp_width, double disp_height) { - gint dar_width, dar_height; gchar *str; - hb_reduce(&dar_width, &dar_height, disp_width, disp_height); - gint iaspect = dar_width * 9 / dar_height; - if (dar_width > 2 * dar_height) + gint iaspect = disp_width * 9 / disp_height; + if (disp_width > 2 * disp_height) { - str = g_strdup_printf("%.2f:1", (gdouble)dar_width / dar_height); + str = g_strdup_printf("%.2f:1", disp_width / disp_height); } else if (iaspect <= 16 && iaspect >= 15) { - str = g_strdup_printf("%.4g:9", (gdouble)dar_width * 9 / dar_height); + str = g_strdup_printf("%.4g:9", disp_width * 9 / disp_height); } else if (iaspect <= 12 && iaspect >= 11) { - str = g_strdup_printf("%.4g:3", (gdouble)dar_width * 3 / dar_height); + str = g_strdup_printf("%.4g:3", disp_width * 3 / disp_height); } else { + gint dar_width, dar_height; + hb_reduce(&dar_width, &dar_height, disp_width, disp_height); str = g_strdup_printf("%d:%d", dar_width, dar_height); } return str; @@ -3821,12 +3821,17 @@ ghb_get_display_aspect_string(int disp_width, int disp_height) void ghb_update_display_aspect_label(signal_user_data_t *ud) { - gint disp_width, disp_height; + gint width, disp_height; + gint par_num, par_den; + double disp_width; gchar *str; - disp_width = ghb_dict_get_int(ud->settings, "PictureDisplayWidth"); - disp_height = ghb_dict_get_int(ud->settings, "PictureDisplayHeight"); - str = ghb_get_display_aspect_string(disp_width, disp_height); + width = ghb_dict_get_int(ud->settings, "scale_width"); + disp_height = ghb_dict_get_int(ud->settings, "scale_height"); + par_num = ghb_dict_get_int(ud->settings, "PicturePARWidth"); + par_den = ghb_dict_get_int(ud->settings, "PicturePARHeight"); + disp_width = (double)width * par_num / par_den; + str = ghb_get_display_aspect_string(disp_width, disp_height); ghb_ui_update(ud, "display_aspect", ghb_string_value(str)); g_free(str); } diff --git a/gtk/src/hb-backend.h b/gtk/src/hb-backend.h index 9cc157a51..481aafbb2 100644 --- a/gtk/src/hb-backend.h +++ b/gtk/src/hb-backend.h @@ -225,7 +225,7 @@ const hb_rate_t* ghb_settings_audio_bitrate( const char* ghb_audio_bitrate_get_short_name(int rate); hb_audio_config_t* ghb_get_audio_info(const hb_title_t *title, gint track); hb_subtitle_t* ghb_get_subtitle_info(const hb_title_t *title, gint track); -char * ghb_get_display_aspect_string(int disp_width, int disp_height); +char * ghb_get_display_aspect_string(double disp_width, double disp_height); hb_handle_t* ghb_scan_handle(void); hb_handle_t* ghb_queue_handle(void); |