summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>2013-08-27 18:06:10 +0200
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>2013-08-27 18:28:10 +0200
commit71e5fd536f1ce2dd33d992437609c98fbedabc69 (patch)
treebe333404a9ca5f2c0ea3455e055c2af47ffdba42
parent771071a4e593e231d111d835ca82e07a57555251 (diff)
downloadgstreamer-vaapi-71e5fd536f1ce2dd33d992437609c98fbedabc69.tar.gz
filter: allow specification of render target regions.
Add support for rendering the source surface to a particular region within the supplied target surface. The default background color is black.
-rw-r--r--docs/reference/libs/libs-sections.txt1
-rwxr-xr-xgst-libs/gst/vaapi/gstvaapifilter.c52
-rwxr-xr-xgst-libs/gst/vaapi/gstvaapifilter.h4
3 files changed, 53 insertions, 4 deletions
diff --git a/docs/reference/libs/libs-sections.txt b/docs/reference/libs/libs-sections.txt
index b70eaaaa..cc00f430 100644
--- a/docs/reference/libs/libs-sections.txt
+++ b/docs/reference/libs/libs-sections.txt
@@ -387,6 +387,7 @@ gst_vaapi_filter_get_formats
gst_vaapi_filter_set_operation
gst_vaapi_filter_set_format
gst_vaapi_filter_set_cropping_rectangle
+gst_vaapi_filter_set_target_rectangle
gst_vaapi_filter_set_denoising_level
gst_vaapi_filter_set_sharpening_level
gst_vaapi_filter_set_hue
diff --git a/gst-libs/gst/vaapi/gstvaapifilter.c b/gst-libs/gst/vaapi/gstvaapifilter.c
index 78ab1078..ef07eb4f 100755
--- a/gst-libs/gst/vaapi/gstvaapifilter.c
+++ b/gst-libs/gst/vaapi/gstvaapifilter.c
@@ -64,7 +64,9 @@ struct _GstVaapiFilter {
GstVideoFormat format;
GArray *formats;
GstVaapiRectangle crop_rect;
+ GstVaapiRectangle target_rect;
guint use_crop_rect : 1;
+ guint use_target_rect : 1;
};
/* ------------------------------------------------------------------------- */
@@ -1178,6 +1180,7 @@ gst_vaapi_filter_process_unlocked(GstVaapiFilter *filter,
if (!ensure_operations(filter))
return GST_VAAPI_FILTER_STATUS_ERROR_ALLOCATION_FAILED;
+ /* Build surface region (source) */
if (filter->use_crop_rect) {
const GstVaapiRectangle * const crop_rect = &filter->crop_rect;
@@ -1199,10 +1202,27 @@ gst_vaapi_filter_process_unlocked(GstVaapiFilter *filter,
src_rect.height = GST_VAAPI_SURFACE_HEIGHT(src_surface);
}
- dst_rect.x = 0;
- dst_rect.y = 0;
- dst_rect.width = GST_VAAPI_SURFACE_WIDTH(dst_surface);
- dst_rect.height = GST_VAAPI_SURFACE_HEIGHT(dst_surface);
+ /* Build output region (target) */
+ if (filter->use_target_rect) {
+ const GstVaapiRectangle * const target_rect = &filter->target_rect;
+
+ if ((target_rect->x + target_rect->width >
+ GST_VAAPI_SURFACE_WIDTH(dst_surface)) ||
+ (target_rect->y + target_rect->height >
+ GST_VAAPI_SURFACE_HEIGHT(dst_surface)))
+ goto error;
+
+ dst_rect.x = target_rect->x;
+ dst_rect.y = target_rect->y;
+ dst_rect.width = target_rect->width;
+ dst_rect.height = target_rect->height;
+ }
+ else {
+ dst_rect.x = 0;
+ dst_rect.y = 0;
+ dst_rect.width = GST_VAAPI_SURFACE_WIDTH(dst_surface);
+ dst_rect.height = GST_VAAPI_SURFACE_HEIGHT(dst_surface);
+ }
for (i = 0, num_filters = 0; i < filter->operations->len; i++) {
GstVaapiFilterOpData * const op_data =
@@ -1352,6 +1372,30 @@ gst_vaapi_filter_set_cropping_rectangle(GstVaapiFilter *filter,
}
/**
+ * gst_vaapi_filter_set_target_rectangle:
+ * @filter: a #GstVaapiFilter
+ * @rect: the target render region
+ *
+ * Sets the region within the target surface where the source surface
+ * would be rendered. i.e. where the hardware accelerator would emit
+ * the outcome of video processing. If @rect is %NULL, the whole
+ * source surface will be used.
+ *
+ * Return value: %TRUE if the operation is supported, %FALSE otherwise.
+ */
+gboolean
+gst_vaapi_filter_set_target_rectangle(GstVaapiFilter *filter,
+ const GstVaapiRectangle *rect)
+{
+ g_return_val_if_fail(filter != NULL, FALSE);
+
+ filter->use_target_rect = rect != NULL;
+ if (filter->use_target_rect)
+ filter->target_rect = *rect;
+ return TRUE;
+}
+
+/**
* gst_vaapi_filter_set_denoising_level:
* @filter: a #GstVaapiFilter
* @level: the level of noise reduction to apply
diff --git a/gst-libs/gst/vaapi/gstvaapifilter.h b/gst-libs/gst/vaapi/gstvaapifilter.h
index bd770771..2ea44052 100755
--- a/gst-libs/gst/vaapi/gstvaapifilter.h
+++ b/gst-libs/gst/vaapi/gstvaapifilter.h
@@ -168,6 +168,10 @@ gst_vaapi_filter_set_cropping_rectangle(GstVaapiFilter *filter,
const GstVaapiRectangle *rect);
gboolean
+gst_vaapi_filter_set_target_rectangle(GstVaapiFilter *filter,
+ const GstVaapiRectangle *rect);
+
+gboolean
gst_vaapi_filter_set_denoising_level(GstVaapiFilter *filter, gfloat level);
gboolean