Intra Refresh of H264 encoder

https://en.wikipedia.org/wiki/X264

x264 is able to use Periodic Intra Refresh instead of keyframes, which enables each frame to be capped to the same size enabling each slice to be immediately transmitted in a single UDP or TCP packet and on arrival immediately decoded.[15] Periodic Intra Refresh can replace keyframes by using a column of intra blocks that move across the video from one side to the other, thereby "refreshing" the image. In effect, instead of a big keyframe, the keyframe is "spread" over many frames. The video is still seekable: a special header, called the SEI Recovery Point, tells the decoder to "start here, decode X frames, and then start displaying the video." This hides the refresh effect from the user while the frame loads. Motion vectors are restricted so that blocks on one side of the refresh column don't reference blocks on the other side, effectively creating a demarcation line in each frame.

 

https://community.freescale.com/thread/311299

ASK:

I am interested in using the i.MX6Q VPU to encode H.264 streams with intra-refresh enabled.  For this I looked up in the i.MX 6Dual/6Quad VPU Application Programming Interface Linux Reference Manual, Rev L3.0.35_4.0.0, 05/2013, page 24 where it states that setting the intraRefresh field to a non-zero value in EncOpenParam structure and passing to the vpu_EncOpen() API will enable intra-refresh:

intraRefresh where 0 = Intra MB refresh is not used. Otherwise = At least N MB's in every P-frame are encoded as intra MB's. This value is ignored in for STD_MJPG.

So, following the above directions, I set intraRefresh to different non-zero values (800, 2400, etc) and encoded 1080 H.264 streams from the camera.  Upon examination of the streams, it looks likes there are still I-frames in the video.  I am under the impression that when intra-refresh parameter is enabled then there would be no I frames in the video, just P frames with the Intra MBs embedded within. 

I am modifying vpu_wrapper.c from the 4.0.0 LTIB release.  In VPU_EncOpen(), I set sEncOpenParam.intraRefresh = 2400.  Also tried other values.

My question is why the VPU is still generating I-frames despite the intra-refresh option set?

Also whether there are other options I need to enable/modify to get this to encode properly?

ANSWER:

The parameter intraRefresh only affect the P frame, it isn't related with I frame.

If you want to encode clip with rare I frame, you can enlarge the I frame interval through assign one big GOP size.

gopSize is the GOP size, where 0 means only first picture is I; 1 means all I pictures, 2 = IPIP, 3 = IPPIPP, and so on. The maximum value is 32,767, but in practice, a smaller value should be chosen by the application for proper error concealment. This value is ignored for STD_MJPG.

 

https://community.freescale.com/thread/321537

what is right configuration of iMX53 vpu of freescale that can generate h264 vedio stream with constant bitrate?

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;  // 0 is 仅第一帧为I; 1 is IIIIII; 2 is IPIPIP; 3 is IPPIPPIPP; 4 is IPPPIPPPIPPP,...
  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;

 

转载于:https://www.cnblogs.com/welhzh/p/5045823.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值