vaapi: Use gst_video_orientation_from_tag to parse orientation
authorColin Kinloch <colin.kinloch@collabora.com>
Tue, 20 Sep 2022 16:39:39 +0000 (17:39 +0100)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Fri, 11 Nov 2022 06:45:48 +0000 (06:45 +0000)
Signed-off-by: Colin Kinloch <colin.kinloch@collabora.com>
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3053>

subprojects/gstreamer-vaapi/gst/vaapi/gstvaapipostproc.c

index 1828cf6..810647e 100644 (file)
@@ -1977,7 +1977,7 @@ gst_vaapipostproc_sink_event (GstBaseTransform * trans, GstEvent * event)
 {
   GstVaapiPostproc *const postproc = GST_VAAPIPOSTPROC (trans);
   GstTagList *taglist;
-  gchar *orientation;
+  GstVideoOrientationMethod method;
   gboolean ret;
   gboolean do_reconf;
 
@@ -1987,33 +1987,12 @@ gst_vaapipostproc_sink_event (GstBaseTransform * trans, GstEvent * 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);
-        }
+      do_reconf = gst_video_orientation_from_tag (taglist, &method);
+
+      if (do_reconf) {
+        postproc->tag_video_direction = method;
+        postproc->flags |= GST_VAAPI_POSTPROC_FLAG_VIDEO_DIRECTION;
+        gst_base_transform_reconfigure_src (trans);
       }
       break;
     default: