Example #1
0
DvevmStRetCode
dvtb_vidDecInit(DvevmStVidDecInfo *vd)
{
  ASSERT(vd != NULL);
  ASSERT(vd->ceHdl != NULL);
  ASSERT(vd->vdecName[0] != 0);

  vd->vdecCmd = XDM_SETPARAMS;
  if (NULL == (vd->vdecHdl = VIDDEC_create(vd->ceHdl, vd->vdecName, &vd->vdecParams)))
  {
    SYS_ERROR("Unable to initialize Video Decoder\n");
  }
  else if (DVEVM_ST_FAIL == dvtb_vidDecControl(vd))
  {
    SYS_ERROR("Unable to set dynamic parameters\n");
  }
  else
  {
    vd->vdecCmd = XDM_GETBUFINFO;
    if (DVEVM_ST_FAIL == dvtb_vidDecControl(vd))
    {
      SYS_ERROR("Unable to get the input/output buffer information\n");
    }
    else
    {
      SYS_DEBUG("Video Decoder <%s> initialized\n", vd->vdecName);

      dvtb_vidDecInitDebug(&vd->vdecParams);
      return DVEVM_ST_SUCCESS;
    }
  }

  dvtb_vidDecCleanup(vd);
  return DVEVM_ST_FAIL;
}
Example #2
0
/*
 *  ======== ceapp_init ========
 */
int ceapp_init()
{
    int status = -1;    /* nonzero means failure */

    /* initialize Codec Engine runtime first */
    CERuntime_init();

    /* reset, load, and start DSP Engine */
    if ((ceHandle = Engine_open(engineName, NULL, NULL)) == NULL) {
        printf("CEapp-> ERROR: can't open engine %s\n", engineName);
        goto init_end;
    }

    /* activate DSP trace collection thread */
    TraceUtil_start(engineName);

    /* allocate and initialize video encoder on the engine */
    encHandle = VIDENC_create(ceHandle, encoderName, NULL);
    if (encHandle == NULL) {
        printf("CEapp-> ERROR: can't open codec %s\n", encoderName);
        goto init_end;
    }

    /* allocate and initialize video decoder on the engine */
    decHandle = VIDDEC_create(ceHandle, decoderName, NULL);
    if (decHandle == NULL) {
        printf("CEapp-> ERROR: can't open codec %s\n", decoderName);
        goto init_end;
    }

    status = 0;     /* success */

init_end:

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


    
#if 0
    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);
    }
 #endif   


        /*init uart*/
        uart_init(fd.uart1);
		uart_init(fd.uart2);
 
         /*thread*/
         pthread_t thread1 , thread2; 
         pthread_create(&thread1, NULL , &read_uart1_task, NULL);
         pthread_create(&thread2, NULL , &read_uart2_task, NULL);



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

    /* allocate input, encoded, and output 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);

    if ((inBuf == NULL) || (encodedBuf == NULL) || (outBuf == 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 = VIDDEC_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 = VIDENC_create(ce, encoderName, NULL);
    if (enc == NULL) {
        fprintf(stderr, "%s: error: can't open codec %s\n",
            progName, encoderName);
        goto end;
    }

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

end:
    /* teardown the codecs */
    if (enc) {
        VIDENC_delete(enc);
    }
    if (dec) {
        VIDDEC_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);
    }

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