[vlc-commits] [Git][videolan/vlc][master] 5 commits: display: reduce line length and reorder variables

Steve Lhomme (@robUx4) gitlab at videolan.org
Tue Dec 2 11:29:41 UTC 2025



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
b1d4ecf5 by Steve Lhomme at 2025-12-02T10:42:31+00:00
display: reduce line length and reorder variables

No functional changes.

- - - - -
507cb437 by Steve Lhomme at 2025-12-02T10:42:31+00:00
display: only compute the scaled dimensions when we use them

- - - - -
f4156560 by Steve Lhomme at 2025-12-02T10:42:31+00:00
vout: pass the display aspect ratio as a vlc_rational_t

So the 2 values are always tied.

- - - - -
e1d2696f by Steve Lhomme at 2025-12-02T10:42:31+00:00
video_output: remove trivial function

It didn't even mention it's the Display aspect ratio.

- - - - -
e203053a by Steve Lhomme at 2025-12-02T10:42:31+00:00
vout: rename GetAspectRatio() to vout_ParseDisplayAspectRatio()

In line with the existing vout_ParseCrop().
We also change the order of parameters to match that function.

- - - - -


5 changed files:

- src/video_output/display.c
- src/video_output/video_output.c
- src/video_output/vout_internal.h
- src/video_output/vout_intf.c
- src/video_output/vout_wrapper.h


Changes:

