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.

IMGENC1_control problem with jpeg encoder

Hello,

I modified the DMAI image_encode_io sample to change some settings of the jpeg encoder.

My changes:


#include <ti/sdo/codecs/jpegenc/ijpegenc.h>

....

....

Void appMain(Args * args)
{
    int ret = 0, i = 0;
    IJPEGENC_DynamicParams  dynJpgParams;
    IJPEGENCQtab            qTab; /* quantization tab */
    IMGENC1_Handle            hImgEnc        = NULL;
    IMGENC1_Status            imgStatus;

....
....

    for(i = 0; i < 64; i++){
        qTab.luma[i] = 0x55;
        qTab.chroma[i] = 0xaa;
    }

    hImgEnc = Ienc1_getVisaHandle(hIe);

    dynParams.size = sizeof(IJPEGENC_DynamicParams);
    dynJpgParams.imgencDynamicParams = dynParams;
    dynJpgParams.rstInterval                        = 84; // default 84
    dynJpgParams.disableEOI                            = 0;  // default 0
    dynJpgParams.rotation                            = 270;  // can be 0 (default), 90, 180, 270

//    dynJpgParams.customQ                            = &qTab; // default NULL
   dynJpgParams.customQ                            = NULL; // default NULL

   imgStatus.size = sizeof(imgStatus);

    ret = IMGENC1_control(hImgEnc, IJPEGENC_SETPARAMS, (IIMGENC1_DynamicParams *)&dynJpgParams, &imgStatus);

....

....


Rotating the image works fine, but I can't  set my own quantization tab (no error message).
Instead the first 20 values in my quantization tab (qTab) are changed by IMGENC1_control() to
0x...00 00 00 00 00 00 00 00 b4 d2 0d 41 00 00 00 00 00 00 00 00- even if I set customQ to NULL.

If I look at the pointers, I see the following paritioning:

imgStatus|qTab|dynJpgParams

Is there something wrong in my code?
Is there a bug in the jpeg encoder?
Is anybody able to set a user defined quantization tab?

S. Stiller

  • Hi Sandro,

    Please add the following code to send control command for setting up Q Table after your below lines of code

    >>    ret = IMGENC1_control(hImgEnc, IJPEGENC_SETPARAMS, (IIMGENC1_DynamicParams *)&dynJpgParams, &imgStatus);

     

        status = IMGENC1_control(hEncode, JPEGENC_TI_ENCODE_SETCUSTOMQ, (IIMGENC1_DynamicParams *)&dynJpgParams, &imgStatus);
        if (status != VIDENC1_EOK) {
          printf("\n JPEG SETERROR in customQ\n");
            return FAILURE;
     }

     

    Regards,

    Anshuman

  • Hello Anshuman,


    thank you for the hint, now I can set the quantization tab.

    I found the following enum in the ijpegenc.h:

    43 typedef enum {
    44   JPEGENC_TI_ENCODE_SETPREPROC= XDM_GETBUFINFO + 1,
    45   JPEGENC_TI_ENCODE_SETOVERLAY,
    46   JPEGENC_TI_ENCODE_SETCUSTOMQ,
    47   JPEGENC_TI_ENCODE_ABORT
    48 } JPEGENC_TI_ENCODE_ExtCmdId;

    But can't find any documentation how to use the different values of JPEGENC_TI_ENCODE_ExtCmdId.
    (e.g. JPEGENC_TI_ENCODE_SETOVERLAY seems to be interesting)


    And I still have the problem that

    IMGENC1_control(hImgEnc, IJPEGENC_SETPARAMS, (IIMGENC1_DynamicParams *)&dynJpgParams, &imgStatus);

    writes to my memory (if I want to rotate the image).

     

    regards,

    Sandro