DvevmStRetCode dvtb_vc1Dec2Init(DvevmStVC1Dec2Info *vd) { DvevmStRetCode retCode = DVEVM_ST_SUCCESS; ASSERT(vd != NULL); ASSERT(vd->ceHdl != NULL); ASSERT(vd->vc1dec2Name[0] != 0); SYS_DEBUG("Codec Instance Init: Engine Handle 0x%x\n", (unsigned int) vd->ceHdl); SYS_DEBUG("Codec Instance Init: vdec name \"%s\"\n", vd->vc1dec2Name); dvtb_vc1Dec2InitDebug((IVC1VDEC_Params *) &vd->vdec2Params.viddecParams); if (NULL == (vd->vdec2Hdl = (IVC1VDEC_Handle) VIDDEC2_create(vd->ceHdl, vd->vc1dec2Name, (VIDDEC2_Params*) &vd->vdec2Params))) { SYS_ERROR("Unable to initialize Video Decoder\n"); retCode = DVEVM_ST_FAIL; } else { SYS_DEBUG("Video Decoder Instance created.\n"); vd->vdec2Cmd = XDM_RESET; if (DVEVM_ST_FAIL == dvtb_vc1Dec2Control(vd)) { SYS_ERROR("Unable to reset codec <%s>\n", vd->vc1dec2Name); return DVEVM_ST_FAIL; } vd->vdec2Cmd = XDM_SETPARAMS; if (DVEVM_ST_FAIL == dvtb_vc1Dec2Control(vd)) { SYS_ERROR("Unable to set dynamic params\n"); retCode = DVEVM_ST_FAIL; } else { SYS_DEBUG("Video Decoder <%s> initialized\n", vd->vc1dec2Name); vd->vdec2Cmd = XDM_GETBUFINFO; if (DVEVM_ST_FAIL == dvtb_vc1Dec2Control(vd)) { SYS_ERROR("Unable to get the input/output buffer information\n"); retCode = DVEVM_ST_FAIL; } else { SYS_DEBUG("Video Decoder <%s> initialized\n", vd->vc1dec2Name); dvtb_vc1Dec2ControlDebug(&vd->vdec2Status); dvtb_vc1Dec2InitDebug((IVC1VDEC_Params*) &vd->vdec2Params.viddecParams); } } } if (DVEVM_ST_FAIL == retCode) dvtb_vc1Dec2Cleanup(vd); return retCode; }
/* * ======== smain ======== */ Int smain(String progName, String procId, String engineName, String inFile, String outFile) { Engine_Handle ce = NULL; Engine_Attrs attrs; VIDDEC2_Handle dec = NULL; VIDENC1_Handle enc = NULL; FILE *in = NULL; FILE *out = NULL; Memory_AllocParams allocParams; createInFileIfMissing(inFile); Log_print4(Diags_USER1, "[+1] App-> Application started, procId %s " "engineName %s input-file %s output-file %s.", (IArg)procId, (IArg)engineName, (IArg)inFile, (IArg)outFile); /* 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); 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; } /* Initialize attrs fields to default values, and set the procId */ Engine_initAttrs(&attrs); attrs.procId = procId; /* reset, load, and start DSP Engine */ if ((ce = Engine_open(engineName, &attrs, 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 = VIDDEC2_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 = VIDENC1_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) { VIDENC1_delete(enc); } if (dec) { VIDDEC2_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); } Log_print0(Diags_USER1, "[+1] app done."); return (0); }