=====================================
src/video_output/display.c
=====================================
@@ -98,14 +98,16 @@ static void vout_display_PlaceRotatedPicture(vout_display_place_t *restrict plac
         vout_display_GetDefaultDisplaySize(&display_width, &display_height,
                                            source, dp);
 
-    const unsigned width  = source->i_visible_width;
-    const unsigned height = source->i_visible_height;
-    /* Compute the height if we use the width to fill up display_width */
-    const int64_t scaled_height = (int64_t)height * display_width  * dp->sar.num * source->i_sar_den / (width  * source->i_sar_num * dp->sar.den);
-    /* And the same but switching width/height */
-    const int64_t scaled_width  = (int64_t)width  * display_height * dp->sar.den * source->i_sar_num / (height * source->i_sar_den * dp->sar.num);
-
     if (source->projection_mode == PROJECTION_MODE_RECTANGULAR) {
+        /* Compute the height if we use the width to fill up display_width */
+        const int64_t scaled_height =
+            (int64_t)source->i_visible_height * source->i_sar_den * dp->sar.num * display_width /
+                    (source->i_visible_width  * source->i_sar_num * dp->sar.den);
+        /* And the same but switching width/height */
+        const int64_t scaled_width  =
+            (int64_t)source->i_visible_width  * source->i_sar_num * dp->sar.den * display_height /
+                    (source->i_visible_height * source->i_sar_den * dp->sar.num);
+
         bool fit_height;
 
         switch (dp->fitting) {
@@ -696,10 +698,10 @@ static int UpdateSourceSAR(vout_display_t *vd, const video_format_t *source)
     return vout_SetSourceAspect(vd, sar_num, sar_den);
 }
 
-void vout_SetDisplayAspect(vout_display_t *vd, unsigned dar_num, unsigned dar_den)
+void vout_SetDisplayAspect(vout_display_t *vd, vlc_rational_t dar)
 {
     vout_display_priv_t *osys = container_of(vd, vout_display_priv_t, display);
-    osys->dar = (vlc_rational_t){dar_num, dar_den};
+    osys->dar = dar;
 
     int err1 = UpdateSourceSAR(vd, vd->source);
     if (err1 != VLC_SUCCESS)


=====================================
src/video_output/video_output.c
=====================================
@@ -548,21 +548,13 @@ void vout_ChangeZoom(vout_thread_t *vout, unsigned num, unsigned den)
     vlc_queuedmutex_unlock(&sys->display_lock);
 }
 
-static void vout_SetAspectRatio(vout_thread_sys_t *sys,
-                                     unsigned dar_num, unsigned dar_den)
-{
-    sys->source.dar.num = dar_num;
-    sys->source.dar.den = dar_den;
-}
-
-void vout_ChangeDisplayAspectRatio(vout_thread_t *vout,
-                                   unsigned dar_num, unsigned dar_den)
+void vout_ChangeDisplayAspectRatio(vout_thread_t *vout, vlc_rational_t dar)
 {
     vout_thread_sys_t *sys = VOUT_THREAD_TO_SYS(vout);
     assert(!sys->dummy);
 
     vlc_mutex_lock(&sys->window_lock);
-    vout_SetAspectRatio(sys, dar_num, dar_den);
+    sys->source.dar = dar;
 
     vout_UpdateWindowSizeLocked(sys);
 
@@ -570,7 +562,7 @@ void vout_ChangeDisplayAspectRatio(vout_thread_t *vout,
     vlc_mutex_unlock(&sys->window_lock);
 
     if (sys->display != NULL)
-        vout_SetDisplayAspect(sys->display, dar_num, dar_den);
+        vout_SetDisplayAspect(sys->display, dar);
     vlc_queuedmutex_unlock(&sys->display_lock);
 }
 
@@ -1861,7 +1853,7 @@ static int vout_Start(vout_thread_sys_t *vout, vlc_video_context *vctx, const vo
 
     vout_display_cfg_t dcfg;
     struct vout_crop crop;
-    unsigned num, den;
+    vlc_rational_t dar;
 
     vlc_mutex_lock(&sys->window_lock);
 #ifndef NDEBUG
@@ -1876,8 +1868,7 @@ static int vout_Start(vout_thread_sys_t *vout, vlc_video_context *vctx, const vo
 
     dcfg = sys->display_cfg;
     crop = sys->source.crop;
-    num = sys->source.dar.num;
-    den = sys->source.dar.den;
+    dar = sys->source.dar;
     vlc_queuedmutex_lock(&sys->display_lock);
     vlc_mutex_unlock(&sys->window_lock);
 
@@ -1910,7 +1901,7 @@ static int vout_Start(vout_thread_sys_t *vout, vlc_video_context *vctx, const vo
 
     vout_SetDisplayCrop(sys->display, &crop);
 
-    vout_SetDisplayAspect(sys->display, num, den);
+    vout_SetDisplayAspect(sys->display, dar);
     vlc_queuedmutex_unlock(&sys->display_lock);
 
     sys->displayed.current       = NULL;
@@ -2334,8 +2325,8 @@ static void vout_InitSource(vout_thread_sys_t *vout)
     char *psz_ar = var_InheritString(&vout->obj, "aspect-ratio");
     if (psz_ar) {
         vlc_rational_t ar;
-        if (GetAspectRatio(psz_ar, &ar))
-            vout_SetAspectRatio(vout, ar.num, ar.den);
+        if (vout_ParseDisplayAspectRatio(&ar, psz_ar))
+            vout->source.dar = ar;
         free(psz_ar);
     }
 


=====================================
src/video_output/vout_internal.h
=====================================
@@ -150,7 +150,7 @@ static inline bool vout_CropEqual(const struct vout_crop *a,
 }
 
 bool vout_ParseCrop(struct vout_crop *, const char *crop_str);
-bool GetAspectRatio(const char *ar_str, vlc_rational_t *ar);
+bool vout_ParseDisplayAspectRatio(vlc_rational_t *ar, const char *ar_str);
 
 /* TODO to move them to vlc_vout.h */
 void vout_ChangeFullscreen(vout_thread_t *, const char *id);
@@ -160,7 +160,7 @@ void vout_ChangeDisplaySize(vout_thread_t *, unsigned width, unsigned height,
                             void (*ack_cb)(void *), void *opaque);
 void vout_ChangeDisplayFitting(vout_thread_t *, enum vlc_video_fitting);
 void vout_ChangeZoom(vout_thread_t *, unsigned num, unsigned den);
-void vout_ChangeDisplayAspectRatio(vout_thread_t *, unsigned num, unsigned den);
+void vout_ChangeDisplayAspectRatio(vout_thread_t *, vlc_rational_t dar);
 void vout_ChangeCrop(vout_thread_t *, const struct vout_crop *);
 void vout_ControlChangeFilters(vout_thread_t *, const char *);
 void vout_ControlChangeInterlacing(vout_thread_t *, bool);


=====================================
src/video_output/vout_intf.c
=====================================
@@ -611,7 +611,7 @@ static int CropBorderCallback(vlc_object_t *object, char const *cmd,
     return VLC_SUCCESS;
 }
 
-bool GetAspectRatio(const char *ar_str, vlc_rational_t *ar)
+bool vout_ParseDisplayAspectRatio(vlc_rational_t *ar, const char *ar_str)
 {
     if (*ar_str == '\0') {
         *ar = VLC_DAR_FROM_SOURCE;
@@ -634,8 +634,8 @@ static int AspectCallback( vlc_object_t *object, char const *cmd,
     VLC_UNUSED(cmd); VLC_UNUSED(oldval); VLC_UNUSED(data);
     vlc_rational_t ar;
 
-    if (GetAspectRatio(newval.psz_string, &ar))
-        vout_ChangeDisplayAspectRatio(vout, ar.num, ar.den);
+    if (vout_ParseDisplayAspectRatio(&ar, newval.psz_string))
+        vout_ChangeDisplayAspectRatio(vout, ar);
     return VLC_SUCCESS;
 }
 


=====================================
src/video_output/vout_wrapper.h
=====================================
@@ -33,7 +33,7 @@ void vout_FilterFlush(vout_display_t *);
 
 void vout_SetDisplayFitting(vout_display_t *, enum vlc_video_fitting);
 void vout_SetDisplayZoom(vout_display_t *, unsigned num, unsigned den);
-void vout_SetDisplayAspect(vout_display_t *, unsigned num, unsigned den);
+void vout_SetDisplayAspect(vout_display_t *, vlc_rational_t dar);
 void vout_SetDisplayCrop(vout_display_t *, const struct vout_crop *);
 void vout_SetDisplayViewpoint(vout_display_t *, const vlc_viewpoint_t *);
 int vout_SetDisplayFormat(vout_display_t *, const video_format_t *fmt,



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8af818eca9e0e33e47bd222e18f2365e415f88af...e203053a72c3488551b1e39441e9ab0e395c7d50

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8af818eca9e0e33e47bd222e18f2365e415f88af...e203053a72c3488551b1e39441e9ab0e395c7d50
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