Example #1
0
void
dvtb_jpegDec1Cleanup(DvevmStJpegDec1Info *jpeg1)
{
	if (NULL != jpeg1->idec1Hdl)
	{
		IMGDEC1_delete(jpeg1->idec1Hdl);
		jpeg1->idec1Hdl = NULL;
	}
}
Example #2
0
/******************************************************************************
 * Idec1_delete
 ******************************************************************************/
Int Idec1_delete(Idec1_Handle hId)
{
    if (hId) {
        if (hId->hDecode) {
            IMGDEC1_delete(hId->hDecode);
        }

        free(hId);
    }

    return Dmai_EOK;
}
Example #3
0
int ALG_jpgDecDelete(void *hndl)
{
  ALG_JpgDecObj *pObj=(ALG_JpgDecObj *)hndl;

  if(pObj==NULL)
    return OSA_EFAIL;

  if(pObj->hDecode)
    IMGDEC1_delete(pObj->hDecode);

  OSA_memFree(pObj);

  return OSA_SOK;
}
Example #4
0
/******************************************************************************
 * Idec1_create
 ******************************************************************************/
Idec1_Handle Idec1_create(Engine_Handle hEngine, Char *codecName,
                        IMGDEC1_Params *params, 
                        IMGDEC1_DynamicParams *dynParams)
{
    Idec1_Handle             hId;
    IMGDEC1_Handle           hDecode;
    IMGDEC1_Status           decStatus;
    XDAS_Int32               status;

    if (hEngine == NULL || codecName == NULL ||
        params == NULL || dynParams == NULL) {
        Dmai_err0("Cannot pass null for engine, codec name, params or "
                  "dynamic params\n");
        return NULL;
    }

    /* Allocate space for the object */
    hId = (Idec1_Handle)calloc(1, sizeof(Idec1_Object));

    if (hId == NULL) {
        Dmai_err0("Failed to allocate space for Idec1 Object\n");
        return NULL;
    }

    /* Create image decoder instance */
    hDecode = IMGDEC1_create(hEngine, codecName, params);

    if (hDecode == NULL) {
        Dmai_err0("Failed to open image decode algorithm\n");
        free(hId);
        return NULL;
    }

    Dmai_dbg0("Image decoder instance created\n");

    /* Set image decoder dynamic params */
    decStatus.data.buf = NULL;
    decStatus.size = sizeof(IMGDEC1_Status);
    status = IMGDEC1_control(hDecode, XDM_SETPARAMS, dynParams,
                            &decStatus);

    if (status != IMGDEC1_EOK) {
        Dmai_err0("XDM_SETPARAMS control failed\n");
        IMGDEC1_delete(hDecode);
        free(hId);
        return NULL;
    }

    /* Get buffer information from image decoder */
    status = IMGDEC1_control(hDecode, XDM_GETBUFINFO, dynParams,
                            &decStatus);

    if (status != IMGDEC1_EOK) {
        Dmai_err0("XDM_GETBUFINFO control failed\n");
        IMGDEC1_delete(hDecode);
        free(hId);
        return NULL;
    }

    Dmai_dbg1("Buffer size %u obtained from XDM_GETBUFINFO control call\n",
              (UInt) decStatus.bufInfo.minInBufSize[0]);

    hId->hDecode = hDecode;
    memcpy(hId->minInBufSize,
           decStatus.bufInfo.minInBufSize, sizeof(hId->minInBufSize));
    hId->minNumInBufs = decStatus.bufInfo.minNumInBufs;
    memcpy(hId->minOutBufSize,
           decStatus.bufInfo.minOutBufSize, sizeof(hId->minOutBufSize));
    hId->minNumOutBufs = decStatus.bufInfo.minNumOutBufs;

    return hId;
}
/*
 *  ======== smain ========
 */
