videosource: auto-flip the image according to image-orientation tag

If there's image-orientation tag, make sure the image is correctly
oriented before we scale it.
This commit is contained in:
Jakub Adam 2019-03-15 16:24:16 +01:00
parent 64f23a2a80
commit 77dac21488

View file

@ -82,6 +82,7 @@
#endif #endif
#include <gst/pbutils/missing-plugins.h> #include <gst/pbutils/missing-plugins.h>
#include <gst/video/video.h>
#include "ges-internal.h" #include "ges-internal.h"
#include "ges/ges-meta-container.h" #include "ges/ges-meta-container.h"
@ -135,8 +136,8 @@ ges_video_source_create_element (GESTrackElement * trksrc)
GstElement *queue = gst_element_factory_make ("queue", NULL); GstElement *queue = gst_element_factory_make ("queue", NULL);
GESVideoSourceClass *source_class = GES_VIDEO_SOURCE_GET_CLASS (trksrc); GESVideoSourceClass *source_class = GES_VIDEO_SOURCE_GET_CLASS (trksrc);
GESVideoSource *self; GESVideoSource *self;
GstElement *positioner, *videoscale, *videorate, *capsfilter, *videoconvert, GstElement *positioner, *videoflip, *videoscale, *videorate, *capsfilter,
*deinterlace; *videoconvert, *deinterlace;
const gchar *positioner_props[] = const gchar *positioner_props[] =
{ "alpha", "posx", "posy", "width", "height", NULL }; { "alpha", "posx", "posy", "width", "height", NULL };
const gchar *deinterlace_props[] = { "mode", "fields", "tff", NULL }; const gchar *deinterlace_props[] = { "mode", "fields", "tff", NULL };
@ -154,6 +155,11 @@ ges_video_source_create_element (GESTrackElement * trksrc)
g_object_set (positioner, "zorder", g_object_set (positioner, "zorder",
G_MAXUINT - GES_TIMELINE_ELEMENT_PRIORITY (self), NULL); G_MAXUINT - GES_TIMELINE_ELEMENT_PRIORITY (self), NULL);
/* If there's image-orientation tag, make sure the image is correctly oriented
* before we scale it. */
videoflip = gst_element_factory_make ("videoflip", "track-element-videoflip");
g_object_set (videoflip, "video-direction", GST_VIDEO_ORIENTATION_AUTO, NULL);
videoscale = videoscale =
gst_element_factory_make ("videoscale", "track-element-videoscale"); gst_element_factory_make ("videoscale", "track-element-videoscale");
videoconvert = videoconvert =
@ -177,13 +183,14 @@ ges_video_source_create_element (GESTrackElement * trksrc)
"deinterlace"), ("deinterlacing won't work")); "deinterlace"), ("deinterlacing won't work"));
topbin = topbin =
ges_source_create_topbin ("videosrcbin", sub_element, queue, ges_source_create_topbin ("videosrcbin", sub_element, queue,
videoconvert, positioner, videoscale, videorate, capsfilter, NULL); videoconvert, positioner, videoflip, videoscale, videorate, capsfilter,
NULL);
} else { } else {
ges_track_element_add_children_props (trksrc, deinterlace, NULL, NULL, ges_track_element_add_children_props (trksrc, deinterlace, NULL, NULL,
deinterlace_props); deinterlace_props);
topbin = topbin =
ges_source_create_topbin ("videosrcbin", sub_element, queue, ges_source_create_topbin ("videosrcbin", sub_element, queue,
videoconvert, deinterlace, positioner, videoscale, videorate, videoconvert, deinterlace, positioner, videoflip, videoscale, videorate,
capsfilter, NULL); capsfilter, NULL);
} }