[vlc-devel] [PATCH v4 1/7] libvlc: allow selecting the video hardware acceleration

Steve Lhomme robux4 at ycbcr.xyz
Fri Mar 13 13:28:32 CET 2020


Pass a string matching one of the decoder device strings.
---
 include/vlc/libvlc_media_player.h | 30 ++++++++++++++++++++++++++++++
 lib/libvlc.sym                    |  1 +
 lib/media_player.c                |  6 ++++++
 3 files changed, 37 insertions(+)

diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 5e0255a10ac..1d66858d28f 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -503,6 +503,36 @@ 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_hw_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,
+} 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 like "any", "none", "dxva2",
+ *             "d3d11", "nvdec", "vdpau", etc.
+ *
+ * \version LibVLC 4.0.0 or later
+ */
+LIBVLC_API
+void libvlc_video_set_hw_acceleration( libvlc_media_player_t *mp,
+                                       const char * 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..159c67f7693 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_hw_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 96af310c340..50d49336403 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -1033,6 +1033,12 @@ void libvlc_video_set_format( libvlc_media_player_t *mp, const char *chroma,
     var_SetInteger( mp, "vmem-pitch", pitch );
 }
 
+void libvlc_video_set_hw_acceleration( libvlc_media_player_t *mp,
+                                       const char * mode )
+{
+    var_SetString ( mp, "dec-dev", mode );
+}
+
 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



More information about the vlc-devel mailing list