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.

dm365 jpegdec v1.0.0.5/v1.0.0.6 decodes some jpeg files failed, while others are ok

dm365 jpegdec v1.0.0.5/v1.0.0.6  decodes some jpeg files failed, while others are ok, and these jpeg files are all created by jpegenc v1.0.0.7.
 
CE_DEBUG gives debug info as below:
 
@14,768,464us: [+0 T:0x4001f960 S:0xbefe1574] ti.sdo.ce.image1.IMGDEC1 - IMGDEC1_process> Enter (handle=0x2371d0, inBufs=0xbefe16dc, outBufs=0xbefe1618, inA)
@14,768,692us: [+5 T:0x4001f960 S:0xbefe1554] CV - VISA_enter(visa=0x2371d0): algHandle = 0x237208
@14,768,862us: [+0 T:0x4001f960 S:0xbefe1544] ti.sdo.ce.alg.Algorithm - Algorithm_activate> Enter(alg=0x237208)
@14,769,073us: [+0 T:0x4001f960 S:0xbefe150c] ti.sdo.ce.osal.SemMP - Entered SemMP_pend> sem[0x236da8] timeout[0xffffffff]
@14,769,272us: [+0 T:0x4001f960 S:0xbefe150c] ti.sdo.ce.osal.SemMP - Leaving SemMP_pend> sem[0x236da8] status[0]
@14,769,621us: [+0 T:0x4001f960 S:0xbefe1554] ti.sdo.ce.alg.Algorithm - Algorithm_activate> Exit
@14,788,596us: [+5 T:0x4001f960 S:0xbefe155c] CV - VISA_exit(visa=0x2371d0): algHandle = 0x237208
@14,788,839us: [+0 T:0x4001f960 S:0xbefe154c] ti.sdo.ce.alg.Algorithm - Algorithm_deactivate> Enter(alg=0x237208)
@14,789,109us: [+0 T:0x4001f960 S:0xbefe152c] ti.sdo.ce.osal.SemMP - Entered SemMP_post> sem[0x236da8]
@14,789,431us: [+0 T:0x4001f960 S:0xbefe152c] ti.sdo.ce.osal.SemMP - Leaving SemMP_post> sem[0x236da8]
@14,789,638us: [+0 T:0x4001f960 S:0xbefe155c] ti.sdo.ce.alg.Algorithm - Algorithm_deactivate> Exit
@14,789,806us: [+0 T:0x4001f960 S:0xbefe1574] ti.sdo.ce.image1.IMGDEC1 - IMGDEC1_process> Exit (handle=0x2371d0, retVal=0xffffffff)
@14,789,977us: [+7 T:0x4001f960 S:0xbefe15c4] ti.sdo.dmai - [Idec1] IMGDEC1_process() failed with error (-1 ext: 0x8800)
 
