diff --git a/common/libs/VkCodecUtils/VulkanFrame.cpp b/common/libs/VkCodecUtils/VulkanFrame.cpp index 3e1dab7..8ddf405 100644 --- a/common/libs/VkCodecUtils/VulkanFrame.cpp +++ b/common/libs/VkCodecUtils/VulkanFrame.cpp @@ -282,7 +282,7 @@ static int InitPreset(VkSharedBaseObj& encoderConfig) { encoderConfig->rateControlMode = VkVideoEncodeRateControlModeFlagBitsKHR::VK_VIDEO_ENCODE_RATE_CONTROL_MODE_CBR_BIT_KHR; encoderConfig->gopStructure.SetConsecutiveBFrameCount(0); - encoderConfig->gopStructure.SetGopFrameCount(-1); + encoderConfig->gopStructure.SetGopFrameCount((uint16_t)-1); encoderConfig->gopStructure.SetIdrPeriod(0); encoderConfig->gopStructure.SetLastFrameType(VkVideoGopStructure::FrameType::FRAME_TYPE_P); // ? set right value encoderConfig->encodeUsageHints = VK_VIDEO_ENCODE_USAGE_STREAMING_BIT_KHR; diff --git a/vk_video_encoder/libs/VkVideoEncoder/VkEncoderConfig.cpp b/vk_video_encoder/libs/VkVideoEncoder/VkEncoderConfig.cpp index 152bde2..c43bc7b 100644 --- a/vk_video_encoder/libs/VkVideoEncoder/VkEncoderConfig.cpp +++ b/vk_video_encoder/libs/VkVideoEncoder/VkEncoderConfig.cpp @@ -346,13 +346,15 @@ int EncoderConfig::ParseArguments(int argc, char *argv[]) averageBitrate = targetBitrate << 20; } } else if (strcmp(argv[i], "--vbvbuf-ratio") == 0) { - int vbvbuf_ratio; - int sscanf_result = sscanf(argv[i+1], "%d", &vbvbuf_ratio); - if (sscanf_result != 1 || vbvbuf_ratio <= 0 || vbvbuf_ratio > 8) { - fprintf(stderr, "invalid parameter for %s\n", argv[i - 1]); - return VK_ERROR_VIDEO_PROFILE_CODEC_NOT_SUPPORTED_KHR; + if ((++i >= argc) !=1) { + int vbvbuf_ratio; + int sscanf_result = sscanf(argv[i], "%d", &vbvbuf_ratio); + if (sscanf_result != 1 || vbvbuf_ratio <= 0 || vbvbuf_ratio > 8) { + fprintf(stderr, "invalid parameter for %s\n", argv[i - 1]); + return VK_ERROR_VIDEO_PROFILE_CODEC_NOT_SUPPORTED_KHR; + } + vbvbufratio = vbvbuf_ratio; } - vbvbufratio = vbvbuf_ratio; #endif //_TRANSCODING } else if (args[i] == "--idrPeriod") { int32_t idrPeriod = EncoderConfig::DEFAULT_GOP_IDR_PERIOD; @@ -678,7 +680,7 @@ VkResult EncoderConfig::CreateCodecConfig(int argc, char *argv[], VkResult result = vkEncoderConfigh264->InitializeParameters(); if (result != VK_SUCCESS) { -#if (!_TRANSCODING) +#if (!_TRANSCODING) assert(!"InitializeParameters failed"); return result; #endif // !_TRANSCODING @@ -698,7 +700,7 @@ VkResult EncoderConfig::CreateCodecConfig(int argc, char *argv[], VkResult result = vkEncoderConfigh265->InitializeParameters(); if (result != VK_SUCCESS) { -#if (!_TRANSCODING) +#if (!_TRANSCODING) assert(!"InitializeParameters failed"); return result; #endif // !_TRANSCODING @@ -718,8 +720,10 @@ VkResult EncoderConfig::CreateCodecConfig(int argc, char *argv[], VkResult result = vkEncoderConfigAV1->InitializeParameters(); if (result != VK_SUCCESS) { +#if (!_TRANSCODING) assert(!"InitializeParameters failed"); return result; +#endif //!_TRANSCODING } encoderConfig = vkEncoderConfigAV1; diff --git a/vk_video_encoder/libs/VkVideoEncoder/VkEncoderConfigH264.cpp b/vk_video_encoder/libs/VkVideoEncoder/VkEncoderConfigH264.cpp index 99bcc02..045a4b7 100644 --- a/vk_video_encoder/libs/VkVideoEncoder/VkEncoderConfigH264.cpp +++ b/vk_video_encoder/libs/VkVideoEncoder/VkEncoderConfigH264.cpp @@ -469,7 +469,7 @@ bool EncoderConfigH264::InitRateControl() #if (_TRANSCODING) if (encodingProfile == EncoderConfig::LOW_LATENCY_STREAMING) { - vbvBufferSize = averageBitrate / frameRate * vbvbufratio; // averageBitrate is a uint32_t, no overflow + vbvBufferSize = (uint32_t)(averageBitrate / frameRate * vbvbufratio); // averageBitrate is a uint32_t, no overflow } else if (encodingProfile == EncoderConfig::ARCHIVING) { diff --git a/vk_video_encoder/libs/VkVideoEncoder/VkVideoEncoder.h b/vk_video_encoder/libs/VkVideoEncoder/VkVideoEncoder.h index 8a69784..d7b9753 100644 --- a/vk_video_encoder/libs/VkVideoEncoder/VkVideoEncoder.h +++ b/vk_video_encoder/libs/VkVideoEncoder/VkVideoEncoder.h @@ -502,7 +502,7 @@ class VkVideoEncoder : public VkVideoRefCountBase { , m_qpMapImagePool() #if (_TRANSCODING) , m_encodeTimeMicroSec(0) -#endif // _TRANSCODING +#endif //_TRANSCODING { } // Factory Function diff --git a/vk_video_encoder/libs/VkVideoEncoder/VkVideoEncoderH265.cpp b/vk_video_encoder/libs/VkVideoEncoder/VkVideoEncoderH265.cpp index de23d27..ef1f87b 100644 --- a/vk_video_encoder/libs/VkVideoEncoder/VkVideoEncoderH265.cpp +++ b/vk_video_encoder/libs/VkVideoEncoder/VkVideoEncoderH265.cpp @@ -76,7 +76,7 @@ VkResult VkVideoEncoderH265::InitEncoderCodec(VkSharedBaseObj& en if (encoderConfig->encodingProfile == EncoderConfig::LOW_LATENCY_STREAMING) { - m_encoderConfig->vbvBufferSize = encoderConfig->averageBitrate / frameRate * encoderConfig->vbvbufratio; // averageBitrate is a uint32_t, no overflow + m_encoderConfig->vbvBufferSize = (uint32_t)(encoderConfig->averageBitrate / frameRate * encoderConfig->vbvbufratio); // averageBitrate is a uint32_t, no overflow printf("vbv size %u\n", m_encoderConfig->vbvBufferSize); } else if (encoderConfig->encodingProfile == EncoderConfig::ARCHIVING)