What's the right configuration of iMX53 vpu that can generate h264 vedio stream with constant bitrate?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

What's the right configuration of iMX53 vpu that can generate h264 vedio stream with constant bitrate?

跳至解决方案
2,492 次查看
sunajiang
Contributor III

Hi Everyone:

   I'm using the mx53 vpu(and will use imx6Q) to encode VGA pictures(yuv420) to h264 vedio stream.  After vpu encodes one frame,  we send related h264 datas using wirless network to another dev. Because the wireless bandwidth is limited to an constant value , we hope the h264 bitrate can be or most nearly  a constant value "400Kb".  My configurations of the vpu are as follows. Howerver ,we mornitored the network's bitrate, the vpu's bitrate isn't an constant, it changes from 100kb to 800kb,  also the video quality is much more worse than vedio from TI's dm365 which generates h264 vedio stream with the same bitrate .

Can anyone help me to check which parameter  is not right or how to config the vpu to get constant bitrate with high vedio quality ?

Thanks !!

   encConfig.stdMode = STD_AVC;

  encConfig.picWidth=640;

  encConfig.picHeight=480;

  encConfig.encWidth=640;

  encConfig.encHeight=480;

  encConfig.offsetX=0;

  encConfig.offsetY=0;

  encConfig.bitRate =400; //bitrate set here ,but  not working

  encConfig.rotatedAngle=0; //rotate

  encConfig.initialDelay=0; // no use for h264

  encConfig.vbvBufferSize=0; //initial delay==0 , delay this param

  encConfig.frameRate=25;    //

  encConfig.gopsize =50;  // 3 IPP, 4IPPP,...

  encConfig.enableAutoSkip= 0;   //skipe encode

  encConfig.intraRefresh =8; // 0 - Intra MB refresh is not used.

  encConfig.rcIntraQp=(26);  //26, default, Quantization parameter for I frame.

  encConfig.annexJ =0;

  encConfig.annexK =1;

  encConfig.annexT =0;

  encConfig.quantparam =48; //vbr 0-51for 264, 1 ~ 31 for MPEG-4

    // Fill parameters for encoding.

    encOP.bitstreamBuffer = g_BitstreamPhy;

    encOP.bitstreamBufferSize = 0x100000;

    encOP.bitstreamFormat = encConfig.stdMode;

    encOP.frameRateInfo = encConfig.frameRate;

    encOP.bitRate = encConfig.bitRate;

    encOP.initialDelay = encConfig.initialDelay;

    encOP.vbvBufferSize = encConfig.vbvBufferSize; // 0 = ignore

    encOP.gopSize = encConfig.gopsize; // only first picture is I

    encOP.slicemode.sliceMode = 1; // 0:1 slice per picture, 1: multi slice

    encOP.slicemode.sliceSizeMode = 0;

    encOP.slicemode.sliceSize = 6000;//12000

    encOP.intraRefresh = encConfig.intraRefresh;

    encOP.rcIntraQp = encConfig.rcIntraQp;

    encOP.userQpMax = 38; //default 1 szj change

    encOP.userQpMin = 38;

    encOP.userQpMinEnable = 1;

    encOP.userQpMaxEnable = 1;

    encOP.userGamma = 4096;

    encOP.RcIntervalMode = 0;

    encOP.MbInterval = 90;

    encOP.interleavedCbCr = 0;

    encOP.avcIntra16x16OnlyModeEnable = 0;

    encOP.picWidth = encConfig.picWidth;

    encOP.picHeight = encConfig.picHeight;

    encOP.encWidth = encConfig.encWidth;

    encOP.encHeight = encConfig.encHeight;

    encOP.offsetX = encConfig.offsetX;

    encOP.offsetY = encConfig.offsetY;

    encOP.rotationAngle = encConfig.rotatedAngle;

   if (encConfig.stdMode == STD_MPEG4)

    {

        encOP.EncStdParam.mp4Param.mp4_dataPartitionEnable = 0;

        encOP.EncStdParam.mp4Param.mp4_reversibleVlcEnable = 0;

        encOP.EncStdParam.mp4Param.mp4_intraDcVlcThr = 0;

        encOP.EncStdParam.mp4Param.mp4_hecEnable    = 0;

        encOP.EncStdParam.mp4Param.mp4_verid = 2;

    }

  if (encConfig.stdMode == STD_AVC)

  {

  encOP.EncStdParam.avcParam.avc_constrainedIntraPredFlag = 0;

  encOP.EncStdParam.avcParam.avc_disableDeblk = 0;

  encOP.EncStdParam.avcParam.avc_deblkFilterOffsetAlpha = 0;

  encOP.EncStdParam.avcParam.avc_deblkFilterOffsetBeta = 0;

  encOP.EncStdParam.avcParam.avc_chromaQpOffset = 0;

  encOP.EncStdParam.avcParam.avc_audEnable = 1;

  encOP.EncStdParam.avcParam.avc_fmoEnable = 0;

  encOP.EncStdParam.avcParam.avc_fmoType = 0;

  encOP.EncStdParam.avcParam.avc_fmoSliceNum = 0;

  encOP.EncStdParam.avcParam.avc_fmoSliceSaveBufSize = MAX_FMO_SLICE_SAVE_BUF_SIZE;

}

    encOP.ringBufferEnable =  0;

    encOP.dynamicAllocEnable = 0;

    encOP.picWidth = (encOP.picWidth + 15) & ~15;

    encOP.picHeight = (encOP.picHeight + 15) & ~15;

    YFrameSize = encOP.picWidth * encOP.picHeight;

    srcFrameIdx = initialInfo.minFrameBufferCount;

  

    exit_t = 0;

    frameIdx = 0;

    encParam.sourceFrame = &frameBuf[srcFrameIdx];

    encParam.quantParam = encConfig.quantparam;

    encParam.forceIPicture = 0;  //default 0

    encParam.skipPicture = 0;

    encParam.enableAutoSkip = encConfig.enableAutoSkip;

0 项奖励
1 解答
1,751 次查看
joanxie
NXP TechSupport
NXP TechSupport

for bitrate control, pls refer to the enclosed file,ENC_SET_BITRATE:

param is a pointer to an integer which represents the bitrate. The bitrate should be between 0

and 32767

在原帖中查看解决方案

0 项奖励
4 回复数
1,752 次查看
joanxie
NXP TechSupport
NXP TechSupport

for bitrate control, pls refer to the enclosed file,ENC_SET_BITRATE:

param is a pointer to an integer which represents the bitrate. The bitrate should be between 0

and 32767

0 项奖励
1,750 次查看
sunajiang
Contributor III

Hi  Xie:

        Thank you for your help .  I found that    encOP.userQpMinEnable and encOP.userQpMaxEnable should be zero, than bitrate contol  will work .

    encOP.userQpMax = 38; //default 1 szj change

    encOP.userQpMin = 38;

   encOP.userQpMinEnable = 1;

    encOP.userQpMaxEnable = 1;

0 项奖励
1,750 次查看
Wlodek_D_
Senior Contributor II

Hello,

Thank you for your post, however please consider moving it to the right community place (e.g. i.MX Community ) to get it visible for active members.

For details please see general advice Where to post a Discussion?

Thank you for using Freescale Community. 

0 项奖励
1,751 次查看
sunajiang
Contributor III

Hi Wlodek_D, I have moved it to iMX Community.  Thank you for reminding me。

0 项奖励