[vlc-devel] [PATCH] libvlc: rename the aspect ratio setter and remove the getter
Thomas Guillem
thomas at gllm.fr
Mon Jun 3 08:45:16 CEST 2019
Nit: split the commit in two.
On Mon, Jun 3, 2019, at 08:43, Steve Lhomme wrote:
> 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 | 16 +++++-----------
> lib/libvlc.sym | 3 +--
> lib/video.c | 21 ++++++++++++---------
> 3 files changed, 18 insertions(+), 22 deletions(-)
>
> diff --git a/include/vlc/libvlc_media_player.h
> b/include/vlc/libvlc_media_player.h
> index d04b57f01e..8b8941c2de 100644
> --- a/include/vlc/libvlc_media_player.h
> +++ b/include/vlc/libvlc_media_player.h
> @@ -1486,23 +1486,17 @@ LIBVLC_API float libvlc_video_get_scale(
> libvlc_media_player_t *p_mi );
> */
> LIBVLC_API void libvlc_video_set_scale( libvlc_media_player_t *p_mi,
> float f_factor );
>
> -/**
> - * Get current video aspect ratio.
> - *
> - * \param p_mi the media player
> - * \return the video aspect ratio or NULL if unspecified
> - * (the result must be released with free() or libvlc_free()).
> - */
> -LIBVLC_API char *libvlc_video_get_aspect_ratio( libvlc_media_player_t
> *p_mi );
> -
> /**
> * 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 01d3c8f72c..58c5221a47 100644
> --- a/lib/libvlc.sym
> +++ b/lib/libvlc.sym
> @@ -218,7 +218,6 @@ libvlc_toggle_fullscreen
> libvlc_track_description_list_release
> libvlc_video_get_adjust_float
> libvlc_video_get_adjust_int
> -libvlc_video_get_aspect_ratio
> libvlc_video_get_crop_geometry
> libvlc_video_get_size
> libvlc_video_get_cursor
> @@ -235,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 b3c36b1cbc..0795bb11c7 100644
> --- a/lib/video.c
> +++ b/lib/video.c
> @@ -229,18 +229,20 @@ void libvlc_video_set_scale(
> libvlc_media_player_t *p_mp, float f_scale )
> free (pp_vouts);
> }
>
> -char *libvlc_video_get_aspect_ratio( libvlc_media_player_t *p_mi )
> +void libvlc_video_set_sample_aspect_ratio( libvlc_media_player_t *p_mi,
> + unsigned numerator,
> + unsigned denominator )
> {
> - return var_GetNonEmptyString (p_mi, "aspect-ratio");
> -}
>
> -void libvlc_video_set_aspect_ratio( libvlc_media_player_t *p_mi,
> - const char *psz_aspect )
> -{
> - if (psz_aspect == NULL)
> - psz_aspect = "";
> - var_SetString (p_mi, "aspect-ratio", psz_aspect);
> + char *psz_aspect;
> + if (denominator == 0 || numerator == 0)
> + {
> + numerator = denominator = 0;
> + }
>
> + if (asprintf(&psz_aspect, "%d:%d", numerator, denominator) == -1 )
> + return;
> + var_SetString(p_mi, "aspect-ratio", psz_aspect);
> size_t n;
> vout_thread_t **pp_vouts = GetVouts (p_mi, &n);
> for (size_t i = 0; i < n; i++)
> @@ -251,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
More information about the vlc-devel
mailing list