diff options
author | John Stebbins <[email protected]> | 2018-03-16 12:06:04 -0600 |
---|---|---|
committer | John Stebbins <[email protected]> | 2018-03-16 12:06:04 -0600 |
commit | 462362a16a4e592424fa0f662f36921ec942d052 (patch) | |
tree | dc7615da8175ce1c67a33fdea1e4251ace1e28fd /gtk/src | |
parent | c03887672673ffd9b03cddf0f6b1317fbf5b1eaa (diff) |
LinGui: fix rounding error in display aspect
This is only a cosmetic display problem. The values used during
encoding are correct.
Diffstat (limited to 'gtk/src')
-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); |