summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2017-07-06 10:18:48 +0200
committerNicolas Dufresne <nicolas.dufresne@collabora.com>2018-01-30 11:51:10 +0000
commit52de8eaca0d45a908d1074be49162635880e3834 (patch)
tree329ae6a584f9392927c2fa6340a77e6726d438cb
parent9d37a92a615e54e8ee12f8c65bcfe386ec9de2d0 (diff)
downloadgst-omx-52de8eaca0d45a908d1074be49162635880e3834.tar.gz
omxvideodec: add internal-entropy-buffers property on zynqultrascaleplus
Custom property to control the number of internal buffers used in the decoder to smooth out entropy decoding performance. https://bugzilla.gnome.org/show_bug.cgi?id=792528
-rw-r--r--omx/gstomxvideodec.c107
-rw-r--r--omx/gstomxvideodec.h5
2 files changed, 111 insertions, 1 deletions
diff --git a/omx/gstomxvideodec.c b/omx/gstomxvideodec.c
index 2d97ca5..4a78c63 100644
--- a/omx/gstomxvideodec.c
+++ b/omx/gstomxvideodec.c
@@ -84,9 +84,12 @@ static OMX_ERRORTYPE gst_omx_video_dec_deallocate_output_buffers (GstOMXVideoDec
enum
{
- PROP_0
+ PROP_0,
+ PROP_INTERNAL_ENTROPY_BUFFERS,
};
+#define GST_OMX_VIDEO_DEC_INTERNAL_ENTROPY_BUFFERS_DEFAULT (5)
+
/* class initialization */
#define DEBUG_INIT \
@@ -98,6 +101,46 @@ G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GstOMXVideoDec, gst_omx_video_dec,
GST_TYPE_VIDEO_DECODER, DEBUG_INIT);
static void
+gst_omx_video_dec_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
+{
+#ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS
+ GstOMXVideoDec *self = GST_OMX_VIDEO_DEC (object);
+#endif
+
+ switch (prop_id) {
+#ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS
+ case PROP_INTERNAL_ENTROPY_BUFFERS:
+ self->internal_entropy_buffers = g_value_get_uint (value);
+ break;
+#endif
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gst_omx_video_dec_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
+{
+#ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS
+ GstOMXVideoDec *self = GST_OMX_VIDEO_DEC (object);
+#endif
+
+ switch (prop_id) {
+#ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS
+ case PROP_INTERNAL_ENTROPY_BUFFERS:
+ g_value_set_uint (value, self->internal_entropy_buffers);
+ break;
+#endif
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
gst_omx_video_dec_class_init (GstOMXVideoDecClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
@@ -105,6 +148,19 @@ gst_omx_video_dec_class_init (GstOMXVideoDecClass * klass)
GstVideoDecoderClass *video_decoder_class = GST_VIDEO_DECODER_CLASS (klass);
gobject_class->finalize = gst_omx_video_dec_finalize;
+ gobject_class->set_property = gst_omx_video_dec_set_property;
+ gobject_class->get_property = gst_omx_video_dec_get_property;
+
+#ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS
+ g_object_class_install_property (gobject_class, PROP_INTERNAL_ENTROPY_BUFFERS,
+ g_param_spec_uint ("internal-entropy-buffers", "Internal entropy buffers",
+ "Number of internal buffers used by the decoder to smooth out entropy decoding performance. "
+ "Increasing it may improve the frame rate when decoding high bitrate streams. "
+ "Decreasing it reduces the memory footprint",
+ 2, 16, GST_OMX_VIDEO_DEC_INTERNAL_ENTROPY_BUFFERS_DEFAULT,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
+ GST_PARAM_MUTABLE_READY));
+#endif
element_class->change_state =
GST_DEBUG_FUNCPTR (gst_omx_video_dec_change_state);
@@ -139,6 +195,11 @@ gst_omx_video_dec_init (GstOMXVideoDec * self)
{
self->dmabuf = FALSE;
+#ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS
+ self->internal_entropy_buffers =
+ GST_OMX_VIDEO_DEC_INTERNAL_ENTROPY_BUFFERS_DEFAULT;
+#endif
+
gst_video_decoder_set_packetized (GST_VIDEO_DECODER (self), TRUE);
gst_video_decoder_set_use_default_pad_acceptcaps (GST_VIDEO_DECODER_CAST
(self), TRUE);
@@ -148,6 +209,45 @@ gst_omx_video_dec_init (GstOMXVideoDec * self)
g_cond_init (&self->drain_cond);
}
+#ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS
+
+#define CHECK_ERR(setting) \
+ if (err == OMX_ErrorUnsupportedIndex || err == OMX_ErrorUnsupportedSetting) { \
+ GST_WARNING_OBJECT (self, \
+ "Setting " setting " parameters not supported by the component"); \
+ } else if (err != OMX_ErrorNone) { \
+ GST_ERROR_OBJECT (self, \
+ "Failed to set " setting " parameters: %s (0x%08x)", \
+ gst_omx_error_to_string (err), err); \
+ return FALSE; \
+ }
+
+static gboolean
+set_zynqultrascaleplus_props (GstOMXVideoDec * self)
+{
+ OMX_ERRORTYPE err;
+
+ {
+ OMX_ALG_VIDEO_PARAM_INTERNAL_ENTROPY_BUFFERS entropy_buffers;
+
+ GST_OMX_INIT_STRUCT (&entropy_buffers);
+ entropy_buffers.nPortIndex = self->dec_in_port->index;
+ entropy_buffers.nNumInternalEntropyBuffers = self->internal_entropy_buffers;
+
+ GST_DEBUG_OBJECT (self, "setting number of internal entropy buffers to %d",
+ self->internal_entropy_buffers);
+
+ err =
+ gst_omx_component_set_parameter (self->dec,
+ (OMX_INDEXTYPE) OMX_ALG_IndexParamVideoInternalEntropyBuffers,
+ &entropy_buffers);
+ CHECK_ERR ("internal entropy buffers");
+ }
+
+ return TRUE;
+}
+#endif
+
static gboolean
gst_omx_video_dec_open (GstVideoDecoder * decoder)
{
@@ -273,6 +373,11 @@ gst_omx_video_dec_open (GstVideoDecoder * decoder)
GST_DEBUG_OBJECT (self, "Opened EGL renderer");
#endif
+#ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS
+ if (!set_zynqultrascaleplus_props (self))
+ return FALSE;
+#endif
+
return TRUE;
}
diff --git a/omx/gstomxvideodec.h b/omx/gstomxvideodec.h
index ee719e4..cb70e02 100644
--- a/omx/gstomxvideodec.h
+++ b/omx/gstomxvideodec.h
@@ -95,6 +95,11 @@ struct _GstOMXVideoDec
/* TRUE if decoder is producing dmabuf */
gboolean dmabuf;
GstOMXBufferAllocation input_allocation;
+
+ /* properties */
+#ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS
+ guint32 internal_entropy_buffers;
+#endif
};
struct _GstOMXVideoDecClass