summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeo Liu <leo.liu@amd.com>2014-03-03 16:38:20 -0500
committerLeo Liu <leo.liu@amd.com>2014-03-03 16:39:09 -0500
commitcc8373dc8bde13677e1a977e3205493fbd318143 (patch)
tree0c8910e145fa6e585af579b59f70aeb98a3b5623
parent48234d61a4cab29dcd5fe4ec6ca767c0e78983e5 (diff)
gstomxvideoenc: add capture geometry support
Signed-off-by: Leo Liu <leo.liu@amd.com>
-rw-r--r--omx/gstomxvideoenc.c78
-rw-r--r--omx/gstomxvideoenc.h2
2 files changed, 75 insertions, 5 deletions
diff --git a/omx/gstomxvideoenc.c b/omx/gstomxvideoenc.c
index cbb8cb9..83c68fe 100644
--- a/omx/gstomxvideoenc.c
+++ b/omx/gstomxvideoenc.c
@@ -99,7 +99,9 @@ enum
PROP_QUANT_B_FRAMES,
PROP_SCALING_WIDTH,
PROP_SCALING_HEIGHT,
- PROP_CAPTURE
+ PROP_CAPTURE,
+ PROP_POS_X,
+ PROP_POS_Y
};
/* FIXME: Better defaults */
@@ -111,6 +113,8 @@ enum
#define GST_OMX_VIDEO_ENC_SCALING_WIDTH_DEFAULT (0xffffffff)
#define GST_OMX_VIDEO_ENC_SCALING_HEIGHT_DEFAULT (0xffffffff)
#define GST_OMX_VIDEO_ENC_CAPTURE_DEFAULT (FALSE)
+#define GST_OMX_VIDEO_ENC_POS_X_DEFAULT (0)
+#define GST_OMX_VIDEO_ENC_POS_Y_DEFAULT (0)
/* class initialization */
@@ -189,6 +193,20 @@ gst_omx_video_enc_class_init (GstOMXVideoEncClass * klass)
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
GST_PARAM_MUTABLE_READY));
+ g_object_class_install_property (gobject_class, PROP_POS_X,
+ g_param_spec_uint ("pos-x", "Position X",
+ "Capture Position X parameter (0=component default)",
+ 0, G_MAXUINT, GST_OMX_VIDEO_ENC_POS_X_DEFAULT,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
+ GST_PARAM_MUTABLE_READY));
+
+ g_object_class_install_property (gobject_class, PROP_POS_Y,
+ g_param_spec_uint ("pos-y", "Position Y",
+ "Capture Position Y parameter (0=component default)",
+ 0, G_MAXUINT, GST_OMX_VIDEO_ENC_POS_Y_DEFAULT,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
+ GST_PARAM_MUTABLE_READY));
+
element_class->change_state =
GST_DEBUG_FUNCPTR (gst_omx_video_enc_change_state);
@@ -226,6 +244,8 @@ gst_omx_video_enc_init (GstOMXVideoEnc * self)
self->scaling_width = GST_OMX_VIDEO_ENC_SCALING_WIDTH_DEFAULT;
self->scaling_height = GST_OMX_VIDEO_ENC_SCALING_HEIGHT_DEFAULT;
self->capture = GST_OMX_VIDEO_ENC_CAPTURE_DEFAULT;
+ self->pos_x = GST_OMX_VIDEO_ENC_POS_X_DEFAULT;
+ self->pos_y = GST_OMX_VIDEO_ENC_POS_Y_DEFAULT;
g_mutex_init (&self->drain_lock);
g_cond_init (&self->drain_cond);
@@ -426,10 +446,46 @@ gst_omx_video_enc_open (GstVideoEncoder * encoder)
if (self->capture)
capture_factor.bEnabled = TRUE;
- err =
- gst_omx_component_set_config (self->enc,
- OMX_IndexConfigCapturing, &capture_factor);
- if (err == OMX_ErrorUnsupportedIndex) {
+ err = gst_omx_component_set_config (self->enc,
+ OMX_IndexConfigCapturing, &capture_factor);
+ if (err == OMX_ErrorNone) {
+ if (self->pos_x || self->pos_y) {
+ OMX_CONFIG_POINTTYPE pos_factor;
+
+ GST_OMX_INIT_STRUCT (&pos_factor);
+ pos_factor.nPortIndex = self->enc_out_port->index;
+
+ err = gst_omx_component_get_config (self->enc,
+ OMX_IndexConfigCommonOutputPosition, &pos_factor);
+
+ if (err == OMX_ErrorNone) {
+ if (self->pos_x)
+ pos_factor.nX = self->pos_x;
+ if (self->pos_y)
+ pos_factor.nY = self->pos_y;
+ err = gst_omx_component_set_config (self->enc,
+ OMX_IndexConfigCommonOutputPosition, &pos_factor);
+ if (err == OMX_ErrorUnsupportedIndex) {
+ GST_WARNING_OBJECT (self,
+ "Setting capture position configuration not supported by the component");
+ } else if (err == OMX_ErrorUnsupportedSetting) {
+ GST_WARNING_OBJECT (self,
+ "Setting capture position configuration %u %u not supported by the component",
+ self->pos_x, self->pos_y);
+ } else if (err != OMX_ErrorNone) {
+ GST_ERROR_OBJECT (self,
+ "Failed to set capture position configuration: %s (0x%08x)",
+ gst_omx_error_to_string (err), err);
+ return FALSE;
+ }
+ }else {
+ GST_ERROR_OBJECT (self,
+ "Failed to set capture position configuration: %s (0x%08x)",
+ gst_omx_error_to_string (err), err);
+ }
+ }
+ }
+ else if (err == OMX_ErrorUnsupportedIndex) {
GST_WARNING_OBJECT (self,
"Setting capture configuration not supported by the component");
} else if (err == OMX_ErrorUnsupportedSetting) {
@@ -554,6 +610,12 @@ gst_omx_video_enc_set_property (GObject * object, guint prop_id,
case PROP_CAPTURE:
self->capture = g_value_get_boolean (value);
break;
+ case PROP_POS_X:
+ self->pos_x = g_value_get_uint (value);
+ break;
+ case PROP_POS_Y:
+ self->pos_y = g_value_get_uint (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -591,6 +653,12 @@ gst_omx_video_enc_get_property (GObject * object, guint prop_id, GValue * value,
case PROP_CAPTURE:
g_value_set_boolean (value, self->capture);
break;
+ case PROP_POS_X:
+ g_value_set_uint (value, self->pos_x);
+ break;
+ case PROP_POS_Y:
+ g_value_set_uint (value, self->pos_y);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
diff --git a/omx/gstomxvideoenc.h b/omx/gstomxvideoenc.h
index e9844b8..3de563b 100644
--- a/omx/gstomxvideoenc.h
+++ b/omx/gstomxvideoenc.h
@@ -81,6 +81,8 @@ struct _GstOMXVideoEnc
guint32 scaling_height;
gboolean capture;
+ guint32 pos_x;
+ guint32 pos_y;
GstFlowReturn downstream_flow_ret;
};