ffmpeg/tools: Function to check for hardware encoding
Implements a function that can be used to check for hardware texture support, which allows full on-GPU encoding to work for supported encoders.
This commit is contained in:
@@ -235,3 +235,17 @@ AVColorRange ffmpeg::tools::obs_videorangetype_to_avcolorrange(video_range_type
|
||||
}
|
||||
throw std::invalid_argument("unknown range");
|
||||
}
|
||||
|
||||
bool ffmpeg::tools::can_hardware_encode(const AVCodec* codec)
|
||||
{
|
||||
AVPixelFormat hardware_formats[] = {AV_PIX_FMT_D3D11};
|
||||
|
||||
for (const AVPixelFormat* fmt = codec->pix_fmts; (fmt != nullptr) && (*fmt != AV_PIX_FMT_NONE); fmt++) {
|
||||
for (auto cmp : hardware_formats) {
|
||||
if (*fmt == cmp) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
extern "C" {
|
||||
#include <libavutil/pixfmt.h>
|
||||
#include <libavcodec/avcodec.h>
|
||||
}
|
||||
|
||||
namespace ffmpeg {
|
||||
@@ -47,6 +48,8 @@ namespace ffmpeg {
|
||||
AVColorSpace obs_videocolorspace_to_avcolorspace(video_colorspace v);
|
||||
|
||||
AVColorRange obs_videorangetype_to_avcolorrange(video_range_type v);
|
||||
|
||||
bool can_hardware_encode(const AVCodec* codec);
|
||||
} // namespace tools
|
||||
} // namespace ffmpeg
|
||||
|
||||
|
||||
Reference in New Issue
Block a user