void FluctuatingChargeParameters::validate() { CheckParameter(Propagator, isEqualIgnoreCase("NVT") || isEqualIgnoreCase("Langevin") || isEqualIgnoreCase("Minimizer") || isEqualIgnoreCase("Exact") ); CheckParameter(Friction, isNonNegative()); CheckParameter(Tolerance, isPositive()); CheckParameter(MaxIterations, isPositive()); CheckParameter(TargetTemp, isNonNegative()); CheckParameter(TauThermostat, isPositive()); CheckParameter(DragCoefficient, isPositive()); }
int WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow) #endif { int i,n,j; u32 dd,nn; dip_t *dip; #if !defined(_DEBUG) && !defined(GEKKO) && !defined(LINUX) int argc; char **argv,*pstart,*pend,*str; list_c argvlist; pstart = lpCmdLine; for(;;) { while(*pstart == ' ') //skip any spaces pstart++; if(strcmp(pstart,"") != 0) //is there another entry? { if(*pstart == '\"') //beginning quote, this is all one str pend = strchr(pstart,'\"'); else if((pend = strchr(pstart,' ')) == 0) pend = lpCmdLine + strlen(lpCmdLine); str = new char[pend - pstart + 1]; memset(str,0,pend - pstart + 1); strncpy(str,pstart,pend - pstart); pstart = pend; argvlist.add(str); } else break; } argc = argvlist.num() + 1; argv = new char*[argc]; argv[0] = new char[_MAX_PATH]; GetModuleFileName(GetModuleHandle(0),argv[0],_MAX_PATH); for(i=1;i<argc;i++) argv[i] = (char*)argvlist.get(i - 1); #endif memset(RomSets,0,sizeof(CRomSet*) * MAX_ROMSETS); AddRomSets(); ParameterInit_Arg(argv,argc); //set our argument pointers freq = 1000; last = ticks = SDL_GetTicks(); frametime = freq / 60; for(n=0;RomSets[n] != 0;n++) //set default dip settings { for(nn=0,j=0;j<4;j++) { if((dip = RomSets[n]->GetDip(j)) == 0) break; for(dd=0,i=0;dip[i].Name;i++) dd |= dip[i].Default; nn |= dd << (j * 8); } settings.dip_default[n] = nn; } settings.SetDefault(); if(CheckParameter("--setdefaults") == 0) //user wants to reset settings, so dont load settings.Load(); //load settings if(InitSystem(800,600,CheckParameter("--fullscreen")) != 0) { //initialize system classes (vid/inp/snd) message("error initializing system\n"); //complain, hopefully the bad component explained return(1); //return error } if(CheckParameter("--rompath")) { strcpy(settings.romdir,GetParameterData("--rompath")); } if(CheckParameter("--romset")) //if romset parameter specified { for(i=0;RomSets[i] != 0;i++) { if(strcmp(RomSets[i]->GetName(),GetParameterData("--romset")) == 0) { if(Init(RomSets[i]) != 0) //try to create machine break; printf("trying to load %s\n",RomSet->GetName()); video->SetSize(RomSet->ScreenW(),RomSet->ScreenH()); if(Machine) { if(CheckParameter("--loadstate")) //load save state { CState *s = new CState(); //create new state object if(s->Load(0,RomSet->GetName()) == 0) //try to load state { Machine->LoadState(s); //load state into machine s->Close(); //close state object } delete s; //destroy state object } } break; } } } if(CheckParameter("--stop") || //see if emulation should begin paused CheckParameter("--pause")) running = 0; //clear running flag if(CheckParameter("--run")) //see if emulation should begin running (default) running = 1; //set running flag while(quit == 0) { nolock = 0; // if(GetAsyncKeyState('Q')) //cheap fast forward hack // nolock = 1; nolock += ~settings.lockfps & 1; if(running && Machine) //if running flag is set and a machine is loaded Machine->Frame(); //execute a machine frame // else // Sleep(100); //else sleep for 0.1 seconds calcfps(); //show frames per second in title bar checkmessages(); //process messages } Kill(); //destroy machine KillSystem(); //destroy system classes settings.Save(); //save settings for(n=0;RomSets[n] != 0;n++) //free romsets delete RomSets[n]; return(0); }
int main(int argc, char *argv[]) { char train_file_name[256]; char test_file_name[256]; char output_file_name[256]; char model_file_name[256]; struct Problem *train, *test; struct Model *model; int num_correct = 0, num_empty = 0, num_multi = 0, num_incl = 0; double avg_conf = 0, avg_cred = 0; const char *error_message; ParseCommandLine(argc, argv, train_file_name, test_file_name, output_file_name, model_file_name); error_message = CheckParameter(¶m); if (error_message != NULL) { std::cerr << error_message << std::endl; exit(EXIT_FAILURE); } train = ReadProblem(train_file_name); test = ReadProblem(test_file_name); std::ofstream output_file(output_file_name); if (!output_file.is_open()) { std::cerr << "Unable to open output file: " << output_file_name << std::endl; exit(EXIT_FAILURE); } std::chrono::time_point<std::chrono::steady_clock> start_time = std::chrono::high_resolution_clock::now(); if (param.load_model == 1) { model = LoadModel(model_file_name); if (model == NULL) { exit(EXIT_FAILURE); } } else { model = TrainCP(train, ¶m); } if (param.save_model == 1) { if (SaveModel(model_file_name, model) != 0) { std::cerr << "Unable to save model file" << std::endl; } } for (int i = 0; i < test->num_ex; ++i) { double conf, cred; std::vector<int> predict_label; predict_label = PredictCP(train, model, test->x[i], conf, cred); avg_conf += conf; avg_cred += cred; output_file << std::resetiosflags(std::ios::fixed) << test->y[i] << ' ' << predict_label[0] << ' ' << std::setiosflags(std::ios::fixed) << conf << ' ' << cred; if (predict_label[0] == test->y[i]) { ++num_correct; } if (predict_label.size() == 1) { ++num_empty; output_file << " Empty\n"; } else { output_file << " set:"; for (size_t j = 1; j < predict_label.size(); ++j) { output_file << ' ' << predict_label[j]; if (predict_label[j] == test->y[i]) { ++num_incl; } } if (predict_label.size() > 2) { ++num_multi; output_file << " Multi\n"; } else { output_file << " Single\n"; } } std::vector<int>().swap(predict_label); } avg_conf /= test->num_ex; avg_cred /= test->num_ex; std::chrono::time_point<std::chrono::steady_clock> end_time = std::chrono::high_resolution_clock::now(); std::cout << "Simple Accuracy: " << 100.0*num_correct/test->num_ex << '%' << " (" << num_correct << '/' << test->num_ex << ") " << "Mean Confidence: " << std::fixed << std::setprecision(4) << 100*avg_conf << "%, " << "Mean Credibility: " << 100*avg_cred << "%\n"; std::cout << "Accuracy: " << 100.0*num_incl/test->num_ex << '%' << " (" << num_incl << '/' << test->num_ex << ") " << "Multi Prediction: " << std::fixed << std::setprecision(4) << 100.0*num_multi/test->num_ex << "%, " << "Empty Prediction: " << 100.0*num_empty/test->num_ex << "%\n"; output_file.close(); std::cout << "Time cost: " << std::chrono::duration_cast<std::chrono::milliseconds>(end_time - start_time).count()/1000.0 << " s\n"; FreeProblem(train); FreeProblem(test); FreeModel(model); FreeParam(¶m); return 0; }
int main(int argc, char *argv[]) { char data_file_name[256]; char output_file_name[256]; struct Problem *prob; int num_correct = 0, num_empty = 0, num_multi = 0, num_incl = 0; int *indices = NULL; double avg_conf = 0, avg_cred = 0; double *conf = NULL, *cred = NULL; std::vector<int> *predict_labels = NULL; const char *error_message; ParseCommandLine(argc, argv, data_file_name, output_file_name); error_message = CheckParameter(¶m); if (error_message != NULL) { std::cerr << error_message << std::endl; exit(EXIT_FAILURE); } prob = ReadProblem(data_file_name); std::ofstream output_file(output_file_name); if (!output_file.is_open()) { std::cerr << "Unable to open output file: " << output_file_name << std::endl; exit(EXIT_FAILURE); } predict_labels = new std::vector<int>[prob->num_ex]; conf = new double[prob->num_ex]; cred = new double[prob->num_ex]; indices = new int[prob->num_ex]; std::chrono::time_point<std::chrono::steady_clock> start_time = std::chrono::high_resolution_clock::now(); OnlinePredict(prob, ¶m, predict_labels, indices, conf, cred); std::chrono::time_point<std::chrono::steady_clock> end_time = std::chrono::high_resolution_clock::now(); output_file << prob->y[indices[0]] << '\n'; for (int i = 1; i < prob->num_ex; ++i) { avg_conf += conf[i]; avg_cred += cred[i]; output_file << std::resetiosflags(std::ios::fixed) << prob->y[indices[i]] << ' ' << predict_labels[i][0] << ' ' << std::setiosflags(std::ios::fixed) << conf[i] << ' ' << cred[i]; if (predict_labels[i][0] == prob->y[indices[i]]) { ++num_correct; } if (predict_labels[i].size() == 1) { ++num_empty; output_file << " Empty\n"; } else { output_file << " set:"; for (size_t j = 1; j < predict_labels[i].size(); ++j) { output_file << ' ' << predict_labels[i][j]; if (predict_labels[i][j] == prob->y[indices[i]]) { ++num_incl; } } if (predict_labels[i].size() > 2) { ++num_multi; output_file << " Multi\n"; } else { output_file << " Single\n"; } } std::vector<int>().swap(predict_labels[i]); } avg_conf /= prob->num_ex - 1; avg_cred /= prob->num_ex - 1; std::cout << "Online Accuracy: " << 100.0*num_correct/(prob->num_ex-1) << '%' << " (" << num_correct << '/' << prob->num_ex-1 << ") " << "Mean Confidence: " << std::fixed << std::setprecision(4) << 100*avg_conf << "%, " << "Mean Credibility: " << 100*avg_cred << "%\n"; std::cout << "Accuracy: " << 100.0*num_incl/(prob->num_ex-1) << '%' << " (" << num_incl << '/' << prob->num_ex-1 << ") " << "Multi Prediction: " << std::fixed << std::setprecision(4) << 100.0*num_multi/(prob->num_ex-1) << "%, " << "Empty Prediction: " << 100.0*num_empty/(prob->num_ex-1) << "%\n"; output_file.close(); std::cout << "Time cost: " << std::chrono::duration_cast<std::chrono::milliseconds>(end_time - start_time).count()/1000.0 << " s\n"; FreeProblem(prob); FreeParam(¶m); delete[] predict_labels; delete[] conf; delete[] cred; delete[] indices; return 0; }
CmCError CheckSyntax(char *filename, CmCParser *synParser) { //***************************************** //parse the file //***************************************** int error; synParser->SetDelimiters("=(){},;'"); synParser->StoreDelimiters(true); error = synParser->Parse(filename); if(error) return (CmCError((CmCToken *) NULL, SYN_INVALID_FILE)); //***************************************** //check syntax //***************************************** int curveId; int parameterId; int commandTypeId, commandId; CmCToken *token, *(tokenSet)[MAX_TOKEN_NUM]; while(token = synParser->GetToken()) { //identify the command... commandId = Command(token->token_); commandTypeId = CommandType(commandId); //based on the command, identify the number of tokens //associated with it and obtain those tokens error = GetTokenSet(commandId, tokenSet, synParser); //if the specified number of tokens does not exist //then return an error if(error == SYN_ERROR) return CmCError((CmCToken *) NULL, error); //if the specified tokens exist, then check them for //their validity switch(commandTypeId) { case CMD_IO: switch(commandId) { case CMD_SAVE: //check structure if(strcmp(tokenSet[0]->token_, "(")) return CmCError(tokenSet[0], SYN_MISSING_LEFT_PARENTHESIS); if(strcmp(tokenSet[1]->token_, "'")) return CmCError(tokenSet[1],SYN_MISSING_QUOTATION); if(strcmp(tokenSet[3]->token_, "'")) return CmCError(tokenSet[3],SYN_MISSING_QUOTATION); if(strcmp(tokenSet[4]->token_, ",")) return CmCError(tokenSet[4],SYN_MISSING_COMMA); if(strcmp(tokenSet[6]->token_, ",")) return CmCError(tokenSet[6],SYN_MISSING_COMMA); if(strcmp(tokenSet[8]->token_, ")")) return CmCError(tokenSet[8],SYN_MISSING_RIGHT_PARENTHESIS); if(strcmp(tokenSet[9]->token_, ";")) return CmCError(tokenSet[9],SYN_MISSING_SEMICOLON); //check constants if(!validFileType(tokenSet[5]->token_)) return CmCError(tokenSet[5],SYN_INVALID_FILETYPE); if(!validOutputType(tokenSet[7]->token_))return CmCError(tokenSet[7],SYN_INVALID_OUTPUTTYPE); if(checkSupported(FileType(tokenSet[5]->token_))) return CmCError(tokenSet[5],SYN_UNSUPPORTED_FILETYPE); break; case CMD_LOAD: //check structure if(strcmp(tokenSet[0]->token_, "(")) return CmCError(tokenSet[0],SYN_MISSING_LEFT_PARENTHESIS); if(strcmp(tokenSet[1]->token_, "'")) return CmCError(tokenSet[1],SYN_MISSING_QUOTATION); if(strcmp(tokenSet[3]->token_, "'")) return CmCError(tokenSet[3],SYN_MISSING_QUOTATION); if(strcmp(tokenSet[4]->token_, ",")) return CmCError(tokenSet[4],SYN_MISSING_COMMA); if(strcmp(tokenSet[6]->token_, ")")) return CmCError(tokenSet[6],SYN_MISSING_RIGHT_PARENTHESIS); if(strcmp(tokenSet[7]->token_, ";")) return CmCError(tokenSet[7],SYN_MISSING_SEMICOLON); //check constants if(!validInputType(tokenSet[5]->token_)) return CmCError(tokenSet[5],SYN_INVALID_INPUTTYPE); break; case CMD_USE_RESULT: if(strcmp(tokenSet[0]->token_, "(")) return CmCError(tokenSet[0], SYN_MISSING_LEFT_PARENTHESIS); if(strcmp(tokenSet[2]->token_, ")")) return CmCError(tokenSet[2], SYN_MISSING_RIGHT_PARENTHESIS); if(strcmp(tokenSet[3]->token_, ";")) return CmCError(tokenSet[3], SYN_MISSING_SEMICOLON); if((OutputType(tokenSet[1]->token_) != OUTPUT_SEGM_IMAGE) && (OutputType(tokenSet[1]->token_) != OUTPUT_FILT_IMAGE)) { if(OutputType(tokenSet[1]->token_) != OUTPUT_UNKNOWN) { return CmCError(tokenSet[1], SYN_ASSIGN_INVALID_ARG); } else { return CmCError(tokenSet[1], SYN_INVALID_OUTPUTTYPE); } } break; } break; case CMD_EXECUTION: if(tokenSet[0]->token_[0] != ';') return CmCError(tokenSet[0],SYN_MISSING_SEMICOLON); break; case CMD_FLAGS: if(!validFlag(tokenSet[0]->token_)) return CmCError(tokenSet[0],SYN_INVALID_FLAG); if(tokenSet[1]->token_[0] != ';') return CmCError(tokenSet[1],SYN_MISSING_SEMICOLON); break; //unknown command default: break; } //if its not a command, then maybe its a parameter if(commandTypeId == UNKNOWN_COMMAND) { //get the parameter type parameterId = Parameter(token->token_); if(parameterId != UNKNOWN_PARAMETER) { //retreive tokens expected given a parameter error = GetParamTokenSet(tokenSet, synParser); if(error == SYN_ERROR) return CmCError(token, SYN_ERROR); //check those tokens for validity if(strcmp(tokenSet[0]->token_, "=")) return CmCError(tokenSet[0],SYN_MISSING_EQUALS); if(strcmp(tokenSet[2]->token_, ";")) return CmCError(tokenSet[2],SYN_MISSING_SEMICOLON); //make sure parameter is of the right type error = CheckParameter(parameterId, tokenSet[1]->token_); if(error) return CmCError(token, error); //if its an unknown parameter then maybe its a curve list } else { //get custom curve curveId = CustomCurve(token->token_); //if its not a custom curve list then flag an error if(curveId == UNKNOWN_CURVE) return CmCError(token,SYN_INVALID_PARAMCMD); //check for equals token = synParser->GetToken(); if(token->token_[0] != '=') return CmCError(token,SYN_MISSING_EQUALS); //if its a curve list, then check that a proper point list //is provided error = CheckList(synParser, &token); if(error) return CmCError(token, error); //check for semicolon token = synParser->GetToken(); if(token->token_[0] != ';') return CmCError(token,SYN_MISSING_SEMICOLON); } } //command/parameter identified and verified for //its validity, next command/parameter } //reset parser synParser->StartOver(); //file is syntaxically correct return CmCError((CmCToken *) NULL, NO_ERRORS); }
void ReadSetup (void) { char filename[ 128 ]; GetPathFromEnvironment( filename, ApogeePath, CONFIG ); if (access (filename, 0) == 0) { LoadScriptFile (filename); // Skip MODEMNAME GetToken (true); // Skip MODEMNAME string GetTokenEOL (false); // Get Initstring GetToken (true); CheckParameter ("MODEMINITSTR", filename); GetTokenEOL (false); if (name[0] != '~') strcpy (&initstring[0], &name[0]); else if (usemodem==true) Error("No INITSTRING defined in SETUP.ROT please run SETUP.EXE\n"); else strcpy (&initstring[0], "ATZ\0"); // Get Hangupstring GetToken (true); CheckParameter ("MODEMHANGUP", filename); GetTokenEOL (false); if (name[0] != '~') strcpy (&hangupstring[0], &name[0]); else if (usemodem==true) Error("No HANGUPSTRING defined in SETUP.ROT please run SETUP.EXE\n"); else strcpy (&hangupstring[0], "ATZ\0"); GetToken (true); CheckParameter ("BAUDRATE", filename); GetToken (false); baudrate = atol (token); GetToken (true); CheckParameter ("COMPORT", filename); GetToken (false); if (strcmpi (token, "~")) comport = atoi (token); else comport = -1; GetToken (true); CheckParameter ("IRQ", filename); GetToken (false); if (strcmpi (token, "~")) irq = atoi (token); else irq = -1; GetToken (true); CheckParameter ("UART", filename); GetToken (false); if (strcmpi (token, "~")) sscanf(token,"%x", &uart); else uart = -1; // Get Pulse parameter GetToken (true); CheckParameter ("PULSE", filename); GetToken (false); if (!(strcmpi (token, "YES"))) pulse=true; else pulse=false; free (scriptbuffer); } else { Error ("Cannot find %s Please run SETUP.EXE\n",filename); } GetPathFromEnvironment( filename, ApogeePath, ROTT ); if (access (filename, 0) == 0) { LoadScriptFile (filename); GetToken (true); CheckParameter ("PHONENUMBER", filename); GetTokenEOL (false); if (name[0] != '~') strcpy (&dialstring[0], &name[0]); else dialstring[0]=0; free (scriptbuffer); } else { Error ("Cannot find %s Please run SETUP.EXE\n",filename); } }
/*------------------------------------------------------------------------------ H264Init Function initializes the Encoder and create new encoder instance. Input pEncCfg Encoder configuration. instAddr Pointer to instance will be stored in this address Return H264ENC_OK H264ENC_MEMORY_ERROR H264ENC_EWL_ERROR H264ENC_EWL_MEMORY_ERROR H264ENC_INVALID_ARGUMENT ------------------------------------------------------------------------------*/ H264EncRet H264Init(const H264EncConfig * pEncCfg, h264Instance_s * pinst) { h264Instance_s *inst = pinst; // const void *ewl = NULL; H264EncRet ret = H264ENC_OK; EWLInitParam_t param; ASSERT(pEncCfg); // ASSERT(instAddr); // *instAddr = NULL; param.clientType = EWL_CLIENT_TYPE_H264_ENC; /* Init EWL */ /*if((ewl = EWLInit(¶m)) == NULL) return H264ENC_EWL_ERROR;*/ /* Encoder instance */ /*inst = (h264Instance_s *) malloc(sizeof(h264Instance_s)); if(inst == NULL) { ret = H264ENC_MEMORY_ERROR; goto err; }*/ /* Default values */ H264SeqParameterSetInit(&inst->seqParameterSet); H264PicParameterSetInit(&inst->picParameterSet); H264SliceInit(&inst->slice); /* Set parameters depending on user config */ if(SetParameter(inst, pEncCfg) != ENCHW_OK) { ret = H264ENC_INVALID_ARGUMENT; goto err; } /* Check and init the rest of parameters */ if(CheckParameter(inst) != ENCHW_OK) { ret = H264ENC_INVALID_ARGUMENT; goto err; } if(inst->asic.regs.vpuid == 0x30) { if(H264InitRc_new(&inst->rateControl) != ENCHW_OK) { return H264ENC_INVALID_ARGUMENT; } } else { if(H264InitRc(&inst->rateControl) != ENCHW_OK) { return H264ENC_INVALID_ARGUMENT; } } /* Initialize ASIC */ inst->asic.ewl = NULL;//ewl; (void) EncAsicControllerInit(&inst->asic); /* Allocate internal SW/HW shared memories */ if(EncAsicMemAlloc_V2(&inst->asic, (u32) inst->preProcess.lumWidth, (u32) inst->preProcess.lumHeight, ASIC_H264) != ENCHW_OK) { ret = H264ENC_EWL_MEMORY_ERROR; goto err; } // *instAddr = inst; /* init VUI */ { const h264VirtualBuffer_s *vb = &inst->rateControl.virtualBuffer; H264SpsSetVuiTimigInfo(&inst->seqParameterSet, vb->timeScale, vb->unitsInTic); } if(inst->seqParameterSet.levelIdc >= 31) inst->asic.regs.h264Inter4x4Disabled = 1; else inst->asic.regs.h264Inter4x4Disabled = 0; /* When resolution larger than 720p = 3600 macroblocks * there is not enough time to do 1/4 pixel ME */ if(inst->mbPerFrame > 3600) inst->asic.regs.disableQuarterPixelMv = 1; else inst->asic.regs.disableQuarterPixelMv = 0; inst->asic.regs.skipPenalty = 1; return ret; err: /*if(inst != NULL) free(inst);*/ /*if(ewl != NULL) (void) EWLRelease(ewl);*/ return ret; }
/*------------------------------------------------------------------------------ EncInit Function initializes the Encoder and create new encoder instance. Input pEncCfg Encoder configuration. instAddr Pointer to instance will be stored in this address Return ENC_OK ENC_MEMORY_ERROR ENC_EWL_ERROR ENC_EWL_MEMORY_ERROR ENC_INVALID_ARGUMENT ------------------------------------------------------------------------------*/ MP4EncRet EncInit(const MP4EncCfg * pEncCfg, instance_s ** instAddr) { instance_s *inst = NULL; const void *ewl = NULL; u32 mbTotal, asic_mode; MP4EncRet ret = ENC_OK; EWLInitParam_t param; ASSERT(pEncCfg); ASSERT(instAddr); *instAddr = NULL; param.clientType = EWL_CLIENT_TYPE_MPEG4_ENC; /* Init EWL */ if((ewl = EWLInit(¶m)) == NULL) return ENC_EWL_ERROR; /* Encoder instance */ inst = (instance_s *) EWLcalloc(1, sizeof(instance_s)); if(inst == NULL) { ret = ENC_MEMORY_ERROR; goto err; } inst->asic.ewl = ewl; EncVosInit(&inst->visualObjectSequence); EncVisObInit(&inst->visualObject); EncVolInit(&inst->videoObjectLayer); EncVopInit(&inst->videoObjectPlane); EncSvhInit(&inst->shortVideoHeader); EncGoVopInit(&inst->groupOfVideoObjectPlane); if(EncAsicControllerInit(&inst->asic) != ENCHW_OK) { ret = ENC_INVALID_ARGUMENT; goto err; } /* Enable/disable stream headers depending on stream type */ if(SetHdr(inst, pEncCfg->strmType) != ENCHW_OK) { ret = ENC_INVALID_ARGUMENT; goto err; } /* Set parameters depending on user config */ if(SetParameter(inst, pEncCfg) != ENCHW_OK) { ret = ENC_INVALID_ARGUMENT; goto err; } /* Check parameters */ if(CheckParameter(inst) != ENCHW_OK) { ret = ENC_INVALID_ARGUMENT; goto err; } asic_mode = (inst->shortVideoHeader.header == ENCHW_YES) ? ASIC_H263 : ASIC_MPEG4; inst->asic.regs.codingType = asic_mode; #ifdef MPEG4_HW_VLC_MODE_ENABLED if(pEncCfg->strmType == MPEG4_PLAIN_STRM || pEncCfg->strmType == MPEG4_SVH_STRM || pEncCfg->strmType == H263_STRM) { /* Allocate internal SW/HW shared memories */ i32 tmp = EncAsicMemAlloc_V2(&inst->asic, inst->preProcess.lumWidth, inst->preProcess.lumHeight, asic_mode); if(tmp != ENCHW_OK) { ret = ENC_EWL_MEMORY_ERROR; goto err; } inst->asic.regs.rlcOutMode = 0; /* use VLC output from HW */ } else #endif { mb_s *mb = &inst->macroblock; /* Allocate SW memories */ /* Macroblock header and macroblock coding stuff */ if(EncMbAlloc(mb) != ENCHW_OK) { ret = ENC_EWL_MEMORY_ERROR; goto err; } mbTotal = (u32) ((mb->width / 16) * (mb->height / 16)); /* Allocate internal SW/HW shared memories */ if(EncAsicMemAlloc(&inst->asic, inst->preProcess.lumWidth, inst->preProcess.lumHeight, ((ENC7280_BUFFER_SIZE_MB * mbTotal) / ENC7280_BUFFER_AMOUNT)) != ENCHW_OK) { EncMbFree(mb); ret = ENC_EWL_MEMORY_ERROR; goto err; } inst->asic.regs.rlcOutMode = 1; /* use RLC output from HW */ } *instAddr = inst; /* return the instance */ return ret; err: if(inst != NULL) EWLfree(inst); if(ewl != NULL) (void) EWLRelease(ewl); return ret; }