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 Encoder problem on DM3730

Other Parts Discussed in Thread: DM3730

I am trying to use the JPEG encoder on the DM3730.  I am using the DMAI layer as my interface.  I can set up and open the JPEG encoder successfully.  When I run the process function the first time, everything works great and I get a good image out (~1.5 MB 14MP image).  However, when I try to do another process call, it returns a very small size output (575 bytes).  There is no indication of any error from the Codec Engine or DMAI layer.  I've even set CE_DEBUG=3 and I don't see any messages that are different from the successful case.  The only way I can get the codec to work the second time is to delete the instance of the JPEG encoder and re-create it.  Can anyone help with this?

 

Thanks,

Jason

  • Jason,

    can you verify DVSDK version and JPEG Encoder version?

    DVSDK 4.02.00.06

    JPEG Encoder 2.00.01

    can you send the app source code? 

     

  • Marc,

     

    DVSDK version is correct, but the JPEG encoder release notes say that the JPEG encoder is version 2.01.01(April 2010).

     

    Snippet of code that sets up and uses the JPEG encoder is given below.  The highlighted section is the setup and is what I want to only run once at startup.  Currently I have to close the JPEG encoder and re-run this setup to make it work the 2nd time.

     

        IMGENC1_Params          jpegdefaultParams         = Ienc1_Params_DEFAULT;
        IMGENC1_DynamicParams   jpegdefaultDynParams      = Ienc1_DynamicParams_DEFAULT;
        IMGENC1_Params          *jpegparams;
        IMGENC1_DynamicParams   *jpegdynParams;
        char                     *jpegEncoder              = "jpegenc";
       
        //Initialize video encoder with default params
        jpegparams = &jpegdefaultParams;
        jpegdynParams = &jpegdefaultDynParams;   

        //Customize parameters here
        jpegparams->maxWidth          = VideoStd_14MP_WIDTH;       //4064
        jpegparams->maxHeight         = VideoStd_14MP_HEIGHT;    //3312
       
        jpegdynParams->inputWidth      = VideoStd_14MP_WIDTH;
        jpegdynParams->inputHeight      = VideoStd_14MP_HEIGHT;
        jpegdynParams->captureWidth      = jpegdynParams->inputWidth;
        jpegdynParams->qValue            = 90;

        //Create the jpeg encoder
        hIe1 = Ienc1_create(hEngine, jpegEncoder, jpegparams, jpegdynParams);

        if (hIe1 == NULL) {
            printf("Failed to create jpeg encoder: %s\n", jpegEncoder);
            return -1;
        }else{
            printf("JPEG Encoder Created Successfully\n");
        }


        //Get output buffer for jpeg encoder
         jpegBuf = BufTab_getBuf(hBufTabJpegEnc, 0);
        
         //Encode the jpeg buffer
         if (Ienc1_process(hIe1, cBuf, jpegBuf) < 0) {     //cBuf is the captured frame
             printf("Failed to encode jpeg buffer\n");
         }
        
         printf("JPEG buf ptr = %p, Encoded Size = %d\n", jpegBuf, Buffer_getNumBytesUsed(jpegBuf));    
       

  • The jpeg encoder has undocumented requirements for how it must be run in a loop.  I found out through other e2e posts, one of which linked to an old TI wiki page, but I can't find the links right now.

     

    while()

    {

    process()

    control()

    }

     

    It takes some doing to call the control loop, since it isn't available through the high level API.

    #include <ti/sdo/dmai/ce/Ienc1.h>

        Ienc1_Handle            hIe1                = NULL;
        IMGENC1_Params          iEncDefaultParams         = Ienc1_Params_DEFAULT;
        IMGENC1_DynamicParams   iEncDefaultDynamicParams  = Ienc1_DynamicParams_DEFAULT;

        IMGENC1_Params          *iEncParams;
        IMGENC1_DynamicParams   *iEncDynamicParams;

        IMGENC1_Handle          hIMGENC1;
        IMGENC1_Status          iEncStatus;

        iEncStatus.size = sizeof(IMGENC1_Status);
        iEncStatus.data.buf = NULL;

        hIMGENC1 = Ienc1_getVisaHandle(hIe1); //needed for control

    ...

    while(1)

    Ienc1_process(xxx);

            if(IMGENC1_control(hIMGENC1, XDM_SETPARAMS, iEncDynamicParams, &iEncStatus))
            {
              printf("Called VIDENC1_control, failed\n");
            }

    }