Unexpectedly, BufferSizeInKB doesn't change when calling MFXVideoEncode_Reset() with a new bit rate for VBR (for H.264). For example, if I configure a mfxVideoParam for 720p59.94 (w: 1280, h: 720, frame rate: 60000/1001, progressive, AVC, high profile, VBR), if I set both TargetKbps and MaxKbps to 1000 (1 Mbps), after calling Init() and then GetVideoParam(), BufferSizeInKB is set to 250 and InitialDelayInKB is set to 125.
If I instead use 4000 (4 Mbps) for TargetKbps and MaxKbps, the values of BufferSizeInKB and InitialDelayInKB are set to 500 and 1000, respectively, after calling init() and then GetVideoParam(). So, it needs a larger buffer size for 4 Mbps than for 1 Mbps, as one might expect.
However, if instead, the sequence is:
- Init() and GetVideoParam() with 1000 for TargetKbps and MaxKbps
- Reset() and GetVideoParam() with 4000 for TargetKbps and MaxKbps
BufferSizeInKB and InitialDelayInKB remain at 250 and 125, respectively. This is even true if I reset BufferSizeInKB and InitialDelayInKB to 0 prior to calling Reset() and GetVideoParam(). This doesn't really make sense. How can a buffer size of 250 KB be sufficient for 4 Mbps after Reset() when it isn't sufficient for the Init() sequence as described above?
This is easily reproduced by creating an instance of the encoder object, and it isn't necessary to actually encode any frames to experience this behavior.
Jiandong Z. (Intel) wrote:
By default MSDK sample_encode using CBR, Have you set m_mfxEncParams.mfx.RateControlMethod = MFX_RATECONTROL_VBR for using VBR
Not once did I mention sample_encode in my post. This has nothing to do with the sample_encode sample. I've already described the issue in my earlier post, which includes the steps necessary to reproduce the issue. What I described is likely indicative of a bug in the Intel Media SDK (or rather, the underlying implementation in the driver media).
If what I have already described isn't sufficient to understand the problem, I can provide source code.
Hi Aaron, Your observation is correct - MSDK does not allow dynamic changes to HRD buffer size. This is our HW implementation (or limitation, say).To allow for bigger buffersizes when changing bitrates, you will have to allocate a bigger buffer at the initialization. It's not pretty, but thats the hw implementation today.