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.

H264 Decoder issues on DMVA2

We are facing some issues with H264 decoder. 
Below is the problem descriptions:
Problem 1:
Need to feed 16 frames to H264 decoder before it gives out a display frame.
This expected for 1st time, at the start for stream decoding.
Problem is whenever a I-frame (having "SPS,PPS,I Slice" information) comes and is feed to decoder.
Then after it does not give display frame for next 15 frames.
Our source camera has I frame interval set to 60.
So we see 45 frames then there is no output for 15 frames. They are missed. This continues.
The video looks breaking.
Observation : When we  configure source camera to give all I-Frames then video is fine. 
Problem 2:
At time green artifacts are seen need the top of decoder image.
Below is sample for codec parameters used to create the codec instance:
/-----------------xx-----------------------xx-------------------------------/
        create->maxHeight = 480;
        create->maxWidth = 720;
        pObj->params.size               = sizeof(VIDDEC2_Params);
        pObj->params.maxHeight          = create->maxHeight;
        pObj->params.maxWidth           = create->maxWidth;
        pObj->params.maxFrameRate       = 30000;
        pObj->params.maxBitRate         = ALG_VID_DEC_MAX_BITRATE;
        pObj->params.dataEndianness     = XDM_BYTE;
        pObj->params.forceChromaFormat  = 9;
/-----------------xx-----------------------xx-------------------------------/
Attached is sample h264 bitstream for analysis and testing. Please rename to .h264 after download.
Bitstream plays fine in VLC player.
We are using IPNC RDK 3.5.0 and "moduletest"application for decode and display on PAL TV.
Please help.
  • HI,

    As your bitstream has IPP sequence with Number of reference frame as 1, set displaydelay = 1. Then decoder will give output just after decoding.

    Thanks,

  • Thank you for your quick reply and suggestion.
    We have tried setting display delay to 1 . After that we are able to see display frames continuously.

    Can you please tell why decoder did not give frames with default display delay(16) ?
    Our board is supposed to read streams from multiple sources and they could have different parameter settings. Is it possible that display delay 1 may not work for some other stream ?

    Also another issues is : we see green artifacts in the stream (near top portion of decode frames). Can you suggest what could be the problem there ?

    Thanks,
    Sagar.
  • Hi,
    Please go thorugh following link to understand displaydelay and buffer handling of the decoder. www.ti.com/.../sprab88.pdf
    And displaydelay = 1 will not work for all cases like streams with B frames. you have to set optimal value(it can take values from 0-16, please see userguide for more information) depending upon usecase or stream property.
    Regarding green patch i guess starting ptr of display buffer might be going wrong. Note that display buffer will have pad data along with actul data. you should display only intersted data using pitch.

    Thanks,
    Veeranna
  • Hi Veeranna,

    For copying decoder output to display buffer and displaying we are using same ALG_vidDecTestDisplayCopy() which in the test code.

    Couple of more issues
    Issue 1:
    For the H264 decoder quality doesnt seem to be good. We see pixelation and stretching effect when there is movement.

    Issue 2:
    1. If whOffset is set to 48 . If some movement is done from very top of the image coming downwards then green artifacts follow the motion.

    Below is code snippet of parameters set before decoding frame.
    /xxxxxxxxxxxxxxxxxxxxxxxxxx/
    whOffset = 0;

    if(pObj->createPrm.codec == ALG_VID_CODEC_H264)
    {
    whOffset = 48;
    runPrm.inAddr = inBuf;
    runPrm.outAddr = outBuf;
    runPrm.inDataSize = inBufSize;
    runPrm.outOffsetH = OSA_align(*outFrameWidth + whOffset, 32);
    runPrm.outOffsetV = *outFrameHeight + whOffset;
    runPrm.inputBufId = inputID;
    }
    else
    {
    runPrm.inAddr = inBuf;
    runPrm.outAddr = outBuf;
    runPrm.inDataSize = inBufSize;
    runPrm.outOffsetH = *outFrameWidth;
    runPrm.outOffsetV = *outFrameHeight;
    runPrm.inputBufId = inputID;

    }

    status = ALG_vidDecRun(hDecode, &runPrm, &runStatus);
    /-------------------------------------/

    Below is code snippet of parameters used to create codec:
    /-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/
    create->maxWidth = 720;
    create->maxHeight = 480;

    pObj->params.size = sizeof(VIDDEC2_Params);
    pObj->params.maxHeight = create->maxHeight;
    pObj->params.maxWidth = create->maxWidth;
    pObj->params.maxFrameRate = 30000;
    pObj->params.maxBitRate = ALG_VID_DEC_MAX_BITRATE;
    pObj->params.dataEndianness = XDM_BYTE;
    pObj->params.forceChromaFormat = 9;

    memcpy(&pObj->h264Params, &IH264VDEC_PARAMS, sizeof(pObj->h264Params));
    pObj->h264Params.displayDelay = 1;
    pObj->h264Params.hdvicpHandle = (void*) NULL;
    pObj->h264Params.disableHDVICPeveryFrame = 1;
    pObj->h264Params.viddecParams = pObj->params;
    pObj->h264Params.viddecParams.size = sizeof(pObj->h264Params);

    /* Create video decoder instance */
    pObj->hDecode = VIDDEC2_create(gALG_hEngine, pObj->algName, &pObj->h264Params);
    /--------------------------------------------------------------------/

    With 720 x 480 input bitstream the decoder gives 768x528 output .. do you think that quality is corrupted because of this resizing done by codec ?

    Please guide.

    Regards,
    Sagar
  • Hi

    sagar patel1 said:
    Issue 1:
    For the H264 decoder quality doesnt seem to be good. We see pixelation and stretching effect when there is movement.

    >>Decoder is no responsible for anytype of quality degradation. it should be with Encoded bitstream. Just make sure that you are using universal decoder.(by setting closedLoopMode = 0).

    sagar patel1 said:
    Issue 2:
    1. If whOffset is set to 48 . If some movement is done from very top of the image coming downwards then green artifacts follow the motion.

    >> whOffset should be 24. There will padding in all directions.

    sagar patel1 said:
    With 720 x 480 input bitstream the decoder gives 768x528 output .. do you think that quality is corrupted because of this resizing done by codec ?

    >> Codec will not do any resizing. 768x528 is the size including padding. Padding is internal to decoder and its not resize.

    Thanks,

  • Hi Veeranna,
    We are able to see the source stream in VLC player. It plays properly.
    We see the source stream on VLC on PC and decoded frames on TV(connected to our board) simultaneously.
    However with onboard decoder the frames seem to be not decoding images properly.
    Some observations :
    1. If we set source camera to give all I-Frames then decoded frames are good.
    2. Our source camera has I-Frame interval of 60.
    When motion comes then seems as if decoded data generated has used incorrect/older reference frame.
    When new I-frame comes in the stream then decoded frame gets corrected. This continues.
    3. We suspected such behaviour could be possible if some frames are getting dropped. From our testing it does not seem that frames are getting
    dropped. We use rtsp client to capture source stream which uses TCP protocol so packet drop seem highly unlikely.
    Do you suspect any other problem that could cause such behaviour ?
    Below are the codec settings we have tried. Please suggest if any of it seem incorrect or can suggest any modification to try out.
    /----------------------------------------------------/
    create->maxHeight = 480; create->maxWidth = 720;
    pObj->params.size = sizeof(VIDDEC2_Params);
    pObj->params.maxHeight = create->maxHeight;
    pObj->params.maxWidth = create->maxWidth;
    pObj->params.maxFrameRate = 0;//60000;
    pObj->params.maxBitRate = ALG_VID_DEC_MAX_BITRATE;
    pObj->params.dataEndianness = XDM_BYTE;
    pObj->params.forceChromaFormat = 9;
    memcpy(&pObj->h264Params, &IH264VDEC_PARAMS, sizeof(pObj->h264Params));
    pObj->h264Params.displayDelay = 1;
    pObj->h264Params.hdvicpHandle = (void*) NULL;
    pObj->h264Params.disableHDVICPeveryFrame = 0;
    pObj->h264Params.frame_closedloop_flag = 0;
    pObj->h264Params.inputDataMode = IH264VDEC_TI_ENTIREFRAME;
    pObj->h264Params.sliceFormat = IH264VDEC_TI_BYTESTREAM;
    pObj->h264Params.viddecParams = pObj->params;
    pObj->h264Params.viddecParams.size = sizeof(pObj->h264Params);
    /* Create video decoder instance */
    pObj->hDecode = VIDDEC2_create(gALG_hEngine, pObj->algName, &pObj->h264Params);
    /----------------------------------------------------/Thanks,Sagar
  • Hi,
    Your params looks fine, except displayDelay. I am not sure what type of stream you are using, If streams has decode and display order different, then you have to set displayDelay accordingly. To confirm Decoder functionality you can run standalone test-application provided with decoder codec package.

    Thanks,
    Veeranna
  • Hi Veeranna,
    Stream is same as attached earlier in this chain(1st post). Let us know if some parameter changes are needed based on such input stream.
    We are using IPNC RDK 3.5.0
    We used moduletest application for standalone testing. There also we same problem.
    ./moduletest.out alg_vidDec <File Name> <Width> <Height>
    Any other decoder test application that we can try ?Regards,Sagar
  • Hi 

    Please set pObj->params.size = sizeof(IH264VDEC_Params), and similar thing for Dynamic and other structure.  And use the fileIO based  test application to validate decoder(dm365_codecs_0x_xx_xx_xx/packages/ti/sdo/codecs/h264dec/apps)

    Thanks,

    Veeranna

  • Hi Veeranna,Thanks for your help.
    We are able to see good video using moduletest application. Main changes were:
    1. displayDelay as 12. wHOffset to 24
    3. some changes to "ALG_vidDecTestDisplayCopy() -> frameCopy.srcStartY = vidDecStatus->outOffsetV - vidDecStatus->frameHeight;"
    With our main application we see some corruption in display. But seems some buffer corruption is happening in application.
    We should be able to figure it out.Appreciate you help to debug the issues.
    Regards,Sagar
  • Hi Veeranna,One more query:1. How to figure out correct value of whOffset ?
    When setting it to 24, some times color information gets missed near the top of image(top few lines).
    We set it to 64. It seemed to resolve the issue. Please suggest how to determine correct value of whOffset.
    Regards,Sagar
  • Please refer TestApp_WriteOutputData() function in stand alone test of decoder to know how to handle the output buffer.

    Thanks,
    Veeranna