[vlc-commits] [Git][videolan/vlc][master] 4 commits: video_widgets: really place the OSD widgets in black bars

Steve Lhomme (@robUx4) gitlab at videolan.org
Thu Jul 17 10:54:12 UTC 2025



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
0384736e by Steve Lhomme at 2025-07-17T09:47:29+00:00
video_widgets: really place the OSD widgets in black bars

Following 2df69a2b1e96a9f48ced28bea88ad11339a52e44 the widgets need
to be placed within the display area, not the video area.

We switch to unsigned for consistency with the input dimensions.

- - - - -
a0ca8b29 by Steve Lhomme at 2025-07-17T09:47:29+00:00
video_widgets: update the OSD widgets regardless of the video dimensions

The video dimensions have no impact since we display them in the whole window.
When the window is resized we need to update the regions, so we don't need to handle a cache.

- - - - -
d9779014 by Steve Lhomme at 2025-07-17T09:47:29+00:00
video_widgets: rename position OSD value

It's not a position on the screen but the value of the slider to display.

- - - - -
5648ebc8 by Steve Lhomme at 2025-07-17T09:47:29+00:00
vlc_vout_osd: use a type for the enum of OSD widgets

- - - - -


4 changed files:

- include/vlc_vout_osd.h
- src/player/osd.c
- src/player/player.h
- src/video_output/video_widgets.c


Changes:

=====================================
include/vlc_vout_osd.h
=====================================
@@ -42,7 +42,7 @@ extern "C" {
 /**
  * OSD menu position and picture type defines
  */
-enum
+typedef enum vlc_osd_widget_type
 {
     /* Icons */
     OSD_PLAY_ICON = 1,
@@ -52,7 +52,7 @@ enum
     /* Sliders */
     OSD_HOR_SLIDER,
     OSD_VERT_SLIDER,
-};
+} vlc_osd_widget_type;
 
 /**
  * \brief Show EPG information about the current program of an input item
@@ -101,7 +101,7 @@ vout_OSDMessage(vout_thread_t *vout, int channel, const char *format, ...)
  * \param i_type    Types are: OSD_HOR_SLIDER and OSD_VERT_SLIDER.
  */
 VLC_API void vout_OSDSlider( vout_thread_t *p_this, int i_channel,
-                             int i_position, short i_type);
+                             int i_position, vlc_osd_widget_type i_type);
 
 /**
  * Display an Icon on the video output.
@@ -110,7 +110,7 @@ VLC_API void vout_OSDSlider( vout_thread_t *p_this, int i_channel,
  * \param i_type    Types are: OSD_PLAY_ICON, OSD_PAUSE_ICON, OSD_SPEAKER_ICON, OSD_MUTE_ICON
  */
 VLC_API void vout_OSDIcon( vout_thread_t *p_this, int i_channel,
-                           short i_type);
+                           vlc_osd_widget_type i_type);
 
 /** @} */
 #ifdef __cplusplus


=====================================
src/player/osd.c
=====================================
@@ -71,14 +71,14 @@ vouts_osd_Message(vout_thread_t **vouts, size_t count, const char *fmt, ...)
 }
 
 static inline void
-vouts_osd_Icon(vout_thread_t **vouts, size_t count, short type)
+vouts_osd_Icon(vout_thread_t **vouts, size_t count, vlc_osd_widget_type type)
 {
     for (size_t i = 0; i < count; ++i)
         vout_OSDIcon(vouts[i], VOUT_SPU_CHANNEL_OSD, type);
 }
 
 static inline void
-vouts_osd_Slider(vout_thread_t **vouts, size_t count, int position, short type)
+vouts_osd_Slider(vout_thread_t **vouts, size_t count, int position, vlc_osd_widget_type type)
 {
     int channel = type == OSD_HOR_SLIDER ?
         VOUT_SPU_CHANNEL_OSD_HSLIDER : VOUT_SPU_CHANNEL_OSD_VSLIDER;
@@ -107,7 +107,7 @@ vlc_player_osd_Message(vlc_player_t *player, const char *fmt, ...)
 }
 
 void
