[vlc-devel] [PATCH 2/2] libvlc: rename the aspect ratio setter and use a fraction
Steve Lhomme
robux4 at ycbcr.xyz
Tue Jun 4 11:03:45 CEST 2019
On 2019-06-03 20:36, Rémi Denis-Courmont wrote:
> Hi,
>
> I think this function sets the display ratio, not the sample ratio though.
The callback calls vout_ChangeSampleAspectRatio(), so either this name
is wrong or it's really the SAR.
> 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)
>
>
> --
> Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser
> ma brièveté.
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
>
More information about the vlc-devel
mailing list