summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/video_core/command_classes/codecs/codec.cpp33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/video_core/command_classes/codecs/codec.cpp b/src/video_core/command_classes/codecs/codec.cpp
index 04d0f3a2f..921f54a41 100644
--- a/src/video_core/command_classes/codecs/codec.cpp
+++ b/src/video_core/command_classes/codecs/codec.cpp
@@ -57,6 +57,18 @@ AVPixelFormat GetGpuFormat(AVCodecContext* av_codec_ctx, const AVPixelFormat* pi
57 av_codec_ctx->pix_fmt = PREFERRED_CPU_FMT; 57 av_codec_ctx->pix_fmt = PREFERRED_CPU_FMT;
58 return PREFERRED_CPU_FMT; 58 return PREFERRED_CPU_FMT;
59} 59}
60
61// List all the currently available hwcontext in ffmpeg
62std::vector<AVHWDeviceType> ListSupportedContexts() {
63 std::vector<AVHWDeviceType> contexts{};
64 AVHWDeviceType current_device_type = AV_HWDEVICE_TYPE_NONE;
65 do {
66 current_device_type = av_hwdevice_iterate_types(current_device_type);
67 contexts.push_back(current_device_type);
68 } while (current_device_type != AV_HWDEVICE_TYPE_NONE);
69 return contexts;
70}
71
60} // namespace 72} // namespace
61 73
62void AVFrameDeleter(AVFrame* ptr) { 74void AVFrameDeleter(AVFrame* ptr) {
@@ -77,17 +89,6 @@ Codec::~Codec() {
77 av_buffer_unref(&av_gpu_decoder); 89 av_buffer_unref(&av_gpu_decoder);
78} 90}
79 91
80// List all the currently available hwcontext in ffmpeg
81static std::vector<AVHWDeviceType> ListSupportedContexts() {
82 std::vector<AVHWDeviceType> contexts{};
83 AVHWDeviceType current_device_type = AV_HWDEVICE_TYPE_NONE;
84 do {
85 current_device_type = av_hwdevice_iterate_types(current_device_type);
86 contexts.push_back(current_device_type);
87 } while (current_device_type != AV_HWDEVICE_TYPE_NONE);
88 return contexts;
89}
90
91bool Codec::CreateGpuAvDevice() { 92bool Codec::CreateGpuAvDevice() {
92 static constexpr auto HW_CONFIG_METHOD = AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX; 93 static constexpr auto HW_CONFIG_METHOD = AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX;
93 static const auto supported_contexts = ListSupportedContexts(); 94 static const auto supported_contexts = ListSupportedContexts();
@@ -128,15 +129,19 @@ bool Codec::CreateGpuAvDevice() {
128 av_codec->name, av_hwdevice_get_type_name(type)); 129 av_codec->name, av_hwdevice_get_type_name(type));
129 break; 130 break;
130 } 131 }
131 if (config->methods & HW_CONFIG_METHOD && config->device_type == type) { 132 if ((config->methods & HW_CONFIG_METHOD) != 0 && config->device_type == type) {
132 av_codec_ctx->pix_fmt = config->pix_fmt; 133#if defined(__unix__)
133 if (config->methods & AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX) { 134 // Some linux decoding backends are reported to crash with this config method
135 // TODO(ameerj): Properly support this method
136 if ((config->methods & AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX) != 0) {
134 // skip zero-copy decoders, we don't currently support them 137 // skip zero-copy decoders, we don't currently support them
135 LOG_DEBUG(Service_NVDRV, "Skipping decoder {} with unsupported capability {}.", 138 LOG_DEBUG(Service_NVDRV, "Skipping decoder {} with unsupported capability {}.",
136 av_hwdevice_get_type_name(type), config->methods); 139 av_hwdevice_get_type_name(type), config->methods);
137 continue; 140 continue;
138 } 141 }
142#endif
139 LOG_INFO(Service_NVDRV, "Using {} GPU decoder", av_hwdevice_get_type_name(type)); 143 LOG_INFO(Service_NVDRV, "Using {} GPU decoder", av_hwdevice_get_type_name(type));
144 av_codec_ctx->pix_fmt = config->pix_fmt;
140 return true; 145 return true;
141 } 146 }
142 } 147 }