vp8dec: Add support for multiple decoding threads

This commit is contained in:
Sebastian Dröge 2012-08-14 11:17:25 +02:00
parent 14317a3408
commit c6b16aed08
2 changed files with 22 additions and 2 deletions

View file

@ -62,6 +62,7 @@ GST_DEBUG_CATEGORY_STATIC (gst_vp8dec_debug);
#define DEFAULT_POST_PROCESSING_FLAGS (VP8_DEBLOCK | VP8_DEMACROBLOCK | VP8_MFQE) #define DEFAULT_POST_PROCESSING_FLAGS (VP8_DEBLOCK | VP8_DEMACROBLOCK | VP8_MFQE)
#define DEFAULT_DEBLOCKING_LEVEL 4 #define DEFAULT_DEBLOCKING_LEVEL 4
#define DEFAULT_NOISE_LEVEL 0 #define DEFAULT_NOISE_LEVEL 0
#define DEFAULT_THREADS 1
enum enum
{ {
@ -69,7 +70,8 @@ enum
PROP_POST_PROCESSING, PROP_POST_PROCESSING,
PROP_POST_PROCESSING_FLAGS, PROP_POST_PROCESSING_FLAGS,
PROP_DEBLOCKING_LEVEL, PROP_DEBLOCKING_LEVEL,
PROP_NOISE_LEVEL PROP_NOISE_LEVEL,
PROP_THREADS
}; };
#define C_FLAGS(v) ((guint) v) #define C_FLAGS(v) ((guint) v)
@ -168,6 +170,11 @@ gst_vp8_dec_class_init (GstVP8DecClass * klass)
0, 16, DEFAULT_NOISE_LEVEL, 0, 16, DEFAULT_NOISE_LEVEL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
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));
gst_element_class_add_pad_template (element_class, gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_vp8_dec_src_template)); gst_static_pad_template_get (&gst_vp8_dec_src_template));
gst_element_class_add_pad_template (element_class, gst_element_class_add_pad_template (element_class,
@ -226,6 +233,9 @@ gst_vp8_dec_set_property (GObject * object, guint prop_id,
case PROP_NOISE_LEVEL: case PROP_NOISE_LEVEL:
dec->noise_level = g_value_get_uint (value); dec->noise_level = g_value_get_uint (value);
break; break;
case PROP_THREADS:
dec->threads = g_value_get_uint (value);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -254,6 +264,9 @@ gst_vp8_dec_get_property (GObject * object, guint prop_id, GValue * value,
case PROP_NOISE_LEVEL: case PROP_NOISE_LEVEL:
g_value_set_uint (value, dec->noise_level); g_value_set_uint (value, dec->noise_level);
break; break;
case PROP_THREADS:
g_value_set_uint (value, dec->threads);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -374,11 +387,13 @@ open_codec (GstVP8Dec * dec, GstVideoCodecFrame * frame)
int flags = 0; int flags = 0;
vpx_codec_stream_info_t stream_info; vpx_codec_stream_info_t stream_info;
vpx_codec_caps_t caps; vpx_codec_caps_t caps;
vpx_codec_dec_cfg_t cfg;
GstVideoCodecState *state = dec->input_state; GstVideoCodecState *state = dec->input_state;
vpx_codec_err_t status; vpx_codec_err_t status;
GstMapInfo minfo; GstMapInfo minfo;
memset (&stream_info, 0, sizeof (stream_info)); memset (&stream_info, 0, sizeof (stream_info));
memset (&cfg, 0, sizeof (cfg));
stream_info.sz = sizeof (stream_info); stream_info.sz = sizeof (stream_info);
if (!gst_buffer_map (frame->input_buffer, &minfo, GST_MAP_READ)) { if (!gst_buffer_map (frame->input_buffer, &minfo, GST_MAP_READ)) {
@ -403,6 +418,10 @@ open_codec (GstVP8Dec * dec, GstVideoCodecFrame * frame)
GST_VIDEO_FORMAT_I420, stream_info.w, stream_info.h, state); GST_VIDEO_FORMAT_I420, stream_info.w, stream_info.h, state);
gst_vp8_dec_send_tags (dec); gst_vp8_dec_send_tags (dec);
cfg.w = stream_info.w;
cfg.h = stream_info.h;
cfg.threads = dec->threads;
caps = vpx_codec_get_caps (&vpx_codec_vp8_dx_algo); caps = vpx_codec_get_caps (&vpx_codec_vp8_dx_algo);
if (dec->post_processing) { if (dec->post_processing) {
@ -414,7 +433,7 @@ open_codec (GstVP8Dec * dec, GstVideoCodecFrame * frame)
} }
status = status =
vpx_codec_dec_init (&dec->decoder, &vpx_codec_vp8_dx_algo, NULL, flags); vpx_codec_dec_init (&dec->decoder, &vpx_codec_vp8_dx_algo, &cfg, flags);
if (status != VPX_CODEC_OK) { if (status != VPX_CODEC_OK) {
GST_ELEMENT_ERROR (dec, LIBRARY, INIT, GST_ELEMENT_ERROR (dec, LIBRARY, INIT,
("Failed to initialize VP8 decoder"), ("%s", ("Failed to initialize VP8 decoder"), ("%s",

View file

@ -66,6 +66,7 @@ struct _GstVP8Dec
enum vp8_postproc_level post_processing_flags; enum vp8_postproc_level post_processing_flags;
gint deblocking_level; gint deblocking_level;
gint noise_level; gint noise_level;
gint threads;
GstVideoCodecState *input_state; GstVideoCodecState *input_state;
GstVideoCodecState *output_state; GstVideoCodecState *output_state;