diff options
-rw-r--r-- | gtk/src/callbacks.c | 8 | ||||
-rw-r--r-- | gtk/src/hb-backend.c | 134 | ||||
-rw-r--r-- | gtk/src/hb-backend.h | 5 | ||||
-rw-r--r-- | gtk/src/queuehandler.c | 28 |
4 files changed, 66 insertions, 109 deletions
diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c index 412185548..bc75a1ead 100644 --- a/gtk/src/callbacks.c +++ b/gtk/src/callbacks.c @@ -930,7 +930,7 @@ static void show_container_options(signal_user_data_t *ud) mux_id = ghb_settings_get_const_string(ud->settings, "FileFormat"); mux = ghb_lookup_container_by_name(mux_id); - gint enc = ghb_settings_combo_int(ud->settings, "VideoEncoder"); + gint enc = ghb_settings_video_encoder_codec(ud->settings, "VideoEncoder"); gtk_widget_set_visible(w1, (mux->format == HB_MUX_MP4V2)); gtk_widget_set_visible(w2, (mux->format & HB_MUX_MASK_MP4)); @@ -2023,8 +2023,9 @@ vquality_changed_cb(GtkWidget *widget, signal_user_data_t *ud) ghb_ui_update(ud, "h264Profile", ghb_string_value("auto")); } - gint vcodec = ghb_settings_combo_int(ud->settings, "VideoEncoder"); + gint vcodec; gdouble step; + vcodec = ghb_settings_video_encoder_codec(ud->settings, "VideoEncoder"); if (vcodec == HB_VCODEC_X264) { step = ghb_settings_combo_double(ud->prefs, "VideoQualityGranularity"); @@ -4922,7 +4923,8 @@ format_deblock_cb(GtkScale *scale, gdouble val, signal_user_data_t *ud) G_MODULE_EXPORT gchar* format_vquality_cb(GtkScale *scale, gdouble val, signal_user_data_t *ud) { - gint vcodec = ghb_settings_combo_int(ud->settings, "VideoEncoder"); + gint vcodec; + vcodec = ghb_settings_video_encoder_codec(ud->settings, "VideoEncoder"); switch (vcodec) { case HB_VCODEC_X264: diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c index 5b4c94eca..e0d871290 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -693,7 +693,8 @@ float ghb_vquality_default(signal_user_data_t *ud) { float quality; - gint vcodec = ghb_settings_combo_int(ud->settings, "VideoEncoder"); + gint vcodec; + vcodec = ghb_settings_video_encoder_codec(ud->settings, "VideoEncoder"); switch (vcodec) { @@ -731,7 +732,8 @@ ghb_vquality_range( int *direction) { float min_step; - gint vcodec = ghb_settings_combo_int(ud->settings, "VideoEncoder"); + gint vcodec; + vcodec = ghb_settings_video_encoder_codec(ud->settings, "VideoEncoder"); *page = 10; *digits = 0; @@ -1086,77 +1088,6 @@ lookup_audio_bitrate_option(const GValue *grate) return "160"; } -static const hb_encoder_t * -lookup_video_encoder_by_int(int ienc) -{ - const hb_encoder_t *enc; - for (enc = hb_video_encoder_get_next(NULL); enc != NULL; - enc = hb_video_encoder_get_next(enc)) - { - if (enc->codec == ienc) - { - return enc; - } - } - return NULL; -} - -static const hb_encoder_t * -lookup_video_encoder(const GValue *genc) -{ - const hb_encoder_t *enc; - - if (G_VALUE_TYPE(genc) == G_TYPE_STRING) - { - gchar *str = ghb_value_string(genc); - for (enc = hb_video_encoder_get_next(NULL); enc != NULL; - enc = hb_video_encoder_get_next(enc)) - { - if (strcmp(enc->name, str) == 0 || - strcmp(enc->short_name, str) == 0) - { - g_free(str); - return enc; - } - } - g_free(str); - } - else if (G_VALUE_TYPE(genc) == G_TYPE_INT || - G_VALUE_TYPE(genc) == G_TYPE_INT64 || - G_VALUE_TYPE(genc) == G_TYPE_DOUBLE) - { - return lookup_video_encoder_by_int(ghb_value_int(genc)); - } - return NULL; -} - -static gint -lookup_video_encoder_int(const GValue *genc) -{ - const hb_encoder_t *enc = lookup_video_encoder(genc); - if (enc != NULL) - return enc->codec; - return 0; -} - -static const gchar* -lookup_video_encoder_option(const GValue *genc) -{ - const hb_encoder_t *enc = lookup_video_encoder(genc); - if (enc != NULL) - return enc->name; - return NULL; -} - -static const gchar* -lookup_video_encoder_string(const GValue *genc) -{ - const hb_encoder_t *enc = lookup_video_encoder(genc); - if (enc != NULL) - return enc->short_name; - return NULL; -} - const iso639_lang_t* ghb_iso639_lookup_by_int(int idx) { return &ghb_language_table[idx]; @@ -1684,17 +1615,41 @@ video_encoder_opts_set( const hb_encoder_t* ghb_lookup_video_encoder(const char *name) { - const hb_encoder_t *enc; - for (enc = hb_video_encoder_get_next(NULL); enc != NULL; + // First find an enabled encoder + int codec = hb_video_encoder_get_from_name(name); + + // Now find the matching encoder info + const hb_encoder_t *enc, *first; + for (first = enc = hb_video_encoder_get_next(NULL); enc != NULL; enc = hb_video_encoder_get_next(enc)) { - if (!strncmp(name, enc->short_name, 80) || - !strncmp(name, enc->name, 80)) + if (codec == enc->codec) { return enc; } } - return NULL; + // Return a default encoder if nothing matches + return first; +} + +int +ghb_lookup_video_encoder_codec(const char *name) +{ + return ghb_lookup_video_encoder(name)->codec; +} + +int +ghb_settings_video_encoder_codec(const GValue *settings, const char *name) +{ + const char *encoder_id = ghb_settings_get_const_string(settings, name); + return ghb_lookup_video_encoder_codec(encoder_id); +} + +const hb_encoder_t* +ghb_settings_video_encoder(const GValue *settings, const char *name) +{ + const char *encoder_id = ghb_settings_get_const_string(settings, name); + return ghb_lookup_video_encoder(encoder_id); } void @@ -2636,8 +2591,6 @@ ghb_lookup_combo_int(const gchar *name, const GValue *gval) return lookup_mixdown_int(gval); else if (strcmp(name, "SrtLanguage") == 0) return lookup_audio_lang_int(gval); - else if (strcmp(name, "VideoEncoder") == 0) - return lookup_video_encoder_int(gval); else { return lookup_generic_int(find_combo_table(name), gval); @@ -2661,8 +2614,6 @@ ghb_lookup_combo_double(const gchar *name, const GValue *gval) return lookup_mixdown_int(gval); else if (strcmp(name, "SrtLanguage") == 0) return lookup_audio_lang_int(gval); - else if (strcmp(name, "VideoEncoder") == 0) - return lookup_video_encoder_int(gval); else { return lookup_generic_double(find_combo_table(name), gval); @@ -2686,8 +2637,6 @@ ghb_lookup_combo_option(const gchar *name, const GValue *gval) return lookup_mixdown_option(gval); else if (strcmp(name, "SrtLanguage") == 0) return lookup_audio_lang_option(gval); - else if (strcmp(name, "VideoEncoder") == 0) - return lookup_video_encoder_option(gval); else { return lookup_generic_option(find_combo_table(name), gval); @@ -2711,8 +2660,6 @@ ghb_lookup_combo_string(const gchar *name, const GValue *gval) return lookup_mixdown_string(gval); else if (strcmp(name, "SrtLanguage") == 0) return lookup_audio_lang_option(gval); - else if (strcmp(name, "VideoEncoder") == 0) - return lookup_video_encoder_string(gval); else { return lookup_generic_string(find_combo_table(name), gval); @@ -2890,7 +2837,8 @@ init_ui_combo_boxes(GtkBuilder *builder) gchar* ghb_build_advanced_opts_string(GValue *settings) { - gint vcodec = ghb_settings_combo_int(settings, "VideoEncoder"); + gint vcodec; + vcodec = ghb_settings_video_encoder_codec(settings, "VideoEncoder"); switch (vcodec) { case HB_VCODEC_X264: @@ -2907,7 +2855,7 @@ ghb_build_advanced_opts_string(GValue *settings) void ghb_set_video_encoder_opts(hb_job_t *job, GValue *js) { - gint vcodec = ghb_settings_combo_int(js, "VideoEncoder"); + gint vcodec = ghb_settings_video_encoder_codec(js, "VideoEncoder"); switch (vcodec) { @@ -4180,7 +4128,7 @@ ghb_validate_video(GValue *settings) mux_id = ghb_settings_get_const_string(settings, "FileFormat"); mux = ghb_lookup_container_by_name(mux_id); - vcodec = ghb_settings_combo_int(settings, "VideoEncoder"); + vcodec = ghb_settings_video_encoder_codec(settings, "VideoEncoder"); if ((mux->format & HB_MUX_MASK_MP4) && (vcodec == HB_VCODEC_THEORA)) { // mp4/theora combination is not supported. @@ -4194,7 +4142,9 @@ ghb_validate_video(GValue *settings) return FALSE; } g_free(message); - ghb_settings_set_int(settings, "VideoEncoder", HB_VCODEC_FFMPEG_MPEG4); + vcodec = hb_video_encoder_get_default(mux->format); + ghb_settings_set_string(settings, "VideoEncoder", + hb_video_encoder_get_short_name(vcodec)); } return TRUE; } @@ -4407,7 +4357,7 @@ ghb_validate_vquality(GValue *settings) gchar *message; gint min, max; - vcodec = ghb_settings_combo_int(settings, "VideoEncoder"); + vcodec = ghb_settings_video_encoder_codec(settings, "VideoEncoder"); gdouble vquality; vquality = ghb_settings_get_double(settings, "VideoQualitySlider"); if (ghb_settings_get_boolean(settings, "vquality_type_constant")) @@ -4714,7 +4664,7 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, int titleindex) g_free(filter_str); } - job->vcodec = ghb_settings_combo_int(js, "VideoEncoder"); + job->vcodec = ghb_settings_video_encoder_codec(js, "VideoEncoder"); if ((job->mux & HB_MUX_MASK_MP4 ) && (job->vcodec == HB_VCODEC_THEORA)) { // mp4/theora combination is not supported. diff --git a/gtk/src/hb-backend.h b/gtk/src/hb-backend.h index de5708701..71435588c 100644 --- a/gtk/src/hb-backend.h +++ b/gtk/src/hb-backend.h @@ -178,5 +178,10 @@ int ghb_lookup_audio_encoder_codec(const char *name); int ghb_settings_audio_encoder_codec(const GValue *settings, const char *name); const hb_encoder_t* ghb_settings_audio_encoder( const GValue *settings, const char *name); +const hb_encoder_t* ghb_lookup_video_encoder(const char *name); +int ghb_lookup_video_encoder_codec(const char *name); +int ghb_settings_video_encoder_codec(const GValue *settings, const char *name); +const hb_encoder_t* ghb_settings_video_encoder( + const GValue *settings, const char *name); #endif // _HBBACKEND_H_ diff --git a/gtk/src/queuehandler.c b/gtk/src/queuehandler.c index 3dd07af69..4507aee6c 100644 --- a/gtk/src/queuehandler.c +++ b/gtk/src/queuehandler.c @@ -384,12 +384,10 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter) // Next line in the display (Video Encoder) // Video: Encoder, Framerate: fps, RF/Bitrate/QP - const char *vcodec_opt; - int vcodec; - vcodec = ghb_settings_combo_int(settings, "VideoEncoder"); - vcodec_opt = ghb_settings_combo_option(settings, "VideoEncoder"); + const hb_encoder_t *video_encoder; + video_encoder = ghb_settings_video_encoder(settings, "VideoEncoder"); - XPRINT("<b>Video:</b> <small>%s</small>", vcodec_opt); + XPRINT("<b>Video:</b> <small>%s</small>", video_encoder->name); const char *fps; fps = ghb_settings_get_const_string(settings, "VideoFramerate"); @@ -429,7 +427,7 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter) // Constant quality vqvalue = ghb_settings_get_double(settings, "VideoQualitySlider"); vq_desc = "Constant Quality:"; - vq_units = hb_video_quality_get_name(vcodec); + vq_units = hb_video_quality_get_name(video_encoder->codec); XPRINT("<small>, %s %.4g(%s)</small>\n", vq_desc, vqvalue, vq_units); } @@ -444,7 +442,7 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter) // Next line in the display (Video Encoder Options) // Video Options: Preset - Tune - Profile - Level - if (vcodec == HB_VCODEC_X264 && + if (video_encoder->codec == HB_VCODEC_X264 && !ghb_settings_get_boolean(settings, "x264UseAdvancedOptions")) { const gchar *preset_opt, *tune_opt; @@ -498,7 +496,8 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter) XPRINT("<b>Advanced Options:</b> <small>%s</small>\n", extra_opt); } } - else if (vcodec == HB_VCODEC_X264 || (vcodec | HB_VCODEC_FFMPEG_MASK)) + else if (video_encoder->codec == HB_VCODEC_X264 || + (video_encoder->codec | HB_VCODEC_FFMPEG_MASK)) { // Next line in the display (Video Encoder Options) // Video Advanced Options: detailed settings @@ -533,16 +532,16 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter) const gchar *mix; GValue *asettings; gdouble sr; - const hb_encoder_t *encoder; + const hb_encoder_t *audio_encoder; asettings = ghb_array_get_nth(audio_list, ii); - encoder = ghb_settings_audio_encoder(asettings, "AudioEncoder"); + audio_encoder = ghb_settings_audio_encoder(asettings, "AudioEncoder"); double q = ghb_settings_get_double(asettings, "AudioTrackQuality"); if (ghb_settings_get_boolean(asettings, "AudioTrackQualityEnable") && q != HB_INVALID_AUDIO_QUALITY) { - quality = ghb_format_quality("Quality: ", encoder->codec, q); + quality = ghb_format_quality("Quality: ", audio_encoder->codec, q); } else { @@ -565,15 +564,16 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter) if (count > 1) XPRINT("\t"); - if (encoder->codec & HB_ACODEC_PASS_FLAG) + if (audio_encoder->codec & HB_ACODEC_PASS_FLAG) { - XPRINT("<small>%s, Encoder: %s</small>\n", track, encoder->name); + XPRINT("<small>%s, Encoder: %s</small>\n", + track, audio_encoder->name); } else { XPRINT( "<small>%s, Encoder: %s, Mixdown: %s, SampleRate: %s, %s</small>\n", - track, encoder->name, mix, samplerate, quality); + track, audio_encoder->name, mix, samplerate, quality); } g_free(track); g_free(quality); |