Browse Source

Add mac hardware video decoder (#9270)

* VideoSettings: Add MAC VideoToolbox decoder

Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>

* GSteamer: Use VideoDecodeOptions enum over bool check

Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
QGC4.4
Patrick José Pereira 4 years ago committed by GitHub
parent
commit
19aac921cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/Settings/Video.SettingsGroup.json
  2. 16
      src/Settings/VideoSettings.cc
  3. 1
      src/Settings/VideoSettings.h
  4. 6
      src/VideoManager/VideoManager.cc
  5. 52
      src/VideoReceiver/GStreamer.cc
  6. 3
      src/VideoReceiver/GStreamer.h

4
src/Settings/Video.SettingsGroup.json

@ -134,8 +134,8 @@ @@ -134,8 +134,8 @@
"shortDesc": "Force specific category of video decode",
"longDesc": "Force the change of prioritization between video decode methods, allowing the user to force some video hardware decode plugins if necessary.",
"type": "uint32",
"enumStrings": "Default,Force software decoder,Force NVIDIA decoder,Force VA-API decoder,Force DirectX3D 11 decoder",
"enumValues": "0,1,2,3,4",
"enumStrings": "Default,Force software decoder,Force NVIDIA decoder,Force VA-API decoder,Force DirectX3D 11 decoder,Force VideoToolbox decoder",
"enumValues": "0,1,2,3,4,5",
"default": 0,
"qgcRebootRequired": true
}

16
src/Settings/VideoSettings.cc

@ -67,9 +67,15 @@ DECLARE_SETTINGGROUP(Video, "Video") @@ -67,9 +67,15 @@ DECLARE_SETTINGGROUP(Video, "Video")
const QVariantList removeForceVideoDecodeList{
#ifdef Q_OS_LINUX
VideoDecoderOptions::ForceVideoDecoderDirectX3D,
VideoDecoderOptions::ForceVideoDecoderVideoToolbox,
#endif
#ifdef Q_OS_WIN
VideoDecoderOptions::ForceVideoDecoderVAAPI,
VideoDecoderOptions::ForceVideoDecoderVideoToolbox,
#endif
#ifdef Q_OS_MAC
VideoDecoderOptions::ForceVideoDecoderDirectX3D,
VideoDecoderOptions::ForceVideoDecoderVAAPI,
#endif
};
@ -125,13 +131,13 @@ DECLARE_SETTINGSFACT_NO_FUNC(VideoSettings, forceVideoDecoder) @@ -125,13 +131,13 @@ DECLARE_SETTINGSFACT_NO_FUNC(VideoSettings, forceVideoDecoder)
_forceVideoDecoderFact = _createSettingsFact(forceVideoDecoderName);
_forceVideoDecoderFact->setVisible(
#ifdef Q_OS_LINUX
true
#else
#ifdef Q_OS_WIN
true
#ifdef Q_OS_IOS
false
#else
#ifdef Q_OS_ANDROID
false
#else
true
#endif
#endif
);

1
src/Settings/VideoSettings.h

@ -43,6 +43,7 @@ public: @@ -43,6 +43,7 @@ public:
ForceVideoDecoderNVIDIA,
ForceVideoDecoderVAAPI,
ForceVideoDecoderDirectX3D,
ForceVideoDecoderVideoToolbox,
};
Q_ENUM(VideoDecoderOptions)

6
src/VideoManager/VideoManager.cc

@ -105,11 +105,7 @@ VideoManager::setToolbox(QGCToolbox *toolbox) @@ -105,11 +105,7 @@ VideoManager::setToolbox(QGCToolbox *toolbox)
connect(pVehicleMgr, &MultiVehicleManager::activeVehicleChanged, this, &VideoManager::_setActiveVehicle);
#if defined(QGC_GST_STREAMING)
bool forceSoftware = _videoSettings->forceVideoDecoder()->rawValue() == VideoSettings::VideoDecoderOptions::ForceVideoDecoderSoftware;
bool forceNVIDIA = _videoSettings->forceVideoDecoder()->rawValue() == VideoSettings::VideoDecoderOptions::ForceVideoDecoderNVIDIA;
bool forceVAAPI = _videoSettings->forceVideoDecoder()->rawValue() == VideoSettings::VideoDecoderOptions::ForceVideoDecoderVAAPI;
bool forceD3D11 = _videoSettings->forceVideoDecoder()->rawValue() == VideoSettings::VideoDecoderOptions::ForceVideoDecoderDirectX3D;
GStreamer::blacklist(forceSoftware, forceVAAPI, forceNVIDIA, forceD3D11);
GStreamer::blacklist(static_cast<VideoSettings::VideoDecoderOptions>(_videoSettings->forceVideoDecoder()->rawValue().toInt()));
#ifndef QGC_DISABLE_UVC
// If we are using a UVC camera setup the device name
_updateUVC();

