Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions common/libs/VkCodecUtils/VulkanDeviceContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion common/libs/VkCodecUtils/VulkanVideoProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
23 changes: 12 additions & 11 deletions vk_video_decoder/demos/vk-video-dec/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -87,7 +88,7 @@ int main(int argc, const char **argv)
requestVideoComputeQueueMask = VK_QUEUE_COMPUTE_BIT;
}

if (!decoderConfig.noPresent) {
if (decoderConfig.noPresent == false) {

VkSharedBaseObj<Shell> displayShell;
const Shell::Configuration configuration(decoderConfig.appName.c_str(),
Expand Down
12 changes: 8 additions & 4 deletions vk_video_decoder/src/vulkan_video_decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;

Expand Down
49 changes: 28 additions & 21 deletions vk_video_decoder/test/vulkan-video-dec/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,34 +51,41 @@ int main(int argc, const char** argv)
return -1;
}

VkSharedBaseObj<VideoStreamDemuxer> 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");
return -1;
}


VkSharedBaseObj<VideoStreamDemuxer> 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
Expand All @@ -99,7 +106,7 @@ int main(int argc, const char** argv)
decoderConfig.forceParserType :
videoStreamDemuxer->GetVideoCodec();

if (!decoderConfig.noPresent) {
if (decoderConfig.noPresent == false) {

VkSharedBaseObj<Shell> displayShell;
const Shell::Configuration configuration(decoderConfig.appName.c_str(),
Expand Down