mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
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.
This commit is contained in:
parent
b8a333e0c3
commit
bcb29e8399
5 changed files with 87 additions and 5 deletions
|
@ -2000,6 +2000,19 @@ gst_vaapi_filter_set_video_direction (GstVaapiFilter * filter,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_filter_get_video_direction:
|
||||
* @filter: a #GstVaapiFilter
|
||||
*
|
||||
* Return value: the currently applied video direction (see #GstVideoOrientationMethod)
|
||||
*/
|
||||
GstVideoOrientationMethod
|
||||
gst_vaapi_filter_get_video_direction (GstVaapiFilter * filter)
|
||||
{
|
||||
g_return_val_if_fail (filter != NULL, GST_VIDEO_ORIENTATION_IDENTITY);
|
||||
return filter->video_direction;
|
||||
}
|
||||
|
||||
static inline gfloat
|
||||
op_get_float_default_value (GstVaapiFilter * filter,
|
||||
GstVaapiFilterOpData * op_data)
|
||||
|
|
|
@ -253,6 +253,9 @@ gboolean
|
|||
gst_vaapi_filter_set_video_direction (GstVaapiFilter * filter,
|
||||
GstVideoOrientationMethod method);
|
||||
|
||||
GstVideoOrientationMethod
|
||||
gst_vaapi_filter_get_video_direction (GstVaapiFilter * filter);
|
||||
|
||||
gboolean
|
||||
gst_vaapi_filter_set_skintone (GstVaapiFilter * filter,
|
||||
gboolean enhance);
|
||||
|
|
|
@ -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++)
|
||||
|
|
|
@ -166,6 +166,7 @@ struct _GstVaapiPostproc
|
|||
GstVaapiScaleMethod scale_method;
|
||||
|
||||
GstVideoOrientationMethod video_direction;
|
||||
GstVideoOrientationMethod tag_video_direction;
|
||||
|
||||
/* Color balance filter values */
|
||||
gfloat hue;
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue