DvevmStRetCode dvtb_audDec1Init(DvevmStAudDec1Info *ad) { DvevmStRetCode retCode = DVEVM_ST_SUCCESS; ASSERT(ad != NULL); ASSERT(ad->ceHdl != NULL); ASSERT(ad->adecName[0] != 0); if (NULL == (ad->adecHdl = AUDDEC1_create(ad->ceHdl, ad->adecName, &ad->adecParams))) { SYS_ERROR("Unable to initialize Audio Decoder\n"); retCode = DVEVM_ST_FAIL; } else { SYS_DEBUG("Audio Decoder <%s> initialized\n", ad->adecName); dvtb_audDec1InitDebug(&ad->adecParams); ad->adecCmd = XDM_SETPARAMS; if (DVEVM_ST_FAIL == dvtb_audDec1Control(ad)) { SYS_ERROR("Unable to set dynamic audio parameters using command <%d>\n", ad->adecCmd); retCode = DVEVM_ST_FAIL; } } if(DVEVM_ST_FAIL == retCode) dvtb_audDec1Cleanup(ad); return retCode; }
/* * ======== smain ======== */ Int smain(Int argc, String argv[]) { Engine_Handle ce = NULL; AUDDEC1_Handle dec = NULL; AUDENC1_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); } 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 USE_ANCDATA ancBuf = (XDAS_Int8 *)Memory_alloc(ENCANCBUFSIZE, &allocParams); if (ancBuf == NULL) { goto end; } #endif 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 = AUDDEC1_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 = AUDENC1_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) { AUDENC1_delete(enc); } if (dec) { AUDDEC1_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); } #if USE_ANCDATA if (ancBuf) { Memory_free(ancBuf, ENCANCBUFSIZE, &allocParams); } #endif GT_0trace(curMask, GT_1CLASS, "app done.\n"); return (0); }
/* * ======== smain ======== */ Int smain(Int argc, String argv[]) { Engine_Handle ce = NULL; AUDDEC1_Handle dec = NULL; AUDENC1_Handle enc = NULL; FILE *in = NULL; FILE *out = NULL; String inFile, outFile; Int i; if (argc <= 1) { inFile = "../in.dat"; outFile = "../out.dat"; } else if (argc == 3) { progName = argv[0]; inFile = argv[1]; outFile = argv[2]; } else { fprintf(stderr, usage, argv[0]); exit(1); } GT_0trace(curMask, GT_1CLASS, "App-> Application started.\n"); /* allocate input, encoded, output, and version buffers */ for (i = 0; i < NBUFFERS; i++) { inBuf[i] = (XDAS_Int8 *)Memory_contigAlloc(IFRAMESIZE, BUFALIGN); encodedBuf[i] = (XDAS_Int8 *)Memory_contigAlloc(EFRAMESIZE, BUFALIGN); outBuf[i] = (XDAS_Int8 *)Memory_contigAlloc(OFRAMESIZE, BUFALIGN); #if USE_ANCDATA ancBuf[i] = (XDAS_Int8 *)Memory_contigAlloc(ENCANCBUFSIZE, BUFALIGN); if (ancBuf[i] == NULL) { goto end; } #endif if ((inBuf[i] == NULL) || (encodedBuf[i] == NULL) || (outBuf[i] == NULL)) { goto end; } } /* we need one more encoded buffer than the others */ encodedBuf[NBUFFERS] = (XDAS_Int8 *)Memory_contigAlloc(EFRAMESIZE, BUFALIGN); if (encodedBuf[NBUFFERS] == NULL) { goto end; } versionBuf = (XDAS_Int8 *)Memory_contigAlloc(MAXVERSIONSIZE, BUFALIGN); if (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 = AUDDEC1_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 = AUDENC1_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) { AUDENC1_delete(enc); } if (dec) { AUDDEC1_delete(dec); } /* close the engine */ if (ce) { Engine_close(ce); } /* close the files */ if (in) { fclose(in); } if (out) { fclose(out); } /* free buffers */ for (i = 0; i < NBUFFERS; i++) { if (inBuf[i]) { Memory_contigFree(inBuf[i], IFRAMESIZE); } if (encodedBuf[i]) { Memory_contigFree(encodedBuf[i], EFRAMESIZE); } if (outBuf[i]) { Memory_contigFree(outBuf[i], OFRAMESIZE); } #if USE_ANCDATA if (ancBuf[i]) { Memory_contigFree(ancBuf[i], ENCANCBUFSIZE); } #endif } if (encodedBuf[NBUFFERS]) { Memory_contigFree(encodedBuf[NBUFFERS], EFRAMESIZE); } if (versionBuf) { Memory_contigFree(versionBuf, MAXVERSIONSIZE); } GT_0trace(curMask, GT_1CLASS, "app done.\n"); return (0); }