our test code:
#include <ti/sdo/ce/Engine.h>
#include <ti/sdo/dmai/ce/Idec1.h>
#include <ti/sdo/dmai/BufferGfx.h>
#include <ti/sdo/codecs/jpegdec/ijpegdec.h>
#include "errno.h"
Int DecodeJpegFileTest(Char *filename)
{
 Engine_Handle hEngine = NULL;
 IMGDEC1_Params   jpgParams  = Idec1_Params_DEFAULT;
 IMGDEC1_DynamicParams jpgDynParams = Idec1_DynamicParams_DEFAULT;
 IJPEGDEC_DynamicParams  jpgExtDynParams;// = IJPEGDEC_DYNAMICPARAMS;
 
 Idec1_Handle   hJpgDec=NULL;
 Int      inBufSize, outBufSize;
 ColorSpace_Type         colorSpace = ColorSpace_YUV420PSEMI;
 BufferGfx_Attrs         gfxAttrs  = BufferGfx_Attrs_DEFAULT;
 Buffer_Attrs      bAttrs    = Buffer_Attrs_DEFAULT;
 Buffer_Handle   hInBuf, hDisplayBuf;
 Int      ret,fifoRet;
 FILE *fp;
 Int  flen;
 
 hEngine = Engine_open(engine->engineName, NULL, NULL);
    if (hEngine == NULL)
 {
        __ERR("Failed to open codec engine %s\n", engine->engineName);
  return -1;
    } 
 
 if(filename == NULL)
  return -1;
 
 if(strstr(filename,".jpg") == NULL)
 {
  __ERR("filename: %s is not a jpg file!\n", filename);
  return -1;
 }
 
 fp = fopen(filename, "rb");
 if(fp == NULL)
 {
  __ERR("open file: %s failed! \n", filename);
  return -1;
 }
 
 fseek(fp, 0, SEEK_END);
 flen = ftell(fp);
 rewind(fp);
 
 if((flen > 500*1000) || (flen <= 0))
 {
  __ERR("file %s length = %d is too large!\n", filename, flen);
  
  fclose(fp);
  return -1;
 }
 
 __ERR("file %s length = %d \n", filename, flen);
  
 hInBuf = Buffer_create(flen, &bAttrs);
 if(hInBuf == NULL)
 {
  __ERR("create inBuf failed!\n");
  fclose(fp);
  return -1;
 }
 
 ret = fread(Buffer_getUserPtr(hInBuf), 1, flen ,fp);
 if(ret <= 0)
 {
  __ERR("read file %s failed, err = %s\n", filename, strerror(errno));
  
  Buffer_delete(hInBuf);
  fclose(fp);
  return -1;
 }
 Buffer_setNumBytesUsed(hInBuf, ret);
 
 // Set the create time base parameters
 jpgParams.size = sizeof(IJPEGDEC_Params);
 jpgParams.maxWidth  = 720;
 jpgParams.maxHeight = 576;
 jpgParams.maxScans= XDM_DEFAULT;
 jpgParams.dataEndianness = XDM_BYTE;
 jpgParams.forceChromaFormat = XDM_YUV_420SP;
 
#if 0
 hJpgDec = Idec1_create(hEngine, "jpegdec", &jpgParams, &jpgDynParams);
#else
 memset(&jpgExtDynParams, 0, sizeof(IJPEGDEC_DynamicParams));
 //jpgExtDynParams.imgdecDynamicParams   = Idec1_DynamicParams_DEFAULT;
 jpgExtDynParams.imgdecDynamicParams.size   = sizeof(IJPEGDEC_DynamicParams);
 jpgExtDynParams.imgdecDynamicParams.numAU   = XDM_DEFAULT;
 jpgExtDynParams.imgdecDynamicParams.decodeHeader = XDM_DECODE_AU; //DEFAULT;
 jpgExtDynParams.imgdecDynamicParams.displayWidth = XDM_DEFAULT; //720;
 jpgExtDynParams.disableEOI  =0;
 jpgExtDynParams.resizeOption =0;
 jpgExtDynParams.subRegionUpLeftX=0; 
 jpgExtDynParams.subRegionUpLeftX=0;
 jpgExtDynParams.subRegionUpLeftX=0;
 jpgExtDynParams.subRegionUpLeftX=0; 
 jpgExtDynParams.rotation  =0;
 __ERR("jped decode use normal mode.\n");
 //jpgExtDynParams.decodingPreset = 0;  //high performance mode will cause decode fail with high quality picture
 jpgExtDynParams.decodingPreset = 1; //normal mode 
 hJpgDec = Idec1_create(hEngine, "jpegdec", &jpgParams, (IMGDEC1_DynamicParams *)&jpgExtDynParams);
#endif
 
 if (hJpgDec == NULL)
 {
  __ERR("Failed to create jpeg decoder!\n");
  Buffer_delete(hInBuf);
  fclose(fp);
  return -1;
 }
 
 __ERR("jpg decode create ok!\n"); 
 
 inBufSize   = Idec1_getInBufSize(hJpgDec);
 outBufSize  = Idec1_getOutBufSize(hJpgDec);
 
 __ERR("jpg inbufSize = %d, outbufSize = %d\n", inBufSize, outBufSize);
 
 gfxAttrs.colorSpace = colorSpace;
 /* Set the original dimensions of the Buffers to the max */
 gfxAttrs.dim.width  = 720;
 gfxAttrs.dim.height = 576;
 gfxAttrs.dim.lineLength = BufferGfx_calcLineLength(gfxAttrs.dim.width,
                                                    colorSpace);
 
 hDisplayBuf = Buffer_create(outBufSize, BufferGfx_getBufferAttrs(&gfxAttrs));
 if(hDisplayBuf == NULL)
 { 
  __ERR("create hDisplayBuf failed! \n");
  
  Idec1_delete(hJpgDec);
  Buffer_delete(hInBuf);
  fclose(fp);
  return -1;
 }
 
 __ERR("create hDisplayBuf OK! \n");
 
 ret = Idec1_process_ext(hJpgDec, hInBuf, hDisplayBuf, (IMGDEC1_DynamicParams *)&jpgExtDynParams);
 if(ret < 0)
 {
  __ERR("decode jpeg file %s failed! \n", filename);
  
  Idec1_delete(hJpgDec);
  Buffer_delete(hInBuf);
  Buffer_delete(hDisplayBuf);
  fclose(fp);
  
  return -1;
 }
 
 BufferGfx_Dimensions dstDim;
 BufferGfx_getDimensions(hDisplayBuf, &dstDim);
 
 __ERR("decode jpg file OK, x=%d, y=%d, w=%d, h=%d \n",
    dstDim.x,
    dstDim.y,
    dstDim.width,
    dstDim.height);
 
 Idec1_delete(hJpgDec);
 Buffer_delete(hInBuf);
 Buffer_delete(hDisplayBuf);
 fclose(fp);
 
 return 0;
 
we have tried simple way using jpgDynParams and exented way using jpgExtDynParams, both failed to decode certain jpeg files.
 
the attached file is the one causes failed, but it's a good jpeg file.
 
Does anybody encounter this problem? we have tried the lastest jpegdec v 1.0.0.10, it also failed to decode this kind of jpeg file.
attached jpeg file:
  • Hi,

    The sample image you have attached is decoding without any problems at my side.

    Regards,

    Akshay

  • Hi,

    Did you use my test code for decoding?

    Please note that jpgParams.forceChromaFormat = XDM_YUV_420SP (to support this, we have modified the dmai code),  because we need to display this image to TV.

    what's the version of you dvsdk and jpegdec?

    the version of my dvsdk is 2_10_01_18 with dmai version 1_21_00_17,  framework_components  version 2_25_00_04,  linuxutils version 2_24_03,  xdctools version 3_15_01_59.

    and my encode.cfg is like below:

    /*  ============================================================================
     *   Copyright (c)  Texas Instruments Incorporated 2009
     *
     *   Use of this software is controlled by the terms and conditions found in the
     *   license agreement under which this software has been supplied or provided.
     *  ============================================================================
     */
    /* Load support for the Codec Engine OSAL */
    var osalGlobal = xdc.useModule('ti.sdo.ce.osal.Global');
    osalGlobal.runtimeEnv = osalGlobal.LINUX;

    /* Load support for the 'Davinci Multimedia Application Interface' module */
    var DMAI = xdc.loadPackage('ti.sdo.dmai');

    /* Load support for SimpleWidget */
    var SW = xdc.loadPackage('ti.sdo.simplewidget');

    environment['xdc.cfg.check.fatal'] = 'false';


    var RMAN = xdc.useModule('ti.sdo.fc.rman.RMAN');
    RMAN.useDSKT2 = false;
    RMAN.persistentAllocFxn = "__ALG_allocMemory";
    RMAN.persistentFreeFxn = "__ALG_freeMemory";
    RMAN.semCreateFxn = "Sem_create";
    RMAN.semDeleteFxn = "Sem_delete";
    RMAN.semPendFxn = "Sem_pend";
    RMAN.semPostFxn = "Sem_post";
    RMAN.tableSize = 10;

    /* added to support codec v2.0 */
    var EDMA3 = xdc.useModule('ti.sdo.fc.edma3.Settings');
    EDMA3.maxRequests = 128;
    var MEMTCM = xdc.useModule('ti.sdo.fc.ires.memtcm.MEMTCM');
    MEMTCM.cmemBlockId = 1;
    /* added end */

    var EDMA3 = xdc.useModule('ti.sdo.fc.edma3.Settings');

    var vicp = xdc.useModule('ti.sdo.linuxutils.vicp.VICP');

    var HDVICP = xdc.useModule('ti.sdo.fc.ires.hdvicp.HDVICP');

    var VICP = xdc.useModule('ti.sdo.fc.ires.vicp.VICP2');

    var VICPSYNC = xdc.useModule('ti.sdo.fc.vicpsync.VICPSYNC');

    var HDVICPSYNC = xdc.useModule('ti.sdo.fc.hdvicpsync.HDVICPSYNC');

    var VICP = xdc.useModule('ti.sdo.fc.memutils.MEMUTILS');

    DDRSPACE = xdc.useModule('ti.sdo.fc.ires.addrspace.ADDRSPACE');

    var EDMA3CHAN = xdc.useModule('ti.sdo.fc.ires.edma3chan.EDMA3CHAN');

    var LSP = xdc.useModule('ti.sdo.linuxutils.edma.EDMA');

    var CMEM = xdc.useModule('ti.sdo.linuxutils.cmem.CMEM');


    xdc.loadPackage("ti.sdo.ce.video2");
    xdc.loadPackage("ti.sdo.fc.hdvicpsync");

    /*
     *  ======== Engine Configuration ========
     */
    algSettings = xdc.useModule('ti.sdo.ce.alg.Settings');
    algSettings.useCache = true;

    var MPEG4ENC = xdc.useModule('ti.sdo.codecs.mpeg4enc.ce.MPEG4ENC');
    var MPEG4DEC = xdc.useModule('ti.sdo.codecs.mpeg4dec.ce.MPEG4DEC');
    var H264ENC = xdc.useModule('ti.sdo.codecs.h264enc.ce.H264ENC');
    var H264DEC = xdc.useModule('ti.sdo.codecs.h264dec.ce.H264DEC');
    var JPEGENC = xdc.useModule('ti.sdo.codecs.jpegenc.ce.JPEGENC');
    var JPEGDEC = xdc.useModule('ti.sdo.codecs.jpegdec.ce.JPEGDEC');
    var G711ENC = xdc.useModule('ti.sdo.ce.examples.codecs.g711.G711ENC');
    var AACENC  = xdc.useModule('ittiam.codecs.aaclc_enc.ce.AACLC_ENC');
    var AACDEC  = xdc.useModule('ittiam.codecs.aac_dec.ce.AAC_DEC');
    var MP3ENC  = xdc.useModule('ittiam.codecs.mp3_enc.ce.MP3_ENC');
    var WMAENC  = xdc.useModule('ittiam.codecs.wma_enc.ce.WMA_ENC');

    var Engine = xdc.useModule('ti.sdo.ce.Engine');
    var myEngine = Engine.create("encode", [
        {name: "mpeg4enc", mod: MPEG4ENC, local: true, groupId: 1},
        {name: "mpeg4dec", mod: MPEG4DEC, local: true, groupId: 1},          
        {name: "h264enc", mod: H264ENC, local: true, groupId: 1},
     {name: "h264dec", mod: H264DEC, local: true, groupId: 1},          
     {name: "jpegenc", mod: JPEGENC, local: true, groupId: 1},
     {name: "jpegdec", mod: JPEGDEC, local: true, groupId: 1},          
     {name: "aacenc", mod: AACENC, local: true},
     {name: "aacdec", mod: AACDEC, local: true},
     {name: "mp3enc", mod: MP3ENC, local: true},
     {name: "wmaenc", mod: WMAENC, local: true},          
    ]);

    /*
    xdc.loadPackage('ti.sdo.fc.ires.vicp').profile = "debug_trace";
    xdc.loadPackage('ti.sdo.fc.ires.edma3chan').profile = "debug_trace";
    xdc.loadPackage('ti.sdo.fc.rman').profile = "debug_trace";
    xdc.loadPackage('ti.sdo.fc.edma3').profile = "debug_trace";
    EDMA3CHAN.trace = true;
    EDMA3CHAN.debug = true;
    */

    Program.main = null;

    Is there any difference between our enviroment?

    thank you.

    Regards,

    Johnny Ling

  • Hi,

    My dvsdk version is dvsdk_2_10_00_16 with dmai_1_21_00_10, framework_components_2_24, linuxutils_2_24_02 and xdctools_3_15_01_59 and jpegdec_1_00_00_10.

    I modified the stock dmai app (image_decode_io1) to support 420SP. It is working with that modification done. 

    Also, my config file is unchanged - it is the one dmai is shipped with.

    Does the problem arise only when the output colour format is 420SP?

     

    Regards,

    Akshay

  • According to the error code 0x8800, it means  JPEGDEC_ERROR_INVALD_SUBWINDOW,  and the comments says, "Successful decoding but SOI not found", I am not so clear what does it mean.

    We have solve this problem by using software jpeg decode (libjpeg) and convert the output YCbCr data to YUV420P for display, it works fine and the speed is ok(about 300ms for a 720*576 picture).

    Anyway, thanks a lot.

    Regards,

    Johnny Ling