This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DM8168 Encoder issue: 2 macroblocks offset at the beginning of each row and each column.

I am using DVR RDK 4.0. I meet a problem with encoder.

The encoder version is:

REL.500.V.H264AVC.E.IVAHD.02.00.06.00

The decoder version is:

REL.500.V.H264AVC.D.HP.IVAHD.02.00.08.00

 In my use case,  I want to encoder the video which is generated by decoder for ROI encoding. The chain is:

out host ipc --> in video ipc -->  decoder -->  encoder -->  out video ipc --> in host ipc.

 the case runs well, but there is some issue about the he generated stream.

 Here is the original H.264 stream.

Here is the generated H.264 stream.

There are 2 macroblocks offset at the beginning of each row and each column.

I want to know why this issue happen and how to solve it. I will be glad if any ideas were provided.

  • Hi,
    Can you please share all the parameter settings and the bitstream?
  • Yes, I‘d like to, even I do not think it is my setting issue. In my opinion, I guess it is because  the decoder do not add the reasonable information to the generated video.

    The declink setting is:

    for (i=0; i<ipcBitsOutHostPrm.inQueInfo.numCh; i++)
    {

          OSA_assert(gVdecModuleContext.vdecConfig.decChannelParams[i].isCodec == VDEC_CHN_H264);

          decPrm.chCreateParams[i].format = IVIDEO_H264HP;

          decPrm.chCreateParams[i].numBufPerCh
                = gVdecModuleContext.vdecConfig.decChannelParams[i].numBufPerCh;

          decPrm.chCreateParams[i].profile = IH264VDEC_PROFILE_ANY;


          decPrm.chCreateParams[i].displayDelay = gVdecModuleContext.vdecConfig.decChannelParams[i].displayDelay;

          decPrm.chCreateParams[i].displayDelay = 0;

          decPrm.chCreateParams[i].dpbBufSizeInFrames = IH264VDEC_DPB_NUMFRAMES_AUTO;
          if (gVdecModuleContext.vdecConfig.decChannelParams[i].fieldPicture)
          {
                OSA_printf("MULTICH_VDEC_VDIS:INFO ChId[%d] configured for field picture\n",i);
                decPrm.chCreateParams[i].processCallLevel = VDEC_FIELDLEVELPROCESSCALL;
          }
          else
          {
                decPrm.chCreateParams[i].processCallLevel = VDEC_FRAMELEVELPROCESSCALL;
          }

          decPrm.chCreateParams[i].targetMaxWidth =
                ipcBitsOutHostPrm.inQueInfo.chInfo[i].width;

          decPrm.chCreateParams[i].targetMaxHeight =
                ipcBitsOutHostPrm.inQueInfo.chInfo[i].height;

          decPrm.chCreateParams[i].defaultDynamicParams.targetFrameRate =
                gVdecModuleContext.vdecConfig.decChannelParams[i].dynamicParam.frameRate;

          decPrm.chCreateParams[i].defaultDynamicParams.targetBitRate =
                gVdecModuleContext.vdecConfig.decChannelParams[i].dynamicParam.targetBitRate;

          if (!gVdecVdisObj.tilerEnable)
          {
                decPrm.chCreateParams[i].tilerEnable = FALSE;
          }
          else
          {
                decPrm.chCreateParams[i].tilerEnable = gVdecModuleContext.vdecConfig.decChannelParams[i].tilerEnable;
          }

          decPrm.chCreateParams[i].enableWaterMarking =
          gVdecModuleContext.vdecConfig.decChannelParams[i].enableWaterMarking;

    }

    The decoder setting is:


    createParamsDec[i].maxVideoWidth = MT_VDEC_DEFAULT_WIDTH ;
    createParamsDec[i].maxVideoHeight = MT_VDEC_DEFAULT_HEIGHT;
    createParamsDec[i].isCodec = MT_VDEC_DEFAULT_CODEC;
    createParamsDec[i].displayDelay = 0;
    createParamsDec[i].tilerEnable = 0;
    createParamsDec[i].numBufPerCh = 4;

    The enclink setting is:


    EncLink_ChCreateParams *pLinkChPrm;
    EncLink_ChDynamicParams *pLinkDynPrm;
    VENC_CHN_DYNAMIC_PARAM_S *pDynPrm;
    VENC_CHN_PARAMS_S *pChPrm;

    for (i = 0; i < 1 ; i++) // MT_VENC_CHN_MAX MT_VENC_CHN_MAX
    {
          pLinkChPrm = &encPrm.chCreateParams[i];
          pLinkDynPrm = &pLinkChPrm->defaultDynamicParams;

          pChPrm = &gVencModuleContext.vencConfig.encChannelParams[i];
          pDynPrm = &pChPrm->dynamicParam;

          pLinkChPrm->format = IVIDEO_H264HP;
          pLinkChPrm->profile = gVencModuleContext.vencConfig.h264Profile[i];
          pLinkChPrm->dataLayout = VCODEC_FIELD_SEPARATED;
          pLinkChPrm->fieldMergeEncodeEnable = FALSE;
          pLinkChPrm->enableAnalyticinfo = pChPrm->enableAnalyticinfo;
          pLinkChPrm->enableWaterMarking = pChPrm->enableWaterMarking;
          pLinkChPrm->maxBitRate = pChPrm->maxBitRate;
          pLinkChPrm->encodingPreset = VENC_XDM_USER_DEFINED;

          pLinkChPrm->rateControlPreset = IVIDEO_NONE;
          pLinkChPrm->enableSVCExtensionFlag = pChPrm->enableSVCExtensionFlag;
          pLinkChPrm->numTemporalLayer = pChPrm->numTemporalLayer;

          pLinkDynPrm->intraFrameInterval = pDynPrm->intraFrameInterval;
          pLinkDynPrm->targetBitRate = pDynPrm->targetBitRate;
          pLinkDynPrm->interFrameInterval = pDynPrm->interFrameInterval;
          pLinkChPrm->enableHighSpeed = FALSE;
          pLinkDynPrm->mvAccuracy = IVIDENC2_MOTIONVECTOR_QUARTERPEL;
          pLinkDynPrm->inputFrameRate = pDynPrm->inputFrameRate;
          pLinkDynPrm->rcAlg = pDynPrm->rcAlg;
          pLinkDynPrm->qpMin = pDynPrm->qpMin;
          pLinkDynPrm->qpMax = pDynPrm->qpMax;
          pLinkDynPrm->qpInit = pDynPrm->qpInit;
          pLinkDynPrm->vbrDuration = pDynPrm->vbrDuration;
          pLinkDynPrm->vbrSensitivity = pDynPrm->vbrSensitivity;

          pLinkChPrm->overrideInputScanFormat = TRUE;
          pLinkChPrm->fieldPicEncode = FALSE;

    }

    The encoder setting is:

    Venc_params_init(&vencParams);
    {
    vencParams.numPrimaryChn = 1;
    vencParams.numSecondaryChn = 0;

    vencParams.encChannelParams[0].enableAnalyticinfo = 1;
    vencParams.encChannelParams[0].rcType = VENC_RATE_CTRL_VBR;
    vencParams.encChannelParams[0].dynamicParam.targetBitRate = 2000 * 1000;

    }

  • Hi,
    This issue is due to padding added by H264 decoder. H264 decoder adds 32,24 padding in the decoded output.
    Decoder gives this information of active video in activeFrameRegion rectangle of display buffer.

    XDM_Rect *r = &decoder->outArgs->>displayBufs.bufDesc[0].activeFrameRegion .

    Encoder's inputBuffer activeFrame region needs to be set with these info.

    enc->InBufs->activeFrameRegion.topLeft.x = r->topLeft.x;
    enc->InBufs->activeFrameRegion.topLeft.y = r->topLeft.y;
    enc->InBufs->activeFrameRegion.bottomRight.x = r->bottomRight.x - r->topLeft.x;
    enc->InBufs->activeFrameRegion.bottomRight.y = r->bottomRight.y - r->topLeft.y;
  • Hi,

    Thanks for sharing the stream. The above reply from Ramprasad should resolve your issue. Its related to padding.

  • Thanks for this right answer.