X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=gtk%2Fsrc%2Fhb-backend.c;h=5a1bc135bdbb0635e4da6fa118eae8c48cd6956c;hb=2327fee8183124631ba4b43e0b35f984e1b85a3a;hp=bff39740105766d4db504821e3c51c275853fc25;hpb=327d5f7ff96fdb6872f1fe9894e82b01b1b5e5ad;p=handbrake-jp%2Fhandbrake-jp-git.git diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c index bff39740..5a1bc135 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -25,7 +25,6 @@ #include #include #include "hb.h" -#include "hbversion.h" #include #include #include "hb-backend.h" @@ -39,7 +38,7 @@ typedef struct { const gchar *option; const gchar *shortOpt; - gint ivalue; + gdouble ivalue; const gchar *svalue; } options_map_t; @@ -64,6 +63,33 @@ static const gchar *index_str[] = "10", }; +static options_map_t d_par_opts[] = +{ + {"Off", "0", 0, "0"}, + {"Strict", "1", 1, "1"}, + {"Loose", "2", 2, "2"}, + {"Custom", "3", 3, "3"}, +}; +combo_opts_t par_opts = +{ + sizeof(d_par_opts)/sizeof(options_map_t), + d_par_opts +}; + +static options_map_t d_alignment_opts[] = +{ + {"1", "1", 1, "1"}, + {"2", "2", 2, "2"}, + {"4", "4", 4, "4"}, + {"8", "8", 8, "8"}, + {"16", "16", 16, "16"}, +}; +combo_opts_t alignment_opts = +{ + sizeof(d_alignment_opts)/sizeof(options_map_t), + d_alignment_opts +}; + static options_map_t d_logging_opts[] = { {"0", "0", 0, "0"}, @@ -76,13 +102,24 @@ combo_opts_t logging_opts = d_logging_opts }; +static options_map_t d_vqual_granularity_opts[] = +{ + {"0.2", "0.2", 0.2, "0.2"}, + {"0.25", "0.25", 0.25, "0.25"}, + {"0.5", "0.5", 0.5, "0.5"}, + {"1", "1", 1, "1"}, +}; +combo_opts_t vqual_granularity_opts = +{ + sizeof(d_vqual_granularity_opts)/sizeof(options_map_t), + d_vqual_granularity_opts +}; + static options_map_t d_container_opts[] = { {"MKV", "mkv", HB_MUX_MKV, "mkv"}, {"MP4", "mp4", HB_MUX_MP4, "mp4"}, {"M4V", "m4v", HB_MUX_MP4, "m4v"}, - {"AVI", "avi", HB_MUX_AVI, "avi"}, - {"OGM", "ogm", HB_MUX_OGM, "ogm"}, }; combo_opts_t container_opts = { @@ -90,12 +127,37 @@ combo_opts_t container_opts = d_container_opts }; +static options_map_t d_detel_opts[] = +{ + {"None", "none", 0, ""}, + {"Custom", "custom", 1, ""}, + {"Default","default",2, NULL}, +}; +combo_opts_t detel_opts = +{ + sizeof(d_detel_opts)/sizeof(options_map_t), + d_detel_opts +}; + +static options_map_t d_decomb_opts[] = +{ + {"None", "none", 0, ""}, + {"Custom", "custom", 1, ""}, + {"Default","default",2, NULL}, +}; +combo_opts_t decomb_opts = +{ + sizeof(d_decomb_opts)/sizeof(options_map_t), + d_decomb_opts +}; + static options_map_t d_deint_opts[] = { {"None", "none", 0, ""}, - {"Fast", "fast", 1, "-1:-1:-1:0:1"}, - {"Slow", "slow", 2, "2:-1:-1:0:1"}, - {"Slower", "slower", 3, "0:-1:-1:0:1"}, + {"Custom", "custom", 1, ""}, + {"Fast", "fast", 2, "-1:-1:-1:0:1"}, + {"Slow", "slow", 3, "2:-1:-1:0:1"}, + {"Slower", "slower", 4, "0:-1:-1:0:1"}, }; combo_opts_t deint_opts = { @@ -106,9 +168,10 @@ combo_opts_t deint_opts = static options_map_t d_denoise_opts[] = { {"None", "none", 0, ""}, - {"Weak", "weak", 1, "2:1:2:3"}, - {"Medium", "medium", 2, "3:2:2:3"}, - {"Strong", "strong", 3, "7:7:5:5"}, + {"Custom", "custom", 1, ""}, + {"Weak", "weak", 2, "2:1:2:3"}, + {"Medium", "medium", 3, "3:2:2:3"}, + {"Strong", "strong", 4, "7:7:5:5"}, }; combo_opts_t denoise_opts = { @@ -119,7 +182,6 @@ combo_opts_t denoise_opts = static options_map_t d_vcodec_opts[] = { {"H.264 (x264)", "x264", HB_VCODEC_X264, ""}, - {"MPEG-4 (XviD)", "xvid", HB_VCODEC_XVID, ""}, {"MPEG-4 (FFMPEG)", "ffmpeg", HB_VCODEC_FFMPEG, ""}, {"Theora", "theora", HB_VCODEC_THEORA, ""}, }; @@ -156,6 +218,18 @@ combo_opts_t direct_opts = d_direct_opts }; +static options_map_t d_badapt_opts[] = +{ + {"Off", "0", 0, "0"}, + {"Fast", "1", 1, "1"}, + {"Optimal", "2", 2, "2"}, +}; +combo_opts_t badapt_opts = +{ + sizeof(d_badapt_opts)/sizeof(options_map_t), + d_badapt_opts +}; + static options_map_t d_me_opts[] = { {"Diamond", "dia", 0, "dia"}, @@ -203,8 +277,8 @@ combo_opts_t analyse_opts = static options_map_t d_trellis_opts[] = { - {"Disabled", "0", 0, "0"}, - {"Final Macro Block", "1", 1, "1"}, + {"Disabled", "0", 0, "0"}, + {"Final Macro Block", "1", 1, "1"}, {"Always", "2", 2, "2"}, }; combo_opts_t trellis_opts = @@ -239,15 +313,19 @@ typedef struct combo_name_map_t combo_name_map[] = { + {"PicturePAR", &par_opts}, + {"PictureAlignment", &alignment_opts}, {"LoggingLevel", &logging_opts}, + {"VideoQualityGranularity", &vqual_granularity_opts}, {"FileFormat", &container_opts}, {"PictureDeinterlace", &deint_opts}, - {"tweak_PictureDeinterlace", &deint_opts}, + {"PictureDecomb", &decomb_opts}, + {"PictureDetelecine", &detel_opts}, {"PictureDenoise", &denoise_opts}, - {"tweak_PictureDenoise", &denoise_opts}, {"VideoEncoder", &vcodec_opts}, {"AudioEncoder", &acodec_opts}, {"x264_direct", &direct_opts}, + {"x264_b_adapt", &badapt_opts}, {"x264_me", &me_opts}, {"x264_subme", &subme_opts}, {"x264_analyse", &analyse_opts}, @@ -493,7 +571,7 @@ del_tree(const gchar *name, gboolean del_top) const gchar* ghb_version() { - return HB_VERSION; + return hb_get_version(NULL); } void @@ -503,41 +581,51 @@ ghb_vquality_range( gdouble *max, gdouble *step, gdouble *page, - gint *digits) + gint *digits, + gboolean *inverted) { - if (ghb_settings_get_boolean(ud->settings, "directqp")) + gint vcodec = ghb_settings_combo_int(ud->settings, "VideoEncoder"); + *page = 10; + *digits = 0; + switch (vcodec) { - gint vcodec = ghb_settings_combo_int(ud->settings, "VideoEncoder"); - // Only x264 and ffmpeg currently support direct qp/crf entry - *step = 1; - *page = 10; - *digits = 0; - if (vcodec == HB_VCODEC_X264) + case HB_VCODEC_X264: { *min = 0; *max = 51; - } - else if (vcodec == HB_VCODEC_FFMPEG) + *step = ghb_settings_combo_double(ud->settings, + "VideoQualityGranularity"); + if (*step == 0.2 || *step == 0.5) + *digits = 1; + else if (*step == 0.25) + *digits = 2; + *inverted = TRUE; + } break; + + case HB_VCODEC_XVID: + case HB_VCODEC_FFMPEG: { - *min = 0; + *min = 1; *max = 31; - } - else + *step = 1; + *inverted = TRUE; + } break; + + case HB_VCODEC_THEORA: { *min = 0; - *max = 1.0; - *step = 0.001; - *page = 0.1; - *digits = 3; - } - } - else - { - *min = 0; - *max = 1.0; - *step = 0.001; - *page = 0.1; - *digits = 3; + *max = 63; + *step = 1; + *inverted = FALSE; + } break; + + default: + { + *min = 0; + *max = 100; + *step = 1; + *inverted = FALSE; + } break; } } @@ -561,6 +649,26 @@ lookup_generic_int(combo_opts_t *opts, const GValue *gval) return result; } +static gdouble +lookup_generic_double(combo_opts_t *opts, const GValue *gval) +{ + gint ii; + gchar *str; + gdouble result = -1; + + str = ghb_value_string(gval); + for (ii = 0; ii < opts->count; ii++) + { + if (strcmp(opts->map[ii].shortOpt, str) == 0) + { + result = opts->map[ii].ivalue; + break; + } + } + g_free(str); + return result; +} + static const gchar* lookup_generic_option(combo_opts_t *opts, const GValue *gval) { @@ -805,7 +913,7 @@ get_acodec_value(gint val) for (ii = 0; ii < acodec_opts.count; ii++) { - if (acodec_opts.map[ii].ivalue == val) + if ((int)acodec_opts.map[ii].ivalue == val) { value = ghb_string_value_new(acodec_opts.map[ii].shortOpt); break; @@ -1155,7 +1263,7 @@ init_combo_box(GtkBuilder *builder, const gchar *name) // 4 - Int value determined by backend // 5 - String value determined by backend store = gtk_list_store_new(5, G_TYPE_STRING, G_TYPE_BOOLEAN, - G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING); + G_TYPE_STRING, G_TYPE_DOUBLE, G_TYPE_STRING); gtk_combo_box_set_model(combo, GTK_TREE_MODEL(store)); if (GTK_WIDGET_TYPE(combo) == GTK_TYPE_COMBO_BOX) @@ -1188,7 +1296,7 @@ audio_samplerate_opts_set(GtkBuilder *builder, const gchar *name, hb_rate_t *rat 0, "Same as source", 1, TRUE, 2, "source", - 3, 0, + 3, 0.0, 4, "source", -1); for (ii = 0; ii < count; ii++) @@ -1198,7 +1306,7 @@ audio_samplerate_opts_set(GtkBuilder *builder, const gchar *name, hb_rate_t *rat 0, rates[ii].string, 1, TRUE, 2, rates[ii].string, - 3, rates[ii].rate, + 3, (gdouble)rates[ii].rate, 4, rates[ii].string, -1); } @@ -1220,7 +1328,7 @@ video_rate_opts_set(GtkBuilder *builder, const gchar *name, hb_rate_t *rates, gi 0, "Same as source", 1, TRUE, 2, "source", - 3, 0, + 3, 0.0, 4, "source", -1); for (ii = 0; ii < count; ii++) @@ -1245,7 +1353,7 @@ video_rate_opts_set(GtkBuilder *builder, const gchar *name, hb_rate_t *rates, gi 0, option, 1, TRUE, 2, rates[ii].string, - 3, rates[ii].rate, + 3, (gdouble)rates[ii].rate, 4, rates[ii].string, -1); g_free(option); @@ -1267,7 +1375,7 @@ mix_opts_set(GtkBuilder *builder, const gchar *name) 0, "None", 1, TRUE, 2, "none", - 3, 0, + 3, 0.0, 4, "none", -1); for (ii = 0; ii < hb_audio_mixdowns_count; ii++) @@ -1277,7 +1385,7 @@ mix_opts_set(GtkBuilder *builder, const gchar *name) 0, hb_audio_mixdowns[ii].human_readable_name, 1, TRUE, 2, hb_audio_mixdowns[ii].short_name, - 3, hb_audio_mixdowns[ii].amixdown, + 3, (gdouble)hb_audio_mixdowns[ii].amixdown, 4, hb_audio_mixdowns[ii].internal_name, -1); } @@ -1300,7 +1408,7 @@ language_opts_set(GtkBuilder *builder, const gchar *name) 0, ghb_language_table[ii].eng_name, 1, TRUE, 2, ghb_language_table[ii].iso639_2, - 3, ii, + 3, (gdouble)ii, 4, ghb_language_table[ii].iso639_1, -1); } @@ -1349,7 +1457,7 @@ title_opts_set(GtkBuilder *builder, const gchar *name) 0, "No Titles", 1, TRUE, 2, "none", - 3, -1, + 3, -1.0, 4, "none", -1); title_opts.map[0].option = "No Titles"; @@ -1375,7 +1483,7 @@ title_opts_set(GtkBuilder *builder, const gchar *name) 0, titles[ii], 1, TRUE, 2, titles[ii], - 3, ii, + 3, (gdouble)ii, 4, titles[ii], -1); title_opts.map[ii].option = titles[ii]; @@ -1389,7 +1497,7 @@ title_opts_set(GtkBuilder *builder, const gchar *name) static gboolean find_combo_item_by_int(GtkTreeModel *store, gint value, GtkTreeIter *iter) { - gint ivalue; + gdouble ivalue; gboolean foundit = FALSE; if (gtk_tree_model_get_iter_first (store, iter)) @@ -1397,7 +1505,7 @@ find_combo_item_by_int(GtkTreeModel *store, gint value, GtkTreeIter *iter) do { gtk_tree_model_get(store, iter, 3, &ivalue, -1); - if (value == ivalue) + if (value == (int)ivalue) { foundit = TRUE; break; @@ -1430,7 +1538,7 @@ audio_track_opts_set(GtkBuilder *builder, const gchar *name, gint titleindex) count = hb_list_count( title->list_audio ); } } - if (count > 10) count = 10; + if (count > 100) count = 100; if (audio_track_opts.map) g_free(audio_track_opts.map); if (count > 0) { @@ -1450,7 +1558,7 @@ audio_track_opts_set(GtkBuilder *builder, const gchar *name, gint titleindex) 0, "No Audio", 1, TRUE, 2, "none", - 3, -1, + 3, -1.0, 4, "none", -1); audio_track_opts.map[0].option = "No Audio"; @@ -1467,7 +1575,7 @@ audio_track_opts_set(GtkBuilder *builder, const gchar *name, gint titleindex) 0, audio->lang.description, 1, TRUE, 2, index_str[ii], - 3, ii, + 3, (gdouble)ii, 4, index_str[ii], -1); audio_track_opts.map[ii].option = audio->lang.description, @@ -1501,7 +1609,7 @@ subtitle_opts_set(GtkBuilder *builder, const gchar *name, gint titleindex) count = hb_list_count( title->list_subtitle ); } } - if (count > 10) count = 10; + if (count > 100) count = 100; if (subtitle_opts.map) g_free(subtitle_opts.map); if (count > 0) { @@ -1519,7 +1627,7 @@ subtitle_opts_set(GtkBuilder *builder, const gchar *name, gint titleindex) 0, "None", 1, TRUE, 2, "none", - 3, -2, + 3, -2.0, 4, "none", -1); subtitle_opts.map[0].option = "None"; @@ -1531,14 +1639,14 @@ subtitle_opts_set(GtkBuilder *builder, const gchar *name, gint titleindex) 0, "Autoselect", 1, TRUE, 2, "auto", - 3, -1, + 3, -1.0, 4, "auto", -1); subtitle_opts.map[0].option = "Same as audio"; subtitle_opts.map[0].shortOpt = "auto"; subtitle_opts.map[0].ivalue = -1; subtitle_opts.map[0].svalue = "auto"; - if (count >0) + if (count > 0) { for (ii = 0; ii < count; ii++) { @@ -1548,7 +1656,7 @@ subtitle_opts_set(GtkBuilder *builder, const gchar *name, gint titleindex) 0, subtitle->lang, 1, TRUE, 2, subtitle->iso639_2, - 3, ii, + 3, (gdouble)ii, 4, subtitle->iso639_2, -1); subtitle_opts.map[ii+2].option = subtitle->lang; @@ -1566,7 +1674,7 @@ subtitle_opts_set(GtkBuilder *builder, const gchar *name, gint titleindex) 0, ghb_language_table[ii].eng_name, 1, TRUE, 2, ghb_language_table[ii].iso639_2, - 3, ii, + 3, (gdouble)ii, 4, ghb_language_table[ii].iso639_2, -1); subtitle_opts.map[ii+2].option = ghb_language_table[ii].eng_name; @@ -1821,6 +1929,27 @@ ghb_lookup_combo_int(const gchar *name, const GValue *gval) return 0; } +gdouble +ghb_lookup_combo_double(const gchar *name, const GValue *gval) +{ + if (strcmp(name, "AudioBitrate") == 0) + return lookup_audio_bitrate_int(gval); + else if (strcmp(name, "AudioSamplerate") == 0) + return lookup_audio_rate_int(gval); + else if (strcmp(name, "VideoFramerate") == 0) + return lookup_video_rate_int(gval); + else if (strcmp(name, "AudioMixdown") == 0) + return lookup_mix_int(gval); + else if (strcmp(name, "SourceAudioLang") == 0) + return lookup_audio_lang_int(gval); + else + { + return lookup_generic_double(find_combo_table(name), gval); + } + g_warning("ghb_lookup_combo_double() couldn't find %s", name); + return 0; +} + const gchar* ghb_lookup_combo_option(const gchar *name, const GValue *gval) { @@ -1879,15 +2008,19 @@ ghb_update_ui_combo_box(GtkBuilder *builder, const gchar *name, gint user_data, subtitle_opts_set(builder, "Subtitles", user_data); title_opts_set(builder, "title"); audio_track_opts_set(builder, "AudioTrack", user_data); + generic_opts_set(builder, "VideoQualityGranularity", &vqual_granularity_opts); + generic_opts_set(builder, "PicturePAR", &par_opts); + generic_opts_set(builder, "PictureAlignment", &alignment_opts); generic_opts_set(builder, "LoggingLevel", &logging_opts); generic_opts_set(builder, "FileFormat", &container_opts); generic_opts_set(builder, "PictureDeinterlace", &deint_opts); - generic_opts_set(builder, "tweak_PictureDeinterlace", &deint_opts); + generic_opts_set(builder, "PictureDetelecine", &detel_opts); + generic_opts_set(builder, "PictureDecomb", &decomb_opts); generic_opts_set(builder, "PictureDenoise", &denoise_opts); - generic_opts_set(builder, "tweak_PictureDenoise", &denoise_opts); generic_opts_set(builder, "VideoEncoder", &vcodec_opts); generic_opts_set(builder, "AudioEncoder", &acodec_opts); generic_opts_set(builder, "x264_direct", &direct_opts); + generic_opts_set(builder, "x264_b_adapt", &badapt_opts); generic_opts_set(builder, "x264_me", &me_opts); generic_opts_set(builder, "x264_subme", &subme_opts); generic_opts_set(builder, "x264_analyse", &analyse_opts); @@ -1961,6 +2094,29 @@ ghb_build_x264opts_string(GValue *settings) return result; } +void +ghb_get_chapter_duration(gint ti, gint ii, gint *hh, gint *mm, gint *ss) +{ + hb_list_t * list; + hb_title_t * title; + hb_chapter_t * chapter; + gint count; + + g_debug("ghb_get_chapter_duration (title = %d)\n", ti); + *hh = *mm = *ss = 0; + if (h_scan == NULL) return; + list = hb_get_titles( h_scan ); + title = (hb_title_t*)hb_list_item( list, ti ); + if (title == NULL) return; + count = hb_list_count( title->list_chapter ); + if (ii >= count) return; + chapter = hb_list_item(title->list_chapter, ii); + if (chapter == NULL) return; + *hh = chapter->hours; + *mm = chapter->minutes; + *ss = chapter->seconds; +} + GValue* ghb_get_chapters(gint titleindex) { @@ -2032,7 +2188,7 @@ audio_bitrate_opts_add(GtkBuilder *builder, const gchar *name, gint rate) 0, str, 1, TRUE, 2, str, - 3, rate, + 3, (gdouble)rate, 4, str, -1); g_free(str); @@ -2044,7 +2200,7 @@ audio_bitrate_opts_clean(GtkBuilder *builder, const gchar *name, gint last_rate) { GtkTreeIter iter; GtkListStore *store; - gint ivalue; + gdouble ivalue; gboolean done = FALSE; gint ii = 0; guint last = (guint)last_rate; @@ -2094,7 +2250,7 @@ audio_bitrate_opts_set(GtkBuilder *builder, const gchar *name) 0, hb_audio_bitrates[ii].string, 1, TRUE, 2, hb_audio_bitrates[ii].string, - 3, hb_audio_bitrates[ii].rate, + 3, (gdouble)hb_audio_bitrates[ii].rate, 4, hb_audio_bitrates[ii].string, -1); } @@ -2419,13 +2575,49 @@ ghb_get_default_acodec() return HB_ACODEC_FAAC; } +static void +picture_settings_deps(signal_user_data_t *ud) +{ + gboolean autoscale, keep_aspect; + gboolean enable_scale_width, enable_scale_height; + gboolean enable_disp_width, enable_disp_height; + gint pic_par, disp_width, disp_height, scale_width, scale_height; + + pic_par = ghb_settings_combo_int(ud->settings, "PicturePAR"); + keep_aspect = ghb_settings_get_boolean(ud->settings, "PictureKeepRatio"); + autoscale = ghb_settings_get_boolean(ud->settings, "autoscale"); + disp_width = ghb_settings_get_int(ud->settings, "PictureDisplayWidth"); + disp_height = ghb_settings_get_int(ud->settings, "PictureDisplayHeight"); + scale_width = ghb_settings_get_int(ud->settings, "scale_width"); + scale_height = ghb_settings_get_int(ud->settings, "scale_height"); + + enable_scale_width = !autoscale && (pic_par != 1); + enable_scale_height = !autoscale && + ((pic_par == 0 && !keep_aspect) || (pic_par == 3)); + enable_disp_width = (pic_par == 3) && !keep_aspect && + (disp_height == scale_height); + enable_disp_height = (pic_par == 3) && !keep_aspect && + (disp_width == scale_width); + + GtkWidget *widget; + widget = GHB_WIDGET(ud->builder, "scale_width"); + gtk_widget_set_sensitive(widget, enable_scale_width); + widget = GHB_WIDGET(ud->builder, "scale_height"); + gtk_widget_set_sensitive(widget, enable_scale_height); + widget = GHB_WIDGET(ud->builder, "PictureDisplayWidth"); + gtk_widget_set_sensitive(widget, enable_disp_width); + widget = GHB_WIDGET(ud->builder, "PictureDisplayHeight"); + gtk_widget_set_sensitive(widget, enable_disp_height); +} + void ghb_set_scale(signal_user_data_t *ud, gint mode) { hb_list_t * list; hb_title_t * title; hb_job_t * job; - gboolean keep_aspect, round_dims, anamorphic; + gboolean keep_aspect; + gint pic_par; gboolean autocrop, autoscale, noscale; gint crop[4], width, height, par_width, par_height; gint crop_width, crop_height; @@ -2434,8 +2626,7 @@ ghb_set_scale(signal_user_data_t *ud, gint mode) gboolean keep_height = (mode == GHB_SCALE_KEEP_HEIGHT); gint step; GtkWidget *widget; - gint modshift; - gint modround; + gint mod; gint max_width = 0; gint max_height = 0; @@ -2457,8 +2648,8 @@ ghb_set_scale(signal_user_data_t *ud, gint mode) if (job == NULL) return; // First configure widgets - round_dims = ghb_settings_get_boolean(ud->settings, "ModDimensions"); - anamorphic = ghb_settings_get_boolean(ud->settings, "anamorphic"); + mod = ghb_settings_combo_int(ud->settings, "PictureAlignment"); + pic_par = ghb_settings_combo_int(ud->settings, "PicturePAR"); keep_aspect = ghb_settings_get_boolean(ud->settings, "PictureKeepRatio"); autocrop = ghb_settings_get_boolean(ud->settings, "PictureAutoCrop"); autoscale = ghb_settings_get_boolean(ud->settings, "autoscale"); @@ -2468,8 +2659,6 @@ ghb_set_scale(signal_user_data_t *ud, gint mode) // Align dimensions to either 16 or 2 pixels // The scaler crashes if the dimensions are not divisible by 2 // x264 also will not accept dims that are not multiple of 2 - modshift = round_dims ? 4 : 1; - modround = round_dims ? 8 : 1; if (autoscale) { keep_width = FALSE; @@ -2480,49 +2669,89 @@ ghb_set_scale(signal_user_data_t *ud, gint mode) keep_height = FALSE; } // Step needs to be at least 2 because odd widths cause scaler crash - step = round_dims ? 16 : 2; + step = mod; widget = GHB_WIDGET (ud->builder, "scale_width"); - gtk_spin_button_set_increments (GTK_SPIN_BUTTON(widget), step, 16); + gtk_spin_button_set_increments (GTK_SPIN_BUTTON(widget), step, mod); widget = GHB_WIDGET (ud->builder, "scale_height"); - gtk_spin_button_set_increments (GTK_SPIN_BUTTON(widget), step, 16); - if (autocrop) + gtk_spin_button_set_increments (GTK_SPIN_BUTTON(widget), step, mod); + if (mod == 1) + { + widget = GHB_WIDGET (ud->builder, "PictureTopCrop"); + gtk_spin_button_set_increments (GTK_SPIN_BUTTON(widget), step, 2); + widget = GHB_WIDGET (ud->builder, "PictureBottomCrop"); + gtk_spin_button_set_increments (GTK_SPIN_BUTTON(widget), step, 2); + widget = GHB_WIDGET (ud->builder, "PictureLeftCrop"); + gtk_spin_button_set_increments (GTK_SPIN_BUTTON(widget), step, 2); + widget = GHB_WIDGET (ud->builder, "PictureRightCrop"); + gtk_spin_button_set_increments (GTK_SPIN_BUTTON(widget), step, 2); + } + else { - ghb_title_info_t tinfo; - - if (ghb_get_title_info (&tinfo, titleindex)) + widget = GHB_WIDGET (ud->builder, "PictureTopCrop"); + gtk_spin_button_set_increments (GTK_SPIN_BUTTON(widget), step, 1); + widget = GHB_WIDGET (ud->builder, "PictureBottomCrop"); + gtk_spin_button_set_increments (GTK_SPIN_BUTTON(widget), step, 1); + widget = GHB_WIDGET (ud->builder, "PictureLeftCrop"); + gtk_spin_button_set_increments (GTK_SPIN_BUTTON(widget), step, 1); + widget = GHB_WIDGET (ud->builder, "PictureRightCrop"); + gtk_spin_button_set_increments (GTK_SPIN_BUTTON(widget), step, 1); + } + ghb_title_info_t tinfo; + if (autocrop && ghb_get_title_info (&tinfo, titleindex)) + { + crop[0] = tinfo.crop[0]; + crop[1] = tinfo.crop[1]; + crop[2] = tinfo.crop[2]; + crop[3] = tinfo.crop[3]; + if (noscale) { - crop[0] = tinfo.crop[0]; - crop[1] = tinfo.crop[1]; - crop[2] = tinfo.crop[2]; - crop[3] = tinfo.crop[3]; - if (noscale) - { - gint need1, need2; - - // Adjust the cropping to accomplish the desired width and height - crop_width = tinfo.width - crop[2] - crop[3]; - crop_height = tinfo.height - crop[0] - crop[1]; - width = (crop_width >> modshift) << modshift; - height = (crop_height >> modshift) << modshift; - need1 = (crop_height - height) / 2; - need2 = crop_height - height - need1; - crop[0] += need1; - crop[1] += need2; - need1 = (crop_width - width) / 2; - need2 = crop_width - width - need1; - crop[2] += need1; - crop[3] += need2; - } + gint need1, need2; + + // Adjust the cropping to accomplish the desired width and height + crop_width = tinfo.width - crop[2] - crop[3]; + crop_height = tinfo.height - crop[0] - crop[1]; + width = MOD_ROUND(crop_width, mod); + height = MOD_ROUND(crop_height, mod); + + need1 = (crop_height - height) / 2; + need2 = crop_height - height - need1; + crop[0] += need1; + crop[1] += need2; + need1 = (crop_width - width) / 2; + need2 = crop_width - width - need1; + crop[2] += need1; + crop[3] += need2; + } + if (mod == 1) + { + crop[0] = MOD_UP(crop[0], 2); + crop[1] = MOD_UP(crop[1], 2); + crop[2] = MOD_UP(crop[2], 2); + crop[3] = MOD_UP(crop[3], 2); + } + ghb_ui_update(ud, "PictureTopCrop", ghb_int64_value(crop[0])); + ghb_ui_update(ud, "PictureBottomCrop", ghb_int64_value(crop[1])); + ghb_ui_update(ud, "PictureLeftCrop", ghb_int64_value(crop[2])); + ghb_ui_update(ud, "PictureRightCrop", ghb_int64_value(crop[3])); + } + else + { + crop[0] = ghb_settings_get_int(ud->settings, "PictureTopCrop"); + crop[1] = ghb_settings_get_int(ud->settings, "PictureBottomCrop"); + crop[2] = ghb_settings_get_int(ud->settings, "PictureLeftCrop"); + crop[3] = ghb_settings_get_int(ud->settings, "PictureRightCrop"); + if (mod == 1) + { + crop[0] = MOD_UP(crop[0], 2); + crop[1] = MOD_UP(crop[1], 2); + crop[2] = MOD_UP(crop[2], 2); + crop[3] = MOD_UP(crop[3], 2); ghb_ui_update(ud, "PictureTopCrop", ghb_int64_value(crop[0])); ghb_ui_update(ud, "PictureBottomCrop", ghb_int64_value(crop[1])); ghb_ui_update(ud, "PictureLeftCrop", ghb_int64_value(crop[2])); ghb_ui_update(ud, "PictureRightCrop", ghb_int64_value(crop[3])); } } - crop[0] = ghb_settings_get_int(ud->settings, "PictureTopCrop"); - crop[1] = ghb_settings_get_int(ud->settings, "PictureBottomCrop"); - crop[2] = ghb_settings_get_int(ud->settings, "PictureLeftCrop"); - crop[3] = ghb_settings_get_int(ud->settings, "PictureRightCrop"); hb_reduce(&aspect_n, &aspect_d, title->width * title->pixel_aspect_width, title->height * title->pixel_aspect_height); @@ -2532,54 +2761,82 @@ ghb_set_scale(signal_user_data_t *ud, gint mode) { width = crop_width; height = crop_height; - max_width = 0; - max_height = 0; } else { width = ghb_settings_get_int(ud->settings, "scale_width"); height = ghb_settings_get_int(ud->settings, "scale_height"); - max_width = ghb_settings_get_int(ud->settings, "PictureWidth"); - max_height = ghb_settings_get_int(ud->settings, "PictureHeight"); - // Align max dims - max_width = (max_width >> modshift) << modshift; - max_height = (max_height >> modshift) << modshift; - // Adjust dims according to max values - if (!max_height) - { - max_height = crop_height; - } - if (!max_width) - { - max_width = crop_width; - } - height = MIN(height, max_height); - width = MIN(width, max_width); - g_debug("max_width %d, max_height %d\n", max_width, max_height); + max_width = MOD_DOWN( + ghb_settings_get_int(ud->settings, "PictureWidth"), mod); + max_height = MOD_DOWN( + ghb_settings_get_int(ud->settings, "PictureHeight"), mod); + } + // Adjust dims according to max values + if (!max_height) + { + max_height = MOD_DOWN(crop_height, mod); + } + if (!max_width) + { + max_width = MOD_DOWN(crop_width, mod); } + // Align max dims + g_debug("max_width %d, max_height %d\n", max_width, max_height); + if (width < 16) width = title->width - crop[2] - crop[3]; if (height < 16) height = title->height - crop[0] - crop[1]; - if (anamorphic) + width = MOD_ROUND(width, mod); + height = MOD_ROUND(height, mod); + if (max_height) + height = MIN(height, max_height); + if (max_width) + width = MIN(width, max_width); + + if (pic_par) { - job->anamorphic.mode = autoscale ? 2 : 3; + job->anamorphic.mode = pic_par; // The scaler crashes if the dimensions are not divisible by 2 // Align mod 2. And so does something in x264_encoder_headers() - job->anamorphic.modulus = round_dims ? 16 : 2; + job->anamorphic.modulus = mod; job->width = width; job->height = height; + if (max_width) + job->maxWidth = max_width; if (max_height) job->maxHeight = max_height; job->crop[0] = crop[0]; job->crop[1] = crop[1]; job->crop[2] = crop[2]; job->crop[3] = crop[3]; + if (job->anamorphic.mode == 3 && !keep_aspect) + { + gint dar_width, dar_height; + dar_width = ghb_settings_get_int(ud->settings, "PictureDisplayWidth"); + dar_height = ghb_settings_get_int(ud->settings, "PictureDisplayHeight"); + if (dar_width > width) + dar_height = height; + else if (dar_height > height) + dar_width = width; + else + { + dar_width = width; + dar_height = height; + } + job->anamorphic.dar_width = dar_width; + job->anamorphic.dar_height = dar_height; + } + else + { + job->anamorphic.dar_width = 0; + job->anamorphic.dar_height = 0; + } hb_set_anamorphic_size( job, &width, &height, &par_width, &par_height ); } else { - job->anamorphic.mode = 0; + job->anamorphic.mode = pic_par; if (keep_aspect) { gdouble par; @@ -2593,16 +2850,12 @@ ghb_set_scale(signal_user_data_t *ud, gint mode) // Try to keep largest dimension new_height = (crop_height * ((gdouble)width/crop_width) / par); new_width = (crop_width * ((gdouble)height/crop_height) * par); - // Height and width are always multiples of 2, so do the rounding - new_height = ((new_height + 1) >> 1) << 1; - new_width = ((new_width + 1) >> 1) << 1; - if ((max_width && new_width > max_width) || - new_width > title->width) + + if (max_width && new_width > max_width) { height = new_height; } - else if ((max_height && new_height > max_height) || - new_height > title->height) + else if (max_height && new_height > max_height) { width = new_width; } @@ -2624,11 +2877,48 @@ ghb_set_scale(signal_user_data_t *ud, gint mode) } g_debug("new w %d h %d\n", width, height); } - width = ((width + modround) >> modshift) << modshift; - height = ((height + modround) >> modshift) << modshift; + width = MOD_ROUND(width, mod); + height = MOD_ROUND(height, mod); + if (max_height) + height = MIN(height, max_height); + if (max_width) + width = MIN(width, max_width); + par_width = par_height = 1; } ghb_ui_update(ud, "scale_width", ghb_int64_value(width)); ghb_ui_update(ud, "scale_height", ghb_int64_value(height)); + + gint disp_width, disp_height, dar_width, dar_height; + gchar *str; + + disp_width = width; + disp_height = height; + if (par_width >= par_height) + { + disp_width = par_width * width / par_height; + } + else + { + disp_height = par_height * height / par_width; + } + hb_reduce(&dar_width, &dar_height, disp_width, disp_height); + + if (dar_width > 2 * dar_height) + { + str = g_strdup_printf("%.2f:1", (gdouble)dar_width / dar_height); + } + else + { + str = g_strdup_printf("%d:%d", dar_width, dar_height); + } + ghb_ui_update(ud, "display_aspect", ghb_string_value(str)); + g_free(str); + str = g_strdup_printf("%d:%d", par_width, par_height); + ghb_ui_update(ud, "pixel_aspect", ghb_string_value(str)); + g_free(str); + ghb_ui_update(ud, "PictureDisplayWidth", ghb_int64_value(disp_width)); + ghb_ui_update(ud, "PictureDisplayHeight", ghb_int64_value(disp_height)); + picture_settings_deps(ud); } static void @@ -2639,25 +2929,31 @@ set_preview_job_settings(hb_job_t *job, GValue *settings) job->crop[2] = ghb_settings_get_int(settings, "PictureLeftCrop"); job->crop[3] = ghb_settings_get_int(settings, "PictureRightCrop"); - gboolean anamorphic, round_dimensions, autoscale; - autoscale = ghb_settings_get_boolean(settings, "autoscale"); - anamorphic = ghb_settings_get_boolean(settings, "anamorphic"); - round_dimensions = ghb_settings_get_boolean(settings, "ModDimensions"); - if (anamorphic) + job->anamorphic.mode = ghb_settings_combo_int(settings, "PicturePAR"); + job->anamorphic.modulus = + ghb_settings_combo_int(settings, "PictureAlignment"); + job->width = ghb_settings_get_int(settings, "scale_width"); + job->height = ghb_settings_get_int(settings, "scale_height"); + + gint deint = ghb_settings_combo_int(settings, "PictureDeinterlace"); + gint decomb = ghb_settings_combo_int(settings, "PictureDecomb"); + job->deinterlace = (!decomb && deint == 0) ? 0 : 1; + + gboolean keep_aspect; + keep_aspect = ghb_settings_get_boolean(settings, "PictureKeepRatio"); + if (job->anamorphic.mode == 3 && !keep_aspect) { - job->anamorphic.modulus = round_dimensions ? 16 : 2; - job->anamorphic.mode = autoscale ? 2 : 3; + gint disp_width, disp_height; + disp_width = ghb_settings_get_int(settings, "PictureDisplayWidth"); + disp_height = ghb_settings_get_int(settings, "PictureDisplayHeight"); + job->anamorphic.dar_width = disp_width; + job->anamorphic.dar_height = disp_height; } else { - job->anamorphic.modulus = 2; - job->anamorphic.mode = 0; + job->anamorphic.dar_width = 0; + job->anamorphic.dar_height = 0; } - job->width = ghb_settings_get_int(settings, "scale_width"); - job->height = ghb_settings_get_int(settings, "scale_height"); - gint deint = ghb_settings_combo_int(settings, "PictureDeinterlace"); - gboolean decomb = ghb_settings_get_boolean(settings, "PictureDecomb"); - job->deinterlace = (!decomb && deint == 0) ? 0 : 1; } gint @@ -2709,79 +3005,77 @@ ghb_validate_filter_string(const gchar *str, gint max_fields) gboolean ghb_validate_filters(signal_user_data_t *ud) { - gboolean tweaks; gchar *str; gint index; gchar *message; - gboolean enabled; - tweaks = ghb_settings_get_boolean(ud->settings, "allow_tweaks"); - if (tweaks) + // deinte 4 + index = ghb_settings_combo_int(ud->settings, "PictureDeinterlace"); + if (index == 1) { - // detele 6 - str = ghb_settings_get_string(ud->settings, "tweak_PictureDetelecine"); - enabled = ghb_settings_get_boolean(ud->settings, "PictureDetelecine"); - if (enabled && !ghb_validate_filter_string(str, 6)) + str = ghb_settings_get_string(ud->settings, "PictureDeinterlaceCustom"); + if (!ghb_validate_filter_string(str, 4)) { message = g_strdup_printf( - "Invalid Detelecine Settings:\n\n%s\n", + "Invalid Deinterlace Settings:\n\n%s\n", str); ghb_message_dialog(GTK_MESSAGE_ERROR, message, "Cancel", NULL); - g_free(str); g_free(message); + g_free(str); return FALSE; } g_free(str); - // decomb 7 - str = ghb_settings_get_string(ud->settings, "tweak_PictureDecomb"); - enabled = ghb_settings_get_boolean(ud->settings, "PictureDecomb"); - if (enabled && !ghb_validate_filter_string(str, 7)) + } + // detel + index = ghb_settings_combo_int(ud->settings, "PictureDetelecine"); + if (index == 1) + { + str = ghb_settings_get_string(ud->settings, "PictureDetelecineCustom"); + if (!ghb_validate_filter_string(str, 6)) { message = g_strdup_printf( - "Invalid Decomb Settings:\n\n%s\n", + "Invalid Detelecine Settings:\n\n%s\n", str); ghb_message_dialog(GTK_MESSAGE_ERROR, message, "Cancel", NULL); - g_free(str); g_free(message); + g_free(str); return FALSE; } g_free(str); - // deinte 4 - index = ghb_lookup_combo_int("tweak_PictureDeinterlace", - ghb_settings_get_value(ud->settings, "tweak_PictureDeinterlace")); - if (index < 0) + } + // decomb 4 + index = ghb_settings_combo_int(ud->settings, "PictureDecomb"); + if (index == 1) + { + str = ghb_settings_get_string(ud->settings, "PictureDecombCustom"); + if (!ghb_validate_filter_string(str, 7)) { - str = ghb_settings_get_string(ud->settings, "tweak_PictureDeinterlace"); - if (!ghb_validate_filter_string(str, 4)) - { - message = g_strdup_printf( - "Invalid Deinterlace Settings:\n\n%s\n", - str); - ghb_message_dialog(GTK_MESSAGE_ERROR, message, "Cancel", NULL); - g_free(message); - g_free(str); - return FALSE; - } + message = g_strdup_printf( + "Invalid Decomb Settings:\n\n%s\n", + str); + ghb_message_dialog(GTK_MESSAGE_ERROR, message, "Cancel", NULL); + g_free(message); g_free(str); + return FALSE; } - // denois 4 - index = ghb_lookup_combo_int("tweak_PictureDenoise", - ghb_settings_get_value(ud->settings, "tweak_PictureDenoise")); - if (index < 0) + g_free(str); + } + // denois 4 + index = ghb_settings_combo_int(ud->settings, "PictureDenoise"); + if (index == 1) + { + str = ghb_settings_get_string(ud->settings, "PictureDenoiseCustom"); + if (!ghb_validate_filter_string(str, 4)) { - str = ghb_settings_get_string(ud->settings, "tweak_PictureDenoise"); - if (!ghb_validate_filter_string(str, 4)) - { - message = g_strdup_printf( - "Invalid Denoise Settings:\n\n%s\n", - str); - ghb_message_dialog(GTK_MESSAGE_ERROR, message, "Cancel", NULL); - g_free(str); - g_free(message); - return FALSE; - } + message = g_strdup_printf( + "Invalid Denoise Settings:\n\n%s\n", + str); + ghb_message_dialog(GTK_MESSAGE_ERROR, message, "Cancel", NULL); g_free(str); + g_free(message); + return FALSE; } + g_free(str); } return TRUE; } @@ -3024,38 +3318,32 @@ ghb_validate_vquality(GValue *settings) vquality = ghb_settings_get_double(settings, "VideoQualitySlider"); if (ghb_settings_get_boolean(settings, "vquality_type_constant")) { - if (!ghb_settings_get_boolean(settings, "directqp")) - { - vquality *= 100.0; - if (vcodec != HB_VCODEC_X264) - { - min = 68; - max = 97; - } - else - { - min = 40; - max = 70; - } - } - else + switch (vcodec) { - if (vcodec == HB_VCODEC_X264) + case HB_VCODEC_X264: { min = 16; max = 30; - } - else if (vcodec == HB_VCODEC_FFMPEG) + } break; + + case HB_VCODEC_XVID: + case HB_VCODEC_FFMPEG: { min = 1; max = 8; - } - else + } break; + + case HB_VCODEC_THEORA: { - min = 68; - max = 97; - vquality *= 100.0; - } + min = 0; + max = 63; + } break; + + default: + { + min = 48; + max = 62; + } break; } if (vquality < min || vquality > max) { @@ -3174,71 +3462,59 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex) job->crop[3] = ghb_settings_get_int(js, "PictureRightCrop"); - gboolean decomb = ghb_settings_get_boolean(js, "PictureDecomb"); - gint deint = ghb_settings_combo_int(js, - tweaks ? "tweak_PictureDeinterlace":"PictureDeinterlace"); + gint decomb = ghb_settings_combo_int(js, "PictureDecomb"); + gint deint = ghb_settings_combo_int(js, "PictureDeinterlace"); if (!decomb) job->deinterlace = (deint != 0) ? 1 : 0; else job->deinterlace = 0; job->grayscale = ghb_settings_get_boolean(js, "VideoGrayScale"); - gboolean autoscale = ghb_settings_get_boolean(js, "autoscale"); - gboolean anamorphic = ghb_settings_get_boolean(js, "anamorphic"); - gboolean round_dimensions = ghb_settings_get_boolean(js, "ModDimensions"); - if (anamorphic) - { - job->anamorphic.mode = autoscale ? 2 : 3; - // Also, x264 requires things to be divisible by 2. - job->anamorphic.modulus = round_dimensions ? 16 : 2; - } - else - { - job->anamorphic.mode = 0; - job->anamorphic.modulus = 2; - } + job->anamorphic.mode = ghb_settings_get_boolean(js, "PicturePAR"); + job->anamorphic.modulus = ghb_settings_combo_int(js, "PictureAlignment"); + /* Add selected filters */ job->filters = hb_list_init(); gint vrate = ghb_settings_combo_int(js, "VideoFramerate"); - if( vrate == 0 && ghb_settings_get_boolean(js, "PictureDetelecine" ) ) + if( vrate == 0 && ghb_settings_combo_int(js, "PictureDetelecine" ) ) job->vfr = 1; else job->vfr = 0; - if( ghb_settings_get_boolean(js, "PictureDetelecine" ) ) + gint detel = ghb_settings_combo_int(js, "PictureDetelecine"); + if ( detel ) { - hb_filter_detelecine.settings = NULL; - if (tweaks) + if (detel != 1) { - detel_str = ghb_settings_get_string(js, "tweak_PictureDetelecine"); - if (detel_str && detel_str[0]) - { - hb_filter_detelecine.settings = detel_str; - } + if (detel_opts.map[detel].svalue != NULL) + detel_str = g_strdup(detel_opts.map[detel].svalue); } + else + detel_str = ghb_settings_get_string(js, "PictureDetelecineCustom"); + hb_filter_detelecine.settings = detel_str; hb_list_add( job->filters, &hb_filter_detelecine ); } - if( decomb ) + if ( decomb ) { - // Use default settings - hb_filter_decomb.settings = NULL; - if (tweaks) + if (decomb != 1) { - decomb_str = ghb_settings_get_string(js, "tweak_PictureDecomb"); - if (decomb_str && decomb_str[0]) - { - hb_filter_decomb.settings = (gchar*)decomb_str; - } + if (decomb_opts.map[decomb].svalue != NULL) + decomb_str = g_strdup(decomb_opts.map[decomb].svalue); } + else + decomb_str = ghb_settings_get_string(js, "PictureDecombCustom"); + hb_filter_decomb.settings = decomb_str; hb_list_add( job->filters, &hb_filter_decomb ); } if( job->deinterlace ) { - if (deint > 0) - deint_str = g_strdup(deint_opts.map[deint].svalue); + if (deint != 1) + { + if (deint_opts.map[deint].svalue != NULL) + deint_str = g_strdup(deint_opts.map[deint].svalue); + } else - deint_str = ghb_settings_get_string(js, - tweaks ? "tweak_PictureDeinterlace" : "PictureDeinterlace"); + deint_str = ghb_settings_get_string(js, "PictureDeinterlaceCustom"); hb_filter_deinterlace.settings = deint_str; hb_list_add( job->filters, &hb_filter_deinterlace ); } @@ -3249,15 +3525,16 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex) hb_filter_deblock.settings = deblock_str; hb_list_add( job->filters, &hb_filter_deblock ); } - gint denoise = ghb_settings_combo_int(js, - tweaks ? "tweak_PictureDenoise" : "PictureDenoise"); - if( denoise != 0 ) + gint denoise = ghb_settings_combo_int(js, "PictureDenoise"); + if( denoise ) { - if (denoise > 0) - denoise_str = g_strdup(denoise_opts.map[denoise].svalue); + if (denoise != 1) + { + if (denoise_opts.map[denoise].svalue != NULL) + denoise_str = g_strdup(denoise_opts.map[denoise].svalue); + } else - denoise_str = (gchar*)ghb_settings_get_string( - js, tweaks ? "tweak_PictureDenoise" : "PictureDenoise"); + denoise_str = ghb_settings_get_string(js, "PictureDenoiseCustom"); hb_filter_denoise.settings = denoise_str; hb_list_add( job->filters, &hb_filter_denoise ); } @@ -3279,11 +3556,6 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex) { gdouble vquality; vquality = ghb_settings_get_double(js, "VideoQualitySlider"); - if (!ghb_settings_get_boolean(js, "directqp")) - { - if (vquality == 0.0) vquality = 0.01; - if (vquality == 1.0) vquality = 0.0; - } job->vquality = vquality; job->vbitrate = 0; } @@ -3352,7 +3624,6 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex) } else { -printf("switching to faac\n"); audio.out.codec = HB_ACODEC_FAAC; } } @@ -3683,6 +3954,17 @@ ghb_get_preview_image( if (title->job->height > title->height) title->job->height = title->height; + + // hb_get_preview doesn't compensate for anamorphic, so lets + // calculate scale factors + gint width, height, par_width = 1, par_height = 1; + gint pic_par = ghb_settings_combo_int(settings, "PicturePAR"); + if (pic_par) + { + hb_set_anamorphic_size( title->job, &width, &height, + &par_width, &par_height ); + } + // And also creates artifacts if the width is not a multiple of 8 //title->job->width = ((title->job->width + 4) >> 3) << 3; // And the height must be a multiple of 2 @@ -3779,42 +4061,35 @@ ghb_get_preview_image( dst += stride; src += (srcWidth - dstWidth); // skip to next row in src } - // Got it, but hb_get_preview doesn't compensate for anamorphic, so lets - // scale - gint width, height, par_width, par_height; - gboolean anamorphic = ghb_settings_get_boolean(settings, "anamorphic"); - if (anamorphic) - { - hb_set_anamorphic_size( title->job, &width, &height, &par_width, &par_height ); - ghb_par_scale(ud, &dstWidth, &dstHeight, par_width, par_height); - } - else - { - ghb_par_scale(ud, &dstWidth, &dstHeight, 1, 1); - } + ghb_par_scale(ud, &dstWidth, &dstHeight, par_width, par_height); *out_width = dstWidth; *out_height = dstHeight; if (ghb_settings_get_boolean(settings, "reduce_hd_preview")) { GdkScreen *ss; gint s_w, s_h; - gint num, den; + gint orig_w, orig_h; + gint factor = 80; + if (ghb_settings_get_boolean(settings, "preview_fullscreen")) + { + factor = 100; + } ss = gdk_screen_get_default(); s_w = gdk_screen_get_width(ss); s_h = gdk_screen_get_height(ss); - num = dstWidth * par_width; - den = dstHeight * par_height; + orig_w = dstWidth; + orig_h = dstHeight; - if (dstWidth > s_w * 80 / 100) + if (dstWidth > s_w * factor / 100) { - dstWidth = s_w * 80 / 100; - dstHeight = dstWidth * den / num; + dstWidth = s_w * factor / 100; + dstHeight = dstHeight * dstWidth / orig_w; } - if (dstHeight > s_h * 80 / 100) + if (dstHeight > s_h * factor / 100) { - dstHeight = s_h * 80 / 100; - dstWidth = dstHeight * num / den; + dstHeight = s_h * factor / 100; + dstWidth = dstWidth * dstHeight / orig_h; } } g_debug("scaled %d x %d\n", dstWidth, dstHeight);