Skip to content

Commit

Permalink
fixed windows build and one argument passing
Browse files Browse the repository at this point in the history
  • Loading branch information
t-boiko committed Nov 30, 2024
1 parent cb4eecf commit 47f0687
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion common/libs/VkCodecUtils/VulkanFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ static int InitPreset(VkSharedBaseObj<EncoderConfig>& 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;
Expand Down
20 changes: 12 additions & 8 deletions vk_video_encoder/libs/VkVideoEncoder/VkEncoderConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion vk_video_encoder/libs/VkVideoEncoder/VkVideoEncoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ class VkVideoEncoder : public VkVideoRefCountBase {
, m_qpMapImagePool()
#if (_TRANSCODING)
, m_encodeTimeMicroSec(0)
#endif // _TRANSCODING
#endif //_TRANSCODING
{ }

// Factory Function
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ VkResult VkVideoEncoderH265::InitEncoderCodec(VkSharedBaseObj<EncoderConfig>& 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)
Expand Down

0 comments on commit 47f0687

Please sign in to comment.