[vlc-commits] [Git][videolan/vlc][master] 3 commits: vout: display: fix inverted logic
Thomas Guillem (@tguillem)
gitlab at videolan.org
Fri Dec 22 12:49:18 UTC 2023
Thomas Guillem pushed to branch master at VideoLAN / VLC
Commits:
3f51e549 by Alaric Senat at 2023-12-22T12:30:45+00:00
vout: display: fix inverted logic
Those mouse coordinates translation were inverted probably due to a bad
copy/paste.
This was found by testing video filters with horizontal captured videos.
(ORIENT_RIGHT_TOP in this case).
- - - - -
384a410a by Alaric Senat at 2023-12-22T12:30:45+00:00
vout: display: split `PlacePicture` internals
Extract video format rotation from the function. This will be useful in
the next commit to avoid rotating the format twice in the translate
function.
- - - - -
ca32e6b9 by Alaric Senat at 2023-12-22T12:30:45+00:00
vout: display: fix coord translation for rotated format
The placed picture might have its width and height swapped due to
rotation. This needs to be taken into account in the translation.
This patch applies the format rotation early so the correct width and
height can be used in the translate code.
- - - - -
1 changed file:
- src/video_output/display.c
Changes:
=====================================
src/video_output/display.c
=====================================
@@ -78,23 +78,17 @@ void vout_display_GetDefaultDisplaySize(unsigned *width, unsigned *height,
}
}
-/* */
-void vout_display_PlacePicture(vout_display_place_t *restrict place,
- const video_format_t *restrict source,
- const struct vout_display_placement *restrict dp)
+static void vout_display_PlaceRotatedPicture(vout_display_place_t *restrict place,
+ const video_format_t *restrict source,
+ const struct vout_display_placement *restrict dp)
{
memset(place, 0, sizeof(*place));
if (dp->width == 0 || dp->height == 0)
return;
- /* */
unsigned display_width;
unsigned display_height;
- video_format_t source_rot;
- video_format_ApplyRotation(&source_rot, source);
- source = &source_rot;
-
if (dp->fitting != VLC_VIDEO_FIT_NONE) {
display_width = dp->width;
display_height = dp->height;
@@ -167,6 +161,17 @@ void vout_display_PlacePicture(vout_display_place_t *restrict place,
place->y = ((int)dp->height - (int)place->height) / 2;
break;
}
+
+}
+
+/* */
+void vout_display_PlacePicture(vout_display_place_t *restrict place,
+ const video_format_t *restrict source,
+ const struct vout_display_placement *restrict dp)
+{
+ video_format_t source_rot;
+ video_format_ApplyRotation(&source_rot, source);
+ vout_display_PlaceRotatedPicture(place, &source_rot, dp);
}
/** Translates window coordinates to video coordinates */
@@ -174,9 +179,11 @@ void vout_display_TranslateCoordinates(int *restrict xp, int *restrict yp,
const video_format_t *restrict source,
const struct vout_display_placement *restrict dp)
{
- vout_display_place_t place;
+ video_format_t source_rot;
+ video_format_ApplyRotation(&source_rot, source);
- vout_display_PlacePicture(&place, source, dp);
+ vout_display_place_t place;
+ vout_display_PlaceRotatedPicture(&place, &source_rot, dp);
if (place.width <= 0 || place.height <= 0)
return;
@@ -206,13 +213,13 @@ void vout_display_TranslateCoordinates(int *restrict xp, int *restrict yp,
y = wx;
break;
case ORIENT_LEFT_BOTTOM:
- x = wy;
- y = place.width - wx;
- break;
- case ORIENT_RIGHT_TOP:
x = place.height - wy;
y = wx;
break;
+ case ORIENT_RIGHT_TOP:
+ x = wy;
+ y = place.width - wx;
+ break;
case ORIENT_RIGHT_BOTTOM:
x = place.height - wy;
y = place.width - wx;
@@ -221,10 +228,10 @@ void vout_display_TranslateCoordinates(int *restrict xp, int *restrict yp,
vlc_assert_unreachable();
}
- x = source->i_x_offset
- + (int64_t)(x - place.x) * source->i_visible_width / place.width;
- y = source->i_y_offset
- + (int64_t)(y - place.y) * source->i_visible_height / place.height;
+ x = source_rot.i_x_offset
+ + (int64_t)(x - place.x) * source_rot.i_visible_width / place.width;
+ y = source_rot.i_y_offset
+ + (int64_t)(y - place.y) * source_rot.i_visible_height / place.height;
*xp = x;
*yp = y;
}
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/46a99f0b73dac93896ed02b05aee2cb879bd2b37...ca32e6b95fa6dfb2e2cc8b2b946d87df168dffa3
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/46a99f0b73dac93896ed02b05aee2cb879bd2b37...ca32e6b95fa6dfb2e2cc8b2b946d87df168dffa3
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list