mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2025-07-20 09:25:45 +00:00
Compare commits
2 commits
027e896065
...
cc7288b35b
Author | SHA1 | Date | |
---|---|---|---|
|
cc7288b35b | ||
|
dbe155f4d4 |
1 changed files with 15 additions and 18 deletions
|
@ -39,23 +39,7 @@ constexpr std::array PreferredGpuDecoders = {
|
|||
};
|
||||
|
||||
AVPixelFormat GetGpuFormat(AVCodecContext* codec_context, const AVPixelFormat* pix_fmts) {
|
||||
// Check if there is a specific pixel format supported by the GPU decoder.
|
||||
for (int i = 0;; i++) {
|
||||
const AVCodecHWConfig* config = avcodec_get_hw_config(codec_context->codec, i);
|
||||
if (!config) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (config->methods & AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX) {
|
||||
if (config->device_type == AV_HWDEVICE_TYPE_CUDA) {
|
||||
return AV_PIX_FMT_CUDA;
|
||||
} else if (config->device_type == AV_HWDEVICE_TYPE_VAAPI) {
|
||||
return AV_PIX_FMT_VAAPI;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if there is another pixel format supported by the GPU decoder.
|
||||
// Check if there is a pixel format supported by the GPU decoder.
|
||||
const auto desc = av_pix_fmt_desc_get(codec_context->pix_fmt);
|
||||
if (desc && desc->flags & AV_PIX_FMT_FLAG_HWACCEL) {
|
||||
for (const AVPixelFormat* p = pix_fmts; *p != AV_PIX_FMT_NONE; ++p) {
|
||||
|
@ -65,11 +49,23 @@ AVPixelFormat GetGpuFormat(AVCodecContext* codec_context, const AVPixelFormat* p
|
|||
}
|
||||
}
|
||||
|
||||
// Another check to confirm if there is a pixel format supported by specific GPU decoders.
|
||||
for (int i = 0;; i++) {
|
||||
const AVCodecHWConfig* config = avcodec_get_hw_config(codec_context->codec, i);
|
||||
if (!config) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ((config->methods & AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX) && (config->device_type == AV_HWDEVICE_TYPE_CUDA || config->device_type == AV_HWDEVICE_TYPE_VAAPI)) {
|
||||
return config->pix_fmt;
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback to CPU decoder.
|
||||
LOG_INFO(HW_GPU, "Could not find compatible GPU pixel format, falling back to CPU");
|
||||
av_buffer_unref(&codec_context->hw_device_ctx);
|
||||
|
||||
return AV_PIX_FMT_YUV420P;
|
||||
return codec_context->pix_fmt;
|
||||
}
|
||||
|
||||
std::string AVError(int errnum) {
|
||||
|
@ -266,6 +262,7 @@ std::shared_ptr<Frame> DecoderContext::ReceiveFrame() {
|
|||
return {};
|
||||
}
|
||||
} else {
|
||||
m_temp_frame->SetFormat(AV_PIX_FMT_YUV420P);
|
||||
m_temp_frame = std::move(intermediate_frame);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue