summaryrefslogtreecommitdiff
path: root/gst
diff options
context:
space:
mode:
authorVíctor Manuel Jáquez Leal <vjaquez@igalia.com>2019-07-15 21:27:20 +0200
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>2019-08-19 16:48:50 +0000
commitbcb29e839938b3d3898ba475536e9d33ff8f0a39 (patch)
tree0c8dc16a129855e6fb28160a279d1eb9433f2100 /gst
parentb8a333e0c3cbe804311ac25d8054cf0d5f5ae1f6 (diff)
vaapipostproc: handle image-orientation upstream event
Now that vaapipostproc can possible handle video-direction, it should also handle the image-orientation event from upstream if video-direction property is set to auto.
Diffstat (limited to 'gst')
-rw-r--r--gst/vaapi/gstvaapipostproc.c71
-rw-r--r--gst/vaapi/gstvaapipostproc.h1
-rw-r--r--gst/vaapi/gstvaapipostprocutil.c4
3 files changed, 71 insertions, 5 deletions
diff --git a/gst/vaapi/gstvaapipostproc.c b/gst/vaapi/gstvaapipostproc.c
index 4c490972..401686ab 100644
--- a/gst/vaapi/gstvaapipostproc.c
+++ b/gst/vaapi/gstvaapipostproc.c
@@ -596,19 +596,22 @@ update_filter (GstVaapiPostproc * postproc)
}
if (postproc->flags & GST_VAAPI_POSTPROC_FLAG_VIDEO_DIRECTION) {
- if (!gst_vaapi_filter_set_video_direction (postproc->filter,
- postproc->video_direction)) {
+ GstVideoOrientationMethod method = postproc->video_direction;
+ if (method == GST_VIDEO_ORIENTATION_AUTO)
+ method = postproc->tag_video_direction;
+
+ if (!gst_vaapi_filter_set_video_direction (postproc->filter, method)) {
GST_ELEMENT_WARNING (postproc, LIBRARY, SETTINGS,
("Unsupported video direction '%s' by driver.",
gst_vaapi_enum_type_get_nick
- (GST_TYPE_VIDEO_ORIENTATION_METHOD, postproc->video_direction)),
+ (GST_TYPE_VIDEO_ORIENTATION_METHOD, method)),
("video direction transformation ignored"));
/* Don't return FALSE because other filters might be set */
}
if (gst_vaapi_filter_get_video_direction_default (postproc->filter) ==
- postproc->video_direction)
+ method)
postproc->flags &= ~(GST_VAAPI_POSTPROC_FLAG_VIDEO_DIRECTION);
}
@@ -1568,6 +1571,61 @@ gst_vaapipostproc_decide_allocation (GstBaseTransform * trans, GstQuery * query)
query);
}
+static gboolean
+gst_vaapipostproc_sink_event (GstBaseTransform * trans, GstEvent * event)
+{
+ GstVaapiPostproc *const postproc = GST_VAAPIPOSTPROC (trans);
+ GstTagList *taglist;
+ gchar *orientation;
+ gboolean ret;
+ gboolean do_reconf;
+
+ GST_DEBUG_OBJECT (postproc, "handling %s event", GST_EVENT_TYPE_NAME (event));
+
+ switch (GST_EVENT_TYPE (event)) {
+ case GST_EVENT_TAG:
+ gst_event_parse_tag (event, &taglist);
+
+ if (gst_tag_list_get_string (taglist, "image-orientation", &orientation)) {
+ do_reconf = TRUE;
+ if (!g_strcmp0 ("rotate-0", orientation))
+ postproc->tag_video_direction = GST_VIDEO_ORIENTATION_IDENTITY;
+ else if (!g_strcmp0 ("rotate-90", orientation))
+ postproc->tag_video_direction = GST_VIDEO_ORIENTATION_90R;
+ else if (!g_strcmp0 ("rotate-180", orientation))
+ postproc->tag_video_direction = GST_VIDEO_ORIENTATION_180;
+ else if (!g_strcmp0 ("rotate-270", orientation))
+ postproc->tag_video_direction = GST_VIDEO_ORIENTATION_90L;
+ else if (!g_strcmp0 ("flip-rotate-0", orientation))
+ postproc->tag_video_direction = GST_VIDEO_ORIENTATION_HORIZ;
+ else if (!g_strcmp0 ("flip-rotate-90", orientation))
+ postproc->tag_video_direction = GST_VIDEO_ORIENTATION_UL_LR;
+ else if (!g_strcmp0 ("flip-rotate-180", orientation))
+ postproc->tag_video_direction = GST_VIDEO_ORIENTATION_VERT;
+ else if (!g_strcmp0 ("flip-rotate-270", orientation))
+ postproc->tag_video_direction = GST_VIDEO_ORIENTATION_UR_LL;
+ else
+ do_reconf = FALSE;
+
+ g_free (orientation);
+
+ if (do_reconf) {
+ postproc->flags |= GST_VAAPI_POSTPROC_FLAG_VIDEO_DIRECTION;
+ gst_base_transform_reconfigure_src (trans);
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
+ ret =
+ GST_BASE_TRANSFORM_CLASS (gst_vaapipostproc_parent_class)->sink_event
+ (trans, event);
+
+ return ret;
+}
+
static void
gst_vaapipostproc_finalize (GObject * object)
{
@@ -1749,6 +1807,7 @@ gst_vaapipostproc_class_init (GstVaapiPostprocClass * klass)
trans_class->query = gst_vaapipostproc_query;
trans_class->propose_allocation = gst_vaapipostproc_propose_allocation;
trans_class->decide_allocation = gst_vaapipostproc_decide_allocation;
+ trans_class->sink_event = gst_vaapipostproc_sink_event;
trans_class->prepare_output_buffer = gst_vaapipostproc_prepare_output_buffer;
@@ -2007,6 +2066,10 @@ gst_vaapipostproc_init (GstVaapiPostproc * postproc)
postproc->keep_aspect = TRUE;
postproc->get_va_surfaces = TRUE;
+ /* AUTO is not valid for tag_video_direction, this is just to
+ * ensure we setup the method as sink event tag */
+ postproc->tag_video_direction = GST_VIDEO_ORIENTATION_AUTO;
+
filter_ops = gst_vaapi_filter_get_operations (NULL);
if (filter_ops) {
for (i = GST_VAAPI_FILTER_OP_HUE; i <= GST_VAAPI_FILTER_OP_CONTRAST; i++)
diff --git a/gst/vaapi/gstvaapipostproc.h b/gst/vaapi/gstvaapipostproc.h
index 9e73002d..0d98923f 100644
--- a/gst/vaapi/gstvaapipostproc.h
+++ b/gst/vaapi/gstvaapipostproc.h
@@ -166,6 +166,7 @@ struct _GstVaapiPostproc
GstVaapiScaleMethod scale_method;
GstVideoOrientationMethod video_direction;
+ GstVideoOrientationMethod tag_video_direction;
/* Color balance filter values */
gfloat hue;
diff --git a/gst/vaapi/gstvaapipostprocutil.c b/gst/vaapi/gstvaapipostprocutil.c
index 81f89c43..2c576b13 100644
--- a/gst/vaapi/gstvaapipostprocutil.c
+++ b/gst/vaapi/gstvaapipostprocutil.c
@@ -23,6 +23,8 @@
* Boston, MA 02110-1301 USA
*/
+#include <gst/vaapi/gstvaapifilter.h>
+
#include "gstvaapipostprocutil.h"
#include "gstvaapipluginutil.h"
@@ -178,7 +180,7 @@ _fixate_frame_size (GstVaapiPostproc * postproc, GstVideoInfo * vinfo,
from_h = GST_VIDEO_INFO_HEIGHT (vinfo);
/* compensate for rotation if needed */
- switch (postproc->video_direction) {
+ switch (gst_vaapi_filter_get_video_direction (postproc->filter)) {
case GST_VIDEO_ORIENTATION_90R:
case GST_VIDEO_ORIENTATION_90L:
case GST_VIDEO_ORIENTATION_UL_LR: