From: sr55 Date: Mon, 24 Jun 2013 18:59:35 +0000 (+0000) Subject: QSV: Merging Trunk X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=559627ca29e60393c2198f3d1d4c3d1bfa07ef6a;p=handbrake QSV: Merging Trunk git-svn-id: svn://svn.handbrake.fr/HandBrake/branches/qsv@5607 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- diff --git a/contrib/ffmpeg/A04-aacenc.patch b/contrib/ffmpeg/A04-aacenc.patch new file mode 100644 index 000000000..b58441a17 --- /dev/null +++ b/contrib/ffmpeg/A04-aacenc.patch @@ -0,0 +1,82 @@ +commit 8bbdd20a293eab2cfac9f332613ead02a4e3c0c2 +Author: Claudio Freire +Date: Sun May 12 09:38:40 2013 +0200 + + aacenc: Fix erasure of surround channels + + This was due to a miscomputation of s->cur_channel, which led to + psy-based encoders using the psy coefficients for the wrong channel. + + Signed-off-by: Martin Storsjö + +diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c +index 60eca59..b2ad47b 100644 +--- a/libavcodec/aacenc.c ++++ b/libavcodec/aacenc.c +@@ -597,7 +597,7 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, + coeffs[ch] = cpe->ch[ch].coeffs; + s->psy.model->analyze(&s->psy, start_ch, coeffs, wi); + for (ch = 0; ch < chans; ch++) { +- s->cur_channel = start_ch * 2 + ch; ++ s->cur_channel = start_ch + ch; + s->coder->search_for_quantizers(avctx, s, &cpe->ch[ch], s->lambda); + } + cpe->common_window = 0; +@@ -613,7 +613,7 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, + } + } + } +- s->cur_channel = start_ch * 2; ++ s->cur_channel = start_ch; + if (s->options.stereo_mode && cpe->common_window) { + if (s->options.stereo_mode > 0) { + IndividualChannelStream *ics = &cpe->ch[0].ics; + +commit f4d0a63b5b5c682c18df3bba730f97a9067408ba +Author: Claudio Freire +Date: Sat May 4 18:36:37 2013 -0300 + + aacenc: Fix target bitrate for twoloop quantiser search + + This fixes a case where multichannel bitrate isn't accurately + targetted by psy model alone, never achieving the target bitrate. + + Signed-off-by: Martin Storsjö + +diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c +index d65d8d9..35b98a9 100644 +--- a/libavcodec/aaccoder.c ++++ b/libavcodec/aaccoder.c +@@ -710,7 +710,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, + const float lambda) + { + int start = 0, i, w, w2, g; +- int destbits = avctx->bit_rate * 1024.0 / avctx->sample_rate / avctx->channels; ++ int destbits = avctx->bit_rate * 1024.0 / avctx->sample_rate / avctx->channels * (lambda / 120.f); + float dists[128] = { 0 }, uplims[128]; + float maxvals[128]; + int fflag, minscaler; + +commit 7c71ada4cad3c6aab5fa24155c379465c41cfd76 +Author: Claudio Freire +Date: Sat May 4 18:35:49 2013 -0300 + + aacenc: Fix a rounding bug in aacpsy channel bitrate computation + + Signed-off-by: Martin Storsjö + +diff --git a/libavcodec/aacpsy.c b/libavcodec/aacpsy.c +index 6f1ac05..66cf6d5 100644 +--- a/libavcodec/aacpsy.c ++++ b/libavcodec/aacpsy.c +@@ -312,7 +312,7 @@ static av_cold int psy_3gpp_init(FFPsyContext *ctx) { + AacPsyCoeffs *coeffs = pctx->psy_coef[j]; + const uint8_t *band_sizes = ctx->bands[j]; + float line_to_frequency = ctx->avctx->sample_rate / (j ? 256.f : 2048.0f); +- float avg_chan_bits = chan_bitrate / ctx->avctx->sample_rate * (j ? 128.0f : 1024.0f); ++ float avg_chan_bits = chan_bitrate * (j ? 128.0f : 1024.0f) / ctx->avctx->sample_rate; + /* reference encoder uses 2.4% here instead of 60% like the spec says */ + float bark_pe = 0.024f * PSY_3GPP_BITS_TO_PE(avg_chan_bits) / num_bark; + float en_spread_low = j ? PSY_3GPP_EN_SPREAD_LOW_S : PSY_3GPP_EN_SPREAD_LOW_L; + + diff --git a/contrib/x264/A00-version-string.patch b/contrib/x264/A00-version-string.patch index dcd4ec628..49a652256 100644 --- a/contrib/x264/A00-version-string.patch +++ b/contrib/x264/A00-version-string.patch @@ -6,7 +6,7 @@ index e5a1600..f635d9e 100644 #include "x264_config.h" --#define X264_BUILD 130 +-#define X264_BUILD 133 +/* + * Define the full version explicitly so that it survives a git --archive. + * @@ -16,8 +16,8 @@ index e5a1600..f635d9e 100644 +#ifdef X264_VERSION +#undef X264_VERSION +#endif -+#define X264_BUILD 130 -+#define X264_VERSION " r2273 b3065e6" ++#define X264_BUILD 133 ++#define X264_VERSION " r2334 a3ac64b" /* Application developers planning to link against a shared library version of * libx264 from a Microsoft Visual Studio or similar development environment diff --git a/contrib/x264/module.defs b/contrib/x264/module.defs index 097f88d42..458a6cddf 100644 --- a/contrib/x264/module.defs +++ b/contrib/x264/module.defs @@ -1,7 +1,7 @@ $(eval $(call import.MODULE.defs,X264,x264,YASM PTHREADW32)) $(eval $(call import.CONTRIB.defs,X264)) -X264.FETCH.url = http://download.handbrake.fr/handbrake/contrib/x264-r2273-b3065e6.tar.gz +X264.FETCH.url = http://download.handbrake.fr/handbrake/contrib/x264-r2334-a3ac64b.tar.gz X264.EXTRACT.tarbase = x264 X264.CONFIGURE.deps = @@ -9,7 +9,7 @@ X264.CONFIGURE.shared = X264.CONFIGURE.static = X264.CONFIGURE.extra = --disable-cli --enable-static --enable-strip -X264.CONFIGURE.extra += --disable-gpac --disable-avs --disable-lavf --disable-ffms --disable-swscale +X264.CONFIGURE.extra += --disable-gpac --disable-avs --disable-lavf --disable-ffms --disable-swscale --disable-opencl ifeq (1-mingw,$(BUILD.cross)-$(BUILD.system)) X264.CONFIGURE.extra += --cross-prefix=$(BUILD.spec)- diff --git a/gtk/configure.ac b/gtk/configure.ac index 6d013f935..64aa72744 100644 --- a/gtk/configure.ac +++ b/gtk/configure.ac @@ -60,6 +60,10 @@ AC_ARG_ENABLE(fdk-aac, AS_HELP_STRING([--enable-fdk-aac], [enable fdk aac encoder]), use_fdk_aac=yes, use_fdk_aac=no) +AC_ARG_ENABLE(faac, + AS_HELP_STRING([--enable-faac], [enable faac encoder]), + use_faac=yes, use_faac=no) + AC_ARG_ENABLE(gst, AS_HELP_STRING([--disable-gst], [disable gstreamer (live preview)]), gst_disable=yes, gst_disable=no) @@ -203,12 +207,16 @@ case $host in ;; esac -HB_LIBS="-lhb -la52 -lmkv -lavresample -lavformat -lavcodec -lavutil -ldvdnav -ldvdread -lfaac -lmp3lame -lmpeg2 -lvorbis -lvorbisenc -logg -lsamplerate -lx264 -lmp4v2 -lswscale -ltheoraenc -ltheoradec -lz -lbz2 -lpthread -lbluray -lass -lfontconfig -lfreetype -lxml2" +HB_LIBS="-lhb -la52 -lmkv -lavresample -lavformat -lavcodec -lavutil -ldvdnav -ldvdread -lmp3lame -lmpeg2 -lvorbis -lvorbisenc -logg -lsamplerate -lx264 -lmp4v2 -lswscale -ltheoraenc -ltheoradec -lz -lbz2 -lpthread -lbluray -lass -lfontconfig -lfreetype -lxml2" if test "x$use_fdk_aac" = "xyes" ; then HB_LIBS+=" -lfdk-aac" fi +if test "x$use_faac" = "xyes" ; then + HB_LIBS+=" -lfaac" +fi + AC_SUBST(HB_LIBS) AC_SUBST(GHB_TOOLS_CFLAGS) AC_SUBST(GHB_TOOLS_LIBS) diff --git a/gtk/module.defs b/gtk/module.defs index 8eddc6d91..cee9d7790 100644 --- a/gtk/module.defs +++ b/gtk/module.defs @@ -32,3 +32,7 @@ endif ifeq (1,$(FEATURE.fdk_aac)) GTK.CONFIGURE.extra += --enable-fdk-aac endif + +ifeq (1,$(FEATURE.faac)) + GTK.CONFIGURE.extra += --enable-faac +endif diff --git a/gtk/src/audiohandler.c b/gtk/src/audiohandler.c index 72f58bfa7..c25cfe1f3 100644 --- a/gtk/src/audiohandler.c +++ b/gtk/src/audiohandler.c @@ -642,6 +642,27 @@ ghb_audio_list_refresh(signal_user_data_t *ud) } } +static void enable_quality_widget(signal_user_data_t *ud, int acodec) +{ + GtkWidget *widget1, *widget2, *widget3; + + widget1 = GHB_WIDGET(ud->builder, "AudioTrackQualityEnable"); + widget2 = GHB_WIDGET(ud->builder, "AudioTrackQualityValue"); + widget3 = GHB_WIDGET(ud->builder, "AudioTrackQuality"); + if (hb_audio_quality_get_default(acodec) == HB_INVALID_AUDIO_QUALITY) + { + gtk_widget_hide(widget1); + gtk_widget_hide(widget2); + gtk_widget_hide(widget3); + } + else + { + gtk_widget_show(widget1); + gtk_widget_show(widget2); + gtk_widget_show(widget3); + } +} + G_MODULE_EXPORT void audio_codec_changed_cb(GtkWidget *widget, signal_user_data_t *ud) { @@ -654,6 +675,7 @@ audio_codec_changed_cb(GtkWidget *widget, signal_user_data_t *ud) acodec_code = ghb_lookup_combo_int("AudioEncoder", gval); ghb_value_free(gval); + enable_quality_widget(ud, acodec_code); if (block_updates) { prev_acodec = acodec_code; diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c index e6b4714cb..eead66275 100644 --- a/gtk/src/callbacks.c +++ b/gtk/src/callbacks.c @@ -1600,6 +1600,35 @@ set_title_settings(GValue *settings, gint titleindex) ghb_set_scale_settings(settings, GHB_PIC_KEEP_PAR|GHB_PIC_USE_MAX); ghb_settings_set_int(settings, "angle_count", title->angle_count); + + ghb_settings_set_string(settings, "MetaName", title->name); + if (title->metadata) + { + if (title->metadata->name) + { + ghb_settings_set_string(settings, "MetaName", + title->metadata->name); + } + ghb_settings_set_string(settings, "MetaArtist", + title->metadata->artist); + ghb_settings_set_string(settings, "MetaReleaseDate", + title->metadata->release_date); + ghb_settings_set_string(settings, "MetaComment", + title->metadata->comment); + if (!title->metadata->name && title->metadata->album) + { + ghb_settings_set_string(settings, "MetaName", + title->metadata->album); + } + ghb_settings_set_string(settings, "MetaAlbumArtist", + title->metadata->album_artist); + ghb_settings_set_string(settings, "MetaGenre", + title->metadata->genre); + ghb_settings_set_string(settings, "MetaDescription", + title->metadata->description); + ghb_settings_set_string(settings, "MetaLongDescription", + title->metadata->long_description); + } } update_chapter_list_settings(settings); ghb_set_pref_audio_settings(titleindex, settings); diff --git a/gtk/src/makedeps.py b/gtk/src/makedeps.py index 9fecd37fe..07830237c 100644 --- a/gtk/src/makedeps.py +++ b/gtk/src/makedeps.py @@ -50,13 +50,8 @@ dep_map = ( DepEntry("VideoEncoder", "x264VideoSettings", "x264", False, True), DepEntry("VideoEncoder", "lavc_mpeg4_tab", "ffmpeg|ffmpeg4|ffmpeg2", False, True), DepEntry("VideoEncoder", "Mp4iPodCompatible", "x264", False, False), - DepEntry("AudioTrackQualityEnable", "AudioTrackQuality", "FALSE", True, False), - DepEntry("AudioTrackQualityEnable", "AudioTrackQualityValue", "FALSE", True, False), DepEntry("AudioTrackQualityEnable", "AudioBitrateLabel", "TRUE", True, False), DepEntry("AudioTrackQualityEnable", "AudioBitrate", "TRUE", True, False), - DepEntry("AudioEncoderActual", "AudioTrackQualityEnable", "lame|vorbis", False, True), - DepEntry("AudioEncoderActual", "AudioTrackQuality", "lame|vorbis", False, True), - DepEntry("AudioEncoderActual", "AudioTrackQualityValue", "lame|vorbis", False, True), DepEntry("AudioEncoderActual", "AudioBitrateLabel", "copy:mp3|copy:aac|copy:ac3|copy:dts|copy:dtshd", True, False), DepEntry("AudioEncoderActual", "AudioBitrate", "copy:mp3|copy:aac|copy:ac3|copy:dts|copy:dtshd", True, False), DepEntry("AudioEncoderActual", "AudioSamplerateLabel", "copy:mp3|copy:aac|copy:ac3|copy:dts|copy:dtshd", True, False), diff --git a/gtk/src/presets.c b/gtk/src/presets.c index 12fdfbd67..8562401e7 100644 --- a/gtk/src/presets.c +++ b/gtk/src/presets.c @@ -2018,158 +2018,6 @@ typedef struct const gchar *lin_val; } value_map_t; -static value_map_t vcodec_xlat_compat[] = -{ - {"MPEG-4 (FFmpeg)", "ffmpeg"}, - {"MPEG-4 (XviD)", "ffmpeg4"}, - {NULL,NULL} -}; - -static value_map_t *vcodec_xlat; - -static value_map_t acodec_xlat_compat[] = -{ - {"AAC (CoreAudio)", "faac"}, - {"HE-AAC (CoreAudio)", "faac"}, - {"AC3 (ffmpeg)", "ac3"}, - {"AC3", "ac3"}, - {"MP3 Passthru", "mp3pass"}, - {"AAC Passthru", "aacpass"}, - {"AC3 Passthru", "ac3pass"}, - {"DTS Passthru", "dtspass"}, - {"DTS-HD Passthru", "dtshdpass"}, - {"Auto Passthru", "auto"}, - {NULL,NULL} -}; - -static value_map_t *acodec_xlat; - -static value_map_t * create_video_encoder_xlat_tbl(value_map_t *compat) -{ - value_map_t *out; - int cc, ii, size = 0; - - for (cc = 0; compat[cc].mac_val != NULL; cc++); - - const hb_encoder_t *enc; - for (enc = hb_video_encoder_get_next(NULL); enc != NULL; - enc = hb_video_encoder_get_next(enc)) - { - size++; - } - out = calloc(cc + size + 1, sizeof(value_map_t)); - - for (ii = 0, enc = hb_video_encoder_get_next(NULL); enc != NULL; - ii++, enc = hb_video_encoder_get_next(enc)) - { - out[ii].mac_val = enc->name; - out[ii].lin_val = enc->short_name; - } - - for (ii = 0; ii < cc; ii++) - out[ii+size] = compat[ii]; - - return out; -} - -static value_map_t * create_audio_encoder_xlat_tbl(value_map_t *compat) -{ - value_map_t *out; - int cc, ii, size = 0; - - for (cc = 0; compat[cc].mac_val != NULL; cc++); - - const hb_encoder_t *enc; - for (enc = hb_audio_encoder_get_next(NULL); enc != NULL; - enc = hb_audio_encoder_get_next(enc)) - { - size++; - } - out = calloc(cc + size + 1, sizeof(value_map_t)); - - for (ii = 0, enc = hb_audio_encoder_get_next(NULL); enc != NULL; - ii++, enc = hb_audio_encoder_get_next(enc)) - { - out[ii].mac_val = enc->name; - out[ii].lin_val = enc->short_name; - } - - for (ii = 0; ii < cc; ii++) - out[ii+size] = compat[ii]; - - return out; -} - -static value_map_t * create_mix_xlat_tbl(value_map_t *compat) -{ - value_map_t *out; - int cc, ii, size = 0;; - - for (cc = 0; compat[cc].mac_val != NULL; cc++); - - const hb_mixdown_t *mix; - for (mix = hb_mixdown_get_next(NULL); mix != NULL; - mix = hb_mixdown_get_next(mix)) - { - size++; - } - out = calloc(cc + size + 1, sizeof(value_map_t)); - - for (ii = 0, mix = hb_mixdown_get_next(NULL); mix != NULL; - ii++, mix = hb_mixdown_get_next(mix)) - { - out[ii].mac_val = mix->name; - out[ii].lin_val = mix->short_name; - } - - for (ii = 0; ii < cc; ii++) - out[ii+size] = compat[ii]; - - return out; -} - -value_map_t framerate_xlat[] = -{ - {"Same as source", "source"}, - {"5", "5"}, - {"10", "10"}, - {"12", "12"}, - {"15", "15"}, - {"23.976 (NTSC Film)", "23.976"}, - {"24", "24"}, - {"25 (PAL Film/Video)", "25"}, - {"29.97 (NTSC Video)", "29.97"}, - {"30", "30"}, - {"50", "50"}, - {"59.94", "59.94"}, - {"60", "60"}, - {NULL, NULL} -}; - -value_map_t samplerate_xlat[] = -{ - {"Auto", "source"}, - {"22.05", "22.05"}, - {"24", "24"}, - {"32", "32"}, - {"44.1", "44.1"}, - {"48", "48"}, - {NULL, NULL} -}; - -// mix translation table filed in with hb_audio_mixdowns table contents -value_map_t *mix_xlat; - -// Backwards compatibility mappings for audio mix -value_map_t mix_xlat_compat[] = -{ - {"6-channel discrete", "5point1"}, - {"AC3 Passthru", "none"}, - {"DTS Passthru", "none"}, - {"DTS-HD Passthru", "none"}, - {NULL, NULL} -}; - value_map_t deint_xlat[] = { {"0", "off"}, @@ -2394,17 +2242,95 @@ export_value_xlat2(value_map_t *value_map, GValue *lin_val, GType mac_type) } static GValue* -export_value_xlat_container(GValue *lin_val) +export_value_video_framerate(GValue *lin_val) +{ + GValue *sval = NULL; + gchar *str; + const gchar *fr; + + str = ghb_value_string(lin_val); + fr = hb_video_framerate_get_name(hb_video_framerate_get_from_name(str)); + g_free(str); + if (fr != NULL) + sval = ghb_string_value_new(fr); + + return sval; +} + +static GValue* +export_value_audio_samplerate(GValue *lin_val) +{ + GValue *sval = NULL; + gchar *str; + const gchar *sr; + + str = ghb_value_string(lin_val); + sr = hb_audio_samplerate_get_name(hb_audio_samplerate_get_from_name(str)); + g_free(str); + if (sr != NULL) + sval = ghb_string_value_new(sr); + + return sval; +} + +static GValue* +export_value_mixdown(GValue *lin_val) +{ + GValue *sval = NULL; + gchar *str; + const gchar *mix; + + str = ghb_value_string(lin_val); + mix = hb_mixdown_get_name(hb_mixdown_get_from_name(str)); + g_free(str); + if (mix != NULL) + sval = ghb_string_value_new(mix); + + return sval; +} + +static GValue* +export_value_video_encoder(GValue *lin_val) +{ + GValue *sval = NULL; + gchar *str; + const gchar *enc; + + str = ghb_value_string(lin_val); + enc = hb_video_encoder_get_name(hb_video_encoder_get_from_name(str)); + g_free(str); + if (enc != NULL) + sval = ghb_string_value_new(enc); + + return sval; +} + +static GValue* +export_value_audio_encoder(GValue *lin_val) +{ + GValue *sval = NULL; + gchar *str; + const gchar *enc; + + str = ghb_value_string(lin_val); + enc = hb_audio_encoder_get_name(hb_audio_encoder_get_from_name(str)); + g_free(str); + if (enc != NULL) + sval = ghb_string_value_new(enc); + + return sval; +} + +static GValue* +export_value_container(GValue *lin_val) { GValue *sval = NULL; gchar *str; const gchar *mux; - int imux; str = ghb_value_string(lin_val); - imux = hb_container_get_from_name(str); + mux = hb_container_get_name(hb_container_get_from_name(str)); g_free(str); - mux = hb_container_get_name(imux); if (mux != NULL) sval = ghb_string_value_new(mux); @@ -2419,17 +2345,17 @@ export_value_xlat(GValue *dict) key = "VideoEncoder"; lin_val = ghb_dict_lookup(dict, key); - gval = export_value_xlat2(vcodec_xlat, lin_val, G_TYPE_STRING); + gval = export_value_video_encoder(lin_val); if (gval) ghb_dict_insert(dict, g_strdup(key), gval); key = "FileFormat"; lin_val = ghb_dict_lookup(dict, key); - gval = export_value_xlat_container(lin_val); + gval = export_value_container(lin_val); if (gval) ghb_dict_insert(dict, g_strdup(key), gval); key = "VideoFramerate"; lin_val = ghb_dict_lookup(dict, key); - gval = export_value_xlat2(framerate_xlat, lin_val, G_TYPE_STRING); + gval = export_value_video_framerate(lin_val); if (gval) ghb_dict_insert(dict, g_strdup(key), gval); key = "PictureDetelecine"; @@ -2474,7 +2400,7 @@ export_value_xlat(GValue *dict) key = "AudioEncoderFallback"; lin_val = ghb_dict_lookup(dict, key); - gval = export_value_xlat2(acodec_xlat, lin_val, G_TYPE_STRING); + gval = export_value_audio_encoder(lin_val); if (gval) ghb_dict_insert(dict, g_strdup(key), gval); @@ -2490,17 +2416,17 @@ export_value_xlat(GValue *dict) ghb_dict_insert(adict, g_strdup(key), gval); key = "AudioEncoder"; lin_val = ghb_dict_lookup(adict, key); - gval = export_value_xlat2(acodec_xlat, lin_val, G_TYPE_STRING); + gval = export_value_audio_encoder(lin_val); if (gval) ghb_dict_insert(adict, g_strdup(key), gval); key = "AudioSamplerate"; lin_val = ghb_dict_lookup(adict, key); - gval = export_value_xlat2(samplerate_xlat, lin_val, G_TYPE_STRING); + gval = export_value_audio_samplerate(lin_val); if (gval) ghb_dict_insert(adict, g_strdup(key), gval); key = "AudioMixdown"; lin_val = ghb_dict_lookup(adict, key); - gval = export_value_xlat2(mix_xlat, lin_val, G_TYPE_STRING); + gval = export_value_mixdown(lin_val); if (gval) ghb_dict_insert(adict, g_strdup(key), gval); } @@ -2579,26 +2505,100 @@ import_value_xlat2( } static GValue* -import_value_xlat_container(GValue *mac_val) +import_value_video_framerate(GValue *mac_val) { GValue *sval = NULL; gchar *str; - const gchar *mux; - int imux; + const gchar *fr; str = ghb_value_string(mac_val); - mux = hb_container_sanitize_name(str); + fr = hb_video_framerate_get_name(hb_video_framerate_get_from_name(str)); g_free(str); - if (mux == NULL) - { - imux = hb_container_get_from_extension("mp4"); - } - else - { - imux = hb_container_get_from_name(mux); - } - mux = hb_container_get_short_name(imux); + if (fr != NULL) + sval = ghb_string_value_new(fr); + + return sval; +} + +static GValue* +import_value_audio_samplerate(GValue *mac_val) +{ + GValue *sval = NULL; + gchar *str; + const gchar *sr; + + str = ghb_value_string(mac_val); + sr = hb_audio_samplerate_get_name(hb_audio_samplerate_get_from_name(str)); + g_free(str); + + if (sr != NULL) + sval = ghb_string_value_new(sr); + + return sval; +} + +static GValue* +import_value_mixdown(GValue *mac_val) +{ + GValue *sval = NULL; + gchar *str; + const gchar *mix; + + str = ghb_value_string(mac_val); + mix = hb_mixdown_get_short_name(hb_mixdown_get_from_name(str)); + g_free(str); + + if (mix != NULL) + sval = ghb_string_value_new(mix); + + return sval; +} + +static GValue* +import_value_video_encoder(GValue *mac_val) +{ + GValue *sval = NULL; + gchar *str; + const gchar *enc; + + str = ghb_value_string(mac_val); + enc = hb_video_encoder_get_short_name(hb_video_encoder_get_from_name(str)); + g_free(str); + + if (enc != NULL) + sval = ghb_string_value_new(enc); + + return sval; +} + +static GValue* +import_value_audio_encoder(GValue *mac_val) +{ + GValue *sval = NULL; + gchar *str; + const gchar *enc; + + str = ghb_value_string(mac_val); + enc = hb_audio_encoder_get_short_name(hb_audio_encoder_get_from_name(str)); + g_free(str); + + if (enc != NULL) + sval = ghb_string_value_new(enc); + + return sval; +} + +static GValue* +import_value_container(GValue *mac_val) +{ + GValue *sval = NULL; + gchar *str; + const gchar *mux; + + str = ghb_value_string(mac_val); + mux = hb_container_get_short_name(hb_container_get_from_name(str)); + g_free(str); if (mux != NULL) sval = ghb_string_value_new(mux); @@ -2615,17 +2615,17 @@ import_value_xlat(GValue *dict) defaults = plist_get_dict(internalPlist, "Presets"); key = "VideoEncoder"; mac_val = ghb_dict_lookup(dict, key); - gval = import_value_xlat2(defaults, vcodec_xlat, key, mac_val); + gval = import_value_video_encoder(mac_val); if (gval) ghb_dict_insert(dict, g_strdup(key), gval); key = "FileFormat"; mac_val = ghb_dict_lookup(dict, key); - gval = import_value_xlat_container(mac_val); + gval = import_value_container(mac_val); if (gval) ghb_dict_insert(dict, g_strdup(key), gval); key = "VideoFramerate"; mac_val = ghb_dict_lookup(dict, key); - gval = import_value_xlat2(defaults, framerate_xlat, key, mac_val); + gval = import_value_video_framerate(mac_val); if (gval) ghb_dict_insert(dict, g_strdup(key), gval); key = "PictureDetelecine"; @@ -2725,7 +2725,7 @@ import_value_xlat(GValue *dict) key = "AudioEncoderFallback"; mac_val = ghb_dict_lookup(dict, key); - gval = import_value_xlat2(defaults, acodec_xlat, key, mac_val); + gval = import_value_audio_encoder(mac_val); if (gval) ghb_dict_insert(dict, g_strdup(key), gval); @@ -2745,17 +2745,23 @@ import_value_xlat(GValue *dict) ghb_dict_insert(adict, g_strdup(key), gval); key = "AudioEncoder"; mac_val = ghb_dict_lookup(adict, key); - gval = import_value_xlat2(adefaults, acodec_xlat, key, mac_val); + gval = import_value_audio_encoder(mac_val); + if (gval == NULL) + gval = ghb_value_dup(ghb_dict_lookup(adefaults, key)); if (gval) ghb_dict_insert(adict, g_strdup(key), gval); key = "AudioSamplerate"; mac_val = ghb_dict_lookup(adict, key); - gval = import_value_xlat2(adefaults, samplerate_xlat, key, mac_val); + gval = import_value_audio_samplerate(mac_val); + if (gval == NULL) + gval = ghb_value_dup(ghb_dict_lookup(adefaults, key)); if (gval) ghb_dict_insert(adict, g_strdup(key), gval); key = "AudioMixdown"; mac_val = ghb_dict_lookup(adict, key); - gval = import_value_xlat2(adefaults, mix_xlat, key, mac_val); + gval = import_value_mixdown(mac_val); + if (gval == NULL) + gval = ghb_value_dup(ghb_dict_lookup(adefaults, key)); if (gval) ghb_dict_insert(adict, g_strdup(key), gval); @@ -3381,11 +3387,6 @@ update_standard_presets(signal_user_data_t *ud) void ghb_presets_load(signal_user_data_t *ud) { - // Create translation tables from libhb tables - mix_xlat = create_mix_xlat_tbl(mix_xlat_compat); - acodec_xlat = create_audio_encoder_xlat_tbl(acodec_xlat_compat); - vcodec_xlat = create_video_encoder_xlat_tbl(vcodec_xlat_compat); - presetsPlist = load_plist("presets"); if (presetsPlist == NULL) { diff --git a/gtk/src/standard_presets.xml b/gtk/src/standard_presets.xml index f73475bd8..989f892de 100644 --- a/gtk/src/standard_presets.xml +++ b/gtk/src/standard_presets.xml @@ -1266,13 +1266,146 @@ x264UseAdvancedOptions 0 + + AudioAllowAACPass + 1 + AudioAllowAC3Pass + 1 + AudioAllowDTSHDPass + 1 + AudioAllowDTSPass + 1 + AudioAllowMP3Pass + 1 + AudioEncoderFallback + AC3 (ffmpeg) + AudioList + + + AudioBitrate + 128 + AudioEncoder + AAC (faac) + AudioMixdown + Dolby Pro Logic II + AudioSamplerate + Auto + AudioTrack + 1 + AudioTrackDRCSlider + 0.0 + AudioTrackGainSlider + 0.0 + + + ChapterMarkers + 0 + Default + 0 + FileFormat + MP4 file + Folder + + Mp4HttpOptimize + 0 + Mp4LargeFile + 0 + Mp4iPodCompatible + 0 + PictureAutoCrop + 1 + PictureBottomCrop + 0 + PictureDeblock + 0 + PictureDecomb + 0 + PictureDecombCustom + + PictureDecombDeinterlace + 1 + PictureDeinterlace + 0 + PictureDeinterlaceCustom + + PictureDenoise + 0 + PictureDenoiseCustom + + PictureDetelecine + 0 + PictureDetelecineCustom + + PictureHeight + 720 + PictureKeepRatio + 0 + PictureLeftCrop + 0 + PictureModulus + 2 + PicturePAR + 2 + PictureRightCrop + 0 + PictureTopCrop + 0 + PictureWidth + 1280 + PresetDescription + HandBrake's preset for Windows Phone 8 devices + PresetName + Windows Phone 8 + Subtitles + None + Type + 0 + UsesPictureFilters + 1 + UsesPictureSettings + 1 + VideoAvgBitrate + 2500 + VideoEncoder + H.264 (x264) + VideoFramerate + 30 + VideoFramerateMode + pfr + VideoGrayScale + 0 + VideoQualitySlider + 22 + VideoQualityType + 2 + VideoTurboTwoPass + 0 + VideoTwoPass + 0 + h264Level + 3.1 + h264Profile + main + lavcOption + + x264Option + + x264OptionExtra + + x264Preset + medium + x264Tune + + x264UseAdvancedOptions + 0 + Default 0 Folder PresetBuildNumber - 2013030401 + 2013061301 PresetName Devices Type @@ -1569,7 +1702,7 @@ Folder PresetBuildNumber - 2013030401 + 2013061301 PresetName Regular Type diff --git a/libhb/common.c b/libhb/common.c index 074d2a135..225bc9c2b 100644 --- a/libhb/common.c +++ b/libhb/common.c @@ -153,10 +153,10 @@ hb_mixdown_t *hb_audio_mixdowns_first_item = NULL; hb_mixdown_t *hb_audio_mixdowns_last_item = NULL; hb_mixdown_internal_t hb_audio_mixdowns[] = { - // legacy mixdowns (disabled) - { { "AC3 Passthru", "ac3pass", HB_AMIXDOWN_NONE, }, NULL, 0, }, - { { "DTS Passthru", "dtspass", HB_AMIXDOWN_NONE, }, NULL, 0, }, - { { "DTS-HD Passthru", "dtshdpass", HB_AMIXDOWN_NONE, }, NULL, 0, }, + // legacy mixdowns, back to HB 0.9.4 whenever possible (disabled) + { { "AC3 Passthru", "", HB_AMIXDOWN_NONE, }, NULL, 0, }, + { { "DTS Passthru", "", HB_AMIXDOWN_NONE, }, NULL, 0, }, + { { "DTS-HD Passthru", "", HB_AMIXDOWN_NONE, }, NULL, 0, }, { { "6-channel discrete", "6ch", HB_AMIXDOWN_5POINT1, }, NULL, 0, }, // actual mixdowns { { "None", "none", HB_AMIXDOWN_NONE, }, NULL, 1, }, @@ -184,22 +184,17 @@ hb_encoder_t *hb_video_encoders_first_item = NULL; hb_encoder_t *hb_video_encoders_last_item = NULL; hb_encoder_internal_t hb_video_encoders[] = { - // legacy encoders, all the way back to HB 0.7.1 (disabled) - { { "x264 (Main profile)", "", HB_VCODEC_X264, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 0, HB_GID_VCODEC_H264, }, - { { "x264 (Baseline profile)", "", HB_VCODEC_X264, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 0, HB_GID_VCODEC_H264, }, - { { "x264 (h.264 Main)", "", HB_VCODEC_X264, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 0, HB_GID_VCODEC_H264, }, - { { "x264 (h.264 iPod)", "", HB_VCODEC_X264, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 0, HB_GID_VCODEC_H264, }, - { { "", "x264b13", HB_VCODEC_X264, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 0, HB_GID_VCODEC_H264, }, - { { "", "x264b30", HB_VCODEC_X264, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 0, HB_GID_VCODEC_H264, }, - { { "XviD", "xvid", HB_VCODEC_FFMPEG_MPEG4, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 0, HB_GID_VCODEC_MPEG4, }, - { { "MPEG-4 (XviD)", "", HB_VCODEC_FFMPEG_MPEG4, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 0, HB_GID_VCODEC_MPEG4, }, + // legacy encoders, back to HB 0.9.4 whenever possible (disabled) { { "FFmpeg", "ffmpeg", HB_VCODEC_FFMPEG_MPEG4, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 0, HB_GID_VCODEC_MPEG4, }, + { { "MPEG-4 (FFmpeg)", "ffmpeg4", HB_VCODEC_FFMPEG_MPEG4, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 0, HB_GID_VCODEC_MPEG4, }, + { { "MPEG-2 (FFmpeg)", "ffmpeg2", HB_VCODEC_FFMPEG_MPEG2, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 0, HB_GID_VCODEC_MPEG2, }, + { { "VP3 (Theora)", "libtheora", HB_VCODEC_THEORA, HB_MUX_MASK_MKV, }, NULL, 0, HB_GID_VCODEC_THEORA, }, // actual encoders { { "H.264 (x264)", "x264", HB_VCODEC_X264, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_VCODEC_H264, }, { { "H.264 (Intel QSV)", "qsv_h264",HB_VCODEC_QSV_H264, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_VCODEC_H264, }, - { { "MPEG-4 (FFmpeg)", "ffmpeg4", HB_VCODEC_FFMPEG_MPEG4, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_VCODEC_MPEG4, }, - { { "MPEG-2 (FFmpeg)", "ffmpeg2", HB_VCODEC_FFMPEG_MPEG2, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_VCODEC_MPEG2, }, - { { "VP3 (Theora)", "theora", HB_VCODEC_THEORA, HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_VCODEC_THEORA, }, + { { "MPEG-4", "mpeg4", HB_VCODEC_FFMPEG_MPEG4, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_VCODEC_MPEG4, }, + { { "MPEG-2", "mpeg2", HB_VCODEC_FFMPEG_MPEG2, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_VCODEC_MPEG2, }, + { { "Theora", "theora", HB_VCODEC_THEORA, HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_VCODEC_THEORA, }, }; int hb_video_encoders_count = sizeof(hb_video_encoders) / sizeof(hb_video_encoders[0]); static int hb_video_encoder_is_enabled(int encoder) @@ -227,28 +222,31 @@ hb_encoder_t *hb_audio_encoders_first_item = NULL; hb_encoder_t *hb_audio_encoders_last_item = NULL; hb_encoder_internal_t hb_audio_encoders[] = { - // legacy encoders (disabled) - { { "AC3", "ac3", HB_ACODEC_AC3, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 0, HB_GID_ACODEC_AC3, }, - { { "AC3 (pass-thru)", "ac3pass", HB_ACODEC_AC3_PASS, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 0, HB_GID_ACODEC_AC3_PASS, }, - { { "DTS (pass-thru)", "dtspass", HB_ACODEC_DCA_PASS, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 0, HB_GID_ACODEC_DTS_PASS, }, + // legacy encoders, back to HB 0.9.4 whenever possible (disabled) { { "", "dts", HB_ACODEC_DCA_PASS, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 0, HB_GID_ACODEC_DTS_PASS, }, + { { "AAC (ffmpeg)", "ffaac", HB_ACODEC_FFAAC, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 0, HB_GID_ACODEC_AAC, }, + { { "AC3 (ffmpeg)", "ffac3", HB_ACODEC_AC3, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 0, HB_GID_ACODEC_AC3, }, + { { "MP3 (lame)", "lame", HB_ACODEC_LAME, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 0, HB_GID_ACODEC_MP3, }, + { { "Vorbis (vorbis)", "libvorbis", HB_ACODEC_VORBIS, HB_MUX_MASK_MKV, }, NULL, 0, HB_GID_ACODEC_VORBIS, }, + { { "FLAC (ffmpeg)", "ffflac", HB_ACODEC_FFFLAC, HB_MUX_MASK_MKV, }, NULL, 0, HB_GID_ACODEC_FLAC, }, + { { "FLAC (24-bit)", "ffflac24", HB_ACODEC_FFFLAC24, HB_MUX_MASK_MKV, }, NULL, 0, HB_GID_ACODEC_FLAC, }, // actual encoders { { "AAC (CoreAudio)", "ca_aac", HB_ACODEC_CA_AAC, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_ACODEC_AAC, }, { { "HE-AAC (CoreAudio)", "ca_haac", HB_ACODEC_CA_HAAC, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_ACODEC_AAC_HE, }, + { { "AAC (faac)", "faac", HB_ACODEC_FAAC, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_ACODEC_AAC, }, + { { "AAC (avcodec)", "av_aac", HB_ACODEC_FFAAC, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_ACODEC_AAC, }, { { "AAC (FDK)", "fdk_aac", HB_ACODEC_FDK_AAC, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_ACODEC_AAC, }, { { "HE-AAC (FDK)", "fdk_haac", HB_ACODEC_FDK_HAAC, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_ACODEC_AAC_HE, }, - { { "AAC (faac)", "faac", HB_ACODEC_FAAC, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_ACODEC_AAC, }, - { { "AAC (ffmpeg)", "ffaac", HB_ACODEC_FFAAC, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_ACODEC_AAC, }, { { "AAC Passthru", "copy:aac", HB_ACODEC_AAC_PASS, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_ACODEC_AAC_PASS, }, - { { "AC3 (ffmpeg)", "ffac3", HB_ACODEC_AC3, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_ACODEC_AC3, }, + { { "AC3", "ac3", HB_ACODEC_AC3, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_ACODEC_AC3, }, { { "AC3 Passthru", "copy:ac3", HB_ACODEC_AC3_PASS, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_ACODEC_AC3_PASS, }, { { "DTS Passthru", "copy:dts", HB_ACODEC_DCA_PASS, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_ACODEC_DTS_PASS, }, { { "DTS-HD Passthru", "copy:dtshd", HB_ACODEC_DCA_HD_PASS, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_ACODEC_DTSHD_PASS, }, - { { "MP3 (lame)", "lame", HB_ACODEC_LAME, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_ACODEC_MP3, }, + { { "MP3", "mp3", HB_ACODEC_LAME, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_ACODEC_MP3, }, { { "MP3 Passthru", "copy:mp3", HB_ACODEC_MP3_PASS, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_ACODEC_MP3_PASS, }, - { { "Vorbis (vorbis)", "vorbis", HB_ACODEC_VORBIS, HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_ACODEC_VORBIS, }, - { { "FLAC (ffmpeg)", "ffflac", HB_ACODEC_FFFLAC, HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_ACODEC_FLAC, }, - { { "FLAC (24-bit)", "ffflac24", HB_ACODEC_FFFLAC24, HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_ACODEC_FLAC, }, + { { "Vorbis", "vorbis", HB_ACODEC_VORBIS, HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_ACODEC_VORBIS, }, + { { "FLAC 16-bit", "flac16", HB_ACODEC_FFFLAC, HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_ACODEC_FLAC, }, + { { "FLAC 24-bit", "flac24", HB_ACODEC_FFFLAC24, HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_ACODEC_FLAC, }, { { "Auto Passthru", "copy", HB_ACODEC_AUTO_PASS, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_ACODEC_AUTO_PASS, }, }; int hb_audio_encoders_count = sizeof(hb_audio_encoders) / sizeof(hb_audio_encoders[0]); @@ -267,12 +265,12 @@ static int hb_audio_encoder_is_enabled(int encoder) return 1; #endif -#if 1 //#ifdef USE_FAAC +#ifdef USE_FAAC case HB_ACODEC_FAAC: return 1; #endif -#if 1 //#ifdef USE_LIBAV_AAC +#ifdef USE_LIBAV_AAC case HB_ACODEC_FFAAC: return 1; #endif @@ -307,11 +305,9 @@ hb_container_t *hb_containers_first_item = NULL; hb_container_t *hb_containers_last_item = NULL; hb_container_internal_t hb_containers[] = { - // legacy muxers (disabled) - { { "AVI file", "avi", "avi", 0, }, NULL, 0, HB_GID_MUX_MP4, }, + // legacy muxers, back to HB 0.9.4 whenever possible (disabled) { { "M4V file", "m4v", "m4v", 0, }, NULL, 0, HB_GID_MUX_MP4, }, { { "MP4 file", "mp4", "mp4", 0, }, NULL, 0, HB_GID_MUX_MP4, }, - { { "OGM file", "ogm", "ogm", 0, }, NULL, 0, HB_GID_MUX_MKV, }, { { "MKV file", "mkv", "mkv", 0, }, NULL, 0, HB_GID_MUX_MKV, }, // actual muxers { { "MPEG-4 (mp4v2)", "mp4v2", "mp4", HB_MUX_MP4V2, }, NULL, 1, HB_GID_MUX_MP4, }, @@ -1320,7 +1316,6 @@ int hb_mixdown_has_codec_support(int mixdown, uint32_t codec) return (mixdown <= HB_AMIXDOWN_7POINT1); case HB_ACODEC_LAME: - case HB_ACODEC_FFAAC: return (mixdown <= HB_AMIXDOWN_DOLBYPLII); case HB_ACODEC_FAAC: diff --git a/libhb/dvd.c b/libhb/dvd.c index 56c1ba571..240582a52 100644 --- a/libhb/dvd.c +++ b/libhb/dvd.c @@ -173,8 +173,6 @@ static hb_title_t * hb_dvdread_title_scan( hb_dvd_t * e, int t, uint64_t min_dur ifo_handle_t * vts = NULL; int pgc_id, pgn, i; hb_chapter_t * chapter; - uint64_t duration; - float duration_correction; unsigned char unused[1024]; const char * codec_name; @@ -609,19 +607,9 @@ static hb_title_t * hb_dvdread_title_scan( hb_dvd_t * e, int t, uint64_t min_dur hb_list_add( title->list_chapter, chapter ); } - /* The durations we get for chapters aren't precise. Scale them so - the total matches the title duration */ - duration = 0; - for( i = 0; i < hb_list_count( title->list_chapter ); i++ ) - { - chapter = hb_list_item( title->list_chapter, i ); - duration += chapter->duration; - } - duration_correction = (float) title->duration / (float) duration; for( i = 0; i < hb_list_count( title->list_chapter ); i++ ) { chapter = hb_list_item( title->list_chapter, i ); - chapter->duration = duration_correction * chapter->duration; int seconds = ( chapter->duration + 45000 ) / 90000; chapter->hours = ( seconds / 3600 ); @@ -1270,8 +1258,8 @@ static int dvdtime2msec(dvd_time_t * dt) if( fps > 0 ) { - ms += ((dt->frame_u & 0x30) >> 3) * 5 + - (dt->frame_u & 0x0f) * 1000.0 / fps; + ms += (((dt->frame_u & 0x30) >> 3) * 5 + + (dt->frame_u & 0x0f)) * 1000.0 / fps; } return ms; diff --git a/libhb/dvdnav.c b/libhb/dvdnav.c index 9217f7dba..ef80bf541 100644 --- a/libhb/dvdnav.c +++ b/libhb/dvdnav.c @@ -318,7 +318,6 @@ static hb_title_t * hb_dvdnav_title_scan( hb_dvd_t * e, int t, uint64_t min_dura int count; uint64_t duration, longest; int longest_pgcn, longest_pgn, longest_pgcn_end; - float duration_correction; const char * name; const char * codec_name; @@ -758,7 +757,6 @@ static hb_title_t * hb_dvdnav_title_scan( hb_dvd_t * e, int t, uint64_t min_dura hb_log( "scan: title %d has %d chapters", t, c ); - duration = 0; count = hb_list_count( title->list_chapter ); for (i = 0; i < count; i++) { @@ -797,16 +795,11 @@ static hb_title_t * hb_dvdnav_title_scan( hb_dvd_t * e, int t, uint64_t min_dura #undef cp cell_cur = FindNextCell( pgc, cell_cur ); } - duration += chapter->duration; } - /* The durations we get for chapters aren't precise. Scale them so - the total matches the title duration */ - duration_correction = (float) title->duration / (float) duration; for( i = 0; i < hb_list_count( title->list_chapter ); i++ ) { chapter = hb_list_item( title->list_chapter, i ); - chapter->duration = duration_correction * chapter->duration; int seconds = ( chapter->duration + 45000 ) / 90000; chapter->hours = ( seconds / 3600 ); @@ -1979,7 +1972,7 @@ static int NextPgcn( ifo_handle_t *ifo, int pgcn, uint32_t pgcn_map[MAX_PGCN/32] **********************************************************************/ static void PgcWalkInit( uint32_t pgcn_map[MAX_PGCN/32] ) { - memset(pgcn_map, 0, sizeof(pgcn_map) ); + memset(pgcn_map, 0, sizeof(uint32_t) * MAX_PGCN/32); } /*********************************************************************** @@ -1998,8 +1991,8 @@ static int dvdtime2msec(dvd_time_t * dt) if( fps > 0 ) { - ms += ((dt->frame_u & 0x30) >> 3) * 5 + - (dt->frame_u & 0x0f) * 1000.0 / fps; + ms += (((dt->frame_u & 0x30) >> 3) * 5 + + (dt->frame_u & 0x0f)) * 1000.0 / fps; } return ms; diff --git a/libhb/encfaac.c b/libhb/encfaac.c index ffdddc8d4..3bdd7cee0 100644 --- a/libhb/encfaac.c +++ b/libhb/encfaac.c @@ -7,6 +7,7 @@ For full terms see the file COPYING file or visit http://www.gnu.org/licenses/gpl-2.0.html */ +#ifdef USE_FAAC #include "hb.h" #include "audio_remap.h" @@ -286,4 +287,4 @@ int encfaacWork( hb_work_object_t * w, hb_buffer_t ** buf_in, return HB_WORK_OK; } - +#endif // USE_FAAC diff --git a/libhb/hb.c b/libhb/hb.c index 6fbb60fb5..4c2eb32e4 100644 --- a/libhb/hb.c +++ b/libhb/hb.c @@ -666,9 +666,6 @@ hb_handle_t * hb_init( int verbose, int update_check ) h->interjob = calloc( sizeof( hb_interjob_t ), 1 ); - /* libavcodec */ - hb_avcodec_init(); - #ifdef USE_QSV /* Intel Quick Sync Video */ hb_qsv_info_print(); @@ -679,37 +676,6 @@ hb_handle_t * hb_init( int verbose, int update_check ) h->die = 0; h->main_thread = hb_thread_init( "libhb", thread_func, h, HB_NORMAL_PRIORITY ); - hb_register( &hb_sync_video ); - hb_register( &hb_sync_audio ); - hb_register( &hb_decmpeg2 ); - hb_register( &hb_decvobsub ); - hb_register( &hb_encvobsub ); - hb_register( &hb_deccc608 ); - hb_register( &hb_decsrtsub ); - hb_register( &hb_decutf8sub ); - hb_register( &hb_dectx3gsub ); - hb_register( &hb_decssasub ); - hb_register( &hb_decpgssub ); - hb_register( &hb_encavcodec ); - hb_register( &hb_encx264 ); -#ifdef USE_QSV - hb_register(&hb_encqsv); -#endif - hb_register( &hb_enctheora ); - hb_register( &hb_deca52 ); - hb_register( &hb_decavcodeca ); - hb_register( &hb_decavcodecv ); - hb_register( &hb_declpcm ); - hb_register( &hb_encfaac ); - hb_register( &hb_enclame ); - hb_register( &hb_encvorbis ); - hb_register( &hb_muxer ); -#ifdef __APPLE__ - hb_register( &hb_encca_aac ); - hb_register( &hb_encca_haac ); -#endif - hb_register( &hb_encavcodeca ); - hb_register( &hb_reader ); return h; } @@ -775,9 +741,6 @@ hb_handle_t * hb_init_dl( int verbose, int update_check ) h->pause_lock = hb_lock_init(); - /* libavcodec */ - hb_avcodec_init(); - #ifdef USE_QSV /* Intel Quick Sync Video */ hb_qsv_info_print(); @@ -789,37 +752,6 @@ hb_handle_t * hb_init_dl( int verbose, int update_check ) h->main_thread = hb_thread_init( "libhb", thread_func, h, HB_NORMAL_PRIORITY ); - hb_register( &hb_sync_video ); - hb_register( &hb_sync_audio ); - hb_register( &hb_decmpeg2 ); - hb_register( &hb_decvobsub ); - hb_register( &hb_encvobsub ); - hb_register( &hb_deccc608 ); - hb_register( &hb_decsrtsub ); - hb_register( &hb_decutf8sub ); - hb_register( &hb_dectx3gsub ); - hb_register( &hb_decssasub ); - hb_register( &hb_encavcodec ); - hb_register( &hb_encx264 ); -#ifdef USE_QSV - hb_register(&hb_encqsv); -#endif - hb_register( &hb_enctheora ); - hb_register( &hb_deca52 ); - hb_register( &hb_decavcodeca ); - hb_register( &hb_decavcodecv ); - hb_register( &hb_declpcm ); - hb_register( &hb_encfaac ); - hb_register( &hb_enclame ); - hb_register( &hb_encvorbis ); - hb_register( &hb_muxer ); -#ifdef __APPLE__ - hb_register( &hb_encca_aac ); - hb_register( &hb_encca_haac ); -#endif - hb_register( &hb_encavcodeca ); - hb_register( &hb_reader ); - return h; } @@ -1926,6 +1858,46 @@ int hb_global_init() return -1; } + /* libavcodec */ + hb_avcodec_init(); + + /* HB work objects */ + hb_register(&hb_muxer); + hb_register(&hb_reader); + hb_register(&hb_sync_video); + hb_register(&hb_sync_audio); +ifdef USE_QSV + hb_register(&hb_encqsv); +#endif + hb_register(&hb_deca52); + hb_register(&hb_decavcodecv); + hb_register(&hb_decavcodeca); + hb_register(&hb_declpcm); + hb_register(&hb_deccc608); + hb_register(&hb_decmpeg2); + hb_register(&hb_decpgssub); + hb_register(&hb_decsrtsub); + hb_register(&hb_decssasub); + hb_register(&hb_dectx3gsub); + hb_register(&hb_decutf8sub); + hb_register(&hb_decvobsub); + hb_register(&hb_encvobsub); + hb_register(&hb_encavcodec); + hb_register(&hb_encavcodeca); +#ifdef __APPLE__ + hb_register(&hb_encca_aac); + hb_register(&hb_encca_haac); +#endif +#ifdef USE_FAAC + hb_register(&hb_encfaac); +#endif + hb_register(&hb_enclame); + hb_register(&hb_enctheora); + hb_register(&hb_encvorbis); + hb_register(&hb_encx264); + + hb_common_global_init(); + #ifdef USE_QSV result = hb_qsv_info_init(); if (result < 0) @@ -1935,8 +1907,6 @@ int hb_global_init() } #endif - hb_common_global_init(); - return result; } diff --git a/libhb/module.defs b/libhb/module.defs index 7b9073134..24e2a6ebe 100644 --- a/libhb/module.defs +++ b/libhb/module.defs @@ -45,7 +45,12 @@ endif ifeq (1,$(FEATURE.fdk_aac)) LIBHB.GCC.D += USE_FDK_AAC endif - +ifeq (1,$(FEATURE.libav_aac)) +LIBHB.GCC.D += USE_LIBAV_AAC +endif +ifeq (1,$(FEATURE.faac)) +LIBHB.GCC.D += USE_FAAC +endif LIBHB.GCC.D += __LIBHB__ USE_PTHREAD LIBHB.GCC.D += __LIBHB__ USE_PTHREAD HAVE_THREADS=1 LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include @@ -106,7 +111,7 @@ LIBHB.dll = $(LIBHB.build/)hb.dll LIBHB.lib = $(LIBHB.build/)hb.lib LIBHB.dll.libs = $(foreach n, \ - a52 ass avcodec avformat avutil avresample dvdnav dvdread faac \ + a52 ass avcodec avformat avutil avresample dvdnav dvdread \ fontconfig freetype mkv mpeg2 mp3lame mp4v2 \ ogg samplerate swscale theora vorbis vorbisenc x264 xml2 bluray, \ $(CONTRIB.build/)lib/lib$(n).a ) @@ -115,6 +120,10 @@ ifeq (1,$(FEATURE.fdk_aac)) LIBHB.dll.libs += $(CONTRIB.build/)lib/libfdk-aac.a endif +ifeq (1,$(FEATURE.faac)) +LIBHB.dll.libs += $(CONTRIB.build/)lib/libfaac.a +endif + ifeq (1,$(FEATURE.qsv)) LIBHB.dll.libs += $(CONTRIB.build/)lib/libmfx.a endif diff --git a/libhb/sync.c b/libhb/sync.c index 6b2f65b90..dee737c19 100644 --- a/libhb/sync.c +++ b/libhb/sync.c @@ -273,7 +273,7 @@ int syncVideoWork( hb_work_object_t * w, hb_buffer_t ** buf_in, { pv->common->first_pts[0] = next->s.start; hb_lock( pv->common->mutex ); - while( pv->common->pts_offset == INT64_MIN ) + while( pv->common->pts_offset == INT64_MIN && !*w->done ) { // Full fifos will make us wait forever, so get the // pts offset from the available streams if full @@ -765,7 +765,7 @@ static int syncAudioWork( hb_work_object_t * w, hb_buffer_t ** buf_in, { pv->common->first_pts[sync->index+1] = buf->s.start; hb_lock( pv->common->mutex ); - while( pv->common->pts_offset == INT64_MIN ) + while( pv->common->pts_offset == INT64_MIN && !*w->done) { // Full fifos will make us wait forever, so get the // pts offset from the available streams if full @@ -785,7 +785,7 @@ static int syncAudioWork( hb_work_object_t * w, hb_buffer_t ** buf_in, /* Wait for start frame if doing point-to-point */ hb_lock( pv->common->mutex ); start = buf->s.start - pv->common->audio_pts_slip; - while ( !pv->common->start_found ) + while ( !pv->common->start_found && !*w->done ) { if ( pv->common->audio_pts_thresh < 0 ) { @@ -801,7 +801,7 @@ static int syncAudioWork( hb_work_object_t * w, hb_buffer_t ** buf_in, return HB_WORK_OK; } while ( !pv->common->start_found && - buf->s.start >= pv->common->audio_pts_thresh ) + buf->s.start >= pv->common->audio_pts_thresh && !*w->done ) { hb_cond_timedwait( pv->common->next_frame, pv->common->mutex, 10 ); // There is an unfortunate unavoidable deadlock that can occur. diff --git a/macosx/English.lproj/Preferences.xib b/macosx/English.lproj/Preferences.xib index ab9a908bf..405e613fd 100644 --- a/macosx/English.lproj/Preferences.xib +++ b/macosx/English.lproj/Preferences.xib @@ -2,31 +2,31 @@ 1050 - 11G63 - 1938 - 1138.51 - 569.00 + 12D78 + 3084 + 1187.37 + 626.00 com.apple.InterfaceBuilder.CocoaPlugin - 1938 + 3084 YES - NSPopUpButtonCell - NSComboBoxCell - NSPopUpButton NSButton - NSMenu - NSTextFieldCell NSButtonCell - NSMenuItem NSComboBox - NSCustomView + NSComboBoxCell NSCustomObject - NSView - NSWindowTemplate + NSCustomView + NSMenu + NSMenuItem + NSPopUpButton + NSPopUpButtonCell NSTextField + NSTextFieldCell NSUserDefaultsController + NSView + NSWindowTemplate YES @@ -64,8 +64,6 @@ 256 {500, 200} - - {{0, 0}, {1440, 878}} {213, 129} @@ -76,7 +74,7 @@ YES - + 256 YES @@ -88,7 +86,7 @@ YES - -2076049856 + -2076180416 133120 LucidaGrande @@ -96,7 +94,7 @@ 3100 - 109199615 + 109199360 129 @@ -194,6 +192,7 @@ YES 2 + NO @@ -203,12 +202,12 @@ YES - -2080244224 + -2080374784 131072 Play System Alert Sound - 1211912703 + 1211912448 2 NSImage @@ -222,6 +221,7 @@ 200 25 + NO @@ -231,7 +231,7 @@ YES - 67239424 + 67108864 134479872 Browse ... @@ -240,13 +240,14 @@ 3614 - -2038284033 + -2038284288 129 200 25 + NO @@ -256,7 +257,7 @@ YES - 68288064 + 68157504 272761856 None @@ -280,6 +281,7 @@ + NO @@ -289,12 +291,12 @@ YES - 67239424 + 67108864 131072 Show Presets Drawer - 1211912703 + 1211912448 2 @@ -302,6 +304,7 @@ 200 25 + NO @@ -311,12 +314,12 @@ YES - 67239424 + 67108864 131072 Use Auto Naming (uses DVD name and title number) - 1211912703 + 1211912448 2 @@ -324,6 +327,7 @@ 200 25 + NO @@ -333,7 +337,7 @@ YES - 67239424 + 67108864 272760832 When Done: @@ -341,6 +345,7 @@ + NO @@ -350,12 +355,12 @@ YES - 67239424 + 67108864 131072 Automatically check for updates - 1211912703 + 1211912448 2 @@ -363,6 +368,7 @@ 200 25 + NO @@ -372,12 +378,12 @@ YES - 67239424 + 67108864 131072 Send file to: - 1211912703 + 1211912448 2 @@ -386,6 +392,7 @@ 200 25 + NO @@ -395,7 +402,7 @@ YES - 67239424 + 67108864 272760832 At launch: @@ -403,6 +410,7 @@ + NO @@ -412,7 +420,7 @@ YES - 67239424 + 67108864 71434240 Default MP4 Extension: @@ -420,6 +428,7 @@ + NO @@ -429,7 +438,7 @@ YES - 67239424 + 67108864 71434240 Source selection: @@ -437,6 +446,7 @@ + NO @@ -446,7 +456,7 @@ YES - 67239424 + 67108864 272760832 Output files: @@ -454,6 +464,7 @@ + NO @@ -462,11 +473,11 @@ YES - 71433792 + 71303232 264192 - 109199615 + 109199360 1 LucidaGrande @@ -528,6 +539,7 @@ YES 1 + NO @@ -537,11 +549,11 @@ YES - 71433792 + 71303232 133120 - 109199615 + 109199360 1 LucidaGrande @@ -607,6 +619,7 @@ YES 1 + NO @@ -616,11 +629,11 @@ YES - 71433792 + 71303232 133120 - 109199615 + 109199360 1 @@ -679,9 +692,11 @@ YES 1 + NO {460, 256} + NSView NSControl @@ -696,11 +711,9 @@ 268 {{34, 42}, {432, 17}} - - YES - 67239488 + 67108928 138413056 Nothing here right now, but I am sure we will think of something @@ -708,11 +721,11 @@ + NO {496, 82} - NSView NSResponder @@ -731,7 +744,7 @@ YES - 67239424 + 67108864 272760832 Alternate Language: @@ -739,6 +752,7 @@ + NO @@ -746,10 +760,10 @@ {{169, 87}, {247, 22}} - + YES - 343014976 + 342884416 272761856 @@ -943,6 +957,8 @@ YES + NO + YES YES @@ -950,7 +966,7 @@ 10 1000 - 75628032 + 75497472 0 @@ -967,7 +983,7 @@ - 338820672 + 338690112 1024 @@ -1011,6 +1027,7 @@ 1 + NO @@ -1021,7 +1038,7 @@ YES - 67239424 + 67108864 272760832 Native Language: @@ -1029,24 +1046,7 @@ - - - - 256 - {{90, 55}, {31, 14}} - - - - YES - - 67239424 - 272760832 - AAC: - - - - - + NO @@ -1057,7 +1057,7 @@ YES - 343014976 + 342884416 272761856 English @@ -1243,6 +1243,8 @@ YES + NO + YES YES @@ -1250,7 +1252,7 @@ 10 1000 - 75628032 + 75497472 0 @@ -1263,7 +1265,7 @@ - 338820672 + 338690112 1024 @@ -1294,22 +1296,22 @@ 1 + NO 256 - {{91, 18}, {292, 26}} + {{122, 45}, {248, 26}} - YES - 67239424 + 67108864 0 Show advanced options for Auto Passthru - 1211912703 + 1211912448 2 @@ -1317,30 +1319,7 @@ 200 25 - - - - 268 - {{123, 53}, {333, 18}} - - - - YES - - -2080244224 - 131072 - Use CoreAudio instead of FAAC for Built-In Presets - - - 1211912703 - 130 - - - - - 200 - 25 - + NO {492, 157} @@ -1353,7 +1332,7 @@ NSResponder - + 256 YES @@ -1362,11 +1341,10 @@ 268 {{302, 172}, {48, 19}} - YES - -1804468671 + -1804599231 272761856 @@ -1380,17 +1358,17 @@ + NO 256 {{17, 207}, {280, 14}} - YES - 67239424 + 67108864 71434240 x264 Constant Quality fractional granularity: @@ -1398,17 +1376,17 @@ + NO 256 {{48, 175}, {249, 14}} - YES - 67239424 + 67108864 71434240 Minimum length of title to scan (seconds): @@ -1416,17 +1394,17 @@ + NO 256 {{99, 145}, {198, 14}} - YES - 67239424 + 67108864 71434240 Number of picture previews to scan: @@ -1434,17 +1412,17 @@ + NO 256 {{137, 53}, {160, 15}} - YES - 67239424 + 67108864 4325376 Activity Log Verbosity Level: @@ -1452,17 +1430,17 @@ + NO 256 {{108, 76}, {27, 14}} - YES - 67239424 + 67108864 272760832 Log: @@ -1470,17 +1448,17 @@ + NO 256 {{70, 110}, {65, 14}} - YES - 67239424 + 67108864 272760832 Dvd-Video: @@ -1488,22 +1466,22 @@ + NO 256 {{137, 74}, {304, 18}} - YES - 67239424 + 67108864 131072 Put individual encode logs in same location as movie - 1211912703 + 1211912448 2 @@ -1511,22 +1489,22 @@ 200 25 + NO 256 {{137, 108}, {220, 18}} - YES - 67239424 + 67108864 131072 Use libdvdnav (instead of libdvdread) - 1211912703 + 1211912448 2 @@ -1534,22 +1512,21 @@ 200 25 + NO 256 {{137, 18}, {217, 18}} - - YES - 67239424 + 67108864 131072 Alert when updating built-in presets - 1211912703 + 1211912448 2 @@ -1557,43 +1534,44 @@ 200 25 + NO 268 {{299, 140}, {73, 22}} - YES - -2076049856 + -2076180416 133120 - 109199615 + 109199360 129 400 75 - + + + 10 + + 1048576 + 2147483647 + 1 + + + _popUpItemAction: + + YES OtherViews YES - - - 10 - - 1048576 - 2147483647 - - - _popUpItemAction: - - + 15 @@ -1704,21 +1682,21 @@ YES 2 + NO 268 {{299, 202}, {76, 22}} - YES - -2076049856 + -2076180416 133120 - 109199615 + 109199360 129 @@ -1781,21 +1759,21 @@ YES 2 + NO 268 {{303, 49}, {66, 22}} - YES - -2076049856 + -2076180416 133120 - 109199615 + 109199360 129 @@ -1849,17 +1827,17 @@ YES 2 + NO 256 {{89, 20}, {46, 14}} - YES - 67239424 + 67108864 272760832 Presets: @@ -1867,11 +1845,10 @@ + NO {495, 241} - - NSView @@ -2173,22 +2150,6 @@ 403 - - - value: values.UseCoreAudio - - - - - - value: values.UseCoreAudio - value - values.UseCoreAudio - 2 - - - 409 - enabled: automaticallyChecksForUpdates @@ -2478,9 +2439,7 @@ - - Audio @@ -2942,20 +2901,6 @@ - - 406 - - - YES - - - - - - 407 - - - 410 @@ -3034,20 +2979,6 @@ - - 446 - - - YES - - - - - - 447 - - - 448 @@ -3344,8 +3275,6 @@ 399.IBPluginDependency 401.IBPluginDependency 402.IBPluginDependency - 406.IBPluginDependency - 407.IBPluginDependency 410.IBPluginDependency 414.IBPluginDependency 415.IBPluginDependency @@ -3357,8 +3286,6 @@ 443.IBPluginDependency 444.IBPluginDependency 445.IBPluginDependency - 446.IBPluginDependency - 447.IBPluginDependency 448.IBPluginDependency 449.IBPluginDependency 450.IBPluginDependency @@ -3397,7 +3324,7 @@ 6.IBPluginDependency 61.IBPluginDependency - + YES com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -3510,10 +3437,6 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin {{69, 656}, {500, 200}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -3570,7 +3493,7 @@ fPictureView fSendEncodeToAppField - + YES NSView NSView @@ -3589,7 +3512,7 @@ fPictureView fSendEncodeToAppField - + YES fAdvancedView @@ -3670,7 +3593,7 @@ NSMenuMixedState NSSwitch - + YES {11, 11} {10, 3} diff --git a/macosx/HBAudioController.m b/macosx/HBAudioController.m index 52cc8284b..30a2f5e95 100644 --- a/macosx/HBAudioController.m +++ b/macosx/HBAudioController.m @@ -295,19 +295,8 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification"; [newAudio setVideoContainerTag: [self videoContainerTag]]; [newAudio setTrackFromIndex: trackIndex]; - // map faac to ca_aac for built-in presets (can be disabled in preferences) - if (0 == aType && - [[NSUserDefaults standardUserDefaults] boolForKey:@"UseCoreAudio"] && - [[dict objectForKey:@"AudioEncoder"] isEqualToString:@"AAC (faac)"]) - { - key = @"AAC (CoreAudio)"; - } - else - { - key = [dict objectForKey:@"AudioEncoder"]; - } - // map legacy encoder names via libhb + key = [dict objectForKey:@"AudioEncoder"]; if (key != nil) { const char *name; diff --git a/macosx/HBPreferencesController.m b/macosx/HBPreferencesController.m index 4e5baccd1..82bdc4d7b 100644 --- a/macosx/HBPreferencesController.m +++ b/macosx/HBPreferencesController.m @@ -45,7 +45,6 @@ @"YES", @"CheckForUpdates", @"Open Source", @"LaunchSourceBehavior", @"English", @"DefaultLanguage", - @"YES", @"UseCoreAudio", @"Auto", @"DefaultMpegExtension", @"YES", @"UseDvdNav", @"", @"DefAdvancedx264Flags", diff --git a/macosx/HBPresets.m b/macosx/HBPresets.m index 0281a4365..a97284b11 100644 --- a/macosx/HBPresets.m +++ b/macosx/HBPresets.m @@ -60,6 +60,7 @@ [childrenArray addObject:[self createAppleTV3Preset]]; [childrenArray addObject:[self createAndroidPreset]]; [childrenArray addObject:[self createAndroidTabletPreset]]; + [childrenArray addObject:[self createW8PhonePreset]]; /* Add the individual presets to the folder */ [preset setObject:[NSMutableArray arrayWithArray:childrenArray] @@ -1081,6 +1082,110 @@ return preset; } +- (NSDictionary *)createW8PhonePreset +{ + NSMutableDictionary *preset = [[NSMutableDictionary alloc] init]; + + /* Preset properties (name, type: factory/user, default, folder, tooltip) */ + [preset setObject:@"Windows Phone 8" forKey:@"PresetName"]; + [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"]; //factory + [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"]; + [preset setObject:[NSNumber numberWithBool:NO] forKey:@"Folder"]; + [preset setObject:@"HandBrake's preset for Windows Phone 8 devices" + forKey:@"PresetDescription"]; + + /* Container format and related settings */ + [preset setObject:@"MP4 file" forKey:@"FileFormat"]; + [preset setObject:[NSNumber numberWithInt:0] forKey:@"Mp4LargeFile"]; + [preset setObject:[NSNumber numberWithInt:0] forKey:@"Mp4HttpOptimize"]; + [preset setObject:[NSNumber numberWithInt:0] forKey:@"Mp4iPodCompatible"]; + + /* Chapter markers */ + [preset setObject:[NSNumber numberWithInt:0] forKey:@"ChapterMarkers"]; + + /* Video encoder and advanced options */ + [preset setObject:@"H.264 (x264)" forKey:@"VideoEncoder"]; + [preset setObject:@"" forKey:@"lavcOption"]; + [preset setObject:@"" forKey:@"x264Option"]; + [preset setObject:[NSNumber numberWithInt:0] forKey:@"x264UseAdvancedOptions"]; + [preset setObject:@"medium" forKey:@"x264Preset"]; + [preset setObject:@"" forKey:@"x264Tune"]; + [preset setObject:@"" forKey:@"x264OptionExtra"]; + [preset setObject:@"main" forKey:@"h264Profile"]; + [preset setObject:@"3.1" forKey:@"h264Level"]; + + /* Video rate control */ + [preset setObject:@"2500" forKey:@"VideoAvgBitrate"]; + [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"]; + [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTurboTwoPass"]; + [preset setObject:[NSNumber numberWithInt:2] forKey:@"VideoQualityType"]; //cq + [preset setObject:[NSNumber numberWithFloat:22.0] forKey:@"VideoQualitySlider"]; + + /* Video frame rate */ + [preset setObject:@"30" forKey:@"VideoFramerate"]; + [preset setObject:@"pfr" forKey:@"VideoFramerateMode"]; + + /* Picture size */ + [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"]; + [preset setObject:[NSNumber numberWithInt:1280] forKey:@"PictureWidth"]; + [preset setObject:[NSNumber numberWithInt:720] forKey:@"PictureHeight"]; + [preset setObject:[NSNumber numberWithInt:2] forKey:@"PicturePAR"]; //loose + [preset setObject:[NSNumber numberWithInt:2] forKey:@"PictureModulus"]; + [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"]; //set to 0 for Loose (FIXME: why?) + + /* Picture filters */ + [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureFilters"]; + [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDecomb"]; //off + [preset setObject:@"" forKey:@"PictureDecombCustom"]; + [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureDecombDeinterlace"]; //decomb + [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"]; + [preset setObject:@"" forKey:@"PictureDeinterlaceCustom"]; + [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDetelecine"]; + [preset setObject:@"" forKey:@"PictureDetelecineCustom"]; + [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDenoise"]; + [preset setObject:@"" forKey:@"PictureDenoiseCustom"]; + [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeblock"]; + [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"]; + + /* Picture crop */ + [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"]; + [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"]; + [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"]; + [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"]; + [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"]; + + /* Auto Passthru */ + [preset setObject:@"AC3 (ffmpeg)" forKey:@"AudioEncoderFallback"]; + [preset setObject:[NSNumber numberWithInt:1] forKey:@"AudioAllowAACPass"]; + [preset setObject:[NSNumber numberWithInt:1] forKey:@"AudioAllowAC3Pass"]; + [preset setObject:[NSNumber numberWithInt:1] forKey:@"AudioAllowDTSHDPass"]; + [preset setObject:[NSNumber numberWithInt:1] forKey:@"AudioAllowDTSPass"]; + [preset setObject:[NSNumber numberWithInt:1] forKey:@"AudioAllowMP3Pass"]; + + /* Audio track list - no need to add "None" at the end */ + NSMutableArray *audioListArray = [[NSMutableArray alloc] init]; + /* Track 1 */ + NSMutableDictionary *audioTrack1Array = [[NSMutableDictionary alloc] init]; + [audioTrack1Array setObject:[NSNumber numberWithInt:1] forKey:@"AudioTrack"]; + [audioTrack1Array setObject:@"AAC (faac)" forKey:@"AudioEncoder"]; + [audioTrack1Array setObject:@"Dolby Pro Logic II" forKey:@"AudioMixdown"]; + [audioTrack1Array setObject:@"Auto" forKey:@"AudioSamplerate"]; + [audioTrack1Array setObject:@"128" forKey:@"AudioBitrate"]; + [audioTrack1Array setObject:[NSNumber numberWithFloat:0.0] forKey:@"AudioTrackGainSlider"]; + [audioTrack1Array setObject:[NSNumber numberWithFloat:0.0] forKey:@"AudioTrackDRCSlider"]; + [audioTrack1Array autorelease]; + [audioListArray addObject:audioTrack1Array]; + /* Add the audio track(s) to the preset's audio list */ + [preset setObject:[NSMutableArray arrayWithArray:audioListArray] forKey:@"AudioList"]; + + /* Subtitles (note: currently ignored) */ + [preset setObject:@"None" forKey:@"Subtitles"]; + + /* Clean up and return the preset */ + [preset autorelease]; + return preset; +} + - (NSDictionary *)createNormalPreset { NSMutableDictionary *preset = [[NSMutableDictionary alloc] init]; diff --git a/macosx/HandBrake.xcodeproj/project.pbxproj b/macosx/HandBrake.xcodeproj/project.pbxproj index df3329743..6762c87e8 100644 --- a/macosx/HandBrake.xcodeproj/project.pbxproj +++ b/macosx/HandBrake.xcodeproj/project.pbxproj @@ -92,8 +92,6 @@ 27D6C75014B102DA00B785E4 /* libdvdnav.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 27D6C72E14B102DA00B785E4 /* libdvdnav.a */; }; 27D6C75114B102DA00B785E4 /* libdvdread.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 27D6C72F14B102DA00B785E4 /* libdvdread.a */; }; 27D6C75214B102DA00B785E4 /* libdvdread.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 27D6C72F14B102DA00B785E4 /* libdvdread.a */; }; - 27D6C75314B102DA00B785E4 /* libfaac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 27D6C73014B102DA00B785E4 /* libfaac.a */; }; - 27D6C75414B102DA00B785E4 /* libfaac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 27D6C73014B102DA00B785E4 /* libfaac.a */; }; 27D6C75514B102DA00B785E4 /* libfontconfig.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 27D6C73114B102DA00B785E4 /* libfontconfig.a */; }; 27D6C75614B102DA00B785E4 /* libfontconfig.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 27D6C73114B102DA00B785E4 /* libfontconfig.a */; }; 27D6C75714B102DA00B785E4 /* libfreetype.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 27D6C73214B102DA00B785E4 /* libfreetype.a */; }; @@ -294,7 +292,6 @@ 27D6C72C14B102DA00B785E4 /* libbluray.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libbluray.a; path = external/contrib/lib/libbluray.a; sourceTree = BUILT_PRODUCTS_DIR; }; 27D6C72E14B102DA00B785E4 /* libdvdnav.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libdvdnav.a; path = external/contrib/lib/libdvdnav.a; sourceTree = BUILT_PRODUCTS_DIR; }; 27D6C72F14B102DA00B785E4 /* libdvdread.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libdvdread.a; path = external/contrib/lib/libdvdread.a; sourceTree = BUILT_PRODUCTS_DIR; }; - 27D6C73014B102DA00B785E4 /* libfaac.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libfaac.a; path = external/contrib/lib/libfaac.a; sourceTree = BUILT_PRODUCTS_DIR; }; 27D6C73114B102DA00B785E4 /* libfontconfig.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libfontconfig.a; path = external/contrib/lib/libfontconfig.a; sourceTree = BUILT_PRODUCTS_DIR; }; 27D6C73214B102DA00B785E4 /* libfreetype.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libfreetype.a; path = external/contrib/lib/libfreetype.a; sourceTree = BUILT_PRODUCTS_DIR; }; 27D6C73314B102DA00B785E4 /* libfribidi.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libfribidi.a; path = external/contrib/lib/libfribidi.a; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -368,7 +365,6 @@ 27D6C74C14B102DA00B785E4 /* libbluray.a in Frameworks */, 27D6C75014B102DA00B785E4 /* libdvdnav.a in Frameworks */, 27D6C75214B102DA00B785E4 /* libdvdread.a in Frameworks */, - 27D6C75414B102DA00B785E4 /* libfaac.a in Frameworks */, 27D6C75614B102DA00B785E4 /* libfontconfig.a in Frameworks */, 27D6C75814B102DA00B785E4 /* libfreetype.a in Frameworks */, 27D6C75A14B102DA00B785E4 /* libfribidi.a in Frameworks */, @@ -411,7 +407,6 @@ 27D6C74B14B102DA00B785E4 /* libbluray.a in Frameworks */, 27D6C74F14B102DA00B785E4 /* libdvdnav.a in Frameworks */, 27D6C75114B102DA00B785E4 /* libdvdread.a in Frameworks */, - 27D6C75314B102DA00B785E4 /* libfaac.a in Frameworks */, 27D6C75514B102DA00B785E4 /* libfontconfig.a in Frameworks */, 27D6C75714B102DA00B785E4 /* libfreetype.a in Frameworks */, 27D6C75914B102DA00B785E4 /* libfribidi.a in Frameworks */, @@ -446,7 +441,6 @@ 27D6C72C14B102DA00B785E4 /* libbluray.a */, 27D6C72E14B102DA00B785E4 /* libdvdnav.a */, 27D6C72F14B102DA00B785E4 /* libdvdread.a */, - 27D6C73014B102DA00B785E4 /* libfaac.a */, 27D6C73114B102DA00B785E4 /* libfontconfig.a */, 27D6C73214B102DA00B785E4 /* libfreetype.a */, 27D6C73314B102DA00B785E4 /* libfribidi.a */, diff --git a/macosx/module.defs b/macosx/module.defs index 1870d5fe9..1a2b6f81d 100644 --- a/macosx/module.defs +++ b/macosx/module.defs @@ -26,9 +26,14 @@ MACOSX.map.g.std = debug MACOSX.map.g.max = debug ifeq (1,$(FEATURE.fdk_aac)) -MACOSX.extra_ldflags = OTHER_LDFLAGS='$(abspath $(BUILD))/contrib/lib/libfdk-aac.a' + extra_libs += $(abspath $(BUILD))/contrib/lib/libfdk-aac.a endif +ifeq (1,$(FEATURE.faac)) + extra_libs += $(abspath $(BUILD))/contrib/lib/libfaac.a +endif +MACOSX.extra_ldflags = OTHER_LDFLAGS='$(extra_libs)' + ## xcconfig: must be one of macosx/xcconfig/*.xcconfig MACOSX.xcconfig = $(foreach x,$(XCODE.xcconfig),-xcconfig $(MACOSX.src/)xcconfig/$(x)) MACOSX.sdk = $(foreach sdk,$(GCC.sysroot),-sdk $(sdk)) diff --git a/make/configure.py b/make/configure.py index 8dbe78a56..2cb3d391d 100644 --- a/make/configure.py +++ b/make/configure.py @@ -1179,7 +1179,16 @@ def createCLI(): grp.add_option( '--enable-qsv', default=False, action='store_true', help=h ) h = IfHost( 'enable use of fdk-aac encoder', '*-*-*', none=optparse.SUPPRESS_HELP ).value - grp.add_option( '--enable-fdk-aac', default=False, action='store_true', help=h ) + grp.add_option( '--enable-fdk-aac', dest="enable_fdk_aac", default=not host.match( '*-*-darwin*' ), action='store_true', help=h ) + grp.add_option( '--disable-fdk-aac', dest="enable_fdk_aac", action='store_false' ) + + h = IfHost( 'enable use of libav aac encoder', '*-*-*', none=optparse.SUPPRESS_HELP ).value + grp.add_option( '--enable-libav-aac', dest="enable_libav_aac", default=not host.match( '*-*-darwin*' ), action='store_true', help=h ) + grp.add_option( '--disable-libav-aac', dest="enable_libav_aac", action='store_false' ) + + h = IfHost( 'enable use of faac encoder', '*-*-*', none=optparse.SUPPRESS_HELP ).value + grp.add_option( '--enable-faac', dest="enable_faac", default=False, action='store_true', help=h ) + grp.add_option( '--disable-faac', dest="enable_faac", action='store_false' ) cli.add_option_group( grp ) @@ -1620,7 +1629,9 @@ int main () doc.add( 'FEATURE.gtk.mingw', int( options.enable_gtk_mingw )) doc.add( 'FEATURE.gst', int( not options.disable_gst )) doc.add( 'FEATURE.ff.mpeg2', int( options.enable_ff_mpeg2 )) - doc.add( 'FEATURE.fdk_aac', int( options.enable_fdk_aac )) + doc.add( 'FEATURE.fdk_aac', int( options.enable_fdk_aac )) + doc.add( 'FEATURE.libav_aac', int( options.enable_libav_aac )) + doc.add( 'FEATURE.faac', int( options.enable_faac )) doc.add( 'FEATURE.qsv', int( options.enable_qsv )) doc.add( 'FEATURE.xcode', int( not (Tools.xcodebuild.fail or options.disable_xcode or options.cross) )) diff --git a/make/include/main.defs b/make/include/main.defs index 703118856..d4d3ee0fb 100644 --- a/make/include/main.defs +++ b/make/include/main.defs @@ -43,8 +43,11 @@ ifeq (1,$(FEATURE.fdk_aac)) MODULES += contrib/fdk-aac endif +ifeq (1,$(FEATURE.faac)) + MODULES += contrib/faac +endif + MODULES += contrib/lame -MODULES += contrib/faac MODULES += contrib/ffmpeg MODULES += contrib/libdvdread MODULES += contrib/libdvdnav diff --git a/scripts/manicure.rb b/scripts/manicure.rb index b8be37432..83b991dd9 100755 --- a/scripts/manicure.rb +++ b/scripts/manicure.rb @@ -280,16 +280,16 @@ class Display end #Video encoder - if hash["VideoEncoder"] != "MPEG-4 (FFmpeg)" - commandString << " -e " - case hash["VideoEncoder"] - when /x264/ - commandString << "x264" - when /Theora/ - commandString << "theora" - when /MPEG/ - commandString << "ffmpeg2" - end + commandString << " -e " + case hash["VideoEncoder"] + when /x264/ + commandString << "x264" + when /Theora/ + commandString << "theora" + when /MPEG-4/ + commandString << "ffmpeg4" + when /MPEG-2/ + commandString << "ffmpeg2" end #VideoRateControl @@ -342,23 +342,23 @@ class Display when /AC3 Pass/ audioEncoders << "copy:ac3" when /AC3/ - audioEncoders << "ffac3" + audioEncoders << "ac3" when /DTS Pass/ audioEncoders << "copy:dts" when /DTS-HD Pass/ audioEncoders << "copy:dtshd" when /AAC Pass/ audioEncoders << "copy:aac" - when "AAC (FDK)" - audioEncoders << "fdk_aac" when "AAC (faac)" audioEncoders << "faac" - when "AAC (ffmpeg)" - audioEncoders << "ffaac" - when "AAC (CoreAudio)" - audioEncoders << "ca_aac" + when "AAC (ffmpeg)", "AAC (avcodec)" + audioEncoders << "av_aac" + when "AAC (FDK)" + audioEncoders << "fdk_aac" when "HE-AAC (FDK)" audioEncoders << "fdk_haac" + when "AAC (CoreAudio)" + audioEncoders << "ca_aac" when "HE-AAC (CoreAudio)" audioEncoders << "ca_haac" when /Vorbis/ @@ -366,11 +366,11 @@ class Display when /MP3 Pass/ audioEncoders << "copy:mp3" when /MP3/ - audioEncoders << "lame" - when "FLAC (ffmpeg)" - audioEncoders << "ffflac" - when "FLAC (24-bit)" - audioEncoders << "ffflac24" + audioEncoders << "mp3" + when "FLAC (ffmpeg)", "FLAC 16-bit" + audioEncoders << "flac16" + when "FLAC (24-bit)", "FLAC 24-bit" + audioEncoders << "flac24" when /Auto Pass/ audioEncoders << "copy" end @@ -467,17 +467,27 @@ class Display case hash["AudioEncoderFallback"] when /AC3/ - audioEncoderFallback << "ffac3" - when "AAC (ffmpeg)" - audioEncoderFallback << "ffaac" - when /AAC/ + audioEncoderFallback << "ac3" + when "AAC (faac)" audioEncoderFallback << "faac" + when "AAC (ffmpeg)", "AAC (avcodec)" + audioEncoderFallback << "av_aac" + when "AAC (FDK)" + audioEncoderFallback << "fdk_aac" + when "HE-AAC (FDK)" + audioEncoderFallback << "fdk_haac" + when "AAC (CoreAudio)" + audioEncoderFallback << "ca_aac" + when "HE-AAC (CoreAudio)" + audioEncoderFallback << "ca_haac" when /Vorbis/ audioEncoderFallback << "vorbis" when /MP3/ - audioEncoderFallback << "lame" - when /FLAC/ - audioEncoderFallback << "ffflac" + audioEncoderFallback << "mp3" + when "FLAC (ffmpeg)", "FLAC 16-bit" + audioEncoderFallback << "flac16" + when "FLAC (24-bit)", "FLAC 24-bit" + audioEncoderFallback << "flac24" end if audioEncoderFallback.size > 0 @@ -678,16 +688,16 @@ class Display commandString << '+ ' << hash["PresetName"] << ":" #Video encoder - if hash["VideoEncoder"] != "MPEG-4 (FFmpeg)" - commandString << " -e " - case hash["VideoEncoder"] - when /x264/ - commandString << "x264" - when /Theora/ - commandString << "theora" - when /MPEG/ - commandString << "ffmpeg2" - end + commandString << " -e " + case hash["VideoEncoder"] + when /x264/ + commandString << "x264" + when /Theora/ + commandString << "theora" + when /MPEG-4/ + commandString << "ffmpeg4" + when /MPEG-2/ + commandString << "ffmpeg2" end #VideoRateControl @@ -740,23 +750,23 @@ class Display when /AC3 Pass/ audioEncoders << "copy:ac3" when /AC3/ - audioEncoders << "ffac3" + audioEncoders << "ac3" when /DTS Pass/ audioEncoders << "copy:dts" when /DTS-HD Pass/ audioEncoders << "copy:dtshd" when /AAC Pass/ audioEncoders << "copy:aac" - when "AAC (FDK)" - audioEncoders << "fdk_aac" when "AAC (faac)" audioEncoders << "faac" - when "AAC (ffmpeg)" - audioEncoders << "ffaac" - when "AAC (CoreAudio)" - audioEncoders << "ca_aac" + when "AAC (ffmpeg)", "AAC (avcodec)" + audioEncoders << "av_aac" + when "AAC (FDK)" + audioEncoders << "fdk_aac" when "HE-AAC (FDK)" audioEncoders << "fdk_haac" + when "AAC (CoreAudio)" + audioEncoders << "ca_aac" when "HE-AAC (CoreAudio)" audioEncoders << "ca_haac" when /Vorbis/ @@ -764,11 +774,11 @@ class Display when /MP3 Pass/ audioEncoders << "copy:mp3" when /MP3/ - audioEncoders << "lame" - when "FLAC (ffmpeg)" - audioEncoders << "ffflac" - when "FLAC (24-bit)" - audioEncoders << "ffflac24" + audioEncoders << "mp3" + when "FLAC (ffmpeg)", "FLAC 16-bit" + audioEncoders << "flac16" + when "FLAC (24-bit)", "FLAC 24-bit" + audioEncoders << "flac24" when /Auto Pass/ audioEncoders << "copy" end @@ -865,17 +875,27 @@ class Display case hash["AudioEncoderFallback"] when /AC3/ - audioEncoderFallback << "ffac3" - when "AAC (ffmpeg)" - audioEncoderFallback << "ffaac" - when /AAC/ + audioEncoderFallback << "ac3" + when "AAC (faac)" audioEncoderFallback << "faac" + when "AAC (ffmpeg)", "AAC (avcodec)" + audioEncoderFallback << "av_aac" + when "AAC (FDK)" + audioEncoderFallback << "fdk_aac" + when "HE-AAC (FDK)" + audioEncoderFallback << "fdk_haac" + when "AAC (CoreAudio)" + audioEncoderFallback << "ca_aac" + when "HE-AAC (CoreAudio)" + audioEncoderFallback << "ca_haac" when /Vorbis/ audioEncoderFallback << "vorbis" when /MP3/ - audioEncoderFallback << "lame" - when /FLAC/ - audioEncoderFallback << "ffflac" + audioEncoderFallback << "mp3" + when "FLAC (ffmpeg)", "FLAC 16-bit" + audioEncoderFallback << "flac16" + when "FLAC (24-bit)", "FLAC 24-bit" + audioEncoderFallback << "flac24" end if audioEncoderFallback.size > 0 @@ -1080,16 +1100,16 @@ class Display end #Video encoder - if hash["VideoEncoder"] != "MPEG-4 (FFmpeg)" - commandString << "vcodec = " - case hash["VideoEncoder"] - when /x264/ - commandString << "HB_VCODEC_X264;\n " - when /Theora/ - commandString << "HB_VCODEC_THEORA;\n " - when /MPEG/ - commandString << "HB_VCODEC_FFMPEG_MPEG2;\n " - end + commandString << "vcodec = " + case hash["VideoEncoder"] + when /x264/ + commandString << "HB_VCODEC_X264;\n " + when /Theora/ + commandString << "HB_VCODEC_THEORA;\n " + when /MPEG-4/ + commandString << "HB_VCODEC_FFMPEG_MPEG4;\n " + when /MPEG-2/ + commandString << "HB_VCODEC_FFMPEG_MPEG2;\n " end #VideoRateControl @@ -1144,23 +1164,23 @@ class Display when /AC3 Pass/ audioEncoders << "copy:ac3" when /AC3/ - audioEncoders << "ffac3" + audioEncoders << "ac3" when /DTS Pass/ audioEncoders << "copy:dts" when /DTS-HD Pass/ audioEncoders << "copy:dtshd" when /AAC Pass/ audioEncoders << "copy:aac" - when "AAC (FDK)" - audioEncoders << "fdk_aac" when "AAC (faac)" audioEncoders << "faac" - when "AAC (ffmpeg)" - audioEncoders << "ffaac" - when "AAC (CoreAudio)" - audioEncoders << "ca_aac" + when "AAC (ffmpeg)", "AAC (avcodec)" + audioEncoders << "av_aac" + when "AAC (FDK)" + audioEncoders << "fdk_aac" when "HE-AAC (FDK)" audioEncoders << "fdk_haac" + when "AAC (CoreAudio)" + audioEncoders << "ca_aac" when "HE-AAC (CoreAudio)" audioEncoders << "ca_haac" when /Vorbis/ @@ -1168,11 +1188,11 @@ class Display when /MP3 Pass/ audioEncoders << "copy:mp3" when /MP3/ - audioEncoders << "lame" - when "FLAC (ffmpeg)" - audioEncoders << "ffflac" - when "FLAC (24-bit)" - audioEncoders << "ffflac24" + audioEncoders << "mp3" + when "FLAC (ffmpeg)", "FLAC 16-bit" + audioEncoders << "flac16" + when "FLAC (24-bit)", "FLAC 24-bit" + audioEncoders << "flac24" when /Auto Pass/ audioEncoders << "copy" end @@ -1287,27 +1307,27 @@ class Display case hash["AudioEncoderFallback"] when /AC3/ - audioEncoderFallback << "ffac3" - when "AAC (FDK)" - audioEncoderFallback << "fdk_aac" + audioEncoderFallback << "ac3" when "AAC (faac)" audioEncoderFallback << "faac" - when "AAC (ffmpeg)" - audioEncoderFallback << "ffaac" - when "AAC (CoreAudio)" - audioEncoderFallback << "ca_aac" + when "AAC (ffmpeg)", "AAC (avcodec)" + audioEncoderFallback << "av_aac" + when "AAC (FDK)" + audioEncoderFallback << "fdk_aac" when "HE-AAC (FDK)" audioEncoderFallback << "fdk_haac" + when "AAC (CoreAudio)" + audioEncoderFallback << "ca_aac" when "HE-AAC (CoreAudio)" audioEncoderFallback << "ca_haac" when /Vorbis/ audioEncoderFallback << "vorbis" when /MP3/ - audioEncoderFallback << "lame" - when "FLAC (ffmpeg)" - audioEncoderFallback << "ffflac" - when "FLAC (24-bit)" - audioEncoderFallback << "ffflac24" + audioEncoderFallback << "mp3" + when "FLAC (ffmpeg)", "FLAC 16-bit" + audioEncoderFallback << "flac16" + when "FLAC (24-bit)", "FLAC 24-bit" + audioEncoderFallback << "flac24" end if audioEncoderFallback.size > 0 @@ -1538,16 +1558,16 @@ class Display commandString << "+ " << hash["PresetName"] << ": " #Video encoder - if hash["VideoEncoder"] != "MPEG-4 (FFmpeg)" - commandString << " -e " - case hash["VideoEncoder"] - when /x264/ - commandString << "x264 " - when /Theora/ - commandString << "theora " - when /MPEG/ - commandString << "ffmpeg2 " - end + commandString << " -e " + case hash["VideoEncoder"] + when /x264/ + commandString << "x264 " + when /Theora/ + commandString << "theora " + when /MPEG-4/ + commandString << "ffmpeg4 " + when /MPEG-2/ + commandString << "ffmpeg2 " end #VideoRateControl @@ -1600,23 +1620,23 @@ class Display when /AC3 Pass/ audioEncoders << "copy:ac3" when /AC3/ - audioEncoders << "ffac3" + audioEncoders << "ac3" when /DTS Pass/ audioEncoders << "copy:dts" when /DTS-HD Pass/ audioEncoders << "copy:dtshd" when /AAC Pass/ audioEncoders << "copy:aac" - when "AAC (FDK)" - audioEncoders << "fdk_aac" when "AAC (faac)" audioEncoders << "faac" - when "AAC (ffmpeg)" - audioEncoders << "ffaac" - when "AAC (CoreAudio)" - audioEncoders << "ca_aac" + when "AAC (ffmpeg)", "AAC (avcodec)" + audioEncoders << "av_aac" + when "AAC (FDK)" + audioEncoders << "fdk_aac" when "HE-AAC (FDK)" audioEncoders << "fdk_haac" + when "AAC (CoreAudio)" + audioEncoders << "ca_aac" when "HE-AAC (CoreAudio)" audioEncoders << "ca_haac" when /Vorbis/ @@ -1624,11 +1644,11 @@ class Display when /MP3 Pass/ audioEncoders << "copy:mp3" when /MP3/ - audioEncoders << "lame" - when "FLAC (ffmpeg)" - audioEncoders << "ffflac" - when "FLAC (24-bit)" - audioEncoders << "ffflac24" + audioEncoders << "mp3" + when "FLAC (ffmpeg)", "FLAC 16-bit" + audioEncoders << "flac16" + when "FLAC (24-bit)", "FLAC 24-bit" + audioEncoders << "flac24" when /Auto Pass/ audioEncoders << "copy" end @@ -1725,17 +1745,27 @@ class Display case hash["AudioEncoderFallback"] when /AC3/ - audioEncoderFallback << "ffac3" - when "AAC (ffmpeg)" - audioEncoderFallback << "ffaac" - when /AAC/ + audioEncoderFallback << "ac3" + when "AAC (faac)" audioEncoderFallback << "faac" + when "AAC (ffmpeg)", "AAC (avcodec)" + audioEncoderFallback << "av_aac" + when "AAC (FDK)" + audioEncoderFallback << "fdk_aac" + when "HE-AAC (FDK)" + audioEncoderFallback << "fdk_haac" + when "AAC (CoreAudio)" + audioEncoderFallback << "ca_aac" + when "HE-AAC (CoreAudio)" + audioEncoderFallback << "ca_haac" when /Vorbis/ audioEncoderFallback << "vorbis" when /MP3/ - audioEncoderFallback << "lame" - when /FLAC/ - audioEncoderFallback << "ffflac" + audioEncoderFallback << "mp3" + when "FLAC (ffmpeg)", "FLAC 16-bit" + audioEncoderFallback << "flac16" + when "FLAC (24-bit)", "FLAC 24-bit" + audioEncoderFallback << "flac24" end if audioEncoderFallback.size > 0 diff --git a/test/module.defs b/test/module.defs index 61444c6c5..25bc99991 100644 --- a/test/module.defs +++ b/test/module.defs @@ -14,7 +14,7 @@ TEST.GCC.L = $(CONTRIB.build/)lib TEST.libs = $(LIBHB.a) TEST.GCC.l = \ - a52 ass avcodec avformat avutil avresample dvdnav dvdread faac \ + a52 ass avcodec avformat avutil avresample dvdnav dvdread \ fontconfig freetype fribidi mkv mpeg2 mp3lame mp4v2 ogg \ samplerate swscale theoraenc theoradec vorbis vorbisenc x264 \ bluray xml2 bz2 z @@ -28,6 +28,10 @@ ifeq (1,$(FEATURE.fdk_aac)) TEST.GCC.l += fdk-aac endif +ifeq (1,$(FEATURE.faac)) +TEST.GCC.l += faac +endif + TEST.install.exe = $(DESTDIR)$(PREFIX/)bin/$(notdir $(TEST.exe)) ############################################################################### diff --git a/test/test.c b/test/test.c index fc1c6cff7..cc72983b2 100644 --- a/test/test.c +++ b/test/test.c @@ -1333,6 +1333,74 @@ static int HandleEvents( hb_handle_t * h ) } modulus = 2; } + if (!strcasecmp(preset_name, "Windows Phone 8")) + { + if( !mux ) + { + mux = HB_MUX_MP4; + } + vcodec = HB_VCODEC_X264; + job->vquality = 22.0; + filter_vrate_base = 900000; + filter_cfr = 2; + if( !atracks ) + { + atracks = strdup("1"); + } + if( !acodecs ) + { + acodecs = strdup("faac"); + } + if( !abitrates ) + { + abitrates = str_split("128", ','); + } + if( !mixdowns ) + { + mixdowns = strdup("dpl2"); + } + if( !arates ) + { + arates = strdup("Auto"); + } + if( !dynamic_range_compression ) + { + dynamic_range_compression = strdup("0.0"); + } + if( allowed_audio_copy == -1 ) + { + allowed_audio_copy = 0; + allowed_audio_copy |= HB_ACODEC_AAC_PASS; + allowed_audio_copy |= HB_ACODEC_AC3_PASS; + allowed_audio_copy |= HB_ACODEC_DCA_HD_PASS; + allowed_audio_copy |= HB_ACODEC_DCA_PASS; + allowed_audio_copy |= HB_ACODEC_MP3_PASS; + allowed_audio_copy &= HB_ACODEC_PASS_MASK; + } + if( acodec_fallback == NULL ) + { + acodec_fallback = "ffac3"; + } + maxWidth = 1280; + maxHeight = 720; + if (x264_preset == NULL) + { + x264_preset = strdup("medium"); + } + if (h264_profile == NULL) + { + h264_profile = strdup("main"); + } + if (h264_level == NULL) + { + h264_level = strdup("3.1"); + } + if( !anamorphic_mode ) + { + anamorphic_mode = 2; + } + modulus = 2; + } if (!strcasecmp(preset_name, "Normal")) { if( !mux ) @@ -2977,6 +3045,7 @@ static void ShowHelp() "### Video Options------------------------------------------------------------\n\n" " -e, --encoder Set video library encoder\n" " Options: " ); + name = NULL; encoder = NULL; while ((encoder = hb_video_encoder_get_next(encoder)) != NULL) { @@ -3445,7 +3514,8 @@ static void ShowPresets() printf("\n + AppleTV 3: -e x264 -q 20.0 -r 30 --pfr -a 1,1 -E faac,copy:ac3 -B 160,160 -6 dpl2,none -R Auto,Auto -D 0.0,0.0 --audio-copy-mask aac,ac3,dtshd,dts,mp3 --audio-fallback ffac3 -f mp4 -4 -X 1920 -Y 1080 --decomb=fast --loose-anamorphic --modulus 2 -m --x264-preset medium --h264-profile high --h264-level 4.0\n"); printf("\n + Android: -e x264 -q 22.0 -r 30 --pfr -a 1 -E faac -B 128 -6 dpl2 -R Auto -D 0.0 --audio-copy-mask aac,ac3,dtshd,dts,mp3 --audio-fallback ffac3 -f mp4 -X 720 -Y 576 --loose-anamorphic --modulus 2 --x264-preset medium --h264-profile main --h264-level 3.0\n"); printf("\n + Android Tablet: -e x264 -q 22.0 -r 30 --pfr -a 1 -E faac -B 128 -6 dpl2 -R Auto -D 0.0 --audio-copy-mask aac,ac3,dtshd,dts,mp3 --audio-fallback ffac3 -f mp4 -X 1280 -Y 720 --loose-anamorphic --modulus 2 --x264-preset medium --h264-profile main --h264-level 3.1\n"); - printf("\n>\n"); + printf("\n + Windows Phone 8: -e x264 -q 22.0 -r 30 --pfr -a 1 -E faac -B 128 -6 dpl2 -R Auto -D 0.0 --audio-copy-mask aac,ac3,dtshd,dts,mp3 --audio-fallback ffac3 -f mp4 -X 1280 -Y 720 --loose-anamorphic --modulus 2 --x264-preset medium --h264-profile main --h264-level 3.1\n"); + printf("\n>\n"); printf("\n< Regular\n"); printf("\n + Normal: -e x264 -q 20.0 -a 1 -E faac -B 160 -6 dpl2 -R Auto -D 0.0 --audio-copy-mask aac,ac3,dtshd,dts,mp3 --audio-fallback ffac3 -f mp4 --loose-anamorphic --modulus 2 -m --x264-preset veryfast --h264-profile main --h264-level 4.0\n"); printf("\n + High Profile: -e x264 -q 20.0 -a 1,1 -E faac,copy:ac3 -B 160,160 -6 dpl2,none -R Auto,Auto -D 0.0,0.0 --audio-copy-mask aac,ac3,dtshd,dts,mp3 --audio-fallback ffac3 -f mp4 -4 --decomb --loose-anamorphic --modulus 2 -m --x264-preset medium --h264-profile high --h264-level 4.1\n"); diff --git a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj index 445b09c36..4888c9e9b 100644 --- a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj +++ b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj @@ -95,6 +95,7 @@ + diff --git a/win/CS/HandBrake.ApplicationServices/LibHb/AudioVideoHelpers.cs b/win/CS/HandBrake.ApplicationServices/LibHb/AudioVideoHelpers.cs new file mode 100644 index 000000000..022d78180 --- /dev/null +++ b/win/CS/HandBrake.ApplicationServices/LibHb/AudioVideoHelpers.cs @@ -0,0 +1,18 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// Defines the AudioVideoHelpers type. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.ApplicationServices.LibHb +{ + /// + /// The audio video helpers. + /// + class AudioVideoHelpers + { + } +} diff --git a/win/CS/HandBrake.ApplicationServices/Model/Encoding/AudioTrack.cs b/win/CS/HandBrake.ApplicationServices/Model/Encoding/AudioTrack.cs index c8238927f..fcbaddf6f 100644 --- a/win/CS/HandBrake.ApplicationServices/Model/Encoding/AudioTrack.cs +++ b/win/CS/HandBrake.ApplicationServices/Model/Encoding/AudioTrack.cs @@ -75,7 +75,7 @@ namespace HandBrake.ApplicationServices.Model.Encoding public AudioTrack() { // Default Values - this.Encoder = AudioEncoder.Faac; + this.Encoder = AudioEncoder.ffaac; this.MixDown = Mixdown.DolbyProLogicII; this.SampleRate = 48; this.Bitrate = 160; @@ -341,7 +341,7 @@ namespace HandBrake.ApplicationServices.Model.Encoding { get { - return this.IsPassthru || this.Encoder == AudioEncoder.ffflac; + return this.IsPassthru || this.Encoder == AudioEncoder.ffflac || this.Encoder == AudioEncoder.ffflac24; } } @@ -352,7 +352,7 @@ namespace HandBrake.ApplicationServices.Model.Encoding { get { - return this.IsPassthru || this.Encoder == AudioEncoder.ffflac; + return this.IsPassthru || this.Encoder == AudioEncoder.ffflac || this.Encoder == AudioEncoder.ffflac24; } } diff --git a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IPresetService.cs b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IPresetService.cs index 63fe25158..83e1206b2 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IPresetService.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IPresetService.cs @@ -28,6 +28,11 @@ namespace HandBrake.ApplicationServices.Services.Interfaces /// Preset DefaultPreset { get; } + /// + /// The load. + /// + void Load(); + /// /// Add a new preset to the system /// diff --git a/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs b/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs index efdce5240..e40c44033 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs @@ -38,11 +38,6 @@ namespace HandBrake.ApplicationServices.Services /// private static readonly XmlSerializer Ser = new XmlSerializer(typeof(List)); - /// - /// The User Setting Service - /// - private readonly IUserSettingService userSettingService; - /// /// User Preset Default Catgory Name /// @@ -61,30 +56,10 @@ namespace HandBrake.ApplicationServices.Services /// /// A Collection of presets /// - private ObservableCollection presets = new ObservableCollection(); + private readonly ObservableCollection presets = new ObservableCollection(); #endregion - - /// - /// Initializes a new instance of the class. - /// - /// - /// The user Setting Service. - /// - public PresetService(IUserSettingService userSettingService) - { - this.userSettingService = userSettingService; - - // If the preset file doesn't exist. Create it. - if (!File.Exists(this.builtInPresetFile)) - { - this.UpdateBuiltInPresets(); - } - - this.LoadPresets(); - } - /// /// Gets a Collection of presets. /// @@ -114,6 +89,20 @@ namespace HandBrake.ApplicationServices.Services #region Public Methods + /// + /// The load. + /// + public void Load() + { + // If the preset file doesn't exist. Create it. + if (!File.Exists(this.builtInPresetFile)) + { + this.UpdateBuiltInPresets(); + } + + this.LoadPresets(); + } + /// /// Add a new preset to the system. /// Performs an Update if it already exists @@ -413,7 +402,7 @@ namespace HandBrake.ApplicationServices.Services // Recover from Error. if (File.Exists(file)) { - string disabledFile = file + ".old"; + string disabledFile = string.Format("{0}.{1}", file, GeneralUtilities.ProcessId); File.Move(file, disabledFile); if (File.Exists(file)) { @@ -458,7 +447,6 @@ namespace HandBrake.ApplicationServices.Services { RecoverFromCorruptedPresetFile(this.builtInPresetFile); this.UpdateBuiltInPresets(); - throw new GeneralApplicationException("HandBrake has detected corruption in the presets file and has attempted to rebuild this file.", "Please restart HandBrake before continuing.", exc); } // Load in the users Presets from UserPresets.xml @@ -479,7 +467,7 @@ namespace HandBrake.ApplicationServices.Services catch (Exception exc) { RecoverFromCorruptedPresetFile(this.userPresetFile); - throw new GeneralApplicationException("HandBrake has detected corruption in the presets file and has attempted to rebuild this file.", "Please restart HandBrake before continuing.", exc); + throw new GeneralApplicationException("HandBrake has detected a problem with your presets.", "Your old presets file has been renamed so that it doesn't get loaded on next launch.", exc); } } diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs b/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs index c69320e1f..10d5fc231 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs @@ -25,7 +25,7 @@ namespace HandBrake.ApplicationServices.Utilities * TODO: * - Many of these converters can be ditched at a later point. Should be able to model all this within the enums themsevles. * - **/ + **/ /// /// Convert HandBrakes time remaining into a TimeSpan @@ -155,46 +155,6 @@ namespace HandBrake.ApplicationServices.Utilities } } - /// - /// Get the GUI equiv to a CLI audio encoder - /// - /// The Audio Encoder - /// The GUI representation of that audio encoder - public static string GetGUIAudioEncoder(string audioEnc) - { - switch (audioEnc) - { - case "faac": - return "AAC (faac)"; - case "lame": - return "MP3 (lame)"; - case "vorbis": - return "Vorbis (vorbis)"; - case "ffac3": - return "AC3 (ffmpeg)"; - case "copy:ac3": - return "AC3 Passthru"; - case "copy:dts": - return "DTS Passthru"; - case "copy:dtshd": - return "MP3 Passthru"; - case "copy:mp3": - return "AAC Passthru"; - case "copy:aac": - return "DTS-HD Passthru"; - case "ffaac": - return "AAC (ffmpeg)"; - case "ffflac": - return "FLAC (ffmpeg)"; - case "ffflac24": - return "FLAC (24-bit)"; - case "copy": - return "Auto Passthru"; - default: - return "AAC (faac)"; - } - } - /// /// Get the GUI equiv to a CLI audio encoder /// @@ -205,17 +165,24 @@ namespace HandBrake.ApplicationServices.Utilities switch (audioEnc) { case "faac": - return AudioEncoder.Faac; case "ffaac": return AudioEncoder.ffaac; + case "fdk_aac": + return AudioEncoder.fdkaac; + case "fdk_haac": + return AudioEncoder.fdkheaac; + case "mp3": case "lame": return AudioEncoder.Lame; case "vorbis": return AudioEncoder.Vorbis; + case "ac3": case "ffac3": return AudioEncoder.Ac3; + case "flac16": case "ffflac": return AudioEncoder.ffflac; + case "flac24": case "ffflac24": return AudioEncoder.ffflac24; case "copy:ac3": @@ -231,7 +198,7 @@ namespace HandBrake.ApplicationServices.Utilities case "copy": return AudioEncoder.Passthrough; default: - return AudioEncoder.Faac; + return AudioEncoder.ffaac; } } @@ -245,16 +212,22 @@ namespace HandBrake.ApplicationServices.Utilities switch (audioEnc) { case "AAC (faac)": - return AudioEncoder.Faac; + case "AAC (CoreAudio)": case "AAC (ffmpeg)": + case "AAC (avcodec)": return AudioEncoder.ffaac; - case "AAC (CoreAudio)": - return AudioEncoder.Faac; + case "AAC (FDK)": + return AudioEncoder.fdkaac; + case "HE-AAC (FDK)": + return AudioEncoder.fdkheaac; case "MP3 (lame)": + case "MP3": return AudioEncoder.Lame; case "Vorbis (vorbis)": + case "Vorbis": return AudioEncoder.Vorbis; case "AC3 (ffmpeg)": + case "AC3": return AudioEncoder.Ac3; case "AC3 Passthru": return AudioEncoder.Ac3Passthrough; @@ -267,13 +240,15 @@ namespace HandBrake.ApplicationServices.Utilities case "MP3 Passthru": return AudioEncoder.Mp3Passthru; case "FLAC (ffmpeg)": + case "FLAC 16-bit": return AudioEncoder.ffflac; case "FLAC (24-bit)": + case "FLAC 24-bit": return AudioEncoder.ffflac24; case "Auto Passthru": return AudioEncoder.Passthrough; default: - return AudioEncoder.Faac; + return AudioEncoder.ffaac; } } @@ -288,43 +263,12 @@ namespace HandBrake.ApplicationServices.Utilities /// public static string GetCliAudioEncoder(AudioEncoder selectedEncoder) { - switch (selectedEncoder) - { - case AudioEncoder.Faac: - return "faac"; - case AudioEncoder.ffaac: - return "ffaac"; - - case AudioEncoder.Lame: - return "lame"; - case AudioEncoder.Vorbis: - return "vorbis"; - case AudioEncoder.Ac3Passthrough: - return "copy:ac3"; - case AudioEncoder.DtsPassthrough: - return "copy:dts"; - case AudioEncoder.DtsHDPassthrough: - return "copy:dtshd"; - case AudioEncoder.Ac3: - return "ffac3"; - case AudioEncoder.AacPassthru: - return "copy:aac"; - case AudioEncoder.Mp3Passthru: - return "copy:mp3"; - case AudioEncoder.Passthrough: - return "copy"; - case AudioEncoder.ffflac: - return "ffflac"; - case AudioEncoder.ffflac24: - return "ffflac24"; - default: - return "faac"; - } + return EnumHelper.GetShortName(selectedEncoder); } #endregion - #region Video + #region Video /// /// Get the Video Encoder for a given string @@ -339,11 +283,12 @@ namespace HandBrake.ApplicationServices.Utilities { switch (encoder) { - case "": case "ffmpeg": case "ffmpeg4": + case "mpeg4": return VideoEncoder.FFMpeg; case "ffmpeg2": + case "mpeg2": return VideoEncoder.FFMpeg2; case "x264": return VideoEncoder.X264; @@ -370,9 +315,9 @@ namespace HandBrake.ApplicationServices.Utilities switch (encoder) { case VideoEncoder.FFMpeg: - return "ffmpeg4"; + return "mpeg4"; case VideoEncoder.FFMpeg2: - return "ffmpeg2"; + return "mpeg2"; case VideoEncoder.X264: return "x264"; case VideoEncoder.Theora: diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/EnumHelper.cs b/win/CS/HandBrake.ApplicationServices/Utilities/EnumHelper.cs index c854e5a05..43667557b 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/EnumHelper.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/EnumHelper.cs @@ -17,6 +17,8 @@ namespace HandBrake.ApplicationServices.Utilities using System.Linq; using System.Reflection; + using HandBrake.Interop.Attributes; + /// /// Enum Helpers /// @@ -93,6 +95,23 @@ namespace HandBrake.ApplicationServices.Utilities throw new ArgumentOutOfRangeException("The Description for the enum was not recognized."); } + /// + /// The get short name. + /// + /// + /// The value. + /// + /// + /// The . + /// + public static string GetShortName(T value) + { + FieldInfo fieldInfo = value.GetType().GetField(value.ToString()); + ShortName[] attributes = (ShortName[])fieldInfo.GetCustomAttributes(typeof(ShortName), false); + + return (attributes.Length > 0) ? attributes[0].Name : value.ToString(); + } + /// /// Return a list of all the enum values. /// diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Attributes/ShortName.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Attributes/ShortName.cs new file mode 100644 index 000000000..cf32cb802 --- /dev/null +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Attributes/ShortName.cs @@ -0,0 +1,35 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// A Short Name for an enum value +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.Interop.Attributes +{ + using System; + + /// + /// A Short Name for an enum value + /// + public class ShortName : Attribute + { + /// + /// Initializes a new instance of the class. + /// + /// + /// The short name. + /// + public ShortName(string shortName) + { + this.Name = shortName; + } + + /// + /// Gets or sets the short name. + /// + public string Name { get; set; } + } +} diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Converters.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Converters.cs index e7f172e32..42d200e57 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Converters.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Converters.cs @@ -25,21 +25,21 @@ namespace HandBrake.Interop /// /// Video Frame Rates /// - private static readonly Dictionary VideoRates = new Dictionary + private static readonly Dictionary VideoRates; + + /// + /// Initializes static members of the Converters class. + /// + static Converters() { - {5, 5400000}, - {10, 2700000}, - {12, 2250000}, - {15, 1800000}, - {23.976, 1126125}, - {24, 1125000}, - {25, 1080000}, - {29.97, 900900}, - {30, 900000}, - {50, 540000}, - {59.94, 450450}, - {60, 450000} - }; + HandBrakeUtils.EnsureGlobalInit(); + + VideoRates = new Dictionary(); + foreach (var framerate in Encoders.VideoFramerates) + { + VideoRates.Add(double.Parse(framerate.Name), framerate.Rate); + } + } /// /// Convert Framerate to Video Rates @@ -78,10 +78,12 @@ namespace HandBrake.Interop return NativeConstants.HB_ACODEC_AC3_PASS; case AudioEncoder.Ac3: return NativeConstants.HB_ACODEC_AC3; - case AudioEncoder.Faac: - return NativeConstants.HB_ACODEC_FAAC; case AudioEncoder.ffaac: return NativeConstants.HB_ACODEC_FFAAC; + case AudioEncoder.fdkaac: + return NativeConstants.HB_ACODEC_FDK_AAC; + case AudioEncoder.fdkheaac: + return NativeConstants.HB_ACODEC_FDK_HAAC; case AudioEncoder.AacPassthru: return NativeConstants.HB_ACODEC_AAC_PASS; case AudioEncoder.Lame: @@ -127,9 +129,12 @@ namespace HandBrake.Interop case NativeConstants.HB_ACODEC_FFAAC: case NativeConstants.HB_ACODEC_CA_AAC: case NativeConstants.HB_ACODEC_CA_HAAC: + case NativeConstants.HB_ACODEC_FDK_HAAC: // TODO Check this is correct + case NativeConstants.HB_ACODEC_FDK_AAC: // TODO Check this is correct return AudioCodec.Aac; case NativeConstants.HB_ACODEC_FFFLAC: return AudioCodec.Flac; + default: return AudioCodec.Other; } @@ -144,9 +149,9 @@ namespace HandBrake.Interop { var result = new HBVideoEncoder { - Id = encoder.encoder, + Id = encoder.codec, ShortName = encoder.short_name, - DisplayName = encoder.human_readable_name, + DisplayName = encoder.name, CompatibleContainers = Container.None }; @@ -172,9 +177,9 @@ namespace HandBrake.Interop { var result = new HBAudioEncoder { - Id = encoder.encoder, + Id = encoder.codec, ShortName = encoder.short_name, - DisplayName = encoder.human_readable_name, + DisplayName = encoder.name, CompatibleContainers = Container.None }; @@ -188,14 +193,28 @@ namespace HandBrake.Interop result.CompatibleContainers = result.CompatibleContainers | Container.Mp4; } - result.QualityLimits = Encoders.GetAudioQualityLimits(encoder.encoder); - result.DefaultQuality = HBFunctions.hb_get_default_audio_quality((uint)encoder.encoder); - result.CompressionLimits = Encoders.GetAudioCompressionLimits(encoder.encoder); - result.DefaultCompression = HBFunctions.hb_get_default_audio_compression((uint) encoder.encoder); + result.QualityLimits = Encoders.GetAudioQualityLimits(encoder.codec); + result.DefaultQuality = HBFunctions.hb_audio_quality_get_default((uint)encoder.codec); + result.CompressionLimits = Encoders.GetAudioCompressionLimits(encoder.codec); + result.DefaultCompression = HBFunctions.hb_audio_compression_get_default((uint)encoder.codec); return result; } + /// + /// Converts a native HB rate structure to an HBRate object. + /// + /// The structure to convert. + /// The converted rate object. + public static HBRate NativeToRate(hb_rate_s rate) + { + return new HBRate + { + Name = rate.name, + Rate = rate.rate + }; + } + /// /// Converts a native HB mixdown structure to a Mixdown model. /// @@ -207,7 +226,7 @@ namespace HandBrake.Interop { Id = mixdown.amixdown, ShortName = mixdown.short_name, - DisplayName = mixdown.human_readable_name + DisplayName = mixdown.name }; } diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs index a65ca3e10..18beda7cc 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs @@ -49,16 +49,6 @@ namespace HandBrake.Interop /// private const string TurboX264Opts = "ref=1:subme=2:me=dia:analyse=none:trellis=0:no-fast-pskip=0:8x8dct=0:weightb=0"; - /// - /// Lock for creation of handbrake instances; - /// - private static object instanceCreationLock = new object(); - - /// - /// True if a handbrake instance has been created. - /// - private static bool globalInitialized; - /// /// The native handle to the HandBrake instance. /// @@ -181,13 +171,7 @@ namespace HandBrake.Interop /// The code for the logging verbosity to use. public void Initialize(int verbosity) { - lock (instanceCreationLock) - { - if (!globalInitialized) - { - globalInitialized = true; - } - } + HandBrakeUtils.EnsureGlobalInit(); HandBrakeUtils.RegisterLogger(); this.hbHandle = HBFunctions.hb_init(verbosity, update_check: 0); @@ -406,6 +390,11 @@ namespace HandBrake.Interop public void StartEncode(EncodeJob job, bool preview, int previewNumber, int previewSeconds, double overallSelectedLengthSeconds) { EncodingProfile profile = job.EncodingProfile; + if (job.ChosenAudioTracks == null) + { + throw new ArgumentException("job.ChosenAudioTracks cannot be null."); + } + this.currentJob = job; IntPtr nativeJobPtr = HBFunctions.hb_job_init_by_index(this.hbHandle, this.GetTitleIndex(job.Title)); @@ -414,7 +403,7 @@ namespace HandBrake.Interop this.encodeAllocatedMemory = this.ApplyJob(ref nativeJob, job, preview, previewNumber, previewSeconds, overallSelectedLengthSeconds); this.subtitleScan = false; - if (job.Subtitles.SourceSubtitles != null) + if (job.Subtitles != null && job.Subtitles.SourceSubtitles != null) { foreach (SourceSubtitle subtitle in job.Subtitles.SourceSubtitles) { @@ -1267,7 +1256,7 @@ namespace HandBrake.Interop } else { - displayWidth = (int)((double)cropHeight * displayAspect); + displayWidth = (int)((double)height * displayAspect); } nativeJob.anamorphic.dar_width = displayWidth; @@ -1454,7 +1443,7 @@ namespace HandBrake.Interop } } - bool hasBurnedSubtitle = job.Subtitles.SourceSubtitles.Any(s => s.BurnedIn); + bool hasBurnedSubtitle = job.Subtitles.SourceSubtitles != null && job.Subtitles.SourceSubtitles.Any(s => s.BurnedIn); if (hasBurnedSubtitle) { this.AddFilter(filterList, (int)hb_filter_ids.HB_FILTER_RENDER_SUB, string.Format(CultureInfo.InvariantCulture, "{0}:{1}:{2}:{3}", crop.Top, crop.Bottom, crop.Left, crop.Right), allocatedMemory); @@ -1684,7 +1673,7 @@ namespace HandBrake.Interop if (encoding.Bitrate == 0) { // Bitrate of 0 means auto: choose the default for this codec, sample rate and mixdown. - nativeAudio.config.output.bitrate = HBFunctions.hb_get_default_audio_bitrate( + nativeAudio.config.output.bitrate = HBFunctions.hb_audio_bitrate_get_default( nativeAudio.config.output.codec, nativeAudio.config.output.samplerate, nativeAudio.config.output.mixdown); diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj index b1a84f48f..9b3c84f4e 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInterop.csproj @@ -132,6 +132,7 @@ + @@ -168,6 +169,7 @@ + diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs index 6833dfc36..48e8117be 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs @@ -39,6 +39,11 @@ namespace HandBrake.Interop /// private static LoggingCallback errorCallback; + /// + /// True if the global initialize function has been called. + /// + private static bool globalInitialized; + /// /// Fires when HandBrake has logged a message. /// @@ -49,6 +54,30 @@ namespace HandBrake.Interop /// public static event EventHandler ErrorLogged; + /// + /// Initializes static members of the HandBrakeUtils class. + /// + static HandBrakeUtils() + { + if (!globalInitialized) + { + if (HBFunctions.hb_global_init() == -1) + { + throw new InvalidOperationException("HB global init failed."); + } + + globalInitialized = true; + } + } + + /// + /// Ensures the HB global initialize method has been called. + /// + public static void EnsureGlobalInit() + { + // Does nothing, but invokes static ctor. + } + /// /// Enables or disables LibDVDNav. If disabled libdvdread will be used instead. /// @@ -94,12 +123,17 @@ namespace HandBrake.Interop if (messageParts.Length > 0) { - if (MessageLogged != null) + message = messageParts[0]; + + // When MP4 muxing fails (for example when the file is too big without Large File Size) + // a message is logged but it isn't marked as an error. + if (message.StartsWith("MP4ERROR", StringComparison.Ordinal)) { - MessageLogged(null, new MessageLoggedEventArgs { Message = messageParts[0] }); + SendErrorEvent(message); + return; } - System.Diagnostics.Debug.WriteLine(messageParts[0]); + SendMessageEvent(message); } } } @@ -115,20 +149,11 @@ namespace HandBrake.Interop // This error happens in normal operations. Log it as a message. if (message == "dvd: ifoOpen failed") { - if (MessageLogged != null) - { - MessageLogged(null, new MessageLoggedEventArgs { Message = message }); - } - + SendMessageEvent(message); return; } - if (ErrorLogged != null) - { - ErrorLogged(null, new MessageLoggedEventArgs { Message = message }); - } - - System.Diagnostics.Debug.WriteLine("ERROR: " + message); + SendErrorEvent(message); } } @@ -197,8 +222,8 @@ namespace HandBrake.Interop throw new ArgumentException("height must be positive."); } - HBFunctions.hb_init(0, 0); - IntPtr ptr = HBFunctions.hb_x264_param_unparse( + HBFunctions.hb_init(0, 0); + IntPtr ptr = HBFunctions.hb_x264_param_unparse( preset, string.Join(",", tunes), extraOptions, @@ -207,10 +232,10 @@ namespace HandBrake.Interop width, height); - string x264Settings = Marshal.PtrToStringAnsi(ptr); + string x264Settings = Marshal.PtrToStringAnsi(ptr); - return x264Settings; + return x264Settings; } /// @@ -331,5 +356,33 @@ namespace HandBrake.Interop return audioBytes; } + + /// + /// Sends the message logged event to any registered listeners. + /// + /// The message to send. + private static void SendMessageEvent(string message) + { + if (MessageLogged != null) + { + MessageLogged(null, new MessageLoggedEventArgs { Message = message }); + } + + System.Diagnostics.Debug.WriteLine(message); + } + + /// + /// Sends the error logged event to any registered listeners. + /// + /// The message to send + private static void SendErrorEvent(string message) + { + if (ErrorLogged != null) + { + ErrorLogged(null, new MessageLoggedEventArgs { Message = message }); + } + + System.Diagnostics.Debug.WriteLine("ERROR: " + message); + } } } diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/HbFunctions.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/HbFunctions.cs index 00130a902..25f595995 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/HbFunctions.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/HbFunctions.cs @@ -21,6 +21,9 @@ namespace HandBrake.Interop.HbLib [DllImport("hb.dll", EntryPoint = "hb_register_error_handler", CallingConvention = CallingConvention.Cdecl)] public static extern void hb_register_error_handler(LoggingCallback callback); + [DllImport("hb.dll", EntryPoint = "hb_global_init", CallingConvention = CallingConvention.Cdecl)] + public static extern int hb_global_init(); + /// Return Type: hb_handle_t* ///verbose: int ///update_check: int @@ -210,81 +213,119 @@ namespace HandBrake.Interop.HbLib public static extern int hb_srt_add(ref hb_job_s job, ref hb_subtitle_config_s subtitleConfig, string lang); - [DllImport("hb.dll", EntryPoint = "hb_mixdown_is_supported", CallingConvention = CallingConvention.Cdecl)] - public static extern int hb_mixdown_is_supported(int mixdown, uint codec, ulong layout); - [DllImport("hb.dll", EntryPoint = "hb_mixdown_has_remix_support", CallingConvention = CallingConvention.Cdecl)] - public static extern int hb_mixdown_has_remix_support(int mixdown, ulong layout); +//int hb_video_framerate_get_from_name(const char *name); +//const char* hb_video_framerate_get_name(int framerate); +//const char* hb_video_framerate_sanitize_name(const char *name); - [DllImport("hb.dll", EntryPoint = "hb_mixdown_has_codec_support", CallingConvention = CallingConvention.Cdecl)] - public static extern int hb_mixdown_has_codec_support(int mixdown, uint codec); + // returns hb_rate_s + [DllImport("hb.dll", EntryPoint = "hb_video_framerate_get_next", CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr hb_video_framerate_get_next(IntPtr last); + + +//int hb_audio_samplerate_get_best(uint32_t codec, int samplerate, int *sr_shift); +//int hb_audio_samplerate_get_from_name(const char *name); +//const char* hb_audio_samplerate_get_name(int samplerate); + + // returns hb_rate_s + [DllImport("hb.dll", EntryPoint = "hb_audio_samplerate_get_next", CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr hb_audio_samplerate_get_next(IntPtr last); + + + [DllImport("hb.dll", EntryPoint = "hb_audio_bitrate_get_best", CallingConvention = CallingConvention.Cdecl)] + public static extern int hb_audio_bitrate_get_best(uint codec, int bitrate, int samplerate, int mixdown); + + [DllImport("hb.dll", EntryPoint = "hb_audio_bitrate_get_default", CallingConvention = CallingConvention.Cdecl)] + public static extern int hb_audio_bitrate_get_default(uint codec, int samplerate, int mixdown); - [DllImport("hb.dll", EntryPoint = "hb_get_default_mixdown", CallingConvention = CallingConvention.Cdecl)] - public static extern int hb_get_default_mixdown(uint codec, ulong layout); + [DllImport("hb.dll", EntryPoint = "hb_audio_bitrate_get_limits", CallingConvention = CallingConvention.Cdecl)] + public static extern int hb_audio_bitrate_get_limits(uint codec, int samplerate, int mixdown, ref int low, ref int high); - [DllImport("hb.dll", EntryPoint = "hb_get_best_mixdown", CallingConvention = CallingConvention.Cdecl)] - public static extern int hb_get_best_mixdown(uint codec, ulong layout, int mixdown); + [DllImport("hb.dll", EntryPoint = "hb_audio_bitrate_get_next", CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr hb_audio_bitrate_get_next(IntPtr last); - [DllImport("hb.dll", EntryPoint = "hb_get_best_audio_bitrate", CallingConvention = CallingConvention.Cdecl)] - public static extern int hb_get_best_audio_bitrate(uint codec, int bitrate, int samplerate, int mixdown); - [DllImport("hb.dll", EntryPoint = "hb_get_default_audio_bitrate", CallingConvention = CallingConvention.Cdecl)] - public static extern int hb_get_default_audio_bitrate(uint codec, int samplerate, int mixdown); + [DllImport("hb.dll", EntryPoint = "hb_audio_quality_get_limits", CallingConvention = CallingConvention.Cdecl)] + public static extern void hb_audio_quality_get_limits(uint codec, ref float low, ref float high, ref float granularity, ref int direction); - [DllImport("hb.dll", EntryPoint = "hb_get_audio_bitrate_limits", CallingConvention = CallingConvention.Cdecl)] - public static extern int hb_get_audio_bitrate_limits(uint codec, int samplerate, int mixdown, ref int low, ref int high); +//float hb_audio_quality_get_best(uint32_t codec, float quality); - [DllImport("hb.dll", EntryPoint = "hb_get_audio_quality_limits", CallingConvention = CallingConvention.Cdecl)] - public static extern void hb_get_audio_quality_limits(uint codec, ref float low, ref float high, ref float granularity, ref int direction); + [DllImport("hb.dll", EntryPoint = "hb_audio_quality_get_default", CallingConvention = CallingConvention.Cdecl)] + public static extern float hb_audio_quality_get_default(uint codec); - [DllImport("hb.dll", EntryPoint = "hb_get_default_audio_quality", CallingConvention = CallingConvention.Cdecl)] - public static extern float hb_get_default_audio_quality(uint codec); - [DllImport("hb.dll", EntryPoint = "hb_get_audio_compression_limits", CallingConvention = CallingConvention.Cdecl)] - public static extern void hb_get_audio_compression_limits(uint codec, ref float low, ref float high, ref float granularity, ref int direction); + [DllImport("hb.dll", EntryPoint = "hb_audio_compression_get_limits", CallingConvention = CallingConvention.Cdecl)] + public static extern void hb_audio_compression_get_limits(uint codec, ref float low, ref float high, ref float granularity, ref int direction); - [DllImport("hb.dll", EntryPoint = "hb_get_default_audio_compression", CallingConvention = CallingConvention.Cdecl)] - public static extern float hb_get_default_audio_compression(uint codec); +//float hb_audio_compression_get_best(uint32_t codec, float compression); + + [DllImport("hb.dll", EntryPoint = "hb_audio_compression_get_default", CallingConvention = CallingConvention.Cdecl)] + public static extern float hb_audio_compression_get_default(uint codec); + + +//int hb_audio_dither_get_default(); +//int hb_audio_dither_get_default_method(); // default method, if enabled && supported +//int hb_audio_dither_is_supported(uint32_t codec); +//int hb_audio_dither_get_from_name(const char *name); +//const char* hb_audio_dither_get_description(int method); +//const hb_dither_t* hb_audio_dither_get_next(const hb_dither_t *last); + + [DllImport("hb.dll", EntryPoint = "hb_mixdown_is_supported", CallingConvention = CallingConvention.Cdecl)] + public static extern int hb_mixdown_is_supported(int mixdown, uint codec, ulong layout); + + [DllImport("hb.dll", EntryPoint = "hb_mixdown_has_codec_support", CallingConvention = CallingConvention.Cdecl)] + public static extern int hb_mixdown_has_codec_support(int mixdown, uint codec); + + [DllImport("hb.dll", EntryPoint = "hb_mixdown_has_remix_support", CallingConvention = CallingConvention.Cdecl)] + public static extern int hb_mixdown_has_remix_support(int mixdown, ulong layout); +//int hb_mixdown_get_discrete_channel_count(int mixdown); +//int hb_mixdown_get_low_freq_channel_count(int mixdown); - [DllImport("hb.dll", EntryPoint = "hb_get_video_rates", CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr hb_get_video_rates(); + [DllImport("hb.dll", EntryPoint = "hb_mixdown_get_best", CallingConvention = CallingConvention.Cdecl)] + public static extern int hb_mixdown_get_best(uint codec, ulong layout, int mixdown); - [DllImport("hb.dll", EntryPoint = "hb_get_video_rates_count", CallingConvention = CallingConvention.Cdecl)] - public static extern int hb_get_video_rates_count(); + [DllImport("hb.dll", EntryPoint = "hb_mixdown_get_default", CallingConvention = CallingConvention.Cdecl)] + public static extern int hb_mixdown_get_default(uint codec, ulong layout); - [DllImport("hb.dll", EntryPoint = "hb_get_audio_rates", CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr hb_get_audio_rates(); +//int hb_mixdown_get_from_name(const char *name); +//const char* hb_mixdown_get_name(int mixdown); +//const char* hb_mixdown_get_short_name(int mixdown); +//const char* hb_mixdown_sanitize_name(const char *name); - [DllImport("hb.dll", EntryPoint = "hb_get_audio_rates_count", CallingConvention = CallingConvention.Cdecl)] - public static extern int hb_get_audio_rates_count(); + [DllImport("hb.dll", EntryPoint = "hb_mixdown_get_next", CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr hb_mixdown_get_next(IntPtr last); - [DllImport("hb.dll", EntryPoint = "hb_get_audio_rates_default", CallingConvention = CallingConvention.Cdecl)] - public static extern int hb_get_audio_rates_default(); +//int hb_video_encoder_get_default(int muxer); +//int hb_video_encoder_get_from_name(const char *name); +//const char* hb_video_encoder_get_name(int encoder); +//const char* hb_video_encoder_get_short_name(int encoder); +//const char* hb_video_encoder_sanitize_name(const char *name); - [DllImport("hb.dll", EntryPoint = "hb_get_audio_bitrates", CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr hb_get_audio_bitrates(); + [DllImport("hb.dll", EntryPoint = "hb_video_encoder_get_next", CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr hb_video_encoder_get_next(IntPtr last); - [DllImport("hb.dll", EntryPoint = "hb_get_audio_bitrates_count", CallingConvention = CallingConvention.Cdecl)] - public static extern int hb_get_audio_bitrates_count(); +/* + * hb_audio_encoder_get_fallback_for_passthru() will sanitize a passthru codec + * to the matching audio encoder (if any is available). + * + * hb_audio_encoder_get_from_name(), hb_audio_encoder_sanitize_name() will + * sanitize legacy encoder names, but won't convert passthru to an encoder. + */ +//int hb_audio_encoder_get_fallback_for_passthru(int passthru); +//int hb_audio_encoder_get_default(int muxer); +//int hb_audio_encoder_get_from_name(const char *name); +//const char* hb_audio_encoder_get_name(int encoder); +//const char* hb_audio_encoder_get_short_name(int encoder); +//const char* hb_audio_encoder_sanitize_name(const char *name); - [DllImport("hb.dll", EntryPoint = "hb_get_audio_mixdowns", CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr hb_get_audio_mixdowns(); + [DllImport("hb.dll", EntryPoint = "hb_audio_encoder_get_next", CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr hb_audio_encoder_get_next(IntPtr last); - [DllImport("hb.dll", EntryPoint = "hb_get_audio_mixdowns_count", CallingConvention = CallingConvention.Cdecl)] - public static extern int hb_get_audio_mixdowns_count(); - [DllImport("hb.dll", EntryPoint = "hb_get_video_encoders", CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr hb_get_video_encoders(); - [DllImport("hb.dll", EntryPoint = "hb_get_video_encoders_count", CallingConvention = CallingConvention.Cdecl)] - public static extern int hb_get_video_encoders_count(); - [DllImport("hb.dll", EntryPoint = "hb_get_audio_encoders", CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr hb_get_audio_encoders(); - [DllImport("hb.dll", EntryPoint = "hb_get_audio_encoders_count", CallingConvention = CallingConvention.Cdecl)] - public static extern int hb_get_audio_encoders_count(); /// void hb_autopassthru_apply_settings( hb_job_t * job ) diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/Misc.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/Misc.cs index c34f5daf5..6d6e62a34 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/Misc.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/Misc.cs @@ -56,7 +56,7 @@ namespace HandBrake.Interop.HbLib { /// char* [MarshalAs(UnmanagedType.LPStr)] - public string @string; + public string name; /// int public int rate; @@ -65,13 +65,8 @@ namespace HandBrake.Interop.HbLib [StructLayout(LayoutKind.Sequential)] public struct hb_mixdown_s { - /// char* [MarshalAs(UnmanagedType.LPStr)] - public string human_readable_name; - - /// char* - [MarshalAs(UnmanagedType.LPStr)] - public string internal_name; + public string name; /// char* [MarshalAs(UnmanagedType.LPStr)] @@ -85,12 +80,12 @@ namespace HandBrake.Interop.HbLib public struct hb_encoder_s { [MarshalAs(UnmanagedType.LPStr)] - public string human_readable_name; + public string name; [MarshalAs(UnmanagedType.LPStr)] public string short_name; - public int encoder; + public int codec; public int muxers; } diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/NativeConstants.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/NativeConstants.cs index 23181e7fe..ae7fcd704 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/NativeConstants.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/NativeConstants.cs @@ -12,38 +12,42 @@ namespace HandBrake.Interop.HbLib { public partial class NativeConstants { - public const uint HB_ACODEC_MASK = 0x00FFFF00; - public const uint HB_ACODEC_FAAC = 0x00000100; - public const uint HB_ACODEC_LAME = 0x00000200; - public const uint HB_ACODEC_VORBIS = 0x00000400; - public const uint HB_ACODEC_AC3 = 0x00000800; - public const uint HB_ACODEC_LPCM = 0x00001000; - public const uint HB_ACODEC_DCA = 0x00002000; - public const uint HB_ACODEC_CA_AAC = 0x00004000; - public const uint HB_ACODEC_CA_HAAC = 0x00008000; - public const uint HB_ACODEC_FFAAC = 0x00010000; - public const uint HB_ACODEC_FFMPEG = 0x00020000; - public const uint HB_ACODEC_DCA_HD = 0x00040000; - public const uint HB_ACODEC_MP3 = 0x00080000; - public const uint HB_ACODEC_FFFLAC = 0x00100000; - public const uint HB_ACODEC_FDK_AAC = 0x00400000; - public const uint HB_ACODEC_FDK_HAAC = 0x00800000; - public const uint HB_ACODEC_FF_MASK = 0x00FF2000; - public const uint HB_ACODEC_PASS_FLAG = 0x40000000; - public const uint HB_ACODEC_PASS_MASK = (HB_ACODEC_MP3 | HB_ACODEC_FFAAC | HB_ACODEC_DCA_HD | HB_ACODEC_AC3 | HB_ACODEC_DCA); - public const uint HB_ACODEC_AUTO_PASS = (HB_ACODEC_PASS_MASK | HB_ACODEC_PASS_FLAG); - public const uint HB_ACODEC_MP3_PASS = (HB_ACODEC_MP3 | HB_ACODEC_PASS_FLAG); - public const uint HB_ACODEC_AAC_PASS = (HB_ACODEC_FFAAC | HB_ACODEC_PASS_FLAG); - public const uint HB_ACODEC_AC3_PASS = (HB_ACODEC_AC3 | HB_ACODEC_PASS_FLAG); - public const uint HB_ACODEC_DCA_PASS = (HB_ACODEC_DCA | HB_ACODEC_PASS_FLAG); - public const uint HB_ACODEC_DCA_HD_PASS = (HB_ACODEC_DCA_HD | HB_ACODEC_PASS_FLAG); - public const uint HB_ACODEC_ANY = (HB_ACODEC_MASK | HB_ACODEC_PASS_FLAG); + // Audio Encoders + public const uint HB_ACODEC_MASK = 0x00FFFF00; + public const uint HB_ACODEC_FAAC = 0x00000100; + public const uint HB_ACODEC_LAME = 0x00000200; + public const uint HB_ACODEC_VORBIS = 0x00000400; + public const uint HB_ACODEC_AC3 = 0x00000800; + public const uint HB_ACODEC_LPCM = 0x00001000; + public const uint HB_ACODEC_DCA = 0x00002000; + public const uint HB_ACODEC_CA_AAC = 0x00004000; + public const uint HB_ACODEC_CA_HAAC = 0x00008000; + public const uint HB_ACODEC_FFAAC = 0x00010000; + public const uint HB_ACODEC_FFMPEG = 0x00020000; + public const uint HB_ACODEC_DCA_HD = 0x00040000; + public const uint HB_ACODEC_MP3 = 0x00080000; + public const uint HB_ACODEC_FFFLAC = 0x00100000; + public const uint HB_ACODEC_FFFLAC24 = 0x00200000; + public const uint HB_ACODEC_FDK_AAC = 0x00400000; + public const uint HB_ACODEC_FDK_HAAC = 0x00800000; + public const uint HB_ACODEC_FF_MASK = 0x00FF2000; + public const uint HB_ACODEC_PASS_FLAG = 0x40000000; + public const uint HB_ACODEC_PASS_MASK = (HB_ACODEC_MP3 | HB_ACODEC_FFAAC | HB_ACODEC_DCA_HD | HB_ACODEC_AC3 | HB_ACODEC_DCA); + public const uint HB_ACODEC_AUTO_PASS = (HB_ACODEC_PASS_MASK | HB_ACODEC_PASS_FLAG); + public const uint HB_ACODEC_MP3_PASS = (HB_ACODEC_MP3 | HB_ACODEC_PASS_FLAG); + public const uint HB_ACODEC_AAC_PASS = (HB_ACODEC_FFAAC | HB_ACODEC_PASS_FLAG); + public const uint HB_ACODEC_AC3_PASS = (HB_ACODEC_AC3 | HB_ACODEC_PASS_FLAG); + public const uint HB_ACODEC_DCA_PASS = (HB_ACODEC_DCA | HB_ACODEC_PASS_FLAG); + public const uint HB_ACODEC_DCA_HD_PASS = (HB_ACODEC_DCA_HD | HB_ACODEC_PASS_FLAG); + public const uint HB_ACODEC_ANY = (HB_ACODEC_MASK | HB_ACODEC_PASS_FLAG); + // Subtitle Types public const int HB_SUBSTREAM_BD_TRUEHD = 0x72; public const int HB_SUBSTREAM_BD_AC3 = 0x76; public const int HB_SUBSTREAM_BD_DTSHD = 0x72; public const int HB_SUBSTREAM_BD_DTS = 0x71; + // Video Encoders public const int HB_VCODEC_MASK = 0x0000FF; public const int HB_VCODEC_X264 = 0x000001; public const int HB_VCODEC_THEORA = 0x000002; @@ -52,9 +56,10 @@ namespace HandBrake.Interop.HbLib public const int HB_VCODEC_FFMPEG_MPEG2 = 0x000020; public const int HB_VCODEC_FFMPEG_MASK = 0x0000F0; + // Muxers public const int HB_MUX_MASK = 0xFF0000; public const int HB_MUX_MP4 = 0x010000; - public const int HB_MUX_MKV = 0x200000; + public const int HB_MUX_MKV = 0x100000; public const int HBTF_NO_IDR = 1 << 0; diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_job_s.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_job_s.cs index e9f08fe47..44f9e5ba8 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_job_s.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_job_s.cs @@ -74,10 +74,6 @@ namespace HandBrake.Interop.HbLib /// int public int vbitrate; - public int pfr_vrate; - - public int pfr_vrate_base; - /// int public int vrate; diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/InteropUtilities.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/InteropUtilities.cs index 8bf68b2e1..bd58ec6a0 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/InteropUtilities.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/InteropUtilities.cs @@ -11,9 +11,11 @@ namespace HandBrake.Interop { using System; using System.Collections.Generic; + using System.Linq; using System.Runtime.InteropServices; using HandBrake.Interop.HbLib; + using Model.Encoding; /// /// Helper utilities for native interop. @@ -91,7 +93,7 @@ namespace HandBrake.Interop } return result; - } + } /// /// Creats a new, empty native HandBrake list. @@ -182,6 +184,42 @@ namespace HandBrake.Interop return returnList; } + /// + /// Reads in a list of objects given an interator and a conversion function. + /// + /// The type of the struct given by the iterator. + /// The object type to convert to. + /// The iterator to use to build the list. + /// The converter to convert from the struct to the object. + /// The list of objects. + public static List GetListFromIterator(Func iterator, Func converter) + { + return ReadStructureListFromIterator(iterator).Select(converter).ToList(); + } + + /// + /// Reads in a list of structs given an iterator. + /// + /// The type of the struct. + /// The iterator to use to build the list. + /// The list of structs. + public static List ReadStructureListFromIterator(Func iterator) + { + var structureList = new List(); + IntPtr current = IntPtr.Zero; + + current = iterator(current); + while (current != IntPtr.Zero) + { + T encoder = ReadStructure(current); + structureList.Add(encoder); + + current = iterator(current); + } + + return structureList; + } + /// /// Closes the given job. /// diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoders.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoders.cs index 9f877cd9b..ebfefff0a 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoders.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoders.cs @@ -17,30 +17,48 @@ namespace HandBrake.Interop.Model using HandBrake.Interop.Model.Encoding; using HandBrake.Interop.SourceData; - /// - /// The encoders. - /// - public static class Encoders + /// + /// The encoders. + /// + public static class Encoders { - /// - /// The audio encoders. - /// - private static List audioEncoders; - - /// - /// The video encoders. - /// - private static List videoEncoders; - - /// - /// The mixdowns. - /// - private static List mixdowns; - - /// - /// The audio bitrates. - /// - private static List audioBitrates; + /// + /// The audio encoders. + /// + private static List audioEncoders; + + /// + /// The video encoders. + /// + private static List videoEncoders; + + /// + /// Video framerates in pts. + /// + private static List videoFramerates; + + /// + /// The mixdowns. + /// + private static List mixdowns; + + /// + /// The audio bitrates. + /// + private static List audioBitrates; + + /// + /// Audio sample rates in Hz. + /// + private static List audioSampleRates; + + /// + /// Initializes static members of the Encoders class. + /// + static Encoders() + { + HandBrakeUtils.EnsureGlobalInit(); + } /// /// Gets a list of supported audio encoders. @@ -51,12 +69,7 @@ namespace HandBrake.Interop.Model { if (audioEncoders == null) { - IntPtr encodersPtr = HBFunctions.hb_get_audio_encoders(); - int encoderCount = HBFunctions.hb_get_audio_encoders_count(); - - audioEncoders = InteropUtilities.ConvertArray(encodersPtr, encoderCount) - .Select(Converters.NativeToAudioEncoder) - .ToList(); + audioEncoders = InteropUtilities.GetListFromIterator(HBFunctions.hb_audio_encoder_get_next, Converters.NativeToAudioEncoder); } return audioEncoders; @@ -72,18 +85,29 @@ namespace HandBrake.Interop.Model { if (videoEncoders == null) { - IntPtr encodersPtr = HBFunctions.hb_get_video_encoders(); - int encoderCount = HBFunctions.hb_get_video_encoders_count(); - - videoEncoders = InteropUtilities.ConvertArray(encodersPtr, encoderCount) - .Select(Converters.NativeToVideoEncoder) - .ToList(); + videoEncoders = InteropUtilities.GetListFromIterator(HBFunctions.hb_video_encoder_get_next, Converters.NativeToVideoEncoder); } return videoEncoders; } } + /// + /// Gets a list of supported video framerates (in pts). + /// + public static List VideoFramerates + { + get + { + if (videoFramerates == null) + { + videoFramerates = InteropUtilities.GetListFromIterator(HBFunctions.hb_video_framerate_get_next, Converters.NativeToRate); + } + + return videoFramerates; + } + } + /// /// Gets a list of supported mixdowns. /// @@ -93,12 +117,7 @@ namespace HandBrake.Interop.Model { if (mixdowns == null) { - IntPtr mixdownsPtr = HBFunctions.hb_get_audio_mixdowns(); - int mixdownsCount = HBFunctions.hb_get_audio_mixdowns_count(); - - mixdowns = InteropUtilities.ConvertArray(mixdownsPtr, mixdownsCount) - .Select(Converters.NativeToMixdown) - .ToList(); + mixdowns = InteropUtilities.GetListFromIterator(HBFunctions.hb_mixdown_get_next, Converters.NativeToMixdown); } return mixdowns; @@ -114,18 +133,29 @@ namespace HandBrake.Interop.Model { if (audioBitrates == null) { - IntPtr audioBitratesPtr = HBFunctions.hb_get_audio_bitrates(); - int audioBitratesCount = HBFunctions.hb_get_audio_bitrates_count(); - - audioBitrates = InteropUtilities.ConvertArray(audioBitratesPtr, audioBitratesCount) - .Select(b => b.rate) - .ToList(); + audioBitrates = InteropUtilities.GetListFromIterator(HBFunctions.hb_audio_bitrate_get_next, b => b.rate); } return audioBitrates; } } + /// + /// Gets a list of supported audio sample rates (in Hz). + /// + public static List AudioSampleRates + { + get + { + if (audioSampleRates == null) + { + audioSampleRates = InteropUtilities.GetListFromIterator(HBFunctions.hb_audio_samplerate_get_next, Converters.NativeToRate); + } + + return audioSampleRates; + } + } + /// /// Gets the audio encoder with the specified short name. /// @@ -199,7 +229,7 @@ namespace HandBrake.Interop.Model /// A sanitized mixdown value. public static HBMixdown SanitizeMixdown(HBMixdown mixdown, HBAudioEncoder encoder, ulong layout) { - int sanitizedMixdown = HBFunctions.hb_get_best_mixdown((uint)encoder.Id, layout, mixdown.Id); + int sanitizedMixdown = HBFunctions.hb_mixdown_get_best((uint)encoder.Id, layout, mixdown.Id); return Mixdowns.Single(m => m.Id == sanitizedMixdown); } @@ -211,7 +241,7 @@ namespace HandBrake.Interop.Model /// The default mixdown for the given codec and channel layout. public static HBMixdown GetDefaultMixdown(HBAudioEncoder encoder, ulong layout) { - int defaultMixdown = HBFunctions.hb_get_default_mixdown((uint)encoder.Id, layout); + int defaultMixdown = HBFunctions.hb_mixdown_get_default((uint)encoder.Id, layout); return Mixdowns.Single(m => m.Id == defaultMixdown); } @@ -227,7 +257,7 @@ namespace HandBrake.Interop.Model int low = 0; int high = 0; - HBFunctions.hb_get_audio_bitrate_limits((uint)encoder.Id, sampleRate, mixdown.Id, ref low, ref high); + HBFunctions.hb_audio_bitrate_get_limits((uint)encoder.Id, sampleRate, mixdown.Id, ref low, ref high); return new BitrateLimits { Low = low, High = high }; } @@ -242,7 +272,7 @@ namespace HandBrake.Interop.Model /// A sanitized audio bitrate. public static int SanitizeAudioBitrate(int audioBitrate, HBAudioEncoder encoder, int sampleRate, HBMixdown mixdown) { - return HBFunctions.hb_get_best_audio_bitrate((uint)encoder.Id, audioBitrate, sampleRate, mixdown.Id); + return HBFunctions.hb_audio_bitrate_get_best((uint)encoder.Id, audioBitrate, sampleRate, mixdown.Id); } /// @@ -254,7 +284,7 @@ namespace HandBrake.Interop.Model /// The default bitrate for these parameters. public static int GetDefaultBitrate(HBAudioEncoder encoder, int sampleRate, HBMixdown mixdown) { - return HBFunctions.hb_get_default_audio_bitrate((uint) encoder.Id, sampleRate, mixdown.Id); + return HBFunctions.hb_audio_bitrate_get_default((uint) encoder.Id, sampleRate, mixdown.Id); } /// @@ -266,7 +296,7 @@ namespace HandBrake.Interop.Model { float low = 0, high = 0, granularity = 0; int direction = 0; - HBFunctions.hb_get_audio_quality_limits((uint)encoderId, ref low, ref high, ref granularity, ref direction); + HBFunctions.hb_audio_quality_get_limits((uint)encoderId, ref low, ref high, ref granularity, ref direction); return new RangeLimits { @@ -286,7 +316,7 @@ namespace HandBrake.Interop.Model { float low = 0, high = 0, granularity = 0; int direction = 0; - HBFunctions.hb_get_audio_compression_limits((uint)encoderId, ref low, ref high, ref granularity, ref direction); + HBFunctions.hb_audio_compression_get_limits((uint)encoderId, ref low, ref high, ref granularity, ref direction); return new RangeLimits { diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/AudioEncoder.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/AudioEncoder.cs index 8fb242ac6..bc7b5bf20 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/AudioEncoder.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/AudioEncoder.cs @@ -11,48 +11,71 @@ namespace HandBrake.Interop.Model.Encoding { using System.ComponentModel.DataAnnotations; + using HandBrake.Interop.Attributes; + /// /// The audio encoder. /// public enum AudioEncoder { [Display(Name = "AAC (faac)")] - Faac = 0, + [ShortName("faac")] + faac = 0, - [Display(Name = "AAC (ffmpeg)")] + [Display(Name = "AAC (avcodec)")] + [ShortName("av_aac")] ffaac, - [Display(Name = "MP3 (lame)")] + [Display(Name = "AAC (FDK)")] + [ShortName("fdk_aac")] + fdkaac, + + [Display(Name = "HE-AAC (FDK)")] + [ShortName("fdk_haac")] + fdkheaac, + + [Display(Name = "MP3")] + [ShortName("mp3")] Lame, - [Display(Name = "AC3 (ffmpeg)")] + [Display(Name = "AC3")] + [ShortName("ac3")] Ac3, [Display(Name = "Auto Passthru")] + [ShortName("copy")] Passthrough, [Display(Name = "AC3 Passthru")] + [ShortName("copy:ac3")] Ac3Passthrough, [Display(Name = "DTS Passthru")] + [ShortName("copy:dts")] DtsPassthrough, [Display(Name = "DTS-HD Passthru")] + [ShortName("copy:dtshd")] DtsHDPassthrough, [Display(Name = "AAC Passthru")] + [ShortName("copy:aac")] AacPassthru, [Display(Name = "MP3 Passthru")] + [ShortName("copy:mp3")] Mp3Passthru, - [Display(Name = "Vorbis (vorbis)")] + [Display(Name = "Vorbis")] + [ShortName("vorbis")] Vorbis, - [Display(Name = "FLAC (ffmpeg)")] + [Display(Name = "FLAC 16-bit")] + [ShortName("flac16")] ffflac, - [Display(Name = "FLAC (24-bit)")] + [Display(Name = "FLAC 24-bit")] + [ShortName("flac24")] ffflac24, } } diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/HBRate.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/HBRate.cs new file mode 100644 index 000000000..2862574dc --- /dev/null +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/HBRate.cs @@ -0,0 +1,24 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.Interop.Model.Encoding +{ + /// + /// Represents a rate in HandBrake: audio sample rate or video framerate. + /// + public class HBRate + { + /// + /// Gets or sets the name to use for this rate. + /// + public string Name { get; set; } + + /// + /// Gets or sets the raw rate. + /// + public int Rate { get; set; } + } +} diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/VideoEncoder.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/VideoEncoder.cs index afdb83148..b355d5038 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/VideoEncoder.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/VideoEncoder.cs @@ -3,7 +3,7 @@ // This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. // // -// Defines the VideoEncoder type. +// The video encoder. // // -------------------------------------------------------------------------------------------------------------------- @@ -11,24 +11,30 @@ namespace HandBrake.Interop.Model.Encoding { using System.ComponentModel.DataAnnotations; + using HandBrake.Interop.Attributes; + /// /// The video encoder. /// public enum VideoEncoder { [Display(Name = "H.264 (x264)")] + [ShortName("x264")] X264 = 0, [Display(Name = "H.264 (Intel QSV)")] QuickSync, [Display(Name = "MPEG-4 (FFmpeg)")] + [ShortName("mpeg4")] FFMpeg, [Display(Name = "MPEG-2 (FFmpeg)")] + [ShortName("mpeg2")] FFMpeg2, [Display(Name = "VP3 (Theora)")] - Theora, + [ShortName("theora")] + Theora } } diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Properties/AssemblyInfo.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Properties/AssemblyInfo.cs index 936eb0fa9..2902f4f11 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Properties/AssemblyInfo.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.40.0.0")] -[assembly: AssemblyFileVersion("1.40.0.0")] +[assembly: AssemblyVersion("1.43.0.0")] +[assembly: AssemblyFileVersion("1.43.0.0")] diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/SourceData/AudioCodec.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/SourceData/AudioCodec.cs index dce947311..d24c9998b 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/SourceData/AudioCodec.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/SourceData/AudioCodec.cs @@ -48,6 +48,6 @@ namespace HandBrake.Interop.SourceData /// /// The flac. /// - Flac + Flac, } } \ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Commands/SourceMenuCommand.cs b/win/CS/HandBrakeWPF/Commands/SourceMenuCommand.cs index 661ef7fe3..8edc537fc 100644 --- a/win/CS/HandBrakeWPF/Commands/SourceMenuCommand.cs +++ b/win/CS/HandBrakeWPF/Commands/SourceMenuCommand.cs @@ -52,8 +52,6 @@ namespace HandBrakeWPF.Commands #region Implemented Interfaces - #region ICommand - /// /// The can execute. /// @@ -80,7 +78,5 @@ namespace HandBrakeWPF.Commands } #endregion - - #endregion } } \ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Converters/Audio/AudioBitrateConverter.cs b/win/CS/HandBrakeWPF/Converters/Audio/AudioBitrateConverter.cs index f4e805957..bd7aeffca 100644 --- a/win/CS/HandBrakeWPF/Converters/Audio/AudioBitrateConverter.cs +++ b/win/CS/HandBrakeWPF/Converters/Audio/AudioBitrateConverter.cs @@ -70,14 +70,10 @@ namespace HandBrakeWPF.Converters.Audio int samplerate = this.GetBestSampleRate(track); int srShift = this.GetSamplerateShift(samplerate); int lfeCount = this.GetLowFreqChannelCount(track.MixDown); - int channels = this.GetChannelCount(track.MixDown) - lfeCount; + int channels = this.GetDiscreteChannelCount(track.MixDown) - lfeCount; switch (track.Encoder) { - case AudioEncoder.Faac: - low = (channels + lfeCount) * 32; - max = (channels + lfeCount) * (192 >> srShift); - break; case AudioEncoder.ffaac: low = ((channels + lfeCount) * 32); max = ((channels + lfeCount) * ((192 + (64 * ((samplerate << srShift) >= 44100 ? 1 : 0))) >> srShift)); @@ -101,8 +97,17 @@ namespace HandBrakeWPF.Converters.Audio case AudioEncoder.Mp3Passthru: case AudioEncoder.Passthrough: case AudioEncoder.ffflac: + case AudioEncoder.ffflac24: max = 1536; // Since we don't care, just set it to the max. break; + case AudioEncoder.fdkaac: + low = channels * samplerate * 2 / 3000; + max = channels * samplerate * 6 / 1000; + break; + case AudioEncoder.fdkheaac: + low = (channels * (12 + (4 * (samplerate >= 44100 ? 1 : 0)))); + max = (channels - (channels > 2 ? 1 : 0)) * (48 + (16 * (samplerate >= 22050 ? 1 : 0))); + break; default: max = 768; break; @@ -132,7 +137,7 @@ namespace HandBrakeWPF.Converters.Audio /// /// The System.Int32. /// - private int GetChannelCount(Mixdown mixdown) + private int GetDiscreteChannelCount(Mixdown mixdown) { switch (mixdown) { @@ -228,6 +233,10 @@ namespace HandBrakeWPF.Converters.Audio { // AC-3 < 32 kHz suffers from poor hardware compatibility bestSamplerate = 32000; + } + else if ((samplerate < 16000) && (track.Encoder == AudioEncoder.fdkheaac)) + { + bestSamplerate = 16000; } else { diff --git a/win/CS/HandBrakeWPF/Converters/Audio/AudioEncoderConverter.cs b/win/CS/HandBrakeWPF/Converters/Audio/AudioEncoderConverter.cs index 1db7a7c0a..27cb2e5de 100644 --- a/win/CS/HandBrakeWPF/Converters/Audio/AudioEncoderConverter.cs +++ b/win/CS/HandBrakeWPF/Converters/Audio/AudioEncoderConverter.cs @@ -51,6 +51,8 @@ namespace HandBrakeWPF.Converters.Audio List encoders = EnumHelper.GetEnumList().ToList(); EncodeTask task = values[1] as EncodeTask; + encoders.Remove(AudioEncoder.faac); + if (task != null && task.OutputFormat != OutputFormat.Mkv) { encoders.Remove(AudioEncoder.Vorbis); diff --git a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj index 85ee06fb7..83535814b 100644 --- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj +++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj @@ -157,6 +157,7 @@ + @@ -432,6 +433,7 @@ Always + Designer diff --git a/win/CS/HandBrakeWPF/Helpers/AppStyleHelper.cs b/win/CS/HandBrakeWPF/Helpers/AppStyleHelper.cs new file mode 100644 index 000000000..9b67f97e2 --- /dev/null +++ b/win/CS/HandBrakeWPF/Helpers/AppStyleHelper.cs @@ -0,0 +1,37 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// Defines the AppStyleHelper type. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.Helpers +{ + using System.Windows; + + using Caliburn.Micro; + + using HandBrake.ApplicationServices.Services.Interfaces; + + /// + /// The AppStyle Helper. + /// + public class AppStyleHelper + { + /// + /// Gets a value indicating whether use system colours. + /// + public static bool UseSystemColours + { + get + { + IUserSettingService userSettingService = IoC.Get(); + bool useSystemColours = userSettingService.GetUserSetting(UserSettingConstants.UseSystemColours); + + return useSystemColours || SystemParameters.HighContrast; + } + } + } +} diff --git a/win/CS/HandBrakeWPF/Model/SourceMenuItem.cs b/win/CS/HandBrakeWPF/Model/SourceMenuItem.cs index f0b809849..4be52964e 100644 --- a/win/CS/HandBrakeWPF/Model/SourceMenuItem.cs +++ b/win/CS/HandBrakeWPF/Model/SourceMenuItem.cs @@ -55,5 +55,10 @@ namespace HandBrakeWPF.Model /// Gets or sets the tag. /// public object Tag { get; set; } + + /// + /// Gets or sets the input gesture text. + /// + public string InputGestureText { get; set; } } } diff --git a/win/CS/HandBrakeWPF/UserSettingConstants.cs b/win/CS/HandBrakeWPF/UserSettingConstants.cs index b01134b91..b9ce40b0c 100644 --- a/win/CS/HandBrakeWPF/UserSettingConstants.cs +++ b/win/CS/HandBrakeWPF/UserSettingConstants.cs @@ -236,6 +236,11 @@ namespace HandBrakeWPF /// public const string ShowPresetPanel = "ShowPresetPanel"; + /// + /// The use system colours. + /// + public const string UseSystemColours = "UseSystemColours"; + #endregion } } \ No newline at end of file diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index c7fcbd0ae..81ac6a688 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -922,6 +922,8 @@ namespace HandBrakeWPF.ViewModels } } + public int ProgressPercentage { get; set; } + #endregion #region Load and Shutdown Handling @@ -936,7 +938,11 @@ namespace HandBrakeWPF.ViewModels // Perform an update check if required this.updateService.PerformStartupUpdateCheck(this.HandleUpdateCheckResults); + // Show or Hide the Preset Panel. + this.IsPresetPanelShowing = this.userSettingService.GetUserSetting(UserSettingConstants.ShowPresetPanel); + // Setup the presets. + this.presetService.Load(); if (this.presetService.CheckIfPresetsAreOutOfDate()) if (!this.userSettingService.GetUserSetting(UserSettingConstants.PresetNotification)) this.errorService.ShowMessageBox("HandBrake has determined your built-in presets are out of date... These presets will now be updated." + Environment.NewLine + @@ -951,9 +957,6 @@ namespace HandBrakeWPF.ViewModels // Populate the Source menu with drives. this.SourceMenu = new BindingList(this.GenerateSourceMenu()); - // Show or Hide the Preset Panel. - this.IsPresetPanelShowing = this.userSettingService.GetUserSetting(UserSettingConstants.ShowPresetPanel); - // Log Cleaning if (userSettingService.GetUserSetting(UserSettingConstants.ClearOldLogs)) { @@ -1910,6 +1913,8 @@ namespace HandBrakeWPF.ViewModels } lastEncodePercentage = percent; + this.ProgressPercentage = percent; + this.NotifyOfPropertyChange(() => ProgressPercentage); } else { @@ -2016,14 +2021,16 @@ namespace HandBrakeWPF.ViewModels Image = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/HandBrake;component/Views/Images/folder.png")), Width = 16, Height = 16 }, Text = "Open Folder", Command = new SourceMenuCommand(this.FolderScan), - IsDrive = false + IsDrive = false, + InputGestureText = "Ctrl + R" }; SourceMenuItem fileScan = new SourceMenuItem { Image = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/HandBrake;component/Views/Images/Movies.png")), Width = 16, Height = 16 }, Text = "Open File", Command = new SourceMenuCommand(this.FileScan), - IsDrive = false + IsDrive = false, + InputGestureText = "Ctrl + F" }; SourceMenuItem titleSpecific = new SourceMenuItem { Text = "Title Specific Scan" }; diff --git a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs index dc9f6806b..e1376363a 100644 --- a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs @@ -358,6 +358,11 @@ namespace HandBrakeWPF.ViewModels /// private bool removePunctuation; + /// + /// The use system colours for styles. + /// + private bool useSystemColoursForStyles; + #endregion #region Constructors and Destructors @@ -604,6 +609,23 @@ namespace HandBrakeWPF.ViewModels this.NotifyOfPropertyChange("WhenDoneOptions"); } } + + /// + /// Gets or sets a value indicating whether use system colours. + /// + public bool UseSystemColoursForStylesForStyles + { + get + { + return this.useSystemColoursForStyles; + } + set + { + this.useSystemColoursForStyles = value; + this.NotifyOfPropertyChange(() => UseSystemColoursForStylesForStyles); + } + } + #endregion #region Output Files @@ -1514,6 +1536,7 @@ namespace HandBrakeWPF.ViewModels this.SendFileTo = Path.GetFileNameWithoutExtension(this.userSettingService.GetUserSetting(UserSettingConstants.SendFileTo)) ?? string.Empty; this.SendFileToPath = this.userSettingService.GetUserSetting(UserSettingConstants.SendFileTo) ?? string.Empty; this.Arguments = this.userSettingService.GetUserSetting(UserSettingConstants.SendFileToArgs) ?? string.Empty; + this.UseSystemColoursForStylesForStyles = this.userSettingService.GetUserSetting(UserSettingConstants.UseSystemColours); // ############################# // Output Settings @@ -1850,6 +1873,7 @@ namespace HandBrakeWPF.ViewModels this.userSettingService.SetUserSetting(UserSettingConstants.SendFileTo, this.SendFileToPath); this.userSettingService.SetUserSetting(UserSettingConstants.SendFile, this.SendFileAfterEncode); this.userSettingService.SetUserSetting(UserSettingConstants.SendFileToArgs, this.Arguments); + this.userSettingService.SetUserSetting(UserSettingConstants.UseSystemColours, this.UseSystemColoursForStylesForStyles); /* Output Files */ this.userSettingService.SetUserSetting(UserSettingConstants.AutoNaming, this.AutomaticallyNameFiles); diff --git a/win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs index a64378a49..39fee77fd 100644 --- a/win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs @@ -15,6 +15,7 @@ namespace HandBrakeWPF.ViewModels using HandBrake.ApplicationServices.Services.Interfaces; + using HandBrakeWPF.Helpers; using HandBrakeWPF.Model; using HandBrakeWPF.Services.Interfaces; using HandBrakeWPF.ViewModels.Interfaces; diff --git a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs index 5d07e2321..60e152a10 100644 --- a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs @@ -1142,7 +1142,6 @@ namespace HandBrakeWPF.ViewModels width = 720; } - // TODO figure out what is wrong with this?? return HandBrakeUtils.CreateX264OptionsString(preset, tunes, this.ExtraArguments, profile, this.H264Level, width, height); } diff --git a/win/CS/HandBrakeWPF/ViewModels/ViewModelBase.cs b/win/CS/HandBrakeWPF/ViewModels/ViewModelBase.cs index f1766741e..7a13881dc 100644 --- a/win/CS/HandBrakeWPF/ViewModels/ViewModelBase.cs +++ b/win/CS/HandBrakeWPF/ViewModels/ViewModelBase.cs @@ -13,6 +13,7 @@ namespace HandBrakeWPF.ViewModels using HandBrake.ApplicationServices.Services.Interfaces; + using HandBrakeWPF.Helpers; using HandBrakeWPF.ViewModels.Interfaces; /// @@ -64,6 +65,17 @@ namespace HandBrakeWPF.ViewModels } } + /// + /// Gets a value indicating whether use system colours. + /// + public bool UseSystemColours + { + get + { + return AppStyleHelper.UseSystemColours; + } + } + /// /// Gets or sets WindowManager. /// diff --git a/win/CS/HandBrakeWPF/Views/AudioView.xaml b/win/CS/HandBrakeWPF/Views/AudioView.xaml index 28d17d776..c71f71858 100644 --- a/win/CS/HandBrakeWPF/Views/AudioView.xaml +++ b/win/CS/HandBrakeWPF/Views/AudioView.xaml @@ -12,7 +12,8 @@ xmlns:dropButton="clr-namespace:HandBrakeWPF.Controls.DropButton" d:DesignHeight="170" d:DesignWidth="616" - mc:Ignorable="d"> + mc:Ignorable="d" + x:Name="audioTab"> @@ -105,17 +106,30 @@ + + + + diff --git a/win/CS/HandBrakeWPF/Views/MainView.xaml b/win/CS/HandBrakeWPF/Views/MainView.xaml index fd95a5b53..67ac70c21 100644 --- a/win/CS/HandBrakeWPF/Views/MainView.xaml +++ b/win/CS/HandBrakeWPF/Views/MainView.xaml @@ -7,7 +7,6 @@ xmlns:Micro="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro" xmlns:attachedProperties="clr-namespace:HandBrakeWPF.AttachedProperties" AllowDrop="True" - Background="#FFF0F0F0" FontSize="11" Micro:Message.Attach="[Event Loaded] = [Action Load]" SnapsToDevicePixels="True" @@ -22,8 +21,7 @@ - - + @@ -160,21 +165,21 @@ - - + + - + - + - - - + + + @@ -203,10 +208,10 @@ @@ -553,9 +558,8 @@ VerticalAlignment="Stretch" Header="Presets" Margin="0,0,0,5" - Background="White" - Visibility="{Binding IsPresetPanelShowing, Converter={StaticResource boolToVisConverter}}" - > + Visibility="{Binding IsPresetPanelShowing, Converter={StaticResource boolToVisConverter}}"> + @@ -664,18 +668,12 @@ /> - + + + diff --git a/win/CS/HandBrakeWPF/Views/OptionsView.xaml b/win/CS/HandBrakeWPF/Views/OptionsView.xaml index dcf9994c8..64d7389ad 100644 --- a/win/CS/HandBrakeWPF/Views/OptionsView.xaml +++ b/win/CS/HandBrakeWPF/Views/OptionsView.xaml @@ -4,7 +4,7 @@ xmlns:Options="clr-namespace:HandBrakeWPF.Converters.Options" xmlns:dd="clr-namespace:GongSolutions.Wpf.DragDrop;assembly=GongSolutions.Wpf.DragDrop" xmlns:Converters="clr-namespace:HandBrakeWPF.Converters" xmlns:local="clr-namespace:HandBrakeWPF.Model" - Background="White"> + Style="{StaticResource whiteUserControlStyle}"> + + + + @@ -14,6 +39,14 @@ + + + + diff --git a/win/CS/HandBrakeWPF/defaultsettings.xml b/win/CS/HandBrakeWPF/defaultsettings.xml index 7ba21e103..30eebc778 100644 --- a/win/CS/HandBrakeWPF/defaultsettings.xml +++ b/win/CS/HandBrakeWPF/defaultsettings.xml @@ -464,4 +464,12 @@ true + + + UseSystemColours + + + false + + \ No newline at end of file diff --git a/win/CS/libraries/WPFDragDrop/GongSolutions.Wpf.DragDrop.XML b/win/CS/libraries/WPFDragDrop/GongSolutions.Wpf.DragDrop.XML index 297f4bf28..e46d7093d 100644 --- a/win/CS/libraries/WPFDragDrop/GongSolutions.Wpf.DragDrop.XML +++ b/win/CS/libraries/WPFDragDrop/GongSolutions.Wpf.DragDrop.XML @@ -366,6 +366,11 @@ Gets a flag enumeration indicating the current state of the SHIFT, CTRL, and ALT keys, as well as the state of the mouse buttons. + + + Indicates if the drop info should be handled by itself (useful for child elements) + + Holds information about a the target of a drag drop operation. diff --git a/win/CS/libraries/WPFDragDrop/GongSolutions.Wpf.DragDrop.dll b/win/CS/libraries/WPFDragDrop/GongSolutions.Wpf.DragDrop.dll index 3e9615082..395aac56d 100644 Binary files a/win/CS/libraries/WPFDragDrop/GongSolutions.Wpf.DragDrop.dll and b/win/CS/libraries/WPFDragDrop/GongSolutions.Wpf.DragDrop.dll differ diff --git a/win/CS/libraries/WPFDragDrop/GongSolutions.Wpf.DragDrop.pdb b/win/CS/libraries/WPFDragDrop/GongSolutions.Wpf.DragDrop.pdb index 997730460..5b01a61e8 100644 Binary files a/win/CS/libraries/WPFDragDrop/GongSolutions.Wpf.DragDrop.pdb and b/win/CS/libraries/WPFDragDrop/GongSolutions.Wpf.DragDrop.pdb differ