Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance H264EncoderNvCodec by adding a buffer threshold property #360

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kushaljain-apra
Copy link
Collaborator

@kushaljain-apra kushaljain-apra commented Jun 3, 2024

IMPORTANT: All PRs must be linked to an issue (except for extremely trivial and straightforward changes).

Fixes #358

Description

  1. Added a buffer threshold property in H264EncoderNvcodec Module
  2. Currently, it uses a fixed number of encoder buffers that are initialized once.
  3. We still have default number of buffers set to 30, but with buffer threshold property you can specify the upper limit for the number encoders.
  4. If the number of free output encoder buffers becomes zero and the total number of encoder buffers is less the buffer threshold, we allocate min(total number of buffers currently allocated, buffer threshold - total number of buffers currently allocated) more buffers.
  5. This lets us control the number of buffers to be allocated if needed using an upper limit as buffer threshold.

Alternative(s) considered

Have you considered any alternatives? And if so, why have you chosen the approach in this PR?

Type

Type Choose one: (Bug fix)

Screenshots (if applicable)

Checklist

  • I have read the Contribution Guidelines
  • I have written Unit Tests
  • I have discussed my proposed solution with code owners in the linked issue(s) and we have agreed upon the general approach

Copy link

github-actions bot commented Jun 3, 2024

Test Results Linux

  1 files  ±0    1 suites  ±0   10m 11s ⏱️ -1s
308 tests ±0  227 ✅ ±0  81 💤 ±0  0 ❌ ±0 
227 runs  ±0  146 ✅ ±0  81 💤 ±0  0 ❌ ±0 

Results for commit d8f59d9. ± Comparison against base commit 53157e2.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Jun 3, 2024

Test Results Win-nocuda

  1 files  ±0    1 suites  ±0   10m 20s ⏱️ -1s
303 tests ±0  227 ✅ ±0  76 💤 ±0  0 ❌ ±0 
227 runs  ±0  151 ✅ ±0  76 💤 ±0  0 ❌ ±0 

Results for commit d8f59d9. ± Comparison against base commit 53157e2.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Jul 4, 2024

Test Results Windows-cuda

  1 files  ±0    1 suites  ±0   12m 19s ⏱️ -1s
404 tests ±0  288 ✅ ±0  116 💤 ±0  0 ❌ ±0 
288 runs  ±0  172 ✅ ±0  116 💤 ±0  0 ❌ ±0 

Results for commit d8f59d9. ± Comparison against base commit 53157e2.

@@ -18,7 +18,14 @@ class H264EncoderNVCodec::Detail
public:
Detail(H264EncoderNVCodecProps &_props) : mProps(_props)
{
helper.reset(new H264EncoderNVCodecHelper(_props.bitRateKbps, _props.cuContext,_props.gopLength,_props.frameRate,_props.vProfile,_props.enableBFrames));
if(_props.bufferThres == 30)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add it to #define instead of hard coding

@@ -204,7 +204,7 @@ class H264EncoderNVCodecHelper::Detail
}
}
public:
Detail(uint32_t& bitRateKbps, apracucontext_sp& cuContext, uint32_t& gopLength, uint32_t& frameRate,H264EncoderNVCodecProps::H264CodecProfile profile,bool enableBFrames) :
Detail(uint32_t& bitRateKbps, apracucontext_sp& cuContext, uint32_t& gopLength, uint32_t& frameRate,H264EncoderNVCodecProps::H264CodecProfile profile,bool enableBFrames, uint32_t& bufferThres) :
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we Have Limit on Max Buffer Threshold, or it can be any

}
H264EncoderNVCodecProps(const uint32_t &_bitRateKbps, const apracucontext_sp& _cuContext, const uint32_t &_gopLength,const uint32_t &_frameRate,H264CodecProfile _vProfile,bool _enableBFrames, uint32_t &_bufferThres)
: cuContext(_cuContext), gopLength(_gopLength), frameRate(_frameRate), bitRateKbps(_bitRateKbps), vProfile(_vProfile), enableBFrames(_enableBFrames), bufferThres(_bufferThres)
{
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add some basic documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants