[vlc-commits] [Git][videolan/vlc][master] 3 commits: display: remove unnecessary #include

Rémi Denis-Courmont (@Courmisch) gitlab at videolan.org
Tue Dec 21 08:57:58 UTC 2021



Rémi Denis-Courmont pushed to branch master at VideoLAN / VLC


Commits:
45b0e4cc by Rémi Denis-Courmont at 2021-12-21T08:36:14+00:00
display: remove unnecessary #include

- - - - -
725d056c by Rémi Denis-Courmont at 2021-12-21T08:36:14+00:00
display: split function for translating coordinates

- - - - -
c75fca11 by Rémi Denis-Courmont at 2021-12-21T08:36:14+00:00
vout: don't stop already stopped display

The display cannot be started if the window is not enabled first.
If enabling the window failed, we can infer that the display was not
started, so there is no point trying to stop it.

- - - - -


3 changed files:

- include/vlc_vout_display.h
- src/video_output/display.c
- src/video_output/video_output.c


Changes:

=====================================
include/vlc_vout_display.h
=====================================
@@ -501,6 +501,21 @@ 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);
 
+/**
+ * Translates coordinates.
+ *
+ * This translates coordinates from window pixel coordinate space to
+ * original video sample coordinate space.
+ *
+ * \param x pointer to abscissa to be translated
+ * \param y pointer to ordinate to be translated
+ * \param fmt video format
+ * \param cfg display configuration
+ */
+void vout_display_TranslateCoordinates(int *x, int *y,
+                                       const video_format_t *fmt,
+                                       const vout_display_cfg_t *cfg);
+
 /**
  * Translates mouse state.
  *


=====================================
src/video_output/display.c
=====================================
@@ -41,7 +41,6 @@
 #include <libvlc.h>
 
 #include "display.h"
-#include "window.h"
 #include "vout_internal.h"
 
 /*****************************************************************************
@@ -201,23 +200,22 @@ void vout_display_PlacePicture(vout_display_place_t *place,
     }
 }
 
-void vout_display_TranslateMouseState(vout_display_t *vd, vlc_mouse_t *video,
-                                      const vlc_mouse_t *window)
+/** Translates window coordinates to video coordinates */
+void vout_display_TranslateCoordinates(int *restrict xp, int *restrict yp,
+                                       const video_format_t *restrict source,
+                                       const vout_display_cfg_t *restrict cfg)
 {
     vout_display_place_t place;
 
-    /* Translate window coordinates to video coordinates */
-    vout_display_PlacePicture(&place, vd->source, vd->cfg);
+    vout_display_PlacePicture(&place, source, cfg);
 
-    if (place.width <= 0 || place.height <= 0) {
-        memset(video, 0, sizeof (*video));
+    if (place.width <= 0 || place.height <= 0)
         return;
-    }
 
-    const int wx = window->i_x, wy = window->i_y;
+    const int wx = *xp, wy = *yp;
     int x, y;
 
-    switch (vd->source->orientation) {
+    switch (source->orientation) {
         case ORIENT_TOP_LEFT:
             x = wx;
             y = wy;
@@ -254,12 +252,20 @@ void vout_display_TranslateMouseState(vout_display_t *vd, vlc_mouse_t *video,
             vlc_assert_unreachable();
     }
 
-    video->i_x = vd->source->i_x_offset
-        + (int64_t)(x - place.x) * vd->source->i_visible_width / place.width;
-    video->i_y = vd->source->i_y_offset
-        + (int64_t)(y - place.y) * vd->source->i_visible_height / place.height;
-    video->i_pressed = window->i_pressed;
-    video->b_double_click = window->b_double_click;
+    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;
+    *xp = x;
+    *yp = y;
+}
+
+void vout_display_TranslateMouseState(vout_display_t *vd, vlc_mouse_t *video,
+                                      const vlc_mouse_t *window)
+{
+    *video = *window;
+    vout_display_TranslateCoordinates(&video->i_x, &video->i_y, vd->source,
+                                      vd->cfg);
 }
 
 typedef struct {


=====================================
src/video_output/video_output.c
=====================================
@@ -2175,8 +2175,11 @@ int vout_Request(const vout_configuration_t *cfg, vlc_video_context *vctx, input
     assert(cfg->fmt != NULL);
     assert(cfg->clock != NULL);
 
-    if (!VoutCheckFormat(cfg->fmt))
-        goto error_stop_display;
+    if (!VoutCheckFormat(cfg->fmt)) {
+        if (sys->display != NULL)
+            vout_StopDisplay(cfg->vout);
+        return -1;
+    }
 
     video_format_t original;
     VoutFixFormat(&original, cfg->fmt);
@@ -2196,7 +2199,8 @@ int vout_Request(const vout_configuration_t *cfg, vlc_video_context *vctx, input
         msg_Err(cfg->vout, "failed to enable window");
         video_format_Clean(&original);
         vlc_mutex_unlock(&sys->window_lock);
-        goto error_stop_display;
+        assert(sys->display == NULL);
+        return -1;
     }
     vlc_mutex_unlock(&sys->window_lock);
 
@@ -2230,11 +2234,6 @@ int vout_Request(const vout_configuration_t *cfg, vlc_video_context *vctx, input
         spu_Attach(sys->spu, input);
     vout_IntfReinit(cfg->vout);
     return 0;
-
-error_stop_display:
-    if (sys->display != NULL)
-        vout_StopDisplay(cfg->vout);
-    return -1;
 }
 
 vlc_decoder_device *vout_GetDevice(vout_thread_t *vout)



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/ef44713140dd7850dd1e7c03ff134f018628516b...c75fca115ea251ec296f3da76fe5b1259ab24216

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/ef44713140dd7850dd1e7c03ff134f018628516b...c75fca115ea251ec296f3da76fe5b1259ab24216
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list