From b848c1b6ffd1e508228820a013f94fb445e4777f Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Mon, 16 Nov 2015 16:23:43 -0500 Subject: [PATCH] vpxdec: Use threads on multi-core systems This adds an automatic mode to the threads property of vpxdec in order to use as many threads as there is CPU on the platform. This brings back GStreamer VPX decoding performance closer to what is achieved by other players, including Chromium. https://bugzilla.gnome.org/show_bug.cgi?id=758195 --- ext/vpx/gstvp8dec.c | 12 ++++++++---- ext/vpx/gstvp9dec.c | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/ext/vpx/gstvp8dec.c b/ext/vpx/gstvp8dec.c index c86cc4c..9d90562 100644 --- a/ext/vpx/gstvp8dec.c +++ b/ext/vpx/gstvp8dec.c @@ -58,7 +58,7 @@ GST_DEBUG_CATEGORY_STATIC (gst_vp8dec_debug); #define DEFAULT_POST_PROCESSING_FLAGS (VP8_DEBLOCK | VP8_DEMACROBLOCK | VP8_MFQE) #define DEFAULT_DEBLOCKING_LEVEL 4 #define DEFAULT_NOISE_LEVEL 0 -#define DEFAULT_THREADS 1 +#define DEFAULT_THREADS 0 enum { @@ -168,8 +168,8 @@ gst_vp8_dec_class_init (GstVP8DecClass * klass) g_object_class_install_property (gobject_class, PROP_THREADS, g_param_spec_uint ("threads", "Max Threads", - "Maximum number of decoding threads", - 1, 16, DEFAULT_THREADS, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + "Maximum number of decoding threads (0 = automatic)", + 0, 16, DEFAULT_THREADS, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&gst_vp8_dec_src_template)); @@ -456,7 +456,11 @@ open_codec (GstVP8Dec * dec, GstVideoCodecFrame * frame) cfg.w = stream_info.w; cfg.h = stream_info.h; - cfg.threads = dec->threads; + + if (dec->threads > 0) + cfg.threads = dec->threads; + else + cfg.threads = g_get_num_processors (); caps = vpx_codec_get_caps (&vpx_codec_vp8_dx_algo); diff --git a/ext/vpx/gstvp9dec.c b/ext/vpx/gstvp9dec.c index 3de5a64..242cdd4 100644 --- a/ext/vpx/gstvp9dec.c +++ b/ext/vpx/gstvp9dec.c @@ -58,7 +58,7 @@ GST_DEBUG_CATEGORY_STATIC (gst_vp9dec_debug); #define DEFAULT_POST_PROCESSING_FLAGS (VP8_DEBLOCK | VP8_DEMACROBLOCK) #define DEFAULT_DEBLOCKING_LEVEL 4 #define DEFAULT_NOISE_LEVEL 0 -#define DEFAULT_THREADS 1 +#define DEFAULT_THREADS 0 enum { @@ -168,8 +168,8 @@ gst_vp9_dec_class_init (GstVP9DecClass * klass) g_object_class_install_property (gobject_class, PROP_THREADS, g_param_spec_uint ("threads", "Max Threads", - "Maximum number of decoding threads", - 1, 16, DEFAULT_THREADS, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + "Maximum number of decoding threads (0 = automatic)", + 0, 16, DEFAULT_THREADS, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&gst_vp9_dec_src_template)); @@ -449,7 +449,11 @@ open_codec (GstVP9Dec * dec, GstVideoCodecFrame * frame) cfg.w = stream_info.w; cfg.h = stream_info.h; - cfg.threads = dec->threads; + + if (dec->threads > 0) + cfg.threads = dec->threads; + else + cfg.threads = g_get_num_processors (); caps = vpx_codec_get_caps (&vpx_codec_vp9_dx_algo); -- 2.7.4