Int smain(Int argc, String argv[])
{
    Engine_Handle ce = NULL;
    IMGDEC1_Handle dec = NULL;
    IMGENC1_Handle enc = NULL;
    FILE *in = NULL;
    FILE *out = NULL;
    String inFile, outFile;
    Memory_AllocParams allocParams;

    if (argc <= 1) {
        inFile = "./in.dat";
        outFile = "./out.dat";
        createInFileIfMissing(inFile);
    }
    else if (argc >= 3) {
        progName = argv[0];
        inFile = argv[1];
        outFile = argv[2];
    }
    else {
        fprintf(stderr, usage, argv[0]);
        exit(1);
    }

    if ((argc == 4) && (argv[3][0] == '1')) {
        appPause = 1;
    }


    GT_0trace(curMask, GT_1CLASS, "App-> Application started.\n");

    /* allocate buffers */
    allocParams.type = Memory_CONTIGPOOL;
    allocParams.flags = Memory_NONCACHED;
    allocParams.align = BUFALIGN;
    allocParams.seg = 0;

    inBuf = (XDAS_Int8 *)Memory_alloc(IFRAMESIZE, &allocParams);
    encodedBuf = (XDAS_Int8 *)Memory_alloc(EFRAMESIZE, &allocParams);
    outBuf = (XDAS_Int8 *)Memory_alloc(OFRAMESIZE, &allocParams);
    versionBuf = (XDAS_Int8 *)Memory_alloc(MAXVERSIONSIZE, &allocParams);

    if ((inBuf == NULL) || (encodedBuf == NULL) || (outBuf == NULL) ||
        (versionBuf == NULL)) {

        goto end;
    }

    /* open file streams for input and output */
    if ((in = fopen(inFile, "rb")) == NULL) {
        printf("App-> ERROR: can't read file %s\n", inFile);
        goto end;
    }
    if ((out = fopen(outFile, "wb")) == NULL) {
        printf("App-> ERROR: can't write to file %s\n", outFile);
        goto end;
    }

    /* reset, load, and start DSP Engine */
    if ((ce = Engine_open(engineName, NULL, NULL)) == NULL) {
        fprintf(stderr, "%s: error: can't open engine %s\n",
            progName, engineName);
        goto end;
    }

    /* allocate and initialize video decoder on the engine */
    dec = IMGDEC1_create(ce, decoderName, NULL);
    if (dec == NULL) {
        printf( "App-> ERROR: can't open codec %s\n", decoderName);
        goto end;
    }

    /* allocate and initialize video encoder on the engine */
    enc = IMGENC1_create(ce, encoderName, NULL);
    if (enc == NULL) {
        fprintf(stderr, "%s: error: can't open codec %s\n",
            progName, encoderName);
        goto end;
    }

#ifdef USE_POWER_MANAGEMENT
    /* open local power manager */
    if (Global_usePowerManagement) {
       LPM_Status  lpmStat = LPM_SOK;
       lpmStat = LPM_open("/dev/lpm0", &lpmHandle);

       if (lpmStat != LPM_SOK) {
            fprintf(stderr, "%s: error: LPM_open() failed\n", progName);
            goto end;
       }
    }
#endif

    /* use engine to encode, then decode the data */
    encode_decode(enc, dec, in, out);

end:
#ifdef USE_POWER_MANAGEMENT
    /* close local power manager */
    if (lpmHandle != NULL) {
       LPM_close(lpmHandle);
    }
#endif

    /* teardown the codecs */
    if (enc) {
        IMGENC1_delete(enc);
    }
    if (dec) {
        IMGDEC1_delete(dec);
    }

    /* close the engine */
    if (ce) {
        Engine_close(ce);
    }

    /* close the files */
    if (in) {
        fclose(in);
    }
    if (out) {
        fclose(out);
    }

    /* free buffers */
    if (inBuf) {
        Memory_free(inBuf, IFRAMESIZE, &allocParams);
    }
    if (encodedBuf) {
        Memory_free(encodedBuf, EFRAMESIZE, &allocParams);
    }
    if (outBuf) {
        Memory_free(outBuf, OFRAMESIZE, &allocParams);
    }
    if (versionBuf) {
        Memory_free(versionBuf, MAXVERSIONSIZE, &allocParams);
    }

    GT_0trace(curMask, GT_1CLASS, "app done.\n");
    return (0);
}