summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar liushuyu2021-11-29 16:47:24 -0700
committerGravatar liushuyu2021-12-02 21:01:34 -0700
commit20a46790d7059c7fa8efeb1c95e62a57d97e42e3 (patch)
tree716206d9dd8c0fb61efad5de1ed295a0b8dd3dec /src
parentvideo_core/codecs: more robust ffmpeg hwdecoder selection logic (diff)
downloadyuzu-20a46790d7059c7fa8efeb1c95e62a57d97e42e3.tar.gz
yuzu-20a46790d7059c7fa8efeb1c95e62a57d97e42e3.tar.xz
yuzu-20a46790d7059c7fa8efeb1c95e62a57d97e42e3.zip
video_core/codec: address comments
Diffstat (limited to 'src')
-rw-r--r--src/video_core/command_classes/codecs/codec.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/video_core/command_classes/codecs/codec.cpp b/src/video_core/command_classes/codecs/codec.cpp
index 1949a8cf3..2c0d8da64 100644
--- a/src/video_core/command_classes/codecs/codec.cpp
+++ b/src/video_core/command_classes/codecs/codec.cpp
@@ -23,14 +23,17 @@ namespace Tegra {
23namespace { 23namespace {
24constexpr AVPixelFormat PREFERRED_GPU_FMT = AV_PIX_FMT_NV12; 24constexpr AVPixelFormat PREFERRED_GPU_FMT = AV_PIX_FMT_NV12;
25constexpr AVPixelFormat PREFERRED_CPU_FMT = AV_PIX_FMT_YUV420P; 25constexpr AVPixelFormat PREFERRED_CPU_FMT = AV_PIX_FMT_YUV420P;
26constexpr std::array PREFERRED_GPU_DECODERS = {AV_HWDEVICE_TYPE_CUDA, 26constexpr std::array PREFERRED_GPU_DECODERS = {
27 AV_HWDEVICE_TYPE_CUDA,
27#ifdef _WIN32 28#ifdef _WIN32
28 AV_HWDEVICE_TYPE_D3D11VA, AV_HWDEVICE_TYPE_DXVA2, 29 AV_HWDEVICE_TYPE_D3D11VA,
29#elif linux 30 AV_HWDEVICE_TYPE_DXVA2,
30 AV_HWDEVICE_TYPE_VDPAU, 31#elif defined(__linux__)
32 AV_HWDEVICE_TYPE_VDPAU,
31#endif 33#endif
32 // last resort for Linux Flatpak (w/ NVIDIA) 34 // last resort for Linux Flatpak (w/ NVIDIA)
33 AV_HWDEVICE_TYPE_VULKAN}; 35 AV_HWDEVICE_TYPE_VULKAN,
36};
34 37
35void AVPacketDeleter(AVPacket* ptr) { 38void AVPacketDeleter(AVPacket* ptr) {
36 av_packet_free(&ptr); 39 av_packet_free(&ptr);
@@ -72,12 +75,13 @@ Codec::~Codec() {
72// List all the currently available hwcontext in ffmpeg 75// List all the currently available hwcontext in ffmpeg
73static std::vector<AVHWDeviceType> ListSupportedContexts() { 76static std::vector<AVHWDeviceType> ListSupportedContexts() {
74 std::vector<AVHWDeviceType> contexts{}; 77 std::vector<AVHWDeviceType> contexts{};
75 enum AVHWDeviceType current_device_type = AV_HWDEVICE_TYPE_NONE; 78 AVHWDeviceType current_device_type = AV_HWDEVICE_TYPE_NONE;
76 do { 79 do {
77 current_device_type = av_hwdevice_iterate_types(current_device_type); 80 current_device_type = av_hwdevice_iterate_types(current_device_type);
78 // filter out VA-API since we will try that first if supported 81 // filter out VA-API since we will try that first if supported
79 if (current_device_type != AV_HWDEVICE_TYPE_VAAPI) 82 if (current_device_type != AV_HWDEVICE_TYPE_VAAPI) {
80 contexts.push_back(current_device_type); 83 contexts.push_back(current_device_type);
84 }
81 } while (current_device_type != AV_HWDEVICE_TYPE_NONE); 85 } while (current_device_type != AV_HWDEVICE_TYPE_NONE);
82 return contexts; 86 return contexts;
83} 87}