52
src/VideoReceiver/GStreamer.cc

@ -106,7 +106,7 @@ static void qgcputenv(const QString& key, const QString& root, const QString& pa @@ -106,7 +106,7 @@ static void qgcputenv(const QString& key, const QString& root, const QString& pa
#endif
void
GStreamer::blacklist(bool forceSoftware, bool forceVAAPI, bool forceNVIDIA, bool forceD3D11)
GStreamer::blacklist(VideoSettings::VideoDecoderOptions option)
{
GstRegistry* registry = gst_registry_get();
@ -131,30 +131,32 @@ GStreamer::blacklist(bool forceSoftware, bool forceVAAPI, bool forceNVIDIA, bool @@ -131,30 +131,32 @@ GStreamer::blacklist(bool forceSoftware, bool forceVAAPI, bool forceNVIDIA, bool
// Set rank for specific features
changeRank("bcmdec", GST_RANK_NONE);
// Force software decode
if (forceSoftware) {
changeRank("avdec_h264", GST_RANK_PRIMARY + 1);
}
// Enable VAAPI drivers
if (forceVAAPI) {
for(auto name : {"vaapimpeg2dec", "vaapimpeg4dec", "vaapih263dec", "vaapih264dec", "vaapivc1dec"}) {
changeRank(name, GST_RANK_PRIMARY + 1);
}
}
// Enable NVIDIA's proprietary APIs for hardware video acceleration
if (forceNVIDIA) {
for(auto name : {"nvh265dec", "nvh265sldec", "nvh264dec", "nvh264sldec"}) {
changeRank(name, GST_RANK_PRIMARY + 1);
}
}
// Enable DirectX3D 11 decoders
if (forceD3D11) {
for(auto name : {"d3d11vp9dec", "d3d11h265dec", "d3d11h264dec"}) {
changeRank(name, GST_RANK_PRIMARY + 1);
}
switch (option) {
case VideoSettings::ForceVideoDecoderDefault:
break;
case VideoSettings::ForceVideoDecoderSoftware:
changeRank("avdec_h264", GST_RANK_PRIMARY + 1);
break;
case VideoSettings::ForceVideoDecoderVAAPI:
for(auto name : {"vaapimpeg2dec", "vaapimpeg4dec", "vaapih263dec", "vaapih264dec", "vaapivc1dec"}) {
changeRank(name, GST_RANK_PRIMARY + 1);
}
break;
case VideoSettings::ForceVideoDecoderNVIDIA:
for(auto name : {"nvh265dec", "nvh265sldec", "nvh264dec", "nvh264sldec"}) {
changeRank(name, GST_RANK_PRIMARY + 1);
}
break;
case VideoSettings::ForceVideoDecoderDirectX3D:
for(auto name : {"d3d11vp9dec", "d3d11h265dec", "d3d11h264dec"}) {
changeRank(name, GST_RANK_PRIMARY + 1);
}
break;
case VideoSettings::ForceVideoDecoderVideoToolbox:
changeRank("vtdec", GST_RANK_PRIMARY + 1);
break;
default:
qCWarning(GStreamerLog) << "Can't handle decode option:" << option;
}
}

3
src/VideoReceiver/GStreamer.h

@ -4,10 +4,11 @@ @@ -4,10 +4,11 @@
#include <QQuickItem>
#include "VideoReceiver.h"
#include "VideoSettings.h"
class GStreamer {
public:
static void blacklist(bool forceSoftware = false, bool forceVAAPI = false, bool forceNVIDIA = false, bool forceD3D11 = false);
static void blacklist(VideoSettings::VideoDecoderOptions option);
static void initialize(int argc, char* argv[], int debuglevel);
static void* createVideoSink(QObject* parent, QQuickItem* widget);
static void releaseVideoSink(void* sink);

Loading…
Cancel
Save