static void dvtb_sphDecCleanup(DvevmStSphDecInfo *sd) { if (NULL != sd->sdecHdl) SPHDEC_delete(sd->sdecHdl); if (NULL != sd->inBuf.start) Memory_contigFree(sd->inBuf.start, sd->inBuf.size); if (NULL != sd->outBuf.start) Memory_contigFree(sd->outBuf.start, sd->outBuf.size); sd->inBuf.start = NULL; sd->outBuf.start = NULL; }
void dvtb_audDecCleanup(DvevmStAudDecInfo *ad) { if (NULL != ad->adecHdl) AUDDEC_delete(ad->adecHdl); if (NULL != ad->inBuf.start) Memory_contigFree(ad->inBuf.start, ad->inBuf.size); if (NULL != ad->outBuf.start) Memory_contigFree(ad->outBuf.start, ad->outBuf.size); ad->adecHdl = NULL; ad->inBuf.start = NULL; ad->outBuf.start = NULL; }
void dvtb_sphEncCleanup(DvevmStSphEncInfo *se) { if (NULL != se->sencHdl) SPHENC_delete(se->sencHdl); if (NULL != se->inBuf.start) Memory_contigFree(se->inBuf.start, se->inBuf.size); if (NULL != se->outBuf.start) Memory_contigFree(se->outBuf.start, se->outBuf.size); se->sencHdl = NULL; se->inBuf.start = NULL; se->outBuf.start = NULL; }
/* * ======== smain ======== */ Int smain(Int argc, String argv[]) { Engine_Handle ce = NULL; SPHDEC1_Handle dec = NULL; SPHENC1_Handle enc = NULL; SPHDEC1_Params decParams; SPHENC1_Params encParams; FILE *in = NULL; FILE *out = NULL; String inFile, outFile; 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, and output buffers */ inBuf = (XDAS_Int8 *)Memory_contigAlloc(IFRAMESIZE, BUFALIGN); encodedBuf = (XDAS_Int8 *)Memory_contigAlloc(EFRAMESIZE, BUFALIGN); outBuf = (XDAS_Int8 *)Memory_contigAlloc(OFRAMESIZE, BUFALIGN); versionBuf = (XDAS_Int8 *)Memory_contigAlloc(MAXVERSIONSIZE, BUFALIGN); 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 decoder in the engine */ decParams.size = sizeof(decParams); decParams.compandingLaw = ISPEECH1_PCM_COMPAND_ULAW; /* no other create params are meaningful for PCM decoders */ dec = SPHDEC1_create(ce, decoderName, &decParams); if (dec == NULL) { printf( "App-> ERROR: can't open codec %s\n", decoderName); goto end; } /* allocate and initialize encoder in the engine */ encParams.size = sizeof(encParams); encParams.frameSize = IFRAMESIZE; encParams.compandingLaw = ISPEECH1_PCM_COMPAND_ULAW; /* no other create params are meaningful for PCM encoders */ enc = SPHENC1_create(ce, encoderName, &encParams); 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) { SPHENC1_delete(enc); } if (dec) { SPHDEC1_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_contigFree(inBuf, IFRAMESIZE); } if (encodedBuf) { Memory_contigFree(encodedBuf, EFRAMESIZE); } if (outBuf) { Memory_contigFree(outBuf, OFRAMESIZE); } if (versionBuf) { Memory_contigFree(versionBuf, MAXVERSIONSIZE); } 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); }
/* * ======== ceapp_freeContigBuf ======== */ void ceapp_freeContigBuf(char *buf, int bufSize) { Memory_contigFree(buf, bufSize); }