-vlc_player_osd_Icon(vlc_player_t *player, short type)
+vlc_player_osd_Icon(vlc_player_t *player, vlc_osd_widget_type type)
 {
     size_t count;
     vout_thread_t **vouts = vlc_player_osd_HoldAll(player, &count);


=====================================
src/player/player.h
=====================================
@@ -26,6 +26,7 @@
 #include <vlc_vector.h>
 #include <vlc_atomic.h>
 #include <vlc_media_library.h>
+#include <vlc_vout_osd.h>
 
 #include "input/input_internal.h"
 
@@ -531,7 +532,7 @@ void
 vlc_player_osd_Message(vlc_player_t *player, const char *fmt, ...);
 
 void
-vlc_player_osd_Icon(vlc_player_t *player, short type);
+vlc_player_osd_Icon(vlc_player_t *player, vlc_osd_widget_type type);
 
 void
 vlc_player_osd_Position(vlc_player_t *player,


=====================================
src/video_output/video_widgets.c
=====================================
@@ -150,27 +150,28 @@ static subpicture_region_t *OSDRegion(int x, int y, int width, int height)
  * Types are: OSD_HOR_SLIDER and OSD_VERT_SLIDER.
  */
 #define SLIDER_MARGIN_BASE 0.10
-static subpicture_region_t *OSDSlider(int type, int position,
-                                      const video_format_t *fmt)
+static subpicture_region_t *OSDSlider(vlc_osd_widget_type type, int position,
+                                      const unsigned i_visible_width,
+                                      const unsigned i_visible_height)
 {
-    const int size = __MAX(fmt->i_visible_width, fmt->i_visible_height);
-    const int margin = size * SLIDER_MARGIN_BASE;
-    const int marginbottom = margin * 0.2;
-    const int marginright = margin * 0.5;
-    uint8_t i_padding = __MIN(1, size * 0.25); /* small sizes */
-
-    int x, y;
-    int width, height;
+    const unsigned size = __MAX(i_visible_width, i_visible_height);
+    const unsigned margin = size * SLIDER_MARGIN_BASE;
+    const unsigned marginbottom = margin * 0.2;
+    const unsigned marginright = margin * 0.5;
+    unsigned i_padding = __MIN(1, size * 0.25); /* small sizes */
+
+    unsigned x, y;
+    unsigned width, height;
     if (type == OSD_HOR_SLIDER) {
-        width  = __MAX(fmt->i_visible_width - 2 * margin, 1);
-        height = __MAX(fmt->i_visible_height * 0.01,      1);
-        x      = __MIN(fmt->i_x_offset + margin, fmt->i_visible_width - width);
-        y      = __MAX(fmt->i_y_offset + fmt->i_visible_height - marginbottom, 0);
+        width  = __MAX(i_visible_width - 2 * margin, 1);
+        height = __MAX(i_visible_height * 0.01,      1);
+        x      = __MIN(margin, i_visible_width - width);
+        y      = __MAX(i_visible_height - marginbottom, 0);
     } else {
-        width  = __MAX(fmt->i_visible_width * 0.010,       1);
-        height = __MAX(fmt->i_visible_height - 2 * margin, 1);
-        x      = __MAX(fmt->i_x_offset + fmt->i_visible_width - marginright, 0);
-        y      = __MIN(fmt->i_y_offset + margin, fmt->i_visible_height - height);
+        width  = __MAX(i_visible_width * 0.010,       1);
+        height = __MAX(i_visible_height - 2 * margin, 1);
+        x      = __MAX(i_visible_width - marginright, 0);
+        y      = __MIN(margin, i_visible_height - height);
     }
 
     if( (width < 1 + 2 * i_padding) || (height < 1 + 2 * i_padding) )
@@ -203,23 +204,25 @@ static subpicture_region_t *OSDSlider(int type, int position,
  * Create the region for an OSD slider.
  * Types are: OSD_PLAY_ICON, OSD_PAUSE_ICON, OSD_SPEAKER_ICON, OSD_MUTE_ICON
  */
-static subpicture_region_t *OSDIcon(int type, const video_format_t *fmt)
+static subpicture_region_t *OSDIcon(vlc_osd_widget_type type,
+                                    const unsigned i_visible_width,
+                                    const unsigned i_visible_height)
 {
     const unsigned int size_ratio = 20;
     const unsigned int margin_ratio = 14;
 
-    const unsigned int size   = __MAX(fmt->i_visible_width, fmt->i_visible_height);
+    const unsigned int size   = __MAX(i_visible_width, i_visible_height);
     if( size < size_ratio )
         return NULL;
 
     const unsigned int width  = size / size_ratio;
     const unsigned int height = width;
     const unsigned int margin = size / margin_ratio;
-    const int x      = fmt->i_x_offset + fmt->i_visible_width - margin - width;
-    const int y      = fmt->i_y_offset                        + margin;
+    const int x      = i_visible_width - margin - width;
+    const int y      =                   margin;
 
     subpicture_region_t *r = OSDRegion(__MAX(x, 0),
-                                       __MIN(y, (int)fmt->i_visible_height - (int)height),
+                                       __MIN(y, (int)i_visible_height - (int)height),
                                        width, height);
     if (!r)
         return NULL;
@@ -250,8 +253,8 @@ static subpicture_region_t *OSDIcon(int type, const video_format_t *fmt)
 }
 
 typedef struct {
-    int type;
-    int position;
+    vlc_osd_widget_type type;
+    int value;
 } osdwidget_spu_updater_sys_t;
 
 static void OSDWidgetUpdate(subpicture_t *subpic,
@@ -259,26 +262,15 @@ static void OSDWidgetUpdate(subpicture_t *subpic,
 {
     osdwidget_spu_updater_sys_t *sys = subpic->updater.sys;
     subpicture_region_t *p_region;
-    const video_format_t *fmt_dst = cfg->video_dst;
-
-    if (video_format_IsSimilar(cfg->prev_dst, fmt_dst))
-        return;
 
     vlc_spu_regions_Clear( &subpic->regions );
 
-    video_format_t fmt = *fmt_dst;
-    fmt.i_width         = fmt.i_width         * fmt.i_sar_num / fmt.i_sar_den;
-    fmt.i_visible_width = fmt.i_visible_width * fmt.i_sar_num / fmt.i_sar_den;
-    fmt.i_x_offset      = fmt.i_x_offset      * fmt.i_sar_num / fmt.i_sar_den;
-    fmt.i_sar_num       = 1;
-    fmt.i_sar_den       = 1;
-
-    subpic->i_original_picture_width  = fmt.i_visible_width;
-    subpic->i_original_picture_height = fmt.i_visible_height;
+    subpic->i_original_picture_width  = cfg->display_width;
+    subpic->i_original_picture_height = cfg->display_height;
     if (sys->type == OSD_HOR_SLIDER || sys->type == OSD_VERT_SLIDER)
-        p_region = OSDSlider(sys->type, sys->position, &fmt);
+        p_region = OSDSlider(sys->type, sys->value, cfg->display_width, cfg->display_height);
     else
-        p_region = OSDIcon(sys->type, &fmt);
+        p_region = OSDIcon(sys->type, cfg->display_width, cfg->display_height);
     if (p_region)
     {
         p_region->b_absolute = true;
@@ -292,7 +284,7 @@ static void OSDWidgetDestroy(subpicture_t *subpic)
     free(subpic->updater.sys);
 }
 
-static void OSDWidget(vout_thread_t *vout, int channel, int type, int position)
+static void OSDWidget(vout_thread_t *vout, int channel, vlc_osd_widget_type type, int position)
 {
     if (!var_InheritBool(vout, "osd"))
         return;
@@ -303,7 +295,7 @@ static void OSDWidget(vout_thread_t *vout, int channel, int type, int position)
     if (!sys)
         return;
     sys->type     = type;
-    sys->position = position;
+    sys->value    = position;
 
     static const struct vlc_spu_updater_ops spu_ops =
     {
@@ -330,12 +322,12 @@ static void OSDWidget(vout_thread_t *vout, int channel, int type, int position)
     vout_PutSubpicture(vout, subpic);
 }
 
-void vout_OSDSlider(vout_thread_t *vout, int channel, int position, short type)
+void vout_OSDSlider(vout_thread_t *vout, int channel, int position, vlc_osd_widget_type type)
 {
     OSDWidget(vout, channel, type, position);
 }
 
-void vout_OSDIcon(vout_thread_t *vout, int channel, short type )
+void vout_OSDIcon(vout_thread_t *vout, int channel, vlc_osd_widget_type type )
 {
     OSDWidget(vout, channel, type, 0);
 }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/83d8cef9cfc4ef373f7e3562cf6c001d8bc44b9f...5648ebc8c5d153b005debf20d64ba6a9150b5e9f

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/83d8cef9cfc4ef373f7e3562cf6c001d8bc44b9f...5648ebc8c5d153b005debf20d64ba6a9150b5e9f
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