/* * ======== main ======== */ Void main(Int argc, Char *argv[]) { /* init Codec Engine */ CERuntime_init(); /* init trace */ GT_init(); /* create a mask to allow a trace-print welcome message below */ GT_create(>Mask, "audio1_ires_server"); /* ...and initialize all masks in this module to "on" */ GT_set("audio1_ires_server=01234567"); GT_0trace(gtMask, GT_4CLASS, "main> Welcome to DSP server's main().\n"); /* Configure and register BUFRES resource with RMAN */ /* * Note that we can't use RMAN's auto-register with the BUFRES resource * because it takes runtime config params that don't have logical * defaults. */ config.iresConfig.size = sizeof(BUFRES_Params); config.iresConfig.allocFxn = DSKT2_allocPersistent; config.iresConfig.freeFxn = DSKT2_freePersistent; config.base = (Void *)&BUFMEM_base; config.length = (UInt32)&BUFMEM_end - (UInt32)&BUFMEM_base + 1; RMAN_register(&BUFRES_MGRFXNS, (IRESMAN_Params *)&config); }
/* * ======== main ======== */ Void main(Int argc, Char *argv[]) { Int status; do { /* init IPC */ status = Ipc_start(); } while (status < 0); /* init Codec Engine */ CERuntime_init(); Log_print0(Diags_USER4, "[+4] main> Welcome to DSP server's main()."); /* Configure and register BUFRES resource with RMAN */ config.iresConfig.size = sizeof(BUFRES_Params); config.iresConfig.allocFxn = DSKT2_allocPersistent; config.iresConfig.freeFxn = DSKT2_freePersistent; config.base = Memory_alloc(BUFSIZE, NULL); config.length = BUFSIZE; RMAN_register(&BUFRES_MGRFXNS, (IRESMAN_Params *)&config); BIOS_start(); }
int H264FHDVENC_RMAN_setup() { IRES_Status status; if ( 1 == g_iRmanAlreadySetup ) { return 0; } RMAN_numRegistryEntries = 0; RMAN_registryEntries = NULL; RMAN_registryResmanArgs = NULL; RMAN_PARAMS.numRegistries = RMAN_PARAMS_NUMREGISTRIES; RMAN_PARAMS.allocFxn = RMAN_PARAMS_ALLOCFXN; RMAN_PARAMS.freeFxn = RMAN_PARAMS_FREEFXN; RMAN_PARAMS.yieldFxn = RMAN_PARAMS_YIELDFXN; RMAN_PARAMS.yieldSamePriority = RMAN_PARAMS_YIELDSAMEPRI; status = RMAN_init(); if (IRES_OK != status) { return -1; } _hdvicpParams.baseConfig.size = sizeof(IRESMAN_HdVicpParams); _hdvicpParams.baseConfig.allocFxn = RMAN_PARAMS.allocFxn; _hdvicpParams.baseConfig.freeFxn = RMAN_PARAMS.freeFxn; _hdvicpParams.numResources = 2; _hdvicpParams.info = NULL; status = RMAN_register(&IRESMAN_HDVICP, (IRESMAN_Params *)&_hdvicpParams); if (IRES_OK != status) { return -1; } _edma3Params.baseConfig.size = sizeof(IRESMAN_Edma3ChanParams); _edma3Params.baseConfig.allocFxn = RMAN_PARAMS.allocFxn; _edma3Params.baseConfig.freeFxn = RMAN_PARAMS.freeFxn; status = RMAN_register(&IRESMAN_EDMA3CHAN, (IRESMAN_Params *)&_edma3Params); if (IRES_OK != status) { return -1; } g_iRmanAlreadySetup = 1; return 0; }
/* ARGSUSED */ int main(Int argc, Char * argv[]) { IRES_Status status; /* Set default Diags mask to all, to get trace for init() functions */ FCSettings_init(); Diags_setMask(FCSETTINGS_MODNAME"+EX1234567"); buf = Memory_calloc(NULL, BUFSIZE, BUFALIGN, NULL); if (buf == NULL) { System_abort("Allocation of buffer for BUFRES failed. Aborting.\n"); } status = RMAN_init(); //Diags_setMask(RMAN_MODNAME"+EX1234567"); if (IRES_OK != status) { System_printf("main> RMAN initialization Failed [%d]\n", status); System_abort("Aborting...\n"); } config.iresConfig.size = sizeof(BUFRES_Params); // config.iresConfig.allocFxn = _ALG_allocMemory; // config.iresConfig.freeFxn = _ALG_freeMemory; config.iresConfig.allocFxn = DSKT2_allocPersistent; config.iresConfig.freeFxn = DSKT2_freePersistent; config.base = buf; config.length = (UInt32)BUFSIZE; status = RMAN_register(&BUFRES_MGRFXNS, (IRESMAN_Params *)&config); /* * Now that are resource is initialized, * set default Diags mask to warnings and errors */ Diags_setMask(FCSETTINGS_MODNAME"-EX12345"); //Diags_setMask(BUFRES_MODNAME"-EX12345"); if (status != IRES_OK) { /* Test failed */ System_printf("BUFRES_init() failed [0x%x]\n", status); System_abort("Aborting.\n"); return (-1); } smain(argc, argv); return (0); }
/* ARGSUSED */ int main(Int argc, Char * argv[]) { IRES_Status status; Int size = 0; // TODO: Use Diags_setMask() #if 0 GT_init(); GT_create(&CURTRACE, "ti.sdo.fc.rman.examples.hdvicp"); GT_set(MOD_NAME "=01234567"); GT_set("ti.sdo.fc.rman" "=4567"); GT_set("ti.sdo.fc.dskt2" "=67"); GT_set("ti.sdo.fc.ires.hdvicp" "=01234567"); /* GT_set("ti.sdo.fc.dskt2" "=01234567");*/ #endif Log_print0(Diags_ENTRY, "[+E] _main> Enter "); status = RMAN_init(); if (IRES_OK != status) { Log_print1(Diags_USER7, "[+7] main> RMAN_init() failed [%d]", (IArg)status); System_abort("RMAN_init() failed, aborting...\n"); } /* * Supply initialization information for the RESMAN while registering */ size = sizeof(IRESMAN_HdVicpParams); configParams.baseConfig.allocFxn = RMAN_PARAMS.allocFxn; configParams.baseConfig.freeFxn = RMAN_PARAMS.freeFxn; configParams.baseConfig.size = size; /* Register the HDVICP protocol/resource manager with the * generic resource manager */ status = RMAN_register(&IRESMAN_HDVICP, (IRESMAN_Params *)&configParams); if (IRES_OK != status) { Log_print1(Diags_USER7, "[+7] main> RMAN_register() failed [%d]", (IArg)status); System_abort("RMAN_register() failed, aborting...\n"); } Log_print0(Diags_EXIT, "[+X] main> Exit"); BIOS_start(); return(0); }
Int main() { IRES_Status status; Int size = 0; GT_init(); GT_create(&ti_sdo_fc_rman_examples_hdvicp,"ti.sdo.fc.rman.examples.hdvicp"); GT_set(MODNAME "=01234567"); GT_set("ti.sdo.fc.rman" "=4567"); GT_set("ti.sdo.fc.dskt2" "=67"); GT_set("ti.sdo.fc.ires.hdvicp" "=01234567"); /* GT_set("ti.sdo.fc.dskt2" "=01234567");*/ GT_0trace(ti_sdo_fc_rman_examples_hdvicp, GT_ENTER, "_main> Enter \n"); status = RMAN_init(); if (IRES_OK != status) { GT_0trace(ti_sdo_fc_rman_examples_hdvicp, GT_7CLASS, "_main> RMAN " "Initialization failed \n"); return -1; } /* * Supply initialization information for the RESMAN while registering */ size = sizeof(IRESMAN_HdVicpParams); configParams.baseConfig.allocFxn = RMAN_PARAMS.allocFxn; configParams.baseConfig.freeFxn = RMAN_PARAMS.freeFxn; configParams.baseConfig.size = size; /* Register the HDVICP protocol/resource manager with the * generic resource manager */ status = RMAN_register(&IRESMAN_HDVICP, (IRESMAN_Params *)&configParams); if (IRES_OK != status) { GT_0trace(ti_sdo_fc_rman_examples_hdvicp, GT_7CLASS, "_main> Protocol " "Initialization failed \n"); return -1; } GT_0trace(ti_sdo_fc_rman_examples_hdvicp, GT_ENTER, "_main> Exit \n"); return 0; }
Int main() { Int size = 0; IRES_Status status; IRESMAN_Edma3ChanParams configParams; Int i = 0; GT_set(MOD_NAME "=01234567"); /* * Call to _DSKT2_init is required as it leaks memory when DSKT2 is actually . * Call it before you do MEM_stat */ printf("Testing for Memory Leaks\n"); _DSKT2_init(); for (i = 0; i < MAXMEMSEGMENTS; i++) { if (!MEM_stat(i, &memStat[i])) { memStat[i].size = memStat[i].used = 0; memStat[i].length = 0; } } status = RMAN_init(); if (IRES_OK != status) { printf("RMAN initialization Failed \n"); return -1; } /* * Supply initialization information for the EDMA3 RESMAN while registering */ size = sizeof(IRESMAN_Edma3ChanParams); configParams.baseConfig.allocFxn = RMAN_PARAMS.allocFxn; configParams.baseConfig.freeFxn = RMAN_PARAMS.freeFxn; configParams.baseConfig.size = size; status = RMAN_register(&IRESMAN_EDMA3CHAN, (IRESMAN_Params *)&configParams); if (IRES_OK != status) { printf("Protocol Registration Failed \n"); return -1; } return 0; }
/* * ======== main ======== */ Int main(Int argc, String argv[]) { #ifdef LOCAL BUFRES_Params config; IRES_Status status; #endif /* init Codec Engine */ CERuntime_init(); /* init trace */ GT_init(); /* create a mask to allow a trace-print welcome message below */ GT_create(&curMask, MOD_NAME); /* Enable all trace for this module */ GT_set(MOD_NAME "=01234567"); GT_0trace(curMask, GT_2CLASS, "main> " MOD_NAME "\n"); #ifdef LOCAL RMAN_init(); /* * Configure and register BUFRES resource. This code is used for both * local and remote Linux apps. In the remote case, registering will * not have any affect, since the IRES codec will be run on the DSP. * * This particular resource cannot be auto-registered, since it needs * to be configured with a buffer. */ config.iresConfig.size = sizeof(BUFRES_Params); config.iresConfig.allocFxn = _ALG_allocMemory; config.iresConfig.freeFxn = _ALG_freeMemory; config.base = (Void *)buffer; config.length = BUFLEN; status = RMAN_register(&BUFRES_MGRFXNS, (IRESMAN_Params *)&config); GT_1trace(curMask, GT_2CLASS, "main> RMAN_register returned 0x%x\n", (IArg)status); #endif return (smain(argc, argv)); }
DvevmStRetCode dvtb_initApp(void) { DvevmStRetCode rc = DVEVM_ST_FAIL; IRESMAN_MemTcmParams memTcmConfigParams; dvtb_ceRuntimeInit(&G->eng); CMEM_init( ); rc = dvtb_initParams( ); ASSERT(rc != DVEVM_ST_FAIL); if (RMAN_init( ) != IRES_OK) { SYS_ERROR("Cannot Init RMAN.\n"); return DVEVM_ST_FAIL; } else SYS_OUT("RMAN initialized.\n"); /* * Register IRES components */ memTcmConfigParams.baseConfig.allocFxn = RMAN_PARAMS.allocFxn; memTcmConfigParams.baseConfig.freeFxn = RMAN_PARAMS.freeFxn; memTcmConfigParams.baseConfig.size = sizeof(IRESMAN_MemTcmParams);; if (RMAN_register(&IRESMAN_MEMTCM, (IRESMAN_Params *) &memTcmConfigParams) != IRES_OK) { SYS_ERROR("MEMTCM Protocol Registration Failed \n"); return DVEVM_ST_FAIL; } SYS_DEBUG("MEMTCM Protocol Registration Success \n"); return DVEVM_ST_SUCCESS; }
/* ARGSUSED - this line tells the compiler to not generate compiler warnings * for unused arguments */ Int smain(Int argc, Char * argv[]) { IRES_Status status; Int size = 0; Int scratchId = 2; IALG_Fxns * algFxns = (IALG_Fxns *)&TEMPLATE_TI_CODECIRES; IRES_Fxns * resFxns = &TEMPLATE_TI_IRES; IALG_Handle dumHandle = NULL; ITEMPLATE_Status algStatus; /* * Create an instance of the algorithm using "algFxns" */ dumHandle = DSKT2_createAlg(scratchId, (IALG_Fxns *)algFxns, NULL, (IALG_Params *)NULL); if (dumHandle == NULL) { printf("Alg creation failed \n"); return -1; } /* * Supply initialization information for the RESMAN while registering */ size = sizeof(IRESMAN_Params); configParams.allocFxn = RMAN_PARAMS.allocFxn; configParams.freeFxn = RMAN_PARAMS.freeFxn; configParams.size = size; /* * Register the NULL protocol/resource manager with the generic resource * manager */ status = RMAN_register(&IRESMAN_NULLRES, (IRESMAN_Params *)&configParams); if (IRES_EEXISTS == status) { printf("Protocol Already Registered\n"); } /* Create an instance of an algorithm that implements IALG and IRES_Fxns */ if (IRES_OK != RMAN_assignResources((IALG_Handle)dumHandle, resFxns,scratchId)) { printf("Assign Resource Failed \n"); return (-1); } /* Activate the Algorithm */ DSKT2_activateAlg(scratchId, (IALG_Handle)dumHandle); /* Activate All Resources */ RMAN_activateAllResources((IALG_Handle)dumHandle, resFxns, -1); /* Use IALG interfaces to do something */ ((ITEMPLATE_Handle)dumHandle)->fxns->process((ITEMPLATE_Handle)dumHandle, (ITEMPLATE_InArgs *)NULL, (ITEMPLATE_OutArgs *)NULL); ((ITEMPLATE_Handle)dumHandle)->fxns->control((ITEMPLATE_Handle)dumHandle, (ITEMPLATE_Cmd )0, (ITEMPLATE_DynamicParams *)NULL, &algStatus); /* Deactivate All Resources */ RMAN_deactivateAllResources((IALG_Handle)dumHandle, resFxns, -1); /* Deactivate algorithm */ DSKT2_deactivateAlg(scratchId, (IALG_Handle)dumHandle); /* Free resources assigned to this algorihtm */ if (IRES_OK != RMAN_freeResources((IALG_Handle)(dumHandle), resFxns, -1)) { printf("Free Resource Failed\n"); return (-1); } /* Free instance of the algorithm created */ DSKT2_freeAlg(scratchId, (IALG_Handle)dumHandle); /* Unregister the protocol */ if (IRES_OK != RMAN_unregister(&IRESMAN_NULLRES)) { printf("Unregister Protocol Failed\n"); return (-1); } RMAN_exit(); return (0); }
/* * ======== smain ======== */ Int smain(Int argc, Char * argv[]) { ISHMALG_Handle alg; ISHMALG_Fxns fxns = SHMALG_TI_ISHMALG; ISHMALG_Params params = ISHMALG_PARAMS; IRES_Fxns iresFxns = SHMALG_TI_IRES; IRES_Status status; Int scratchId; Bool passed = FALSE; Bool retVal = TRUE; Int fillVal = 1; if (argc > 1) { fillVal = atoi(argv[1]); } params.fillVal = fillVal; System_printf("shmbuf_test2> Started. buffer fill value: %d\n", fillVal); /* Initialize and register resource manager */ System_printf("Calling RMAN_init()...\n"); status = RMAN_init(); if (status != IRES_OK) { /* Test failed */ System_printf("RMAN_init() failed: %s [%d]\n", getError(status), status); goto done; } SHMBUF_PARAMS.bufsize = SHMBUFSIZE; SHMBUF_PARAMS.isScratch = TRUE; /* Make the buffer sharable */ System_printf("Calling RMAN_register()...\n"); status = RMAN_register(&SHMBUF_MGRFXNS, (IRESMAN_Params *)&SHMBUF_PARAMS); if (status != IRES_OK) { /* Test failed */ System_printf("RMAN_register() failed %s [%d]\n", getError(status), status); goto done; } scratchId = 1; System_printf("Calling DSKT2_createAlg()...\n"); alg = (ISHMALG_Handle)DSKT2_createAlg(scratchId, (IALG_Fxns *)&fxns, NULL, (IALG_Params *)¶ms); if (alg == NULL) { System_printf("DSKT2_createAlg() failed\n"); goto done; } /* Assign resources to the algorithm */ System_printf("Calling RMAN_assignResources()...\n"); status = RMAN_assignResources((IALG_Handle)alg, &iresFxns, scratchId); if (status != IRES_OK) { System_printf("RMAN_assignResources() failed %s [%d]\n", getError(status), status); goto done; } System_printf("Calling DSKT2_activateAlg()...\n"); DSKT2_activateAlg(scratchId, (IALG_Handle)alg); /* Activate All Resources */ System_printf("Calling RMAN_activateAllResources()...\n"); status = RMAN_activateAllResources((IALG_Handle)alg, &iresFxns, scratchId); if (status != IRES_OK) { System_printf("RMAN_activateAllResourceRMAN_unregister(&SHMBUF_MGRFXNS);s() failed %s [%d]\n", getError(status), status); goto done; } /* Use the buffer */ alg->fxns->useBufs(alg); /* Hold onto the resource for awhile */ System_printf("Sleeping...\n"); sleep(10); /* Check contents of the buffer */ if (!(retVal = alg->fxns->checkBufs(alg))) { System_printf("Buffer overwritten by another alg.\n"); } /* Deactivate All Resources */ System_printf("Calling RMAN_deactivateAllResources()...\n"); status = RMAN_deactivateAllResources((IALG_Handle)alg, &iresFxns, scratchId); if (status != IRES_OK) { System_printf("RMAN_deactivateAllResources() failed %s [%d]\n", getError(status), status); goto done; } /* Deactivate algorithm */ System_printf("Calling DSKT2_deactivateAlg()...\n"); DSKT2_deactivateAlg(scratchId, (IALG_Handle)alg); /* Free resources assigned to this algorihtm */ System_printf("Calling RMAN_freeResources()...\n"); status = RMAN_freeResources((IALG_Handle)(alg), &iresFxns, scratchId); if (status != IRES_OK) { System_printf("RMAN_freeResources() failed %s [%d]\n", getError(status), status); goto done; } /* Free instance of the algorithm created */ System_printf("Calling DSKT2_freeAlg()...\n"); DSKT2_freeAlg(scratchId, (IALG_Handle)alg); System_printf("Calling RMAN_unregister()...\n"); status = RMAN_unregister(&SHMBUF_MGRFXNS); if (status != IRES_OK) { System_printf("RMAN_unregister() failed %s [%d]\n", getError(status), status); goto done; } System_printf("Calling RMAN_exit()...\n"); status = RMAN_exit(); if (status != IRES_OK) { System_printf("RMAN_exit() failed %s [%d]\n", getError(status), status); goto done; } else { if (retVal) { passed = TRUE; } } done: RMAN_exit(); if (passed) { System_printf("TEST PASSED\n"); } else { System_printf("TEST FAILED\n"); } return (0); }
/* * ======== RMAN_init ======== * Initialize the RMAN object with static information from the headers/ * configuration etc. This function has to return successfully before the * other APIs can be called */ IRES_Status RMAN_init() { Int i = 0; IRES_Status status; IRESMAN_Params nullParams; Registry_Result regResult; /* * Register the module name for logging only once. Do this before any * Log functions are called. */ if (regInit == 0) { regResult = Registry_addModule(&ti_sdo_fc_rman_desc, RMAN_MODNAME); Assert_isTrue(regResult == Registry_SUCCESS, (Assert_Id)NULL); /* Set diags mask to FC default */ FCSettings_init(); FCSettings_setDiags(RMAN_MODNAME); regInit = 1; } /* Ensure it is called/initialized at least once */ if (rmanInit++) { Log_print0(Diags_ENTRY, "[+E] RMAN_init> Enter"); Log_print0(Diags_EXIT, "[+X] RMAN_init> Exit (status=IRES_OK)"); /* TODO: Return IRES_OK even if RMAN_init() failed earlier? */ return (IRES_OK); } Log_print0(Diags_ENTRY, "[+E] RMAN_init> Enter"); if ((NULL == RMAN_PARAMS.allocFxn) || (NULL == RMAN_PARAMS.freeFxn)) { Log_print0(Diags_USER7, "[+7] RMAN_init> RMAN_PARAMS not " "configured with allocFxn and freeFxn functions"); initStatus = IRES_ENOMEM; } else { /* Set initStatus to IRES_OK so RMAN_register() can succeed. */ initStatus = IRES_OK; } if (initStatus == IRES_OK) { /* Create a lock for protecting RMAN_data object */ gate = OsalSupport_createGate(ti_sdo_fc_rman_RMAN_ipcKey); if (gate == NULL) { Log_print1(Diags_USER7, "[+7] RMAN_init> Failed to create IPC gate, key = 0x%x", ti_sdo_fc_rman_RMAN_ipcKey); initStatus = IRES_ENOMEM; } } if (initStatus == IRES_OK) { /* * Register the NULL resource. */ resTable.tableSize = RMAN_PARAMS.numRegistries; /* Initialize the registry table and the free index table */ for (i = 0; i < resTable.tableSize; i++) { RMAN_TABLE[i] = NULL; RMAN_FREE_ENTRIES[i] = 0; } resTable.tableIndex = 0; resTable.freeIndex = -1; /* First pre-register the NULL resource */ nullParams.allocFxn = RMAN_PARAMS.allocFxn; nullParams.freeFxn = RMAN_PARAMS.freeFxn; nullParams.size = sizeof(IRESMAN_Params); status = RMAN_register(&IRESMAN_NULLRES, &nullParams); if (status != IRES_OK) { Log_print1(Diags_USER7, "[+7] RMAN_init> Register failed " "on NULL IRESMAN implementation: %d", (IArg)status); initStatus = status; } } if (initStatus == IRES_OK) { /* * In this function, we can populate the RMAN_registryEntries, * RMAN_registeryResmanArgs and fix RMAN_numRegistryEntries */ initStatus = RMAN_autoRegister(); } /* * Static registration of Resource Registry entries */ if ((initStatus == IRES_OK) && (RMAN_registryEntries != NULL)) { Assert_isTrue(RMAN_numRegistryEntries < resTable.tableSize, (Assert_Id)NULL); Log_print0(Diags_USER2, "[+2] RMAN_init> Registering statically " "added resources"); /* * Copy the entries from the static configuration into the resource * table. */ for (i = 0; i < RMAN_numRegistryEntries; i++) { status = RMAN_register(RMAN_registryEntries[i], RMAN_registryResmanArgs[i]); if (status != IRES_OK) { Log_print2(Diags_USER7, "[+7] RMAN_init> Register failed on " "IRESMAN implementation 0x%x, status: %d", (IArg)(RMAN_registryEntries[i]), (IArg)status); initStatus = status; break; } } } getInternalState(); if (NULL == rmanInternalState) { initStatus = IRES_EFAIL; } Log_print1(Diags_EXIT, "[+X] RMAN_init> Exit (status=%d)", (IArg)initStatus); return (initStatus); }
/* Main Function acting as a client for Image Encode Call*/ XDAS_Int32 main(int argc, char *argv[]) { /* File I/O variables */ FILE *fConfigFile, /**ftestFile, *finFile,*/ *fparamsFile; #ifdef LINUX CMEM_AllocParams memParams; memParams.type=CMEM_POOL; memParams.flags=CMEM_NONCACHED; memParams.alignment=256; #endif char* colorf[]={"YUV422P", "YUV420P", "YUV422P", "YUV422IL", "YUV422IL", "YUV444", "YUV411", "GRAY", "RGB", "YUV420_LINE"}; #ifdef LINUX XDAS_Int8 *fname = "../TestVecs/Config/Testvecs.cfg"; #else XDAS_Int8 *fname = "..\\..\\Test\\TestVecs\\Config\\Testvecs_ccs.cfg"; #endif Int32 lTemp,countConfigSet; Int32 retVal; Uint32 numAU, totalAU,repeat; Uint32 bytesGenerated; Uint16 mbSizeX, mbSizeY,mbY; char *RefBuffPtr; FILE *fp_out; FILE *fp_in; int processTime = 0, processTimeTotal = 0,algActivateTime =0, algDeactivateTime =0,copctime=0; int val,queue_word,queue_num=0,i,k; char baseParams[STRING_SIZE]; int baseParamsOnly; int Offset; int num_markers; IIMGENC1_Fxns *iimgEncfxns; IIMGENC1_Status imgencStatus; IIMGENC1_InArgs imgencInArgs; IIMGENC1_OutArgs imgencOutArgs; IJPEGENC_Status status; IJPEGENC_InArgs inArgs; IJPEGENC_OutArgs outArgs; unsigned int lTemp1; /*Algorithm specific handle */ IALG_Handle handle; /* Input/Output Buffer Descriptor variables */ XDM1_BufDesc inputBufDesc, outputBufDesc; #ifdef ENABLE_RMAN // IRES/RMAN Related declarations // temp_trace_init(); IRES_Status iresStatus; Int size =0; Int scratchId =0; Bool result = TRUE; IRES_Fxns *resFxns = &JPEGENC_TI_IRES; IRESMAN_Edma3ChanParams configParams; IRESMAN_VicpParams iresmanConfigParams; IRESMAN_AddrSpaceParams addrspaceConfigParams; iresStatus = RMAN_init(); if (IRES_OK != iresStatus) { printf("RMAN initialization Failed \n"); return -1; } printf("RMAN initialization done \n"); #ifndef LINUX /* Call the functions to enable ARM926 FIQ and do some basic * setup to AINTC to accept KLD INTC (arm968) interupt in * FIQ pin of Arm926 */ ARM926_enable_FIQ(); /* SWI call to enable interrupts */ ARM926_INTC_init(); /* Init AINTC */ #endif /* * Supply initialization information for the RESMAN while registering */ size = sizeof(IRESMAN_VicpParams); iresmanConfigParams.baseConfig.allocFxn = RMAN_PARAMS.allocFxn; iresmanConfigParams.baseConfig.freeFxn = RMAN_PARAMS.freeFxn; iresmanConfigParams.baseConfig.size = size; /* Register the VICP protocol/resource manager with the * * generic resource manager */ iresStatus = RMAN_register(&IRESMAN_VICP2, (IRESMAN_Params *)&iresmanConfigParams); if (IRES_OK != iresStatus) { printf("VICP Protocol Registration Failed \n"); return -1; } printf("VICP Protocol Registration Success \n"); /* * * Supply initialization information for the EDMA3 RESMAN while registering * */ size = sizeof(IRESMAN_Edma3ChanParams); configParams.baseConfig.allocFxn = RMAN_PARAMS.allocFxn; configParams.baseConfig.freeFxn = RMAN_PARAMS.freeFxn; configParams.baseConfig.size = size; iresStatus = RMAN_register(&IRESMAN_EDMA3CHAN, (IRESMAN_Params *)&configParams); if (IRES_OK != iresStatus) { printf("EDMA3 Protocol Registration Failed \n"); return -1; } printf("EDMA3 Protocol Registration Success \n"); /** Supply initialization information for the ADDRSPACE RESMAN while registering * */ #if 1 size = sizeof(IRESMAN_AddrSpaceParams); addrspaceConfigParams.baseConfig.allocFxn = RMAN_PARAMS.allocFxn; addrspaceConfigParams.baseConfig.freeFxn = RMAN_PARAMS.freeFxn; addrspaceConfigParams.baseConfig.size = size; iresStatus = RMAN_register(&IRESMAN_ADDRSPACE, (IRESMAN_Params *)&addrspaceConfigParams); if (IRES_OK != iresStatus) { printf("ADDRSPACE Protocol Registration Failed \n"); return -1; } #ifdef _DBG_MSG printf("ADDRSPACE Protocol Registration Success \n"); #endif #endif #endif //IRES/RMAN related code ends here #ifdef LINUX CMEM_init(); ExternalGlobalMemPool = ExternalGlobalMemPoolBase = CMEM_alloc(EXTERNAL_DATA_MEM_SIZE,&memParams); #ifdef ENABLE_RING_BUF_USAGE ringbuf = CMEM_alloc(RINGBUFSIZE, &memParams); #endif OrgPictureY_0=CMEM_alloc( (LUMABUF_SIZE*2+ORGBUF_OFFSET), &memParams); OrgPictureCb_0=CMEM_alloc((CHROMABUF_SIZE+ORGBUF_OFFSET), &memParams); OrgPictureCr_0=CMEM_alloc((CHROMABUF_SIZE+ORGBUF_OFFSET), &memParams); media=CMEM_alloc((ENCODED_DATA_BUFFER_SIZE), &memParams); //#ifdef LINUX // DM350MM_init(); //#endif if (argc==2) { strncpy(baseParams,argv[1],256); if (!strcmp(baseParams,"-ext")) { printf("\n----- Running in extended parameter mode -----\n"); baseParamsOnly=0; } else { printf("Argument -ext needed to run in extended param mode\n"); exit(0); } } else { printf("\n----- Running in base parameter mode -----\n"); baseParamsOnly=1; } #else baseParamsOnly=0; #endif //memset(ringbuf,0xaa,RINGBUFSIZE ); memset(media, 0xaa, ENCODED_DATA_BUFFER_SIZE); memset(ExternalGlobalMemPool, 0xaa,EXTERNAL_DATA_MEM_SIZE ); memset(OrgPictureY_0, 0xaa, (LUMABUF_SIZE*2+ORGBUF_OFFSET)); memset(OrgPictureCb_0, 0xaa, (CHROMABUF_SIZE+ORGBUF_OFFSET)); memset(OrgPictureCr_0, 0xaa, (CHROMABUF_SIZE+ORGBUF_OFFSET)); OrgPictureY = &OrgPictureY_0[ORGBUF_OFFSET]; OrgPictureCb = &OrgPictureCb_0[ORGBUF_OFFSET]; OrgPictureCr = &OrgPictureCr_0[ORGBUF_OFFSET]; /* Open Test Config File */ fConfigFile = fopen(fname, "r"); if (!fConfigFile) { printf("Couldn't open parameter file %s\n", fname); return XDM_EFAIL; } countConfigSet = 1; /* Reset countConfigSet value to 1 */ /* Read the Config File until it reaches the end of file */ while (!feof(fConfigFile)) { /* Read Compliance Checking parameter */ if (fgets(line, 254, fConfigFile)) { sscanf(line, "%d\n", &testCompliance); printf("\nTestcompliance = %d\n",testCompliance); } else { break; } /* Read Parameters file name */ if (fgets(line, 254, fConfigFile)) { sscanf(line, "%s", paramsFile); printf("\nParam file = %s\n",paramsFile); } else { break; } /* Read Input file name */ if (fgets(line, 254, fConfigFile)) { sscanf(line, "%s", inFile); printf("\nInput file = %s\n",inFile); } else { break; } /* Read Output/Reference file name */ if (fgets(line, 254, fConfigFile)) { sscanf(line, "%s", testFile); printf("\nOutput file = %s\n",testFile); } else { break; } printf("\n*******************************************"); printf("\nRead Configuration Set %d", countConfigSet); printf("\n*******************************************"); countConfigSet++; fp_out=fopen(testFile,"wb"); fp_in = fopen(inFile,"rb"); if ((fp_in == NULL) || (fp_out == NULL)) { printf("'Input/out file cannot be opened\n"); exit(0); } /** Set initialization parameters * Parameters in structure params are default image encode parameters required by XDM * Paraemters in extn_params are parameters specific to jpeg encoder, * */ /* Open Parameters file */ fparamsFile = fopen(paramsFile, "rb"); //fparamsFile = fopen("Testparams.cfg", "rb"); if (!fparamsFile) { printf("\nCouldn't open Parameters file... %s\n ", paramsFile); printf("Exiting for this configuration...\n"); continue; } printf("\nParameter file read starts...\n"); if (readparamfile(fparamsFile,baseParamsOnly) < 0) { printf("\nSyntax Error in %s\n ", paramsFile); printf("Exiting for this configuration...\n"); continue; } /* Close Parameters File */ fclose(fparamsFile); if (testCompliance) { printf("\nRunning in Compliance Mode"); } else { printf("\nRunning in Output Dump Mode"); } /** Call algorithm creation function * See file alg_create. * memory allocation functions are called inside alg_malloc file. * Modify _ALG_allocMemory in alg_malloc.c to suit the application need (static allocation vs dynamic through malloc()) */ if (baseParamsOnly==0) { #ifdef ENABLE_RING_BUF_USAGE extn_params.halfBufCB =(XDAS_Void (*)(Uint32, XDAS_Void*))JPEGENC_TI_DM350_HalfBufCB; extn_params.halfBufCBarg= (void*)&ring2media; #else extn_params.halfBufCB = (XDAS_Void (*))NULL; #endif extn_params.imgencParams = params; extn_params.imgencParams.size = sizeof(IJPEGENC_Params); } else { params.size = sizeof(IIMGENC1_Params); dynamicParams.size =sizeof(IIMGENC1_DynamicParams); } if (baseParamsOnly==0) { if ((handle = (IALG_Handle)ALG_create ( (IALG_Fxns *) &JPEGENC_TI_IJPEGENC, (IALG_Handle) NULL, (IALG_Params *)&extn_params)) == NULL) { printf("\nFailed to Create Instance... Exiting for this configuration.."); exit(0); } printf("\nAlgorithm Instance Creation Done...\n"); } else { if ((handle = (IALG_Handle)ALG_create ( (IALG_Fxns *) &JPEGENC_TI_IJPEGENC, (IALG_Handle) NULL, (IALG_Params *)¶ms)) == NULL) { printf("\nFailed to Create Instance... Exiting for this configuration.."); exit(0); } printf("\nAlgorithm Instance Creation Done...\n"); } #ifdef ENABLE_RMAN // IRES/RMAN Related code /* Create an instance of an algorithm that implements IALG and IRES_Fxns */ iresStatus = RMAN_assignResources((IALG_Handle)handle, resFxns,scratchId); if (IRES_OK != iresStatus) { printf("Assign Resource Failed \n"); result = FALSE; } #endif //IRES/RMAN code ends here. /** Set up dynamic parameters (can be changed before each call to jpeg processing) * Parameters in structure dynamicParams are default image encode parameters required by XDM */ if (baseParamsOnly==0) { extn_dynamicParams.imgencDynamicParams = dynamicParams; extn_dynamicParams.imgencDynamicParams.size = sizeof(IJPEGENC_DynamicParams); extn_dynamicParams.disableEOI = 0; iimgEncfxns = (IIMGENC1_Fxns *)handle->fxns ; status.imgencStatus.size= sizeof(IJPEGENC_Status); } else { dynamicParams.size = sizeof(IIMGENC1_DynamicParams); iimgEncfxns = (IIMGENC1_Fxns *)handle->fxns ; imgencStatus.size= sizeof(IIMGENC1_Status); } /** Request input and output buffer characteristics by calling control() function * with command XDM_GETBUFINFO */ // Call control function to setup dynamic params if (baseParamsOnly==0) { retVal=iimgEncfxns->control((IIMGENC1_Handle)handle,/*IJPEGENC_SETDEFAULT*/XDM_SETPARAMS, (IIMGENC1_DynamicParams *)&extn_dynamicParams, (IIMGENC1_Status *)&status); if (retVal== XDM_EFAIL) { printf("\n Error control SetParams command1\n"); exit(0); } retVal= iimgEncfxns->control((IIMGENC1_Handle)handle, XDM_GETBUFINFO, (IIMGENC1_DynamicParams *) &extn_dynamicParams, (IIMGENC1_Status *)&status); if (retVal== XDM_EFAIL) { printf("\n Error control Getbuffinfo command1\n"); exit(0); } inputBufDesc.numBufs = status.imgencStatus.bufInfo.minNumInBufs; Offset = 0; for (i=0;i<inputBufDesc.numBufs;i++) { inputBufDesc.descs[i].buf = (XDAS_Int8 *) ( (unsigned int)inputData + Offset); Offset += status.imgencStatus.bufInfo.minInBufSize[i]; inputBufDesc.descs[i].bufSize = status.imgencStatus.bufInfo.minInBufSize[i]; } outputBufDesc.numBufs = status.imgencStatus.bufInfo.minNumOutBufs; Offset = 0; for (i=0;i<outputBufDesc.numBufs;i++) { outputBufDesc.descs[i].buf = (XDAS_Int8 *) ( (unsigned int)outputData + Offset); Offset += status.imgencStatus.bufInfo.minOutBufSize[i]; outputBufDesc.descs[i].bufSize = status.imgencStatus.bufInfo.minOutBufSize[i]; } if (retVal== XDM_EFAIL) { printf("\n Error control GetInfo command\n"); exit(0); } } else { retVal=iimgEncfxns->control((IIMGENC1_Handle)handle, XDM_SETPARAMS, (IIMGENC1_DynamicParams *)&dynamicParams, (IIMGENC1_Status *)&imgencStatus); if (retVal== XDM_EFAIL) { printf("\n Error control SetParams command1\n"); exit(0); } retVal= iimgEncfxns->control((IIMGENC1_Handle)handle, XDM_GETBUFINFO, (IIMGENC1_DynamicParams *)&dynamicParams, (IIMGENC1_Status *)&imgencStatus); if (retVal== XDM_EFAIL) { printf("\n Error control GetBuffInfo command1\n"); exit(0); } inputBufDesc.numBufs = imgencStatus.bufInfo.minNumInBufs; Offset = 0; for (i=0;i<inputBufDesc.numBufs;i++) { inputBufDesc.descs[i].buf = (XDAS_Int8 *) ( (unsigned int)inputData + Offset); Offset += imgencStatus.bufInfo.minInBufSize[i]; inputBufDesc.descs[i].bufSize = imgencStatus.bufInfo.minInBufSize[i]; } outputBufDesc.numBufs = imgencStatus.bufInfo.minNumOutBufs; Offset = 0; for (i=0;i<outputBufDesc.numBufs;i++) { outputBufDesc.descs[i].buf = (XDAS_Int8 *) ( (unsigned int)outputData + Offset); Offset += imgencStatus.bufInfo.minOutBufSize[i]; outputBufDesc.descs[i].bufSize = imgencStatus.bufInfo.minOutBufSize[i]; } if (retVal== XDM_EFAIL) { printf("\n Error control GetInfo command\n"); exit(0); } } if (baseParamsOnly==0) { /** Read input file. */ printf("Number of Input bufs =%d\n",status.imgencStatus.bufInfo.minNumInBufs ); if (status.imgencStatus.bufInfo.minNumInBufs == 3) { memset(OrgPictureY,0,(status.imgencStatus.bufInfo.minInBufSize[0])); memset(OrgPictureCb,0,(status.imgencStatus.bufInfo.minInBufSize[1])); memset(OrgPictureCr,0,(status.imgencStatus.bufInfo.minInBufSize[2])); printf("Input file read starts\n" ); lTemp = fread(OrgPictureY,1,(status.imgencStatus.bufInfo.minInBufSize[0]),fp_in); if (dynamicParams.inputWidth < dynamicParams.captureWidth) { fseek(fp_in,(dynamicParams.captureWidth*(params.maxHeight-dynamicParams.inputHeight)),SEEK_CUR); } printf("number of bytes read from input file = %d \n",lTemp); lTemp = fread(OrgPictureCb,1,((status.imgencStatus.bufInfo.minInBufSize[1])),fp_in); if (dynamicParams.inputWidth < dynamicParams.captureWidth) { fseek(fp_in,(dynamicParams.captureWidth*(params.maxHeight-dynamicParams.inputHeight)/4),SEEK_CUR); } printf("number of bytes read from input file = %d \n",lTemp); lTemp = fread(OrgPictureCr,1,((status.imgencStatus.bufInfo.minInBufSize[2])),fp_in); printf("number of bytes read from input file = %d \n",lTemp); } else if (status.imgencStatus.bufInfo.minNumInBufs == 1) { printf("status.imgencStatus.bufInfo.minInBufSize[0]=%d\n",status.imgencStatus.bufInfo.minInBufSize[0]); memset(OrgPictureY,0,(status.imgencStatus.bufInfo.minInBufSize[0])); lTemp = fread(OrgPictureY,1,(status.imgencStatus.bufInfo.minInBufSize[0]),fp_in); printf("number of bytes read from input file = %d \n",lTemp); } else if (status.imgencStatus.bufInfo.minNumInBufs == 2) /* 420 semi planar*/ { printf("status.imgencStatus.bufInfo.minInBufSize[0]=%d\n",status.imgencStatus.bufInfo.minInBufSize[0]); memset(OrgPictureY,0,(status.imgencStatus.bufInfo.minInBufSize[0])); printf("status.imgencStatus.bufInfo.minInBufSize[1]=%d\n",status.imgencStatus.bufInfo.minInBufSize[1]); memset(OrgPictureCb,'-',(status.imgencStatus.bufInfo.minInBufSize[1])); memset(OrgPictureCr,'-',(status.imgencStatus.bufInfo.minInBufSize[1])); lTemp = fread(OrgPictureY,1,(status.imgencStatus.bufInfo.minInBufSize[0]),fp_in); if (dynamicParams.inputWidth < dynamicParams.captureWidth) { fseek(fp_in,(dynamicParams.captureWidth*(params.maxHeight-dynamicParams.inputHeight)),SEEK_CUR); } printf("number of bytes read from input file = %d \n",lTemp); if (dynamicParams.inputWidth < dynamicParams.captureWidth) { lTemp = fread(OrgPictureCr,1,(status.imgencStatus.bufInfo.minInBufSize[1])/2,fp_in); fseek(fp_in,(dynamicParams.captureWidth*(params.maxHeight-dynamicParams.inputHeight)/4),SEEK_CUR); lTemp += fread((OrgPictureCr+(status.imgencStatus.bufInfo.minInBufSize[1])/2),1,(status.imgencStatus.bufInfo.minInBufSize[1])/2,fp_in); } else { lTemp = fread(OrgPictureCr,1,(status.imgencStatus.bufInfo.minInBufSize[1]),fp_in); } printf("number of bytes read from input file = %d \n",lTemp); /* The input file is 420 planar, the following function converts the 420P to 420 semi planar i.e CbCr will be interleaved. planar chrmoa data is read into OrgPictureCr buffer and converted to interleaved. output is stored in OrgPictureCb buffer*/ /*convert the 420 planar to 420 semi planar*/ lTemp = Convert420Pto420Semi(OrgPictureCr,OrgPictureCb,status.imgencStatus.bufInfo.minInBufSize[1]); } else { printf("Unsupported number of input buffers \n"); } fclose(fp_in); } else { /** Read input file. */ printf("Number of Input bufs =%d\n",imgencStatus.bufInfo.minNumInBufs ); if (imgencStatus.bufInfo.minNumInBufs == 3) { memset(OrgPictureY,0,(imgencStatus.bufInfo.minInBufSize[0])); memset(OrgPictureCb,0,(imgencStatus.bufInfo.minInBufSize[1])); memset(OrgPictureCr,0,(imgencStatus.bufInfo.minInBufSize[2])); printf("Input file read starts\n" ); lTemp = fread(OrgPictureY,1,(imgencStatus.bufInfo.minInBufSize[0]),fp_in); if (dynamicParams.inputWidth < dynamicParams.captureWidth) { fseek(fp_in,(dynamicParams.captureWidth*(params.maxHeight-dynamicParams.inputHeight)),SEEK_CUR); } printf("number of bytes read from input file = %d \n",lTemp); lTemp = fread(OrgPictureCb,1,((imgencStatus.bufInfo.minInBufSize[1])),fp_in); if (dynamicParams.inputWidth < dynamicParams.captureWidth) { fseek(fp_in,(dynamicParams.captureWidth*(params.maxHeight-dynamicParams.inputHeight)/4),SEEK_CUR); } printf("number of bytes read from input file = %d \n",lTemp); lTemp = fread(OrgPictureCr,1,((imgencStatus.bufInfo.minInBufSize[2])),fp_in); printf("number of bytes read from input file = %d \n",lTemp); } else if (imgencStatus.bufInfo.minNumInBufs == 1) { printf("imgencStatus.bufInfo.minInBufSize[0]=%d\n",imgencStatus.bufInfo.minInBufSize[0]); memset(OrgPictureY,0,(imgencStatus.bufInfo.minInBufSize[0])); lTemp = fread(OrgPictureY,1,(imgencStatus.bufInfo.minInBufSize[0]),fp_in); printf("number of bytes read from input file = %d \n",lTemp); } else if (imgencStatus.bufInfo.minNumInBufs == 2) /* 420 semi planar*/ { printf("imgencStatus.bufInfo.minInBufSize[0]=%d\n",imgencStatus.bufInfo.minInBufSize[0]); memset(OrgPictureY,0,(imgencStatus.bufInfo.minInBufSize[0])); printf("imgencStatus.bufInfo.minInBufSize[1]=%d\n",imgencStatus.bufInfo.minInBufSize[1]); memset(OrgPictureCb,'-',(imgencStatus.bufInfo.minInBufSize[1])); memset(OrgPictureCr,'-',(imgencStatus.bufInfo.minInBufSize[1])); lTemp = fread(OrgPictureY,1,(imgencStatus.bufInfo.minInBufSize[0]),fp_in); if (dynamicParams.inputWidth < dynamicParams.captureWidth) { fseek(fp_in,(dynamicParams.captureWidth*(params.maxHeight-dynamicParams.inputHeight)),SEEK_CUR); } printf("number of bytes read from input file = %d \n",lTemp); if (dynamicParams.inputWidth < dynamicParams.captureWidth) { lTemp = fread(OrgPictureCr,1,(imgencStatus.bufInfo.minInBufSize[1])/2,fp_in); fseek(fp_in,(dynamicParams.captureWidth*(params.maxHeight-dynamicParams.inputHeight)/4),SEEK_CUR); lTemp += fread((OrgPictureCr+(imgencStatus.bufInfo.minInBufSize[1])/2),1,(imgencStatus.bufInfo.minInBufSize[1])/2,fp_in); } else { lTemp = fread(OrgPictureCr,1,(imgencStatus.bufInfo.minInBufSize[1]),fp_in); } printf("number of bytes read from input file = %d \n",lTemp); /* The input file is 420 planar, the following function converts the 420P to 420 semi planar i.e CbCr will be interleaved. planar chrmoa data is read into OrgPictureCr buffer and converted to interleaved. output is stored in OrgPictureCb buffer*/ /*convert the 420 planar to 420 semi planar*/ lTemp = Convert420Pto420Semi(OrgPictureCr,OrgPictureCb,imgencStatus.bufInfo.minInBufSize[1]); // printf("OrgPictureCb=%x\n",OrgPictureCb); } else { printf("Unsupported number of input buffers \n"); } fclose(fp_in); } /*Fill up the buffers as required by algorithm */ if (baseParamsOnly==0) { inputBufDesc.numBufs = status.imgencStatus.bufInfo.minNumInBufs ; } else { inputBufDesc.numBufs = imgencStatus.bufInfo.minNumInBufs ; } inputBufDesc.descs[0].buf= (XDAS_Int8 *)OrgPictureY; if (dynamicParams.inputChromaFormat== IJPEGENC_YUV_420LINE) { inputBufDesc.descs[1].buf= (XDAS_Int8 *)OrgPictureY + dynamicParams.inputWidth; inputBufDesc.descs[2].buf= inputBufDesc.descs[1].buf + dynamicParams.inputWidth*3/2; } else if (dynamicParams.inputChromaFormat!= XDM_YUV_422ILE) { if (dynamicParams.inputChromaFormat== XDM_YUV_420SP) { inputBufDesc.descs[1].buf= (XDAS_Int8 *)OrgPictureCb; } else { inputBufDesc.descs[1].buf= (XDAS_Int8 *)OrgPictureCb; inputBufDesc.descs[2].buf= (XDAS_Int8 *)OrgPictureCr; } } if (baseParamsOnly==0) { inputBufDesc.descs[0].bufSize = status.imgencStatus.bufInfo.minInBufSize[0]; // actually ignored by codec outputBufDesc.numBufs = status.imgencStatus.bufInfo.minNumOutBufs ; } else { inputBufDesc.descs[0].bufSize = imgencStatus.bufInfo.minInBufSize[0]; // actually ignored by codec outputBufDesc.numBufs = imgencStatus.bufInfo.minNumOutBufs ; } if (baseParamsOnly==0) { #ifdef ENABLE_RING_BUF_USAGE outputBufDesc.descs[0].buf = (XDAS_Int8 *)ringbuf; outputBufDesc.descs[0].bufSize = RINGBUFSIZE; // actually ignored by codec ring2media.mediaPtr= media; ring2media.ringCurPtr= ringbuf; ring2media.ringStartPtr=ringbuf; ring2media.ringEndPtr= (Uint8*)((Uint32)ringbuf +RINGBUFSIZE) ; inArgs.ringBufStart= (XDAS_UInt8*)ringbuf; inArgs.ringBufSize= RINGBUFSIZE; printf("RINGBUFSIZE %x\n", RINGBUFSIZE); #else outputBufDesc.descs[0].buf = (XDAS_Int8 *)media; outputBufDesc.descs[0].bufSize = ENCODED_DATA_BUFFER_SIZE; // actually ignored by codec ring2media.mediaPtr= media; ring2media.ringCurPtr= media; ring2media.ringStartPtr=media; ring2media.ringEndPtr= (Uint8*)((Uint32)media +ENCODED_DATA_BUFFER_SIZE) ; inArgs.ringBufStart= (XDAS_UInt8*)media; inArgs.ringBufSize= ENCODED_DATA_BUFFER_SIZE; #endif inArgs.imgencInArgs.size = sizeof(IJPEGENC_InArgs); outArgs.imgencOutArgs.size= sizeof(IJPEGENC_OutArgs); } else { outputBufDesc.descs[0].buf = (XDAS_Int8 *)media; outputBufDesc.descs[0].bufSize = ENCODED_DATA_BUFFER_SIZE; // actually ignored by codec imgencInArgs.size = sizeof(IIMGENC1_InArgs); imgencOutArgs.size= sizeof(IIMGENC1_OutArgs); } #ifdef LINUX algActStart.tv_sec = 0; algActStart.tv_usec = 0; gettimeofday(&algActStart, 0); #endif handle->fxns->algActivate(handle); #ifdef LINUX processStart.tv_sec = 0; processStart.tv_usec = 0; gettimeofday(&processStart, 0); #endif if (baseParamsOnly==0) { inArgs.insertCommentMarker = 0; inArgs.appDataType =0; inArgs.commentSegLen = 0; retVal = iimgEncfxns->process((IIMGENC1_Handle)handle, (XDM1_BufDesc *)&inputBufDesc, (XDM1_BufDesc *)&outputBufDesc, (IIMGENC1_InArgs *)&inArgs, (IIMGENC1_OutArgs *)&outArgs); bytesGenerated= outArgs.imgencOutArgs.bytesGenerated; } else { retVal = iimgEncfxns->process((IIMGENC1_Handle)handle, (XDM1_BufDesc *)&inputBufDesc, (XDM1_BufDesc *)&outputBufDesc, (IIMGENC1_InArgs *)&imgencInArgs, (IIMGENC1_OutArgs *)&imgencOutArgs); bytesGenerated= imgencOutArgs.bytesGenerated; } #ifdef SLICE_MODE_TEST /* SLICE_MODE_TEST*/ // Call get status to get number of total AU if (baseParamsOnly==0) { retVal=iimgEncfxns->control((IIMGENC1_Handle)handle, IJPEGENC_GETSTATUS, (IIMGENC1_DynamicParams *)&extn_dynamicParams, (IIMGENC1_Status *)&status); if (retVal== XDM_EFAIL) { printf("\n Error control in slice mode get status command\n"); exit(0); } totalAU= status.imgencStatus.totalAU; printf("totalAU = %d\n",totalAU); extn_dynamicParams.imgencDynamicParams.numAU= 50/*totalAU/5*/; // Call control function to setup dynamic params retVal=iimgEncfxns->control((IIMGENC1_Handle)handle, XDM_SETPARAMS, (IIMGENC1_DynamicParams *)&extn_dynamicParams, (IIMGENC1_Status *)&status); numAU = status.numAU; printf("numAU = %d\n",numAU); if (retVal== XDM_EFAIL) { printf("\n Error control in slice mode SetParams command\n"); exit(0); } // Get real numAU computed by codec // In case of 270 rotation, must point to right most slice of the image if (extn_dynamicParams.rotation== 90) { if (dynamicParams.inputChromaFormat==XDM_YUV_420SP) { Uint16 sliceWidth= (numAU*16/dynamicParams.inputHeight)*(8<<(params.forceChromaFormat==XDM_YUV_420P)); inputBufDesc.descs[0].buf+= (dynamicParams.inputWidth - sliceWidth); inputBufDesc.descs[1].buf+= (dynamicParams.inputWidth - sliceWidth); // inputBufDesc.descs[2].buf+= (dynamicParams.inputWidth - sliceWidth);//dynamicParams.inputWidth/2 - sliceWidth/2; } else { Uint16 sliceWidth= (numAU*16/dynamicParams.inputHeight)*(8<<(params.forceChromaFormat==XDM_YUV_420P)); inputBufDesc.descs[0].buf+= (dynamicParams.inputChromaFormat== XDM_YUV_422ILE ? 2 : 1)*(dynamicParams.inputWidth - sliceWidth); inputBufDesc.descs[1].buf+= dynamicParams.inputWidth/2 - sliceWidth/2; inputBufDesc.descs[2].buf+= dynamicParams.inputWidth/2 - sliceWidth/2; } } else if (extn_dynamicParams.rotation== 180) { Uint16 sliceHeight = (numAU*16/dynamicParams.inputWidth)*(8<<(params.forceChromaFormat==XDM_YUV_420P)); if (dynamicParams.inputChromaFormat != XDM_YUV_420SP) { inputBufDesc.descs[0].buf+= dynamicParams.captureWidth*(dynamicParams.inputChromaFormat== XDM_YUV_422ILE ? 2 : 1)*(dynamicParams.inputHeight - sliceHeight); inputBufDesc.descs[1].buf+= dynamicParams.captureWidth*(dynamicParams.inputHeight - sliceHeight)>>(1 + (dynamicParams.inputChromaFormat== XDM_YUV_420P)); inputBufDesc.descs[2].buf+= dynamicParams.captureWidth*(dynamicParams.inputHeight - sliceHeight)>>(1 + (dynamicParams.inputChromaFormat== XDM_YUV_420P)); } else {