video_core/codec: address comments

This commit is contained in:
liushuyu 2021-11-29 16:47:24 -07:00
parent cd27f211c8
commit 20a46790d7

View file

@ -23,14 +23,17 @@ namespace Tegra {
namespace { namespace {
constexpr AVPixelFormat PREFERRED_GPU_FMT = AV_PIX_FMT_NV12; constexpr AVPixelFormat PREFERRED_GPU_FMT = AV_PIX_FMT_NV12;
constexpr AVPixelFormat PREFERRED_CPU_FMT = AV_PIX_FMT_YUV420P; constexpr AVPixelFormat PREFERRED_CPU_FMT = AV_PIX_FMT_YUV420P;
constexpr std::array PREFERRED_GPU_DECODERS = {AV_HWDEVICE_TYPE_CUDA, constexpr std::array PREFERRED_GPU_DECODERS = {
AV_HWDEVICE_TYPE_CUDA,
#ifdef _WIN32 #ifdef _WIN32
AV_HWDEVICE_TYPE_D3D11VA, AV_HWDEVICE_TYPE_DXVA2, AV_HWDEVICE_TYPE_D3D11VA,
#elif linux AV_HWDEVICE_TYPE_DXVA2,
AV_HWDEVICE_TYPE_VDPAU, #elif defined(__linux__)
AV_HWDEVICE_TYPE_VDPAU,
#endif #endif
// last resort for Linux Flatpak (w/ NVIDIA) // last resort for Linux Flatpak (w/ NVIDIA)
AV_HWDEVICE_TYPE_VULKAN}; AV_HWDEVICE_TYPE_VULKAN,
};
void AVPacketDeleter(AVPacket* ptr) { void AVPacketDeleter(AVPacket* ptr) {
av_packet_free(&ptr); av_packet_free(&ptr);
@ -72,12 +75,13 @@ Codec::~Codec() {
// List all the currently available hwcontext in ffmpeg // List all the currently available hwcontext in ffmpeg
static std::vector<AVHWDeviceType> ListSupportedContexts() { static std::vector<AVHWDeviceType> ListSupportedContexts() {
std::vector<AVHWDeviceType> contexts{}; std::vector<AVHWDeviceType> contexts{};
enum AVHWDeviceType current_device_type = AV_HWDEVICE_TYPE_NONE; AVHWDeviceType current_device_type = AV_HWDEVICE_TYPE_NONE;
do { do {
current_device_type = av_hwdevice_iterate_types(current_device_type); current_device_type = av_hwdevice_iterate_types(current_device_type);
// filter out VA-API since we will try that first if supported // filter out VA-API since we will try that first if supported
if (current_device_type != AV_HWDEVICE_TYPE_VAAPI) if (current_device_type != AV_HWDEVICE_TYPE_VAAPI) {
contexts.push_back(current_device_type); contexts.push_back(current_device_type);
}
} while (current_device_type != AV_HWDEVICE_TYPE_NONE); } while (current_device_type != AV_HWDEVICE_TYPE_NONE);
return contexts; return contexts;
} }