[vlc-devel] [PATCH 2/2] libvlc: rename the aspect ratio setter and use a fraction

Rémi Denis-Courmont remi at remlab.net
Mon Jun 3 20:36:02 CEST 2019


Hi,

I think this function sets the display ratio, not the sample ratio though.

Le 3 juin 2019 07:57:14 GMT+01:00, Steve Lhomme <robux4 at ycbcr.xyz> a écrit :
>Using sample in the name is more accurate than just an "aspect ratio",
>even
>though that's probably the one most people know.
>---
> include/vlc/libvlc_media_player.h |  7 +++++--
> lib/libvlc.sym                    |  2 +-
> lib/video.c                       | 16 ++++++++++++----
> 3 files changed, 18 insertions(+), 7 deletions(-)
>
>diff --git a/include/vlc/libvlc_media_player.h
>b/include/vlc/libvlc_media_player.h
>index 6ee926e362..8b8941c2de 100644
>--- a/include/vlc/libvlc_media_player.h
>+++ b/include/vlc/libvlc_media_player.h
>@@ -1490,10 +1490,13 @@ LIBVLC_API void libvlc_video_set_scale(
>libvlc_media_player_t *p_mi, float f_fac
>  * Set new video aspect ratio.
>  *
>  * \param p_mi the media player
>- * \param psz_aspect new video aspect-ratio or NULL to reset to
>default
>+ * \param numerator new video aspect-ratio numerator or 0 to reset to
>default
>+ * \param denominator new video aspect-ratio numerator or 0 to reset
>to default
>  * \note Invalid aspect ratios are ignored.
>  */
>-LIBVLC_API void libvlc_video_set_aspect_ratio( libvlc_media_player_t
>*p_mi, const char *psz_aspect );
>+LIBVLC_API void libvlc_video_set_sample_aspect_ratio(
>libvlc_media_player_t *p_mi,
>+                                                      unsigned
>numerator,
>+                                                      unsigned
>denominator );
> 
> /**
>  * Create a video viewpoint structure.
>diff --git a/lib/libvlc.sym b/lib/libvlc.sym
>index 888c385a16..58c5221a47 100644
>--- a/lib/libvlc.sym
>+++ b/lib/libvlc.sym
>@@ -234,7 +234,7 @@ libvlc_video_get_track_count
> libvlc_video_get_track_description
> libvlc_video_set_adjust_float
> libvlc_video_set_adjust_int
>-libvlc_video_set_aspect_ratio
>+libvlc_video_set_sample_aspect_ratio
> libvlc_video_set_callbacks
> libvlc_video_set_crop_geometry
> libvlc_video_set_deinterlace
>diff --git a/lib/video.c b/lib/video.c
>index e87ded45fc..fa6985c012 100644
>--- a/lib/video.c
>+++ b/lib/video.c
>@@ -229,11 +229,18 @@ void libvlc_video_set_scale(
>libvlc_media_player_t *p_mp, float f_scale )
>     free (pp_vouts);
> }
> 
>-void libvlc_video_set_aspect_ratio( libvlc_media_player_t *p_mi,
>-                                    const char *psz_aspect )
>+void libvlc_video_set_sample_aspect_ratio( libvlc_media_player_t
>*p_mi,
>+                                           unsigned numerator,
>+                                           unsigned denominator )
> {
>-    if (psz_aspect == NULL)
>-        psz_aspect = "";
>+    if (denominator == 0 || numerator == 0)
>+    {
>+        numerator = denominator = 0;
>+    }
>+
>+    char *psz_aspect;
>+    if (unlikely(asprintf(&psz_aspect, "%u:%u", numerator,
>denominator) == -1))
>+        return;
>     var_SetString (p_mi, "aspect-ratio", psz_aspect);
> 
>     size_t n;
>@@ -246,6 +253,7 @@ void libvlc_video_set_aspect_ratio(
>libvlc_media_player_t *p_mi,
>         vout_Release(p_vout);
>     }
>     free (pp_vouts);
>+    free(psz_aspect);
> }
> 
> libvlc_video_viewpoint_t *libvlc_video_new_viewpoint(void)
>-- 
>2.17.1
>
>_______________________________________________
>vlc-devel mailing list
>To unsubscribe or modify your subscription options:
>https://mailman.videolan.org/listinfo/vlc-devel

-- 
Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20190603/9d3a6659/attachment.html>


More information about the vlc-devel mailing list