diff --git a/common/libs/VkCodecUtils/VulkanDeviceContext.cpp b/common/libs/VkCodecUtils/VulkanDeviceContext.cpp index 1901ebcb..2b29d798 100644 --- a/common/libs/VkCodecUtils/VulkanDeviceContext.cpp +++ b/common/libs/VkCodecUtils/VulkanDeviceContext.cpp @@ -1144,15 +1144,23 @@ VkResult VulkanDeviceContext::InitVulkanDecoderDevice(const char * pAppName, if (videoCodecs == VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR) { AddReqDeviceExtension(VK_KHR_VIDEO_DECODE_H264_EXTENSION_NAME); - } - if (videoCodecs == VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR) { + } else if (videoCodecs == VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR) { AddReqDeviceExtension(VK_KHR_VIDEO_DECODE_H265_EXTENSION_NAME); - } - if (videoCodecs == VK_VIDEO_CODEC_OPERATION_DECODE_AV1_BIT_KHR) { + } else if (videoCodecs == VK_VIDEO_CODEC_OPERATION_DECODE_AV1_BIT_KHR) { AddReqDeviceExtension(VK_KHR_VIDEO_DECODE_AV1_EXTENSION_NAME); - } - if (videoCodecs == VK_VIDEO_CODEC_OPERATION_DECODE_VP9_BIT_KHR) { + } else if (videoCodecs == VK_VIDEO_CODEC_OPERATION_DECODE_VP9_BIT_KHR) { AddReqDeviceExtension(VK_KHR_VIDEO_DECODE_VP9_EXTENSION_NAME); + } else { + static const char* const optinalCodecsExtensions[] = { + VK_KHR_VIDEO_DECODE_H264_EXTENSION_NAME, + VK_KHR_VIDEO_DECODE_H265_EXTENSION_NAME, + VK_KHR_VIDEO_DECODE_AV1_EXTENSION_NAME, + VK_KHR_VIDEO_DECODE_VP9_EXTENSION_NAME, + nullptr + }; + // If the codec set is VK_VIDEO_CODEC_OPERATION_NONE_KHR or + // VIDEO_CODEC_OPERATIONS_ALL, then set all codecs as optional extensions. + AddOptDeviceExtensions(optinalCodecsExtensions); } VkResult result = InitVulkanDevice(pAppName, vkInstance, enbaleVerboseDump); diff --git a/common/libs/VkCodecUtils/VulkanVideoProcessor.cpp b/common/libs/VkCodecUtils/VulkanVideoProcessor.cpp index dc21ac58..da480f3e 100644 --- a/common/libs/VkCodecUtils/VulkanVideoProcessor.cpp +++ b/common/libs/VkCodecUtils/VulkanVideoProcessor.cpp @@ -54,7 +54,7 @@ int32_t VulkanVideoProcessor::Initialize(const VulkanDeviceContext* vkDevCtx, const int32_t numBitstreamBuffersToPreallocate = std::max(programConfig.numBitstreamBuffersToPreallocate, 4); const bool enableHwLoadBalancing = programConfig.enableHwLoadBalancing; const bool enablePostProcessFilter = (programConfig.enablePostProcessFilter >= 0); - const bool enableDisplayPresent = (programConfig.noPresent == 0); + const bool enableDisplayPresent = (programConfig.noPresent == false); const VulkanFilterYuvCompute::FilterType postProcessFilterType = enablePostProcessFilter ? (VulkanFilterYuvCompute::FilterType)programConfig.enablePostProcessFilter : VulkanFilterYuvCompute::YCBCRCOPY; diff --git a/vk_video_decoder/demos/vk-video-dec/Main.cpp b/vk_video_decoder/demos/vk-video-dec/Main.cpp index 8ddc3e7b..0ced75d6 100644 --- a/vk_video_decoder/demos/vk-video-dec/Main.cpp +++ b/vk_video_decoder/demos/vk-video-dec/Main.cpp @@ -52,19 +52,20 @@ int main(int argc, const char **argv) return -1; } - VkVideoCodecOperationFlagsKHR videoCodecOperation = (decoderConfig.forceParserType != VK_VIDEO_CODEC_OPERATION_NONE_KHR) ? - decoderConfig.forceParserType : - videoStreamDemuxer->GetVideoCodec(); + const VkVideoCodecOperationFlagsKHR videoCodecOperation = + (decoderConfig.forceParserType != VK_VIDEO_CODEC_OPERATION_NONE_KHR) ? + decoderConfig.forceParserType : + ((videoStreamDemuxer != nullptr) ? videoStreamDemuxer->GetVideoCodec() : VK_VIDEO_CODEC_OPERATION_NONE_KHR); VulkanDeviceContext vkDevCtxt; result = vkDevCtxt.InitVulkanDecoderDevice(decoderConfig.appName.c_str(), - VK_NULL_HANDLE, - videoCodecOperation, - !decoderConfig.noPresent, - decoderConfig.directMode, - decoderConfig.validate, - decoderConfig.validateVerbose, - decoderConfig.verbose); + VK_NULL_HANDLE, + videoCodecOperation, + decoderConfig.noPresent, + decoderConfig.directMode, + decoderConfig.validate, + decoderConfig.validateVerbose, + decoderConfig.verbose); if (result != VK_SUCCESS) { printf("Could not initialize the Vulkan decoder device!\n"); @@ -87,7 +88,7 @@ int main(int argc, const char **argv) requestVideoComputeQueueMask = VK_QUEUE_COMPUTE_BIT; } - if (!decoderConfig.noPresent) { + if (decoderConfig.noPresent == false) { VkSharedBaseObj displayShell; const Shell::Configuration configuration(decoderConfig.appName.c_str(), diff --git a/vk_video_decoder/src/vulkan_video_decoder.cpp b/vk_video_decoder/src/vulkan_video_decoder.cpp index 76f8d692..0d05fa44 100644 --- a/vk_video_decoder/src/vulkan_video_decoder.cpp +++ b/vk_video_decoder/src/vulkan_video_decoder.cpp @@ -141,9 +141,15 @@ VkResult VulkanVideoDecoderImpl::Initialize(VkInstance vkInstance, return VK_NOT_READY; } + const VkVideoCodecOperationFlagsKHR videoCodecOperation = + (m_decoderConfig.forceParserType != VK_VIDEO_CODEC_OPERATION_NONE_KHR) ? + m_decoderConfig.forceParserType : + ((videoStreamDemuxer != nullptr) ? videoStreamDemuxer->GetVideoCodec() : VK_VIDEO_CODEC_OPERATION_NONE_KHR); + VkResult result = m_vkDevCtxt.InitVulkanDecoderDevice(m_decoderConfig.appName.c_str(), vkInstance, - !m_decoderConfig.noPresent, + videoCodecOperation, + m_decoderConfig.noPresent, m_decoderConfig.directMode, m_decoderConfig.validate, m_decoderConfig.validateVerbose, @@ -170,9 +176,7 @@ VkResult VulkanVideoDecoderImpl::Initialize(VkInstance vkInstance, requestVideoComputeQueueMask = VK_QUEUE_COMPUTE_BIT; } - VkVideoCodecOperationFlagsKHR videoCodecOperation = videoStreamDemuxer->GetVideoCodec(); - - const bool supportsShellPresent = ((!m_decoderConfig.noPresent == false) && (pWsiDisplay != nullptr)); + const bool supportsShellPresent = ((m_decoderConfig.noPresent == false) && (pWsiDisplay != nullptr)); const bool createGraphicsQueue = supportsShellPresent ? true : false; const bool createDisplayQueue = supportsShellPresent ? true : false; diff --git a/vk_video_decoder/test/vulkan-video-dec/Main.cpp b/vk_video_decoder/test/vulkan-video-dec/Main.cpp index 1aac07d9..8928551f 100644 --- a/vk_video_decoder/test/vulkan-video-dec/Main.cpp +++ b/vk_video_decoder/test/vulkan-video-dec/Main.cpp @@ -51,14 +51,34 @@ int main(int argc, const char** argv) return -1; } + VkSharedBaseObj videoStreamDemuxer; + VkResult result = VideoStreamDemuxer::Create(decoderConfig.videoFileName.c_str(), + decoderConfig.forceParserType, + decoderConfig.enableStreamDemuxing, + decoderConfig.initialWidth, + decoderConfig.initialHeight, + decoderConfig.initialBitdepth, + videoStreamDemuxer); + if (result != VK_SUCCESS) { + assert(!"Can't initialize the VideoStreamDemuxer!"); + return result; + } + + const VkVideoCodecOperationFlagsKHR videoCodecOperation = + (decoderConfig.forceParserType != VK_VIDEO_CODEC_OPERATION_NONE_KHR) ? + decoderConfig.forceParserType : + ((videoStreamDemuxer != nullptr) ? videoStreamDemuxer->GetVideoCodec() : VK_VIDEO_CODEC_OPERATION_NONE_KHR); + + VulkanDeviceContext vkDevCtxt; - VkResult result = vkDevCtxt.InitVulkanDecoderDevice(decoderConfig.appName.c_str(), - VK_NULL_HANDLE, - !decoderConfig.noPresent, - decoderConfig.directMode, - decoderConfig.validate, - decoderConfig.validateVerbose, - decoderConfig.verbose); + result = vkDevCtxt.InitVulkanDecoderDevice(decoderConfig.appName.c_str(), + VK_NULL_HANDLE, + videoCodecOperation, + decoderConfig.noPresent, + decoderConfig.directMode, + decoderConfig.validate, + decoderConfig.validateVerbose, + decoderConfig.verbose); if (result != VK_SUCCESS) { printf("Could not initialize the Vulkan decoder device!\n"); @@ -66,19 +86,6 @@ int main(int argc, const char** argv) } - VkSharedBaseObj videoStreamDemuxer; - result = VideoStreamDemuxer::Create(decoderConfig.videoFileName.c_str(), - decoderConfig.forceParserType, - decoderConfig.enableStreamDemuxing, - decoderConfig.initialWidth, - decoderConfig.initialHeight, - decoderConfig.initialBitdepth, - videoStreamDemuxer); - if (result != VK_SUCCESS) { - assert(!"Can't initialize the VideoStreamDemuxer!"); - return result; - } - const int32_t numDecodeQueues = ((decoderConfig.queueId != 0) || (decoderConfig.enableHwLoadBalancing != 0)) ? -1 : // all available HW decoders @@ -99,7 +106,7 @@ int main(int argc, const char** argv) decoderConfig.forceParserType : videoStreamDemuxer->GetVideoCodec(); - if (!decoderConfig.noPresent) { + if (decoderConfig.noPresent == false) { VkSharedBaseObj displayShell; const Shell::Configuration configuration(decoderConfig.appName.c_str(),