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.

JPEG encode on DM365EVM.



Hello,

I want to use jpeg codec on dvsdk encode demo (using DM365EVM).

I changed the source code of three files.

     1. codec.c      2. encode.cnf         3. video.c

The source code was able to be compile. But JPEG image was not able to be displayed .

Why cannot I do ?

 

An additional content is the following :

● codec.c

static Char *jpegExtensions[] = { ".jpeg", NULL };

static Codec videoEncoders[] = {
    {
        "jpegenc",
        "JPEG Video",
        jpegExtensions,
        NULL,
        NULL
    },

    {
        "mpeg4enc",
        "MPEG4 Video",
        mpeg4Extensions,
        NULL,
        NULL
    },
    {
        "h264enc",
        "H.264 HP",
        h264Extensions,
        NULL,
        NULL
    },    
    { NULL }
};

● encode .cnf

var JPEGENC = xdc.useModule('ti.sdo.codecs.jpegenc.ce.JPEGENC');

var myEngine = Engine.create("encode", [
    {name: "jpegenc", mod: JPEGENC, local: true, groupId: 1}, 
    {name: "mpeg4enc", mod: MPEG4ENC, local: true, groupId: 1},
    {name: "h264enc", mod: H264ENC, local: true, groupId: 1},
    {name: "g711enc", mod: G711ENC, local: true},
]);

● video.c


    Encoder = strcmp(envp->videoEncoder,"jpegenc");

    if (Encoder == 0){

        printf("JPEG encode start %s\n",envp->videoEncoder);

            /* Open the codec engine */
            JEngine = Engine_open(envp->engineName, NULL, NULL);

            if (JEngine == NULL) {
                ERR("Failed to open jpeg codec engine %s\n", envp->engineName);
                cleanup(THREAD_FAILURE);
            }

        /* Set up codec parameters */
        iparams = envp->params ? envp->params : &idefaultParams;
        idynParams = envp->dynParams ? envp->dynParams : &idefaultDynParams;

        iparams->size        = sizeof(IMGENC1_Params);
        iparams->maxWidth        = envp->imageWidth;
        iparams->maxHeight        = envp->imageHeight;
        iparams->maxScans        = 1;
        iparams->dataEndianness    = XDM_BYTE;
        iparams->forceChromaFormat    = XDM_YUV_422P;

        idynParams->inputWidth    = iparams->maxWidth;
        idynParams->inputHeight    = iparams->maxHeight; 
       
        hIe1 = Ienc1_create(JEngine, envp->videoEncoder, iparams, idynParams);

        if (hIe1 == NULL) {
            ERR("Failed to create JPEG encoder: %s\n", envp->videoEncoder);
            cleanup(THREAD_FAILURE);
        }

        /* Store the output buffer size in the environment */
        envp->outBufSize = Ienc1_getOutBufSize(hIe1);
    }

    else {

    /* H.264 encode  */

}

 

while (!gblGetQuit()) {

...

 

    if (Encoder == JPEG){

                if (Ienc1_process(hIe1, hCapBuf, hDstBuf) < 0) {

                    ERR("Failed to JPEG encode video buffer\n");
                    cleanup(THREAD_FAILURE);
                }
            }
     else {

              if (Venc1_process(hVe1, hCapBuf, hDstBuf) < 0) {

                    ERR("Failed to encode video buffer\n");
                    cleanup(THREAD_FAILURE);

                }

            }

     }

}

 

 

  • Can you please verify if the inputChromaFormat parameter is set properly?

    It looks some wrong setting of input parameters.

    Please share the complete list of both Create time & Dynamic parameters with values.

     

    Regards,

    Tej

  • Were you ever able to figure out what your problem was for encoding a proper JPEG on the dm365?  I'm seeing the exact same output when I'm encoding and I'm pulling my hair out trying to figure out what's wrong. My gut feeling is that I want to be using UYVY instead of 420semi-planar but that's only because I feel like the buffer is getting half of the captured data.

    I've gotten mpeg4 encoding and decoding + jpeg encoding working previously but that was using the dm355 and dvsdk 1.30.0.40.  All these changes along with the inclusion of dmai have really muddied the waters for me.

    On a lark I tried modifying the encodedecode demo (using passthrough option) to use Colorspace_UYVY for capture/display instead of 420PSEMI but then I get major tearing on my display.  I'm thinking this is a driver setting but can't for the life of me figure out what's wrong. 

    Any help is greatly appreciated.

    Thanks,

    BJ

    Oh, and I'm using the arago kernel 2.6.32 with dvsdk 3.10.00.16 and the dm365 evm.

  • Hi, BJ

      It seems we have met the same problem to yours. I think it is the color space not be set proper. It seems that DM365 don't support 420PSEMI colorspace.

  •  Sorry, I mean it seems the JPEG encoder of DM365 doen't support 420PSEMI .

  • Hi David,

     

    DM365 JPEG Encoder does support YUV 420 SemiPlanar as Input.

    You need to set inputChromaFormat = XDM_YUV_420SP

     

    Regards,

    Tej

  • Using a similar We are able to encode D1 frames but not CIF frames. When we encode CIF frames we get noise which we don't get using D1 frames.

    I attach amd example.

    We are using dvsdk_3_10_00_12.

    We using Ienc1 with the follwing parameters:


    //  m_sParams.forceChromaFormat = XDM_YUV_420SP;
      m_sParams.maxWidth  = m_iWidth;
      m_sParams.maxHeight = m_iHeight;

      m_sDynParams.inputWidth         = m_iWidth;
      m_sDynParams.inputHeight        = m_iHeight;
      m_sDynParams.captureWidth       = m_sDynParams.inputWidth;
      m_sDynParams.inputChromaFormat  =  XDM_YUV_420SP;

      m_hEncoder = Ienc1_create(m_hEngine, "jpegenc", &m_sParams, &m_sDynParams);

    Can anybody help?

     

    Shlomo

  • This seems to be a problem with the chroma data (CbCr) that is passed to the JPEG encoder. Can you please check if the inBuff address for chroma is correctly set and also do you have the right line offset set for the input buffers. I assume line offset might not be a problem as you are getting luma data correctly encoded.

     

    Regards,

    Anshuman

  • Hi Anshuma,

    By putting in printfs I have verified that  Ienc1_process function sends the correct inBuff Adress for both chroma and CbCr  for both D1. That is

    Chroma address is widfh * height and

    CbCr address is (width * height)/2

    Which is what the data sheet recommends.

    Have you any other suggestions?

    Shlomo

     

     

     


  • Hi,

    Looks like there is some typo error in your post. Do you mean to say Luma and Chroma data address, both are correct? What is the width and height of your captured data that is sent to the JPEG encoder? Can you share the YUV data that you are providing as input to the JPEG encoder? We can look at it and then compare the JPEG encoder settings you have used. I still think that possibly your capture height is different from the height you are using to calculate encoder InBuff address (specially for Chroma (CbCr) data.

    Regards,

    Anshuman

  • respected  sir,

    I am  currently working on leopard DM 365 with  LI-5M02image sensor, my basic problem is i have to perform face detection using leo 365. For this i need the source code for image capture. As i was new to this topic i couldn't able to find out the source code for image capturing using leo 365. please provide some information in this regard. I am stuck here. please help

    Thank you

    Arjun