DvevmStRetCode dvtb_deInterInit(DvevmStDeInterInfo *deinter) { DvevmStRetCode retCode = DVEVM_ST_SUCCESS; ASSERT(deinter != NULL); ASSERT(deinter->ceHdl != NULL); ASSERT(deinter->deinterName[0] != 0); if (NULL == (deinter->deinterHdl = UNIVERSAL_create(deinter->ceHdl, deinter->deinterName, (UNIVERSAL_Params *)&deinter->deinterParams))) { SYS_ERROR("Unable to initialize DeInterlacer\n"); retCode = DVEVM_ST_FAIL; } else { deinter->deinterInArgs.inObject.width = deinter->deinterInWidth; deinter->deinterInArgs.inObject.height = deinter->deinterInHeight; deinter->deinterInArgs.inObject.pitch_cur_frame = (deinter->deinterInWidth << 1); deinter->deinterInArgs.inObject.pitch_cur_frame = (deinter->deinterInWidth << 1); deinter->deinterInArgs.inObject.pitch_out_frame = (deinter->deinterInWidth << 1); if(XDM_YUV_422ILE == deinter->deinterInputFormat) { deinter->deinterInArgs.inObject.imageFormat = II2P_FOUR22_ILE; // II2P_FOUR22_ILE =1 deinter->outBuf.numBufs = 1; deinter->outBuf.bufSizes[0] = deinter->deinterInWidth * deinter->deinterInHeight * 2; if(DVEVM_ST_FAIL == dvtb_allocCmem(&deinter->outBuf)) { SYS_ERROR("Unable to allocate out buffer for DeInterlacer \n"); retCode = DVEVM_ST_FAIL; } } else { SYS_ERROR("Chroma format %d not supported \n",deinter->deinterInputFormat); retCode = DVEVM_ST_FAIL; } } if (DVEVM_ST_FAIL == retCode) dvtb_deInterCleanup(deinter); return retCode; }
/* * ======== smain ======== */ Int smain(String progName, String procId, String engineName, String inFile, String outFile) { Engine_Handle ce = NULL; Engine_Attrs attrs; UNIVERSAL_Handle hUniversal = NULL; FILE *in = NULL; FILE *out = NULL; Memory_AllocParams allocParams; XDAS_Int8 *inBuf; XDAS_Int8 *outBuf; XDAS_Int8 *versionBuf; /* acquire optional version from codecs */ /* create the input file if it doesn't already exist */ 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 buffers. * Note that the .flags field (cache) is ignored on BIOS-based systems. */ allocParams.type = Memory_CONTIGPOOL; allocParams.flags = Memory_NONCACHED; allocParams.align = BUFALIGN; allocParams.seg = 0; inBuf = (XDAS_Int8 *)Memory_alloc(IFRAMESIZE, &allocParams); outBuf = (XDAS_Int8 *)Memory_alloc(OFRAMESIZE, &allocParams); versionBuf = (XDAS_Int8 *)Memory_alloc(MAXVERSIONSIZE, &allocParams); if ((inBuf == 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; /* Open the Engine */ if ((ce = Engine_open(engineName, &attrs, NULL)) == NULL) { printf("App-> ERROR: can't open engine %s\n", engineName); goto end; } /* allocate and initialize universal alg on the engine */ hUniversal = UNIVERSAL_create(ce, universalName, NULL); if (hUniversal == NULL) { printf( "App-> ERROR: can't open codec %s\n", universalName); goto end; } /* use engine to encode, then decode the data */ processLoop(hUniversal, in, out, inBuf, outBuf, versionBuf); end: /* teardown the codec */ if (hUniversal) { UNIVERSAL_delete(hUniversal); } /* 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 (outBuf) { Memory_free(outBuf, OFRAMESIZE, &allocParams); } if (versionBuf) { Memory_free(versionBuf, MAXVERSIONSIZE, &allocParams); } Log_print0(Diags_USER1, "[+1] app done."); return (0); }
/* * ======== smain ======== */ Int smain(Int argc, String argv[]) { Engine_Handle ce = NULL; UNIVERSAL_Handle hUniversal = 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 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); outBuf = (XDAS_Int8 *)Memory_alloc(OFRAMESIZE, &allocParams); versionBuf = (XDAS_Int8 *)Memory_alloc(MAXVERSIONSIZE, &allocParams); if ((inBuf == 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 universal alg on the engine */ hUniversal = UNIVERSAL_create(ce, universalName, NULL); if (hUniversal == NULL) { printf( "App-> ERROR: can't open codec %s\n", universalName); goto end; } /* use engine to encode, then decode the data */ processLoop(hUniversal, in, out); end: /* teardown the codec */ if (hUniversal) { UNIVERSAL_delete(hUniversal); } /* 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 (outBuf) { Memory_free(outBuf, OFRAMESIZE, &allocParams); } if (versionBuf) { Memory_free(versionBuf, MAXVERSIONSIZE, &allocParams); } GT_0trace(curMask, GT_1CLASS, "app done.\n"); return (0); }