[vlc-devel] [PATCH v3 09/14] libvlc: allow selecting the video hardware acceleration
Thomas Guillem
thomas at gllm.fr
Mon Feb 17 11:24:52 CET 2020
On Thu, Feb 13, 2020, at 16:44, Steve Lhomme wrote:
> The values in the enum reflect the currently available decoder devices.
> ---
> include/vlc/libvlc_media_player.h | 53 +++++++++++++++++++++++++++++++
> lib/libvlc.sym | 1 +
> lib/media_player.c | 22 +++++++++++++
> 3 files changed, 76 insertions(+)
>
> diff --git a/include/vlc/libvlc_media_player.h
> b/include/vlc/libvlc_media_player.h
> index 5e0255a10ac..ad19c383a0c 100644
> --- a/include/vlc/libvlc_media_player.h
> +++ b/include/vlc/libvlc_media_player.h
> @@ -503,6 +503,59 @@ void libvlc_video_set_format_callbacks(
> libvlc_media_player_t *mp,
> libvlc_video_cleanup_cb
> cleanup );
>
>
> +/**
> + * Enumeration of the Video hardware processing acceleration to be
> used.
> + * can be passed to @a libvlc_video_set_video_acceleration
> + */
> +typedef enum libvlc_video_acceleration_t {
> + /** Pick the best hardware decoder/processor for the source
> material */
> + libvlc_video_acceleration_default,
> +
> + /** Only software processing of video */
> + libvlc_video_acceleration_disable,
> +
> + /** NVIDIA based video decoding (Windows, Linux) */
> + libvlc_video_acceleration_nvdec,
> +
> + /** Direct3D11 video decoding/processing (Windows) */
> + libvlc_video_acceleration_d3d11,
> +
> + /** DXVA2 video decoding/processing (Windows) */
> + libvlc_video_acceleration_dxva2,
> +
> + /** VAAPI based decoding/processing (Linux) */
> + libvlc_video_acceleration_vaapi,
> +
> + /** VDPAU based decoding/processing (Linux) */
> + libvlc_video_acceleration_vdpau,
> +
> + /** Mediacodec based decoding (Android) */
> + libvlc_video_acceleration_mediacodec,
> +
> + /** VideoToolbox based decoding/processing (macOS, iOS, tvOS) */
> + libvlc_video_acceleration_videotoolbox,
> +
> + /** MMAL based decoding/processing (Raspberry Pi) */
> + libvlc_video_acceleration_mmal,
> +} libvlc_video_acceleration_t;
> +
> +/**
> + * Set the hardware acceleration system to use to decode videos.
> + *
> + * Not all videos might be decoded through the selected mode depending
> on the
> + * hardware and the source material.
> + *
> + * Selecting an unsupported mode for the platform or video source will
> result
> + * in the video being decoded/processing in software.
> + *
> + * \param mode hardware acceleration system to use
> + *
> + * \version LibVLC 4.0.0 or later
> + */
> +LIBVLC_API
> +void libvlc_video_set_video_acceleration( libvlc_media_player_t *mp,
> + libvlc_video_acceleration_t
libvlc_video_set_video...() seems weird
I propose libvlc_video_set_hw_acceleration().
What about just using a string instead of the enum ?
> mode );
> +
> typedef struct
> {
> bool hardware_decoding; /** set if
> D3D11_CREATE_DEVICE_VIDEO_SUPPORT is needed for D3D11 */
> diff --git a/lib/libvlc.sym b/lib/libvlc.sym
> index 67e4dcf7482..4e815bc4bd8 100644
> --- a/lib/libvlc.sym
> +++ b/lib/libvlc.sym
> @@ -239,6 +239,7 @@ libvlc_video_set_deinterlace
> libvlc_video_set_format
> libvlc_video_set_format_callbacks
> libvlc_video_set_output_callbacks
> +libvlc_video_set_video_acceleration
> libvlc_video_set_key_input
> libvlc_video_set_logo_int
> libvlc_video_set_logo_string
> diff --git a/lib/media_player.c b/lib/media_player.c
> index b64307aa720..077b3077f5b 100644
> --- a/lib/media_player.c
> +++ b/lib/media_player.c
> @@ -1033,6 +1033,28 @@ void libvlc_video_set_format(
> libvlc_media_player_t *mp, const char *chroma,
> var_SetInteger( mp, "vmem-pitch", pitch );
> }
>
> +void libvlc_video_set_video_acceleration( libvlc_media_player_t *mp,
> + libvlc_video_acceleration_t mode )
> +{
> + const char *dec_dev;
> + switch(mode)
> + {
> + case libvlc_video_acceleration_default: dec_dev = "";
> + case libvlc_video_acceleration_disable: dec_dev = "none";
> + case libvlc_video_acceleration_nvdec: dec_dev = "nvdec";
> + case libvlc_video_acceleration_d3d11: dec_dev = "d3d11";
> + case libvlc_video_acceleration_dxva2: dec_dev = "dxva2";
> + case libvlc_video_acceleration_vaapi: dec_dev = "vaapi";
> + case libvlc_video_acceleration_vdpau: dec_dev = "vdpau";
> + case libvlc_video_acceleration_mediacodec: dec_dev = "android";
> + case libvlc_video_acceleration_videotoolbox: dec_dev = "videotoolbox";
> + case libvlc_video_acceleration_mmal: dec_dev = "mmal";
> + default:
> + vlc_assert_unreachable();
> + }
> + var_SetString ( mp, "dec-dev", dec_dev );
> +}
> +
> bool libvlc_video_set_output_callbacks(libvlc_media_player_t *mp,
> libvlc_video_engine_t engine,
> libvlc_video_output_setup_cb setup_cb,
> --
> 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