mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-13 12:51:16 +00:00
waylandsink: Fix surface cropping for rotated streams
The wp_viewport source rectangle is applied in surface-local coordinates
after buffer_transform and buffer_scale. Therefore we need to swap width
and height for 90/270 deg. rotations.
This fixes playback of rotated videos such as portrait videos from
mobile devices.
See also: https://wayland.app/protocols/viewporter#wp_viewport
Fixes: 0b648f9a2d
("waylandsink: Crop surfaces to their display width height")
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7136>
This commit is contained in:
parent
a786c85c4f
commit
abf3361de3
1 changed files with 10 additions and 2 deletions
|
@ -456,6 +456,8 @@ gst_wl_window_resize_video_surface (GstWlWindow * self, gboolean commit)
|
|||
GstVideoRectangle src = { 0, };
|
||||
GstVideoRectangle dst = { 0, };
|
||||
GstVideoRectangle res;
|
||||
int wp_src_width;
|
||||
int wp_src_height;
|
||||
|
||||
switch (priv->buffer_transform) {
|
||||
case WL_OUTPUT_TRANSFORM_NORMAL:
|
||||
|
@ -464,6 +466,8 @@ gst_wl_window_resize_video_surface (GstWlWindow * self, gboolean commit)
|
|||
case WL_OUTPUT_TRANSFORM_FLIPPED_180:
|
||||
src.w = priv->scaled_width;
|
||||
src.h = priv->video_height;
|
||||
wp_src_width = priv->video_width;
|
||||
wp_src_height = priv->video_height;
|
||||
break;
|
||||
case WL_OUTPUT_TRANSFORM_90:
|
||||
case WL_OUTPUT_TRANSFORM_270:
|
||||
|
@ -471,7 +475,11 @@ gst_wl_window_resize_video_surface (GstWlWindow * self, gboolean commit)
|
|||
case WL_OUTPUT_TRANSFORM_FLIPPED_270:
|
||||
src.w = priv->video_height;
|
||||
src.h = priv->scaled_width;
|
||||
wp_src_width = priv->video_height;
|
||||
wp_src_height = priv->video_width;
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
dst.w = priv->render_rectangle.w;
|
||||
|
@ -481,8 +489,8 @@ gst_wl_window_resize_video_surface (GstWlWindow * self, gboolean commit)
|
|||
if (priv->video_viewport) {
|
||||
gst_video_center_rect (&src, &dst, &res, TRUE);
|
||||
wp_viewport_set_source (priv->video_viewport, wl_fixed_from_int (0),
|
||||
wl_fixed_from_int (0), wl_fixed_from_int (priv->video_width),
|
||||
wl_fixed_from_int (priv->video_height));
|
||||
wl_fixed_from_int (0), wl_fixed_from_int (wp_src_width),
|
||||
wl_fixed_from_int (wp_src_height));
|
||||
wp_viewport_set_destination (priv->video_viewport, res.w, res.h);
|
||||
} else {
|
||||
gst_video_center_rect (&src, &dst, &res, FALSE);
|
||||
|
|
Loading…
Reference in a new issue