[vlc-commits] chromecast: try to encode with QSV if possible

Steve Lhomme git at videolan.org
Thu Apr 5 16:07:31 CEST 2018


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Thu Apr  5 09:49:44 2018 +0200| [74ff08ca3b101b98103df5c85b800b671f44e9e7] | committer: Steve Lhomme

chromecast: try to encode with QSV if possible

It will be handled by the GPU so use less resource.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=74ff08ca3b101b98103df5c85b800b671f44e9e7
---

 modules/stream_out/chromecast/cast.cpp | 40 ++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/modules/stream_out/chromecast/cast.cpp b/modules/stream_out/chromecast/cast.cpp
index 625b9306f9..8b1c690dd2 100644
--- a/modules/stream_out/chromecast/cast.cpp
+++ b/modules/stream_out/chromecast/cast.cpp
@@ -929,6 +929,45 @@ static std::string GetVencVPXOption( sout_stream_t * /* p_stream */,
     return "venc=vpx{quality-mode=1}";
 }
 
+static std::string GetVencQSVH264Option( sout_stream_t * /* p_stream */,
+                                         const video_format_t * /* p_vid */,
+                                         int i_quality )
+{
+    std::stringstream ssout;
+    static const char video_target_usage_quality[]  = "quality";
+    static const char video_target_usage_balanced[] = "balanced";
+    static const char video_target_usage_speed[]    = "speed";
+    static const char video_bitrate_high[] = "vb=8000000";
+    static const char video_bitrate_low[]  = "vb=3000000";
+    const char *psz_video_target_usage;
+    const char *psz_video_bitrate;
+
+    switch ( i_quality )
+    {
+        case CONVERSION_QUALITY_HIGH:
+            psz_video_target_usage = video_target_usage_quality;
+            psz_video_bitrate = video_bitrate_high;
+            break;
+        case CONVERSION_QUALITY_MEDIUM:
+            psz_video_target_usage = video_target_usage_balanced;
+            psz_video_bitrate = video_bitrate_high;
+            break;
+        case CONVERSION_QUALITY_LOW:
+            psz_video_target_usage = video_target_usage_balanced;
+            psz_video_bitrate = video_bitrate_low;
+            break;
+        default:
+        case CONVERSION_QUALITY_LOWCPU:
+            psz_video_target_usage = video_target_usage_speed;
+            psz_video_bitrate = video_bitrate_low;
+            break;
+    }
+
+    ssout << "venc=qsv{target-usage=" << psz_video_target_usage <<
+             "}," << psz_video_bitrate;
+    return ssout.str();
+}
+
 static std::string GetVencX264Option( sout_stream_t * /* p_stream */,
                                       const video_format_t *p_vid,
                                       int i_quality )
@@ -1008,6 +1047,7 @@ static struct
 #ifdef __APPLE__
     { .fcc = VLC_CODEC_H264, .get_opt = GetVencAvcodecVTOption },
 #endif
+    { .fcc = VLC_CODEC_H264, .get_opt = GetVencQSVH264Option },
     { .fcc = VLC_CODEC_H264, .get_opt = GetVencX264Option },
     { .fcc = VLC_CODEC_VP8,  .get_opt = GetVencVPXOption },
     { .fcc = VLC_CODEC_H264, .get_opt = NULL },



More information about the vlc-commits mailing list