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.

decoder return Dmai_EBITERROR, how to ignore it?

Hi,guys:

I am using DM365+DVSDK4.0.

My H264 stream comes from network and other interface, not filesystem. there are some lost package when send to decoder.

the stream is sent as "29 P frames + 1 IDR frame" repeatly. each frame is cut to several slice. So when I package the stream to frame, some frame may not contain enough

slice as encoded. But I will make sure params "SPS/PPS" in IDR is complete.

Here is the problem:

when Vdec2_process() return DMAI_BITERROR, not buffers will be sent to displsy thread, I ignore it and get next frame.

But at the next time , I found BufTab_getFreeBuf() will not return the previous buffer. it seems the codec donot release the hDstBuf, so when this error happens again for about 31 times, BufTab_getFreeBuf() will return NULL. At this moment , not buffer will be available, the application is dead.

So ,have you guys meet this problem? how can I let the codec release the buffer/ or handle this error?

thank you.

  • Here is the sample code based dvsdk decode program:


            ret = Vdec2_process(hVd2, hBufFromLoader, hDstBuf);
            if (ret < 0) {
                printf("Failed to decode video frame Vdec2_process()=%d\n", ret);
                cleanup(THREAD_FAILURE);
            }

            /* If no encoded data was used we cannot find the next frame*/
            if (ret == Dmai_EBITERROR && Buffer_getNumBytesUsed(hBufFromLoader) == 0){
                printf("Dmai_EBITERROR, Buffer_getNumBytesUsed()=0\r\n");
            }
            //gblIncVideoBytesProcessed(Buffer_getNumBytesUsed(hBufFromLoader));

            bufs_sent = handleCodecBufs(hVd2, envp->hDisplayInFifo);
            if (bufs_sent == 0){
                printf("send 0 frame to display,record(%d),get next<<--\n",++fail_send);
                //Buffer_freeUseMask(hDstBuf, CODEC_FREE | DISPLAY_FREE); // ???
                Loader_getVFramex(hLoader,0);
                continue;
            }

        numDisplayBufs += bufs_sent;

     .......

  • Hi,

    You can look at attached files, how i handled that some time ago.
    Files are from DVSDK_4.01.00.09
    Demos\Decode\video.c
    dmai_2_20_00_14\packages\ti\sdo\dmai\ce\Vdec2.c (new function  Vdec2_process_2)

    Regards.

    decode.zip
  • Hi,Marko。

    thanks for replying. I also read this thread: http://e2e.ti.com/support/embedded/linux/f/354/t/88083.aspx.

    I will try your method and let you know the result ASAP.

  • Hi,Marko:

    Sorry for replying late.

    I have try handleCodecErrBufs() and not work , When Dmai_EBITERROR happen , it will send about 10 frames to displayThread. there are some code I am not really understanding:

    1、at First,hDisplayBufs[] will be set to NULL

    for (i=0;i<IVIDDEC2_MAX_IO_BUFFERS;i++)
        {
            hVd->hDisplayBufs[i] = NULL;
        }
        hVd->displayBufIdx = 0;

    2、then it will get display buffer and try to send to displayThread:

    hOutBuf = Vdec2_getDisplayBuf(hVd2);
            
        while (hOutBuf) {...}

    So, why Vdec2_getDisplayBuf() will return NOT-NULL buffer while it has been set to NULL above? is it because the calling "VIDDEC2_control(hDecode, XDM_RESET, 0, &decStatus);"?

  • Hi Liu,

    Sorry, i forgot details, it's been a while since i've been working on that,
    but i'm pretty sure it works well.
    Make sure you are using "Vdec2.c"  (DMAI) that i sent you,
    and first rebuild dmai (make dmai_clean, make dmai), before building decode demo.

    Regards.

    decode9.zip
  • ... and make sure you are using new dmai function  "Vdec2_process_2", before  "handleCodecErrBufs".

  • Hi,Marko:

    thanks again for your kindness.

    I did use vdec2_process_2 and handleCodecErrbufs, however ,I found sometimes the function cannot release the buffer held by codec,while sometimes can free. when BitError happen, the condition:

    i = Buffer_getId(hFreeBuf);        
           if (i == (freebufid-1))
               {

                  //=====//

                }

    maybe true, but sometimes it's not, hence the buffer cannot be free.

  • Hi,Marko:

    I have figured it out, thank you !

  • Hi,YJ Liu

          I have Question about using XDM_RESET on DM368 H264 Decoder.  can you give me ,your file about   Vdec2.c and Demos\Decode\video.c .

    email:  weijingjing_yh@163.com        thank you!