[vlc-devel] [PATCH v3 01/20] vlc_vout_display: add a helper function to flip the vertical placement value

Steve Lhomme robux4 at ycbcr.xyz
Wed Aug 26 13:55:28 CEST 2020


OpenGL uses a bottom-left-based coordinate system and need to flip the picture
placement from the usual top-left-based coordinate system.

We can use this math because the sum of
  place->y + place->height + flipped_place->y
is always equal to
  cfg->display.height
---
 include/vlc_vout_display.h | 12 ++++++++++++
 src/video_output/display.c |  1 +
 2 files changed, 13 insertions(+)

diff --git a/include/vlc_vout_display.h b/include/vlc_vout_display.h
index 2a0b593a13e..765ce57c9e2 100644
--- a/include/vlc_vout_display.h
+++ b/include/vlc_vout_display.h
@@ -515,6 +515,18 @@ static inline bool vout_display_PlaceEquals(const vout_display_place_t *p1,
  */
 VLC_API void vout_display_PlacePicture(vout_display_place_t *place, const video_format_t *source, const vout_display_cfg_t *cfg);
 
+/**
+ * Helper function to flip the vertical alignment start.
+ *
+ * OpenGL uses a bottom-left-based coordinate system and need to flip the picture
+ * placement from the usual top-left-based coordinate system.
+ */
+static inline void vout_display_PlaceFlipVertical(const vout_display_cfg_t *cfg,
+                                                  vout_display_place_t *place)
+{
+    place->y = cfg->display.height - place->height - place->y;
+}
+
 /**
  * Translates mouse state.
  *
diff --git a/src/video_output/display.c b/src/video_output/display.c
index 0112425ac14..bbd2f650e5a 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -218,6 +218,7 @@ void vout_display_PlacePicture(vout_display_place_t *place,
         place->y = cfg->display.height - place->height;
         break;
     default:
+        // round to lower value
         place->y = ((int)cfg->display.height - (int)place->height) / 2;
         break;
     }
-- 
2.26.2



More information about the vlc-devel mailing list