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.

Deinterlacing for DM365

Hi,

    following a post in this forum, I asked and got the code for deinterlacing. There was also a DMAI interface for it. I see the calling procedure is as follows:

     if (DEI_process(hVe1, hCapBuf, hPrevBuf, hDisBuf) < 0) {
            ERR("Failed to encode video buffer\n");
            cleanup(THREAD_FAILURE);
        }

and I wonder if hCapBuf, hPrevBuf should be considered as the even and odd fields or as full interlaced frames. The documentation refers to frames but it uses the terminology of video codecs which deals with frames so I not sure about it.

If I have to consider the buffers as fields, since the DVR framework outputs with frames where the two fields are interleved, I would ask what is the most efficient way to separate the two fields.

I am trying to use the deinterlacer to get 736x576 4:2:0 semi planer progressive frames from the 736x576 4:2:2 ILE frames provided by the capture interface.

The deinterlacer instance is created but the call to DEI_process produces a SEGMENTATION FAULT. All the required pools have been allocated.

The deinterlacer is configured as follows:

    Dei_Parameters.videncParams = Venc1_Params_DEFAULT;
    Dei_Parameters.videncParams.inputChromaFormat = XDM_YUV_422ILE;
    Dei_Parameters.videncParams.maxHeight = VideoStd_D1_PAL_HEIGHT;
    Dei_Parameters.videncParams.maxWidth  = 736;
    Dei_Parameters.threshold             = 5; //recomended 0-255 (0 = BOB 255 weave)
    Dei_Parameters.subWindowHeight        = VideoStd_D1_PAL_HEIGHT;
    Dei_Parameters.subWindowWidth        = 736;//VideoStd_D1_WIDTH;
    Dei_Parameters.outputFormat            = XDM_YUV_420SP;//XDM_YUV_420SP; or XDM_YUV_422ILE
    Dei_Parameters.q_num                = 1; //1 or 3
    Dei_Parameters.askIMCOPRes            = 0;

 

   I call the DEI in this way, where hCapBuf is the 736x576 captured buffer, hDeinterlacerPrevBuf is the previous captured buffer and hDstBuf is the buffer allocated for the output.

      DEI_process(hVe1,
                               hCapBuf, hDeinterlacerPrevBuf,
                               hDstBuf);

      if (Framecopy_execute(hFc, hCapBuf, hDeinterlacerPrevBuf) < 0) {
                            ERR("Failed to execute frame copy job\n");
                            cleanup(THREAD_FAILURE);
        }

 

I know this is not an official release but if you can get some info about it I will be very grateful.

 

Thank you in advance.

  • Peregrinus said:
    The documentation refers to frames but it uses the terminology of video codecs which deals with frames so I not sure about it.

    The reference for a frame in deinterlacer algorithm documentation is for an actual "frame" which is combination of two fields. DEI algorithm expects that capture driver has provided a data buffer which has two fields interleaved in it.

    Peregrinus said:

    The deinterlacer instance is created but the call to DEI_process produces a SEGMENTATION FAULT. All the required pools have been allocated.

    Where is the segmentation fault happening? Is it inside the VIDENC1_process call for DEI? If yes, i would recommend you to look at the InArgs once. The other parameters seem to be ok as mentioned in your post.

    Regards,

    Anshuman

  • Hi Anshuman,

        thank you very much for the answer. So it seems I provide the right buffers to the codec engine. I wonder why the algorithm requires also the previous input buffer: is for the motion estimation?

    Yes, the segmentation fault occurs inside the VIDENC1_process. In the DMAI interface I get, only the size field of the InArgs was set. I tried to set the other fields in this way, without improvements even if I am not sure these settings are right.

     inArgs.size                         = sizeof(VIDENC1_InArgs);
     inArgs.inputID                        = Buffer_getId(hInBuf);
     inArgs.topFieldFirstFlag            = XDAS_TRUE;

     

    Another thing I tried to change was this part of the interface:

    if (BufferGfx_getColorSpace(hOutBuf) == ColorSpace_YUV420PSEMI) {

            outBufSizeArray[0]                  = Buffer_getSize(hOutBuf)*2/3;//Before it was:  120; //Dummy
            outBufSizeArray[1]                  = Buffer_getSize(hOutBuf)/3;   //Before it was 120; //Dummy
            outBufs[0]                          = (XDAS_Int8*)outPtr;
            outBufs[1]                          = (XDAS_Int8*)(outPtr+ Buffer_getSize(hOutBuf) * 2/3);
            outBufDesc.numBufs      = 2;
            outBufDesc.bufSizes      = outBufSizeArray; //Before the line was commented
            outBufDesc.bufs              = outBufs;

    }

    All the buffers are allocated, I also tried to double the output buffer size but the segmentation fault still occurs.

    Is it possible there is something wrong in the codec package?

     

     

     

  • I'm using DVSDK 4_00_00_22 on the DM368 and cannot find any reference to DEI_process or any kind of DEI related codec.

    Where do I get this?

    John A

  • John, I found a post where it was said to ask to the local FAE for the Deintelacer. I asked and I get it. 

    I have to say that it does not work, I have a segmentation fault from the deinterlacer function. In any case there is a post where someone was able to make it work but I am not sure he/she has the same code I have. I found some discrepancy, for instance, in the functions arguments of the included example compared to the codec (the deintalcer is managed as a codec in the codec engine).

    Please let me know if you make some progress here, thank you.

  • Venc1_Params_DEFAULT means Dei_Parameters.videncParams.size = sizeof(VIDENC1_Params)

    We should use  sizeof(IDEI_Params) instead, as followed:

    Dei_Parameters.videncParams = Venc1_Params_DEFAULT;
    Dei_Parameters.videncParams.size = sizeof(IDEI_Params);

     

    Now the problem is, when I called Vdei_process(hVe, hCapBuf, hPrevBuf, hOutBuf), the DEI returned with fatal error:

    VIDENC1_process() failed with error (-1 ext: 0x8000).

    And the testbench_dei_h264 return the same fatal error.

     

    Vdei_process() is attached.

     

    /******************************************************************************
    * Vdei_process
    ******************************************************************************/
    Int Vdei_process(Vdei_Handle hVe, Buffer_Handle hInBuf, Buffer_Handle hPrevBuf, Buffer_Handle hOutBuf)
    {
    IVIDEO1_BufDescIn inBufDesc;
    XDM_BufDesc outBufDesc;
    XDAS_Int32 status;
    VIDENC1_InArgs inArgs;
    IDEI_OutArgs outArgs;
    XDAS_Int8 *inPtr;
    XDAS_Int8 *prevPtr;
    XDAS_Int8 *outPtr;
    BufferGfx_Dimensions dim;
    UInt32 offset = 0;
    Uint32 bpp;
    XDAS_Int8 *outbufs[2];
    XDAS_Int32 outBufSizeArray[2], bufferSize;

    assert(hVe);
    assert(hInBuf);
    assert(hPrevBuf);
    assert(hOutBuf);
    assert(Buffer_getUserPtr(hInBuf));
    assert(Buffer_getUserPtr(hPrevBuf));
    assert(Buffer_getUserPtr(hOutBuf));
    assert(Buffer_getSize(hInBuf));
    assert(Buffer_getSize(hPrevBuf));
    assert(Buffer_getSize(hOutBuf));
    assert(Buffer_getType(hInBuf) == Buffer_Type_GRAPHICS);
    assert(BufferGfx_getColorSpace(hInBuf) == ColorSpace_UYVY);

    bpp = ColorSpace_getBpp(BufferGfx_getColorSpace(hInBuf));

    BufferGfx_getDimensions(hInBuf, &dim);

    offset = (dim.y * dim.lineLength) + (dim.x * (bpp >> 3));
    assert(offset < Buffer_getSize(hInBuf));

    inPtr = Buffer_getUserPtr(hInBuf) + offset;

    /* Set up the codec buffer dimensions */
    inBufDesc.frameWidth = dim.width;
    inBufDesc.frameHeight = dim.height;
    inBufDesc.framePitch = dim.width;

    bufferSize = dim.width * dim.height;

    inPtr = Buffer_getUserPtr(hInBuf);
    prevPtr = Buffer_getUserPtr(hPrevBuf);
    inBufDesc.numBufs = 2;

    inBufDesc.bufDesc[0].bufSize = bufferSize;
    inBufDesc.bufDesc[0].buf = inPtr;
    inBufDesc.bufDesc[0].accessMask = 0;

    inBufDesc.bufDesc[1].bufSize = bufferSize;
    inBufDesc.bufDesc[1].buf = prevPtr;
    inBufDesc.bufDesc[1].accessMask = 0;


    outPtr = Buffer_getUserPtr(hOutBuf);
    outbufs[0] = outPtr;
    outBufSizeArray[0] = bufferSize;
    outBufDesc.numBufs = 1;
    outBufDesc.bufs = outbufs;
    outBufDesc.bufSizes = outBufSizeArray;

    inArgs.size = sizeof(IDEI_InArgs);

    outArgs.videncOutArgs.size = sizeof(IDEI_OutArgs);

    /* Encode video buffer */
    status = VIDENC1_process(hVe->hEncode, &inBufDesc, &outBufDesc, &inArgs,
    (IVIDENC1_OutArgs *)&outArgs);

    if (status != VIDENC1_EOK) {
    Dmai_err2("VIDENC1_process() failed with error (%d ext: 0x%x)\n",
    (Int)status, (Uns) outArgs.videncOutArgs.extendedError);
    printf("VIDENC1_process() failed with error (%d ext: 0x%x)\n",
    (Int)status, (Uns) outArgs.videncOutArgs.extendedError);
    return Dmai_EFAIL;
    }

    return Dmai_EOK;
    }

  • Hi All,

    Can someone please direct me to the DMAI implemetation of the deinterlacer codec? (I'm using  DVSDK 2_10_01_18)

    Thanks,

    Shai.

     

  • You have to ask to the local FAE for the code. I think I get a buggy version since the call to the deinterlacer produces segmentation fault. Maybe you will be more lucky.

  • Hi :

    I have the same problem in the same place. In addition ,I have a kernel warning before the Segmentation fault: Alignment trap: moduletest.out (1501) PC=0x00013cdc Instr=0xe5815050 Address=0x0000004f FSR 0x801,and the warning is difficult to be located.

    Peregrinus, Are you solving now? thanks!

     

  • Hi aGuang,   
      sorry but unfortunately I didn't solve the problem. I think the code I get from my local FAE is unuseable. If you look here in these days there is a certain activity on DEI issue. I hope this bring to a stable code. 

     

  • Hi  Peregrinus:

    Although the test code run error segment fault, but i runned it ok when i migrate it to my application. threshold value should be 30 or bigger,otherwise DEI VIDENC1_process call may be block. good luck!

  • Hi all,

    I am facing the same problem: "segmentation fault" during the 2nd execution of VIDENC1_process.

    I checked all params but I didn't found anything.

    Did someone found the solution?

    Running deinterlacer with CE_DEBUG=3 there are no errors except "segmentation error" at last.

    Here is the log:

    @33,701,784us: [+0 T:0x44f03490 S:0x44f02acc] ti.sdo.ce.video1.VIDENC1 - VIDENC1_control> Enter (handle=0x15b10, id=1, dynParams=0x15a7c (size=0x30), status=0x44f02d14 (size=0x1934)
    @33,702,175us: [+5 T:0x44f03490 S:0x44f02aac] CV - VISA_enter(visa=0x15b10): algHandle = 0x15548
    @33,702,522us: [+0 T:0x44f03490 S:0x44f02a9c] ti.sdo.ce.alg.Algorithm - Algorithm_activate> Enter(alg=0x15548)
    @33,702,785us: [+0 T:0x44f03490 S:0x44f02a64] ti.sdo.ce.osal.SemMP - Entered SemMP_pend> sem[0x152b0] timeout[0xffffffff]
    @33,703,017us: [+0 T:0x44f03490 S:0x44f02a64] ti.sdo.ce.osal.SemMP - Leaving SemMP_pend> sem[0x152b0] status[0]
    @33,703,428us: [+0 T:0x44f03490 S:0x44f02aac] ti.sdo.ce.alg.Algorithm - Algorithm_activate> Exit
    @33,703,709us: [+5 T:0x44f03490 S:0x44f02ab4] CV - VISA_exit(visa=0x15b10): algHandle = 0x15548
    @33,703,951us: [+0 T:0x44f03490 S:0x44f02aa4] ti.sdo.ce.alg.Algorithm - Algorithm_deactivate> Enter(alg=0x15548)
    @33,704,226us: [+0 T:0x44f03490 S:0x44f02a84] ti.sdo.ce.osal.SemMP - Entered SemMP_post> sem[0x152b0]
    @33,704,458us: [+0 T:0x44f03490 S:0x44f02a84] ti.sdo.ce.osal.SemMP - Leaving SemMP_post> sem[0x152b0]
    @33,704,644us: [+0 T:0x44f03490 S:0x44f02ab4] ti.sdo.ce.alg.Algorithm - Algorithm_deactivate> Exit
    @33,704,810us: [+0 T:0x44f03490 S:0x44f02acc] ti.sdo.ce.video1.VIDENC1 - VIDENC1_control> Exit (handle=0x15b10, retVal=0x0)
    @33,705,039us: [+0 T:0x44f03490 S:0x44f02afc] ti.sdo.ce.video1.VIDENC1 - VIDENC1_process> Enter (handle=0x15b10, inBufs=0x44f02b9c, outBufs=0x44f02cf8, inArgs=0x44f02cec, outArgs=0x44f02c6c)
    @33,705,270us: [+5 T:0x44f03490 S:0x44f02adc] CV - VISA_enter(visa=0x15b10): algHandle = 0x15548
    @33,705,451us: [+0 T:0x44f03490 S:0x44f02acc] ti.sdo.ce.alg.Algorithm - Algorithm_activate> Enter(alg=0x15548)
    @33,705,632us: [+0 T:0x44f03490 S:0x44f02a94] ti.sdo.ce.osal.SemMP - Entered SemMP_pend> sem[0x152b0] timeout[0xffffffff]
    @33,705,836us: [+0 T:0x44f03490 S:0x44f02a94] ti.sdo.ce.osal.SemMP - Leaving SemMP_pend> sem[0x152b0] status[0]
    @33,706,041us: [+0 T:0x44f03490 S:0x44f02adc] ti.sdo.ce.alg.Algorithm - Algorithm_activate> Exit
    @33,713,964us: [+5 T:0x44f03490 S:0x44f02ae4] CV - VISA_exit(visa=0x15b10): algHandle = 0x15548
    @33,714,221us: [+0 T:0x44f03490 S:0x44f02ad4] ti.sdo.ce.alg.Algorithm - Algorithm_deactivate> Enter(alg=0x15548)
    @33,714,428us: [+0 T:0x44f03490 S:0x44f02ab4] ti.sdo.ce.osal.SemMP - Entered SemMP_post> sem[0x152b0]
    @33,714,640us: [+0 T:0x44f03490 S:0x44f02ab4] ti.sdo.ce.osal.SemMP - Leaving SemMP_post> sem[0x152b0]
    @33,714,820us: [+0 T:0x44f03490 S:0x44f02ae4] ti.sdo.ce.alg.Algorithm - Algorithm_deactivate> Exit
    @33,714,986us: [+0 T:0x44f03490 S:0x44f02afc] ti.sdo.ce.video1.VIDENC1 - VIDENC1_process> Exit (handle=0x15b10, retVal=0x0)
    @34,927,751us: [+0 T:0x44f03490 S:0x44f02acc] ti.sdo.ce.video1.VIDENC1 - VIDENC1_control> Enter (handle=0x15b10, id=1, dynParams=0x15a7c (size=0x30), status=0x44f02d14 (size=0x1e)
    @34,928,023us: [+5 T:0x44f03490 S:0x44f02aac] CV - VISA_enter(visa=0x15b10): algHandle = 0x15548
    @34,928,219us: [+0 T:0x44f03490 S:0x44f02a9c] ti.sdo.ce.alg.Algorithm - Algorithm_activate> Enter(alg=0x15548)
    @34,928,392us: [+0 T:0x44f03490 S:0x44f02a64] ti.sdo.ce.osal.SemMP - Entered SemMP_pend> sem[0x152b0] timeout[0xffffffff]
    @34,928,599us: [+0 T:0x44f03490 S:0x44f02a64] ti.sdo.ce.osal.SemMP - Leaving SemMP_pend> sem[0x152b0] status[0]
    @34,928,806us: [+0 T:0x44f03490 S:0x44f02aac] ti.sdo.ce.alg.Algorithm - Algorithm_activate> Exit
    @34,928,986us: [+5 T:0x44f03490 S:0x44f02ab4] CV - VISA_exit(visa=0x15b10): algHandle = 0x15548
    @34,929,148us: [+0 T:0x44f03490 S:0x44f02aa4] ti.sdo.ce.alg.Algorithm - Algorithm_deactivate> Enter(alg=0x15548)
    @34,929,327us: [+0 T:0x44f03490 S:0x44f02a84] ti.sdo.ce.osal.SemMP - Entered SemMP_post> sem[0x152b0]
    @34,929,703us: [+0 T:0x44f03490 S:0x44f02a84] ti.sdo.ce.osal.SemMP - Leaving SemMP_post> sem[0x152b0]
    @34,929,902us: [+0 T:0x44f03490 S:0x44f02ab4] ti.sdo.ce.alg.Algorithm - Algorithm_deactivate> Exit
    @34,930,076us: [+0 T:0x44f03490 S:0x44f02acc] ti.sdo.ce.video1.VIDENC1 - VIDENC1_control> Exit (handle=0x15b10, retVal=0x0)
    @34,930,264us: [+0 T:0x44f03490 S:0x44f02afc] ti.sdo.ce.video1.VIDENC1 - VIDENC1_process> Enter (handle=0x15b10, inBufs=0x44f02b9c, outBufs=0x44f02cf8, inArgs=0x44f02cec, outArgs=0x44f02c6c)
    @34,930,473us: [+5 T:0x44f03490 S:0x44f02adc] CV - VISA_enter(visa=0x15b10): algHandle = 0x15548
    @34,930,641us: [+0 T:0x44f03490 S:0x44f02acc] ti.sdo.ce.alg.Algorithm - Algorithm_activate> Enter(alg=0x15548)
    @34,930,817us: [+0 T:0x44f03490 S:0x44f02a94] ti.sdo.ce.osal.SemMP - Entered SemMP_pend> sem[0x152b0] timeout[0xffffffff]
    @34,931,014us: [+0 T:0x44f03490 S:0x44f02a94] ti.sdo.ce.osal.SemMP - Leaving SemMP_pend> sem[0x152b0] status[0]
    @34,931,221us: [+0 T:0x44f03490 S:0x44f02adc] ti.sdo.ce.alg.Algorithm - Algorithm_activate> Exit
    Segmentation fault

     

    It's running on a DM365 board, here are the components versions:

    - DEI algorithm version 1.70.00
    - dvsdk_2_10_01_18
    - framework_components_2_24_01
    - linuxutils_2_24_03
    - xdctools_3_15_01_59
    - codec_engine_2_24

    I'm running DEI in standalone mode.

    Thanks in advance.
    Best regards

     

     

  • Hi Stefano,

    You can download the latest DM36x DEI(ver 1.9) lib and test bench from the following link:

    https://twiki.dal.design.ti.com/twiki/bin/view/ASP/DSPS/VsiProjects

    Use the DEI test bench to test it out.

    regards,

    Anand

  • Hi Anand,

    the link is not working.

    Regards

  • HI,

      I am using DVSDK_2_10_01_18. I  got DEI from my local Ti support. The DEI version is 1.90.00.  However, the current DM365mm module doesn't has the function for dm365mm_mmp. 

    From test source code, there are the following codes:   sysRegBase = DM365MM_mmap(0x01C40000,0x4000);    DM365MM_ummap(sysRegBase,0x4000);

    So  Could you send me the updated DM365mm module for DEI?  I contacted my local support almost one month, he asked me to download the latest DVSDK for checking. I downloaded the latest DVSDK and found there is no DM365mm_mmap function in DM365mm module either. I guess my local support don't know whether to get it.

    my email:jianpengz@tme-inc.com

    Thanks

    Bill

  • "Although the test code run error segment fault, but i runned it ok when i migrate it to my application. threshold value should be 30 or bigger,otherwise DEI VIDENC1_process call may be block. good luck!"

     

     

    Can you tell me which file needed to be changed threshold value ?