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.

C6678 Jpeg Encoder DRI Marker

Other Parts Discussed in Thread: SYSBIOS

Hi, everyone:

   I use the C6678 for jpeg encoder, the jpeg encoder codec version is C66x_jpegenc_02_02_00_01_ELF.

  My question is when I encode the picture without the DRI Marker, the encode total time is about 80ms, while with the DRI Marker, the total time is about 300ms!!!  When I change the DRI_Interval, it is also about 300ms!!!

  Is it ture? (I am sure that the encoded jpeg picture is right, and the size of the picture with or without DRI Marker is almost the same.)

  thanks a lot.

  • Can anyone help me?

    thank you

  •  Hi, which image resolution are you using? could you share your configuration file? also could you please try latest JPEG enc JPEG_E 02_02_01_05 (http://software-dl.ti.com/dsps/dsps_public_sw/codecs/C6678/JPEG_E/latest/index_FDS.html) and let us know if the behaviour is the same?

    Thank you,

    Paula

  • hi,Paula,

       thanks for your reply. The image resolution is 3264*2448, the configuration is :

      IALG_Handle JpegEncAlgCreate (uint32_t uwImageWidth, uint32_t uwImageHeight, XDM_ChromaFormat eForceChromaFormat)
    {
       IALG_Handle hJpegEnc;
       IDMJPGE_TIGEM_Params tJpegEncParams;

       memset(&tJpegEncParams, 0, sizeof(IDMJPGE_TIGEM_Params));
       tJpegEncParams.params.size              = sizeof(IDMJPGE_TIGEM_Params);
       tJpegEncParams.params.maxWidth          = uwImageWidth;       
       tJpegEncParams.params.maxHeight         = uwImageHeight;
       tJpegEncParams.params.maxScans          = XDM_DEFAULT;
       tJpegEncParams.params.dataEndianness    = XDM_BYTE;
       tJpegEncParams.params.forceChromaFormat = eForceChromaFormat;     /* XDM_YUV_420P/YUV422P*/
       
        hJpegEnc = (IALG_Handle)ALG_create((IALG_Fxns *)&DMJPGE_TIGEM_IDMJPGE,
                                     (IALG_Handle)NULL, (IALG_Params *)(&tJpegEncParams));
        return hJpegEnc;
    }

    And the eForceChromaFormat is XDM_YUV_420P.

    The Dynamic Params is :

    XDAS_Void jpegEncSetDynamicParams (IDMJPGE_TIGEM_DynamicParams *ptJpegEncDynamicParams,
                  uint32_t uwInputWidth, uint32_t uwInputHeight,
                  int32_t wQValue, XDM_ChromaFormat eInputChromaFormat)
    {
     memset(ptJpegEncDynamicParams, 0, sizeof(IDMJPGE_TIGEM_DynamicParams));
        ptJpegEncDynamicParams->params.size              = sizeof(IDMJPGE_TIGEM_DynamicParams);
        ptJpegEncDynamicParams->params.numAU             = 0;//(uwInputWidth >> 4) * (uwInputHeight >> 4);
        ptJpegEncDynamicParams->params.generateHeader    = XDM_ENCODE_AU;

        ptJpegEncDynamicParams->params.inputWidth        = uwInputWidth;
        ptJpegEncDynamicParams->params.inputHeight       = uwInputHeight;
        ptJpegEncDynamicParams->params.inputChromaFormat = eInputChromaFormat; //XDM_YUV_420P;
        ptJpegEncDynamicParams->params.qValue            = wQValue;
        ptJpegEncDynamicParams->params.captureWidth      = uwInputWidth;

        ptJpegEncDynamicParams->captureHeight            = uwInputHeight;
        ptJpegEncDynamicParams->quantTable               = &gtStandardQuantTable;

        ptJpegEncDynamicParams->DRI_Interval = 0; //(uwInputWidth >> 4) * (uwInputHeight >> 4);
        return;
    }

    And the eInputChromaFormat is XDM_YUV_420P.

    I will try the latest JPEG enc JPEG_E 02_02_01_05 , then i will give you a message.

    Thanks again.

    qbliu

  • hi,Paula,

       I tested the  JPEG enc JPEG_E 02_02_01_05 ,  the time is about 290ms,without DRI Marker, about 77ms!!

      The alg create params are: 

    IALG_Handle JpegEncAlgCreate (uint32_t uwImageWidth, uint32_t uwImageHeight, XDM_ChromaFormat eForceChromaFormat)
    {
     IALG_Handle hJpegEnc;
     IDMJPGE_TIGEM_Params tJpegEncParams;

     tJpegEncParams.params.size              = sizeof(IDMJPGE_TIGEM_Params);
     tJpegEncParams.params.maxWidth          = uwImageWidth;
     tJpegEncParams.params.maxHeight         = uwImageHeight;
     tJpegEncParams.params.maxScans          = 0;
     tJpegEncParams.params.dataEndianness    = XDM_BYTE;
     tJpegEncParams.params.forceChromaFormat = eForceChromaFormat;     /* XDM_YUV_420P/XDM_YUV_422P*/
       
     tJpegEncParams.MaxThumbnail_H_size_App0 = XDM_DEFAULT;
     tJpegEncParams.MaxThumbnail_V_size_App0 = XDM_DEFAULT;
     tJpegEncParams.MaxThumbnail_H_size_App1 = XDM_DEFAULT;
     tJpegEncParams.MaxThumbnail_V_size_App1 = XDM_DEFAULT;
     tJpegEncParams.MaxThumbnail_H_size_App13 = XDM_DEFAULT;
     tJpegEncParams.MaxThumbnail_V_size_App13 = XDM_DEFAULT;

        hJpegEnc = (IALG_Handle)ALG_create((IALG_Fxns *)&DMJPGE_TIGEM_IDMJPGE,
                                     (IALG_Handle)NULL, (IALG_Params *)(&tJpegEncParams));
        return hJpegEnc;
    }

    and the Dynamic Params:

     

    XDAS_Void jpegEncSetDynamicParams (IDMJPGE_TIGEM_DynamicParams *ptJpegEncDynamicParams,
                  uint32_t uwInputWidth, uint32_t uwInputHeight,
                  int32_t wQValue, XDM_ChromaFormat eInputChromaFormat)
    {
     //memset(ptJpegEncDynamicParams, 0, sizeof(IDMJPGE_TIGEM_DynamicParams));
        ptJpegEncDynamicParams->params.size              = sizeof(IDMJPGE_TIGEM_DynamicParams);
        ptJpegEncDynamicParams->params.numAU             = 0;//(uwInputWidth >> 4) * (uwInputHeight >> 4);
        ptJpegEncDynamicParams->params.generateHeader    = XDM_ENCODE_AU;

        ptJpegEncDynamicParams->params.inputWidth        = uwInputWidth;
        ptJpegEncDynamicParams->params.inputHeight       = uwInputHeight;
        ptJpegEncDynamicParams->params.inputChromaFormat = eInputChromaFormat; //XDM_YUV_420P;
        ptJpegEncDynamicParams->params.qValue            = wQValue;
        ptJpegEncDynamicParams->params.captureWidth      = uwInputWidth;

        ptJpegEncDynamicParams->captureHeight            = uwInputHeight;
        ptJpegEncDynamicParams->quantTable               = &gtStandardQuantTable;

        ptJpegEncDynamicParams->DRI_Interval = (uwInputWidth >> 4); //(uwInputWidth >> 4) * (uwInputHeight >> 4);

        ptJpegEncDynamicParams->captureHeight = 0;
     ptJpegEncDynamicParams->Thumbnail_Index_App0 = 0;
     ptJpegEncDynamicParams->Thumbnail_Index_App1 = 0;
     ptJpegEncDynamicParams->Thumbnail_Index_App13 = 0;
     ptJpegEncDynamicParams->Thumbnail_H_size_App1 = 0;
     ptJpegEncDynamicParams->Thumbnail_V_size_App1 = 0;
     ptJpegEncDynamicParams->Thumbnail_H_size_App0 = 0;
     ptJpegEncDynamicParams->Thumbnail_V_size_App0 = 0;
     ptJpegEncDynamicParams->Thumbnail_H_size_App13 = 0;
     ptJpegEncDynamicParams->Thumbnail_V_size_App13 = 0;
     ptJpegEncDynamicParams->APPN0_numBufs = 0;
     ptJpegEncDynamicParams->APPN1_numBufs = 0;
     ptJpegEncDynamicParams->APPN13_numBufs = 0;
     ptJpegEncDynamicParams->APPN0_startBuf = 0;
     ptJpegEncDynamicParams->APPN1_startBuf = 0;
     ptJpegEncDynamicParams->APPN13_startBuf = 0;
     ptJpegEncDynamicParams->COMMENT_insert = 0;
     ptJpegEncDynamicParams->COMMENT_startBuf = 0;

        return;
    }

    The encoded jpeg is right. Can you check it.

    thanks, qbliu

  • Hi qblui,

    How are you measuring time? are you using JPEG Enc unitest framework? If so, can you please share with me Testparams.cfg? (located at C:\Program Files\Texas Instruments\Codecs\C66x_jpegenc_02_02_01_05_ELF\packages\ti\sdo\codecs\jpegenc\App\Client\Test\TestVecs\Config\ ), which DRI_Interval is giving you ~300ms?

    Thank you,

    Paula

     

     

  • hi,paula,

    1、How are you measuring time?

         I use the module 'ti.sysbios.family.c64p.TimestampProvider' to measure time like that:

       uwStartClock = TimestampProvider_get32();

       jpegEncode();

        uwEndClock = TimestampProvider_get32();

       System_printf("jpeg encode time = %.2fms, jpeg size = %d.\n",
              (double)(uwEndClock - uwStartClock) / 1000.0 / 1000.0, uwJpgSize);  // the cpu clock is 1GHz

       2、can you please share with me Testparams.cfg?

         I create a new project, so i do not use the Testparams.cfg. And  I will share the project.

       In this project, i use the xds560v2 to load the yuv data(for example,Input_420p.yuv at D:\ti\Codecs\C66x_jpegenc_02_02_01_05_ELF\packages\ti\sdo\codecs\jpegenc\App\Client\Test\TestVecs\Input) to 0x0c000000(MSMCSRAM), and use the function:

      JpegEncAlgCreate() to create the encode alg. and then use the function jpegEnc() to encode the yuv data at 0x0c000000 .

    3、Paula,you can use the project at D:\ti\Codecs\C66x_jpegenc_02_02_01_05_ELF\packages\ti\sdo\codecs\jpegenc\App\Client\Build\TestAppEncoderand change the params->DRI_Interval in the function TestApp_SetDynamicParams() in TestAppEncoder.c to imageWidth/16 or other value. Then you can measure the jpeg encode time with params->DRI_Interval = 0 and other value to check the time with DRI Marker and without DRI Marker. I will also do it.

    Look forward to your reply!

    qbliu

  • Hi qblui, As a test I encode same image (720x480) with and without DRI. In the case in which DRI was enabled I used DRI_Interval = 20, the rest of the parameter were the same in both configurations. I used unitest framework (CCS and JTAG), please see below results:

    [C66xx_0] *******************************************

    [C66xx_0] Read Configuration Set 1

    [C66xx_0] *******************************************

    [C66xx_0] Running in Output Dump Mode

    [C66xx_0] Input file... ..\..\..\Test\TestVecs\Input\Input_420p.yuv

    [C66xx_0] Test File... ..\..\..\Test\TestVecs\Output\Output_420p_DRI.jpg

    [C66xx_0] Creating Algorithm Instance...

    [C66xx_0] Algorithm Instance Creation Done...

    [C66xx_0]

    [C66xx_0] Encoder output dump completed

    [C66xx_0] Encoder output dump completed

    [C66xx_0] Image Encoded = 1

    [C66xx_0] Width and Height = 720, 480

    [C66xx_0] QP = 80

    [C66xx_0] Ratio = 10.121837

    [C66xx_0] MegaPixel/sec 500 : 50.154207 Cycles Taken : 3445374 Cycles per pixel : 9.969253 Total_BytesRead : 518400 TotalBytes: 0 Ratio : 10.121837

    [C66xx_0]

    [C66xx_0] *******************************************

    [C66xx_0] Read Configuration Set 2

    [C66xx_0] *******************************************

    [C66xx_0] Running in Output Dump Mode

    [C66xx_0] Input file... ..\..\..\Test\TestVecs\Input\Input_420p.yuv

    [C66xx_0] Test File... ..\..\..\Test\TestVecs\Output\Output_420p_NoDRI.jpg

    [C66xx_0] Creating Algorithm Instance...

    [C66xx_0] Algorithm Instance Creation Done...

    [C66xx_0]

    [C66xx_0] Encoder output dump completed

    [C66xx_0] Encoder output dump completed

    [C66xx_0] Image Encoded = 2

    [C66xx_0] Width and Height = 720, 480

    [C66xx_0] QP = 80

    [C66xx_0] Ratio = 10.121837

    [C66xx_0] MegaPixel/sec 500 : 50.152227 Cycles Taken : 3445510 Cycles per pixel : 9.969647 Total_BytesRead : 518400 TotalBytes: 0 Ratio : 10.121837

    [C66xx_0]

    [C66xx_0] End of execution

    At least for these resolution # cycles is ~= for both cases. Could you please share with me your input file?

    Thank you,

    Paula

  • hi, ,

    If you use the project at c:\ti\Codecs\C66x_jpegenc_02_02_01_05_ELF\packages\ti\sdo\codecs\jpegenc\App\Client\Build\TestAppEncoder. You must change the params->DRI_Interval = 0 in the function TestApp_SetDynamicParams or it will be useless.

     

    qbliu

  • hi,paula,

    Could you please give your email address, i will send my project to you.

    Because I do not know how to upload my project here.

    qbliu 

  • hi,Paula,

      with my project, I test the picture 720x480, Input_420p.yuv at c:\ti\Codecs\C66x_jpegenc_02_02_01_05_ELF\packages\ti\sdo\codecs\jpegenc\App\Client\Test\TestVecs\Input,

    My encode time is about 3.64ms, about 3640000 cycles, and the encode time of your test is 3445374 cycles without DRI Marker or 3445510 cycles with DRI marker 20,

    It looks like the same. But in my project if I use the DRI marker = 720/16(An integer multiple of the number of the MCU in one MCU row), its endode time is about 12.86ms=12860000cycles!!

    qbliu

  • Hi qbliu,

    I was able to reproduce you times (please see below console outputs). I will check with the codec team if this is a expected behaviour. By the way thanks for reporting the bug about no being able to set DRI_Interval using Testparams.cfg. In order to being able to get DRI_Interval from .cfg I commented //params->DRI_Interval = 0; inside TestApp_SetDynamicParams(IIMGENC1_DynamicParams *dynamicParams) function. I will open and IR for this so it will be fixed by next release.

    >>>> DRI / console output >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    [C66xx_0] Encoder output dump completed

    [C66xx_0] Image Encoded = 1

    [C66xx_0] Width and Height = 720, 480

    [C66xx_0] QP = 80

    [C66xx_0] Ratio = 9.891053

    [C66xx_0] MegaPixel/sec 500 : 13.826290 Cycles Taken : 12497930 Cycles per pixel : 36.162992 Total_BytesRead : 518400 TotalBytes: 0 Ratio : 9.891053

    [C66xx_0] DRI_interval = 40

    [C66xx_0]

     

    >>>> No DRI / console output >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    [C66xx_0] Encoder output dump completed

    [C66xx_0] Image Encoded = 2

    [C66xx_0] Width and Height = 720, 480

    [C66xx_0] QP = 80

    [C66xx_0] Ratio = 10.121837

    [C66xx_0] MegaPixel/sec 500 : 50.099677 Cycles Taken : 3449124 Cycles per pixel : 9.980104 Total_BytesRead : 518400 TotalBytes: 0 Ratio : 10.121837

    [C66xx_0] DRI_interval = 0

    thank you,

    Paula

  • Hi, Paula,

       Ok and thanks for your reply.

       When you find out if this is a expected behaviour or not, please give me the answer as soon as possible.

       qbliu

  • hi, Paula,

       Do you have any results?

      Thanks

      qbliu

  • Hi qbliu, an SR was opened to the codec team, they will come back with a fix schedule. I will let you know when this is done.

    Thank you,

    Paula

  • hi, Paula,

       Do you have any results? Our project team need the result to do the next step.

      Thanks very much.

      qbliu

  • Hi qliu,

    Some of the entropy coding functions (e.g Huffman entropy coding of DC DCT coefficients, Quantization and Run lenght encoding) are optimazed for encoding 4 blocks of 8x8 at once. However, when DRI marker is enabled, RST interval is also enabled and forces the encode to process each 8x8 block independently. Since RST interval makes the encoder to process one block of 8x8 at the time, no matters which interval is selected, the total processing time of previously mentioned entropy encoding functions increases ~x4times. So, the behivour that you are facing is expected for current implementation.

    Thank you,

    Paula

  • Hi,Paula,

    Thanks for your reply.

    About your answer to the question, I have some problems:

    1、if i can set some interval to satisfy the condition of 4 blocks of 8x8, so the encode time with or without DRI marker is about the same? I think it is feasible. If not, could the codec team release a new version of jpeg encode library to fix it?

    2、When i finish encoding  the image, the field  'currentAU' of 'IIMGENC1_OutArgs' is 56200, I do not know why. The image is 3264*2448, YUV420P, I think the 'currentAU' is 3264*2448/8/8 or 3264*2448/16/16.

    thank you, qbliu

  • Hi qbliu,

    1) changing the code to satisfy the condition of 4 blocks would require some algorithm modifications and testing. As far as I know this modifications are not planned for the codec, but I will ask and let you know.

    2) I will check what "currentAU" is actually returning and let you know.

    thanks,

    Paula

  • Hi qbliu,

    I was checking outArgs->currentAU after IIMGENC1fxns->process() (TestAppEncoder.c) and results looks ok. I got outArgs->currentAU=8100 for a 720x480 image (720x480*3/2 *1/(8x8)=8100) which is the total number of 8x8 in a 420 input. Please help me to double check in your end, if still you get a wrong AU number for a especific input and configuration (Testparams) please attach then so I can test them in my end.

    thank you,

    Paula

  • hi,paula,

      Thanks.

    Question1. Ok, And thanks.

    Question2. I know the answer, but i think there is a bug,  outArgs->currentAU is a XDAS_Int32 in the <JPEG_BL_Encoder_C6678_UserGuide.pdf>, but i think it is a Uint16 Datatype. 3264*2448*1.5/8/8 = 187272 = 0x2DB88, if the DataType is Uint16, the value 56200 (0xDB88) is true.

    qbliu

  • Hi qbliu, could you please try attached Jpeg lib and .out in your end and let me know if currentAU now show you the right value? I built them in debug so it might be a little slow.. Please let me know.

    1373.jpgealg_ti.rar

    1067.TestAppEncoder.rar

    thanks,

    Paula

  • Qbliu, forgot to mention I modify one u16 to u32 accordingly with your observation. If new lib gives you the right AU, I will submit an IR with the codec team for an official fix in the next release.

    Thanks for your help,

    Paula

  • hi,paula,

      With your 'jpgealg_ti.rar', there is a problem.

    [C66xx_0] A0=0xf8920d18 A1=0xf8920d10
    [C66xx_0] A2=0x0 A3=0x82b3d8
    [C66xx_0] A4=0xf8920d18 A5=0x0
    [C66xx_0] A6=0xf8920d18 A7=0x2
    [C66xx_0] A8=0x0 A9=0x0
    [C66xx_0] A10=0x0 A11=0x0
    [C66xx_0] A12=0x0 A13=0x0
    [C66xx_0] A14=0x0 A15=0x0
    [C66xx_0] A16=0xf89202b4 A17=0x0
    [C66xx_0] A18=0xf8920284 A19=0x20
    [C66xx_0] A20=0x6c A21=0x4c
    [C66xx_0] A22=0x0 A23=0x1
    [C66xx_0] A24=0x0 A25=0x13
    [C66xx_0] A26=0x0 A27=0x0
    [C66xx_0] A28=0x0 A29=0x0
    [C66xx_0] A30=0x0 A31=0x0
    [C66xx_0] B0=0xf89202ec B1=0x0
    [C66xx_0] B2=0x1 B3=0x81847a
    [C66xx_0] B4=0xf89202ec B5=0x818440
    [C66xx_0] B6=0x0 B7=0xc
    [C66xx_0] B8=0xf89200f0 B9=0x0
    [C66xx_0] B10=0x0 B11=0x0
    [C66xx_0] B12=0x0 B13=0x0
    [C66xx_0] B14=0x82c774 B15=0xf89202a0
    [C66xx_0] B16=0xf8920b7c B17=0x0
    [C66xx_0] B18=0xa B19=0x82a04c
    [C66xx_0] B20=0x69 B21=0x1
    [C66xx_0] B22=0x0 B23=0x40000000
    [C66xx_0] B24=0x82a050 B25=0x83100000
    [C66xx_0] B26=0x24a64 B27=0x81000000
    [C66xx_0] B28=0x28fef B29=0x83000000
    [C66xx_0] B30=0xffffffff B31=0xffffffff
    [C66xx_0] NTSR=0x1000f
    [C66xx_0] ITSR=0xf
    [C66xx_0] IRP=0x81eada
    [C66xx_0] SSR=0x0
    [C66xx_0] AMR=0x0
    [C66xx_0] RILC=0x0
    [C66xx_0] ILC=0x0
    [C66xx_0] Exception at 0x7f99c0
    [C66xx_0] EFR=0x2 NRP=0x7f99c0
    [C66xx_0] Internal exception: IERR=0x1
    [C66xx_0] Instruction fetch exception
    [C66xx_0] ti.sysbios.family.c64p.Exception: line 248: E_exceptionMin: pc = 0x0081eada, sp = 0xf89202a0.
    [C66xx_0] To see more exception detail, use ROV or set 'ti.sysbios.family.c64p.Exception.enablePrint = true;'
    [C66xx_0] xdc.runtime.Error.raise: terminating execution

    qbliu

  • Hi qbliu, could be due to different tools versions between shared lib and your application. In order to align, I used compiler version v7.4.0 also please see snapshot with used versions for bios, xdc, xdais and FC. If you are using these tool versions and still experience errors please attach the input file and I will proceed to verify correctness of currentAU in my setup.

    thank you,

    Paula

  • hi, Paula,

      I change the compiler version to v7.4.0, The used version of ccs is 5.0.1.201105110900.

    But there is also a error : ti.sysbios.heaps.HeapMem: line 294: out of memory: handle=0x82b710, size=2937323008.

    I give you the input file and you can check it.

    qbliu

  • Paula,

     The input image is 3264*2448, YUV420P.

    The snapshot is :

    qbliu

  • Hi, Paula,

      After I encoded the image with DRI marker, I tested the jpeg decode algorithm. There is a problem:

     The input image 720x480 YUV420P, 'Input_420p.yuv'.

     With the DRI marker = 720 * 480 / 4 / 8 / 8 (480 / 4 rows of 8*8 block),  I can decode the encoded picture.

    But with the DRI marker = 720 * 8 / 4 / 8 / 8 (8 rows of 8*8 block),  I can not decode the encoded picture. The 'imgdecOutArgs.extendedError' is 4103.

    Could you please try the attached  jpeg picture with your jpeg decode demo? Please let me know.

    The version of jpeg decode is C66x_jpegdec_03_01_01_05_ELF.

    Thanks, qbliu

    7416.jpegPictures.rar

     

     

  • Hi Qliu,could you please help me to open a new e2e thread for this? so we can keep issues separate it. in the meantime I will try it.

    thanks,

    Paula

  • Hi Qblui, Please see below link with latest Jpeg encoder release. This release addressed DRI cycles increase and fixed outargs->currentAU for  images >2k

    http://software-dl.ti.com/dsps/dsps_public_sw/codecs/C6678/JPEG_E/latest/index_FDS.html

    thank you,

    Paula