Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.
6709 Discussions

has anyone gotton bitrate controls to work with #define SLICE_CHECK_LIMIT ?

steveipp
Beginner
394 Views

Hi,

When ipp-samples is compiled with #define SLICE_CHECK_LIMIT eabled, H264VideoEncoder's bitrate controls aren't obeyed. For example, on CIF videos with a good amount of movement, target bitrate set to 200 kbps, and params.num_slices set to -1300, the H264VideoEncoder generates output whose bitrate is almost 3X that requested.

I'm setting the following:

params.profile_idc = UMC::H264_BASE_PROFILE;
params.B_frame_rate = 0; // Disable B-frames
params.entropy_coding_mode = 0; // CAVLC
params.transform_8x8_mode_flag = false;

params.num_slices = -1300; // Maximum slice size: 1300 bytes
params.numThreads = 1;
params.num_ref_frames = 2;
params.mv_search_method = 2;
params.me_split_mode = 1;
params.rate_controls.method = UMC::H264_RCM_CBR;
params.me_search_x = 8;
params.me_search_y = 8;
params.direct_pred_mode = 1;

encoderParams.info.clip_info.width = 352;
encoderParams.info.clip_info.height = 288;
encoderParams.info.framerate = 15.0;

encoderParams.level_idc = 12;
encoderParams.info.bitrate = 200000;
encoderParams.key_frame_controls.method = UMC::H264_KFCM_INTERVAL;
encoderParams.key_frame_controls.interval = (Ipp32s) (2*15.0);
encoderParams.key_frame_controls.idr_interval = 1; // Each intra-frame is an IDR frame


On the other hand, if SLICE_CHECK_LIMIT is disabled and params.num_slices not explicitly set (i.e. - default value), the H264VideoEncoder gnerates output whose bitrate is for all practical purposes equal to that requested.


Has anyone gotton bitrate controls to work with #define SLICE_CHECK_LIMIT? If so, what changes are required?

Thanks In Advance,
Steve

0 Kudos
6 Replies
Emmanuel_W_
New Contributor I
394 Views

Hi Steve,

I was able to make it work several releases ago.
Looking at the latest drop, it seems that the api H264_AVBR_PostFrame in the H264_RCM_CBR case is not called when SLICE_CHECK_LIMIT is enabled. However there is a call to H264_AVBR_PostFrame in the H264_RCM_CBR_SLICE mode, maybe you can try this one.

Emmanuel

0 Kudos
steveipp
Beginner
394 Views

Hi Emmanuel,

Thanks for your response. I tried your suggestion of setting params.rate_controls.method = UMC::H264_RCM_CBR_SLICE. It resulted in a bitstream with an even higher bitrate (e.g. - over 5X what I was previously experiencing).

Did you have to modify the code in older releases to make bitrate controls work? If so, what modifications should I make in ipp-samples 6.1.5.068 ?

Many Thanks,

Steve

0 Kudos
Emmanuel_W_
New Contributor I
394 Views
Hi Steve,

I did have to change quite some code at the time includingcode related to therate control to make the SLICE_CHECK_LIMIT works.
I can't remember exactly what code I had to change and I am not currently using the IPP rate control algorithm.

In order to make things work I think you need to add up the bits generated for each slice to get the total size of the frame generated and provide the information to the AVBR object in the H264_AVBR_PostFrame method once for each frame.

Hope this helps.
Emmanuel
0 Kudos
steveipp
Beginner
394 Views

Hi Emmanuel,

Thanks again for your reply. Would you mind ifwe discuss this further offline? You can reach me at steveipps@gmail.com.

Thanks,
Steve

0 Kudos
Emmanuel_W_
New Contributor I
394 Views
[bash][/bash]

Here is a small fix that seems to address the issue.

In the umc_h264_gen_enc_templ.cpp.h inthe H264CoreEncoder_CompressFrame function, around line 858 replace

[bash]#ifdef SLICE_CHECK_LIMIT
            }
#endif // SLICE_CHECK_LIMIT[/bash]

by

#ifdef SLICE_CHECK_LIMIT

}

else

{

if (core_enc->m_info.rate_controls.method == H264_RCM_VBR || core_enc->m_info.rate_controls.method == H264_RCM_CBR) {

bitsPerFrame = (dst->GetDataSize() - data_size) << 3;

H264_AVBR_PostFrame(&core_enc->avbr, core_enc->m_PicType, bitsPerFrame);

}

}

#endif // SLICE_CHECK_LIMIT

Emmanuel

0 Kudos
Ying_H_Intel
Employee
394 Views
Hi Emmanuel, steve

Just let you know the modified codewas integrated to IPP 7.0.5 sample. Code Samples for the Intel Integrated Performance Primitives (Intel IPP) Library 7.0*


Thanks a lot for the sharing

Best Regards,
Ying
0 Kudos
Reply