vp9enc: expose frame-parallel-decoding property

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/874>
This commit is contained in:
Jakub Adam 2021-02-16 13:28:00 +01:00 committed by GStreamer Marge Bot
parent 846ee58cac
commit a5cccf13d4
2 changed files with 42 additions and 0 deletions

View file

@ -73,6 +73,7 @@ GST_DEBUG_CATEGORY_STATIC (gst_vp9enc_debug);
#define DEFAULT_TILE_ROWS 0 #define DEFAULT_TILE_ROWS 0
#define DEFAULT_ROW_MT 0 #define DEFAULT_ROW_MT 0
#define DEFAULT_AQ_MODE 0 #define DEFAULT_AQ_MODE 0
#define DEFAULT_FRAME_PARALLEL_DECODING TRUE
enum enum
{ {
@ -81,6 +82,7 @@ enum
PROP_TILE_ROWS, PROP_TILE_ROWS,
PROP_ROW_MT, PROP_ROW_MT,
PROP_AQ_MODE, PROP_AQ_MODE,
PROP_FRAME_PARALLEL_DECODING,
}; };
/* FIXME: Y42B do not work yet it seems */ /* FIXME: Y42B do not work yet it seems */
@ -192,6 +194,20 @@ gst_vp9_enc_class_init (GstVP9EncClass * klass)
0, 4, DEFAULT_AQ_MODE, 0, 4, DEFAULT_AQ_MODE,
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS))); (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
/**
* GstVP9Enc:frame-parallel-decoding:
*
* Whether encoded bitstream should allow parallel processing of video frames in the decoder
*
* Since: 1.20
*/
g_object_class_install_property (gobject_class, PROP_FRAME_PARALLEL_DECODING,
g_param_spec_boolean ("frame-parallel-decoding",
"Frame Parallel Decoding",
"Whether encoded bitstream should allow parallel processing of video frames in the decoder "
"(default is on)", DEFAULT_FRAME_PARALLEL_DECODING,
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
gst_element_class_add_static_pad_template (element_class, gst_element_class_add_static_pad_template (element_class,
&gst_vp9_enc_src_template); &gst_vp9_enc_src_template);
gst_element_class_add_static_pad_template (element_class, gst_element_class_add_static_pad_template (element_class,
@ -241,6 +257,7 @@ gst_vp9_enc_init (GstVP9Enc * gst_vp9_enc)
gst_vp9_enc->tile_rows = DEFAULT_TILE_ROWS; gst_vp9_enc->tile_rows = DEFAULT_TILE_ROWS;
gst_vp9_enc->row_mt = DEFAULT_ROW_MT; gst_vp9_enc->row_mt = DEFAULT_ROW_MT;
gst_vp9_enc->aq_mode = DEFAULT_AQ_MODE; gst_vp9_enc->aq_mode = DEFAULT_AQ_MODE;
gst_vp9_enc->frame_parallel_decoding = DEFAULT_FRAME_PARALLEL_DECODING;
} }
static void static void
@ -304,6 +321,19 @@ gst_vp9_enc_set_property (GObject * object, guint prop_id,
} }
} }
break; break;
case PROP_FRAME_PARALLEL_DECODING:
gst_vp9_enc->frame_parallel_decoding = g_value_get_boolean (value);
if (gst_vpx_enc->inited) {
status = vpx_codec_control (&gst_vpx_enc->encoder,
VP9E_SET_FRAME_PARALLEL_DECODING,
gst_vp9_enc->frame_parallel_decoding ? 1 : 0);
if (status != VPX_CODEC_OK) {
GST_WARNING_OBJECT (gst_vpx_enc,
"Failed to set VP9E_SET_FRAME_PARALLEL_DECODING: %s",
gst_vpx_error_name (status));
}
}
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;
@ -334,6 +364,9 @@ gst_vp9_enc_get_property (GObject * object, guint prop_id, GValue * value,
case PROP_AQ_MODE: case PROP_AQ_MODE:
g_value_set_int (value, gst_vp9_enc->aq_mode); g_value_set_int (value, gst_vp9_enc->aq_mode);
break; break;
case PROP_FRAME_PARALLEL_DECODING:
g_value_set_boolean (value, gst_vp9_enc->frame_parallel_decoding);
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;
@ -460,6 +493,14 @@ gst_vp9_enc_configure_encoder (GstVPXEnc * encoder, GstVideoCodecState * state)
GST_WARNING_OBJECT (encoder, GST_WARNING_OBJECT (encoder,
"Failed to set VP9E_SET_AQ_MODE: %s", gst_vpx_error_name (status)); "Failed to set VP9E_SET_AQ_MODE: %s", gst_vpx_error_name (status));
} }
status =
vpx_codec_control (&encoder->encoder, VP9E_SET_FRAME_PARALLEL_DECODING,
vp9enc->frame_parallel_decoding ? 1 : 0);
if (status != VPX_CODEC_OK) {
GST_WARNING_OBJECT (encoder,
"Failed to set VP9E_SET_FRAME_PARALLEL_DECODING: %s",
gst_vpx_error_name (status));
}
return TRUE; return TRUE;
} }

View file

@ -51,6 +51,7 @@ struct _GstVP9Enc
gboolean row_mt; gboolean row_mt;
#endif #endif
guint aq_mode; guint aq_mode;
gboolean frame_parallel_decoding;
}; };
G_END_DECLS G_END_DECLS