void CFunction::load(CReadConfig & configBuffer, CReadConfig::Mode mode) { // cleanup(); C_INT32 Type; mode = CReadConfig::SEARCH; configBuffer.getVariable("User-defined", "C_INT32", &Type, mode); switch (Type) { case 1: setType(UserDefined); break; default: fatalError(); } configBuffer.getVariable("Reversible", "C_INT32", &mReversible); mode = CReadConfig::SEARCH; std::string tmp; configBuffer.getVariable("FunctionName", "string", &tmp, mode); setObjectName(tmp); configBuffer.getVariable("Description", "string", &tmp); setInfix(tmp); // For older file version the parameters have to be build from information // dependend on the function type. Luckilly, only user defined functions are // the only ones occuring in those files. }
C_INT32 CMetabOld::load(CReadConfig &configbuffer) { C_INT32 Fail = 0; std::string tmp; Fail = configbuffer.getVariable("Metabolite", "string", (void *) & tmp, CReadConfig::SEARCH); if (Fail) return Fail; setObjectName(tmp); Fail = configbuffer.getVariable("Concentration", "C_FLOAT64", (void *) & mIConc); if (Fail) return Fail; Fail = configbuffer.getVariable("Compartment", "C_INT32", (void *) & mCompartment); if (Fail) return Fail; C_INT32 Status; Fail = configbuffer.getVariable("Type", "C_INT32", (void *) & Status); if (Status == 0) mStatus = CModelEntity::FIXED; else mStatus = CModelEntity::REACTIONS; // sanity check if ((mStatus < 0) || (mStatus > 7)) { CCopasiMessage(CCopasiMessage::WARNING, "The file specifies a non-existing type " "for '%s'.\nReset to internal species.", getObjectName().c_str()); mStatus = CModelEntity::REACTIONS; } // sanity check if ((mStatus != METAB_MOIETY) && (mIConc < 0.0)) { CCopasiMessage(CCopasiMessage::WARNING, "The file specifies a negative concentration " "for '%s'.\nReset to default.", getObjectName().c_str()); mIConc = 1.0; } return Fail; }
/** * Load a steadystate problem * @param "CReadConfig &" configBuffer */ void CSteadyStateProblem::load(CReadConfig & configBuffer, CReadConfig::Mode C_UNUSED(mode)) { if (configBuffer.getVersion() < "4.0") { configBuffer.getVariable("RepStabilityAnalysis", "bool" , &getValue< bool >("StabilityAnalysisRequested"), CReadConfig::LOOP); setValue("JacobianRequested", getValue< bool >("StabilityAnalysisRequested")); } }
/** * Load a lna problem * @param "CReadConfig &" configBuffer */ void CLNAProblem::load(CReadConfig & configBuffer, CReadConfig::Mode C_UNUSED(mode)) { if (configBuffer.getVersion() < "4.0") { bool SteadyStateRequested; configBuffer.getVariable("RepxSteadyStateAnalysis", "bool", &SteadyStateRequested, CReadConfig::LOOP); setSteadyStateRequested(SteadyStateRequested); } }
C_INT32 CMetab::load(CReadConfig &configbuffer) { C_INT32 Fail = 0; std::string tmp; Fail = configbuffer.getVariable("Metabolite", "string", (void *) & tmp, CReadConfig::SEARCH); if (Fail) return Fail; setObjectName(tmp); Fail = configbuffer.getVariable("InitialConcentration", "C_FLOAT64", (void *) & mIConc); setInitialConcentration(mIConc); setConcentration(mIConc); Status GepasiStatus; Fail = configbuffer.getVariable("Type", "C_INT16", (void *) & GepasiStatus); if (Fail) return Fail; setStatus(GepasiStatus); // sanity check if ((GepasiStatus < 0) || (GepasiStatus > 7)) { CCopasiMessage(CCopasiMessage::WARNING, "The file specifies a non-existing type " "for '%s'.\nReset to internal species.", getObjectName().c_str()); setStatus(REACTIONS); } // sanity check if ((GepasiStatus != METAB_MOIETY) && (mIConc < 0.0)) { CCopasiMessage(CCopasiMessage::WARNING, "The file specifies a negative concentration " "for '%s'.\nReset to default.", getObjectName().c_str()); mIConc = 1.0; } return Fail; }
/** * Load a trajectory problem * @param "CReadConfig &" configBuffer */ void CTrajectoryProblem::load(CReadConfig & configBuffer, CReadConfig::Mode C_UNUSED(mode)) { if (configBuffer.getVersion() < "4.0") { configBuffer.getVariable("EndTime", "C_FLOAT64", mpDuration, CReadConfig::LOOP); configBuffer.getVariable("Points", "C_INT32", mpStepNumber); mStepNumberSetLast = true; sync(); } }
/** * Load a trajectory problem * @param "CReadConfig &" configBuffer */ void CTrajectoryProblem::load(CReadConfig & configBuffer, CReadConfig::Mode C_UNUSED(mode)) { if (configBuffer.getVersion() < "4.0") { CCopasiDataModel* pDataModel = getObjectDataModel(); assert(pDataModel != NULL); mpModel = pDataModel->getModel(); configBuffer.getVariable("EndTime", "C_FLOAT64", mpDuration, CReadConfig::LOOP); configBuffer.getVariable("Points", "C_INT32", mpStepNumber); mStepNumberSetLast = true; sync(); } }
void CSteadyStateTask::load(CReadConfig & configBuffer) { configBuffer.getVariable("SteadyState", "bool", &mScheduled, CReadConfig::LOOP); ((CSteadyStateProblem *) mpProblem)->load(configBuffer); ((CSteadyStateMethod *) mpMethod)->load(configBuffer); }
void CMCATask::load(CReadConfig & configBuffer) { configBuffer.getVariable("MCA", "bool", &mScheduled, CReadConfig::LOOP); ((CMCAProblem *) mpProblem)->load(configBuffer); ((CMCAMethod *) mpMethod)->load(configBuffer); }
C_INT32 CFunctionDB::load(CReadConfig &configbuffer) { CFunction Function; CFunction * pFunction = NULL; C_INT32 Size = 0; C_INT32 Fail = 0; configbuffer.getVariable("TotalUDKinetics", "C_INT32", &Size, CReadConfig::LOOP); for (C_INT32 i = 0; i < Size; i++) { Function.load(configbuffer); switch (Function.getType()) { case CEvaluationTree::Function: pFunction = new CFunction(Function); break; case CEvaluationTree::MassAction: pFunction = new CMassAction(Function); break; case CEvaluationTree::PreDefined: case CEvaluationTree::UserDefined: pFunction = new CKinFunction(Function, &configbuffer); break; default: fatalError(); break; } pFunction->compile(); if (!mLoadedFunctions.add(pFunction, true)) { pdelete(pFunction); // We ignore: // CCopasiVector (2): Object '%s' allready exists. if ((MCCopasiVector + 2) != CCopasiMessage::peekLastMessage().getNumber()) return Fail = 1; // Remove the ignored meesage. CCopasiMessage::getLastMessage(); } } return Fail; }
void CTrajectoryTask::load(CReadConfig & configBuffer) { configBuffer.getVariable("Dynamics", "bool", &mScheduled, CReadConfig::LOOP); pdelete(mpProblem); mpProblem = new CTrajectoryProblem(this); ((CTrajectoryProblem *) mpProblem)->load(configBuffer); pdelete(mpMethod); mpMethod = CTrajectoryMethod::createMethod(); this->add(mpMethod, true); CCopasiParameter * pParameter = mpMethod->getParameter("Integrate Reduced Model"); if (pParameter != NULL) mUpdateMoieties = *pParameter->getValue().pBOOL; ((CTrajectoryMethod *)mpMethod)->setProblem((CTrajectoryProblem *) mpProblem); }
int32_t main (int32_t iArgC, char* pArgV[]) { ISVCDecoder* pDecoder = NULL; SDecodingParam sDecParam = {0}; string strInputFile (""), strOutputFile (""), strOptionFile (""); sDecParam.sVideoProperty.size = sizeof (sDecParam.sVideoProperty); if (iArgC < 2) { printf ("usage 1: h264dec.exe welsdec.cfg\n"); printf ("usage 2: h264dec.exe welsdec.264 out.yuv\n"); printf ("usage 3: h264dec.exe welsdec.264\n"); return 1; } else if (iArgC == 2) { if (strstr (pArgV[1], ".cfg")) { // read config file //confirmed_safe_unsafe_usage CReadConfig cReadCfg (pArgV[1]); string strTag[4]; string strReconFile (""); if (!cReadCfg.ExistFile()) { printf ("Specified file: %s not exist, maybe invalid path or parameter settting.\n", cReadCfg.GetFileName().c_str()); return 1; } while (!cReadCfg.EndOfFile()) { long nRd = cReadCfg.ReadLine (&strTag[0]); if (nRd > 0) { if (strTag[0].compare ("InputFile") == 0) { strInputFile = strTag[1]; } else if (strTag[0].compare ("OutputFile") == 0) { strOutputFile = strTag[1]; } else if (strTag[0].compare ("RestructionFile") == 0) { strReconFile = strTag[1]; int32_t iLen = strReconFile.length(); sDecParam.pFileNameRestructed = new char[iLen + 1]; if (sDecParam.pFileNameRestructed != NULL) { sDecParam.pFileNameRestructed[iLen] = 0; } strncpy (sDecParam.pFileNameRestructed, strReconFile.c_str(), iLen); //confirmed_safe_unsafe_usage } else if (strTag[0].compare ("TargetDQID") == 0) { sDecParam.uiTargetDqLayer = (uint8_t)atol (strTag[1].c_str()); } else if (strTag[0].compare ("OutColorFormat") == 0) { sDecParam.iOutputColorFormat = atol (strTag[1].c_str()); } else if (strTag[0].compare ("ErrorConcealmentFlag") == 0) { sDecParam.uiEcActiveFlag = (uint8_t)atol (strTag[1].c_str()); } else if (strTag[0].compare ("CPULoad") == 0) { sDecParam.uiCpuLoad = (uint32_t)atol (strTag[1].c_str()); } else if (strTag[0].compare ("VideoBitstreamType") == 0) { sDecParam.sVideoProperty.eVideoBsType = (VIDEO_BITSTREAM_TYPE)atol (strTag[1].c_str()); } } } if (strOutputFile.empty()) { printf ("No output file specified in configuration file.\n"); return 1; } } else if (strstr (pArgV[1], ".264")) { // no output dump yuv file, just try to render the decoded pictures //confirmed_safe_unsafe_usage strInputFile = pArgV[1]; sDecParam.iOutputColorFormat = videoFormatI420; sDecParam.uiTargetDqLayer = (uint8_t) - 1; sDecParam.uiEcActiveFlag = 1; sDecParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT; } } else { //iArgC > 2 strInputFile = pArgV[1]; strOutputFile = pArgV[2]; sDecParam.iOutputColorFormat = videoFormatI420; sDecParam.uiTargetDqLayer = (uint8_t) - 1; sDecParam.uiEcActiveFlag = 1; sDecParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT; if (iArgC > 3) { for (int i = 3; i < iArgC; i++) { char* cmd = pArgV[i]; if (!strcmp (cmd, "-options")) { if (i + 1 < iArgC) strOptionFile = pArgV[i++]; else { printf ("options file not specified.\n"); return 1; } } else if (!strcmp (cmd, "-trace")) { if (i + 1 < iArgC) WelsStderrSetTraceLevel (atoi (pArgV[i++])); else { printf ("trace level not specified.\n"); return 1; } } } } if (strOutputFile.empty()) { printf ("No output file specified in configuration file.\n"); return 1; } } if (strInputFile.empty()) { printf ("No input file specified in configuration file.\n"); return 1; } #if defined(_MSC_VER) HMODULE hModule = LoadLibraryA (".\\welsdec.dll"); PCreateDecoderFunc pCreateDecoderFunc = NULL; PDestroyDecoderFunc pDestroyDecoderFunc = NULL; pCreateDecoderFunc = (PCreateDecoderFunc)::GetProcAddress (hModule, "CreateDecoder"); pDestroyDecoderFunc = (PDestroyDecoderFunc)::GetProcAddress (hModule, "DestroyDecoder"); if ((hModule != NULL) && (pCreateDecoderFunc != NULL) && (pDestroyDecoderFunc != NULL)) { printf ("load library sw function successfully\n"); if (pCreateDecoderFunc (&pDecoder) || (NULL == pDecoder)) { printf ("Create Decoder failed.\n"); return 1; } } else { printf ("load library sw function failed\n"); return 1; } #else if (CreateDecoder (&pDecoder) || (NULL == pDecoder)) { printf ("Create Decoder failed.\n"); return 1; } #endif if (pDecoder->Initialize (&sDecParam, INIT_TYPE_PARAMETER_BASED)) { printf ("Decoder initialization failed.\n"); return 1; } int32_t iWidth = 0; int32_t iHeight = 0; H264DecodeInstance (pDecoder, strInputFile.c_str(), strOutputFile.c_str(), iWidth, iHeight, (!strOptionFile.empty() ? (void_t*) (const_cast<char*> (strOptionFile.c_str())) : NULL)); if (sDecParam.pFileNameRestructed != NULL) { delete []sDecParam.pFileNameRestructed; sDecParam.pFileNameRestructed = NULL; } if (pDecoder) { pDecoder->Uninitialize(); #if defined(_MSC_VER) pDestroyDecoderFunc (pDecoder); #else DestroyDecoder (pDecoder); #endif } return 0; }
int32_t DecMain (int32_t iArgC, char* pArgV[]) { #else int32_t main (int32_t iArgC, char* pArgV[]) { #endif ISVCDecoder* pDecoder = NULL; SDecodingParam sDecParam = {0}; string strInputFile (""), strOutputFile (""), strOptionFile (""); int iLevelSetting = (int) WELS_LOG_WARNING; sDecParam.sVideoProperty.size = sizeof (sDecParam.sVideoProperty); if (iArgC < 2) { printf ("usage 1: h264dec.exe welsdec.cfg\n"); printf ("usage 2: h264dec.exe welsdec.264 out.yuv\n"); printf ("usage 3: h264dec.exe welsdec.264\n"); return 1; } else if (iArgC == 2) { if (strstr (pArgV[1], ".cfg")) { // read config file //confirmed_safe_unsafe_usage CReadConfig cReadCfg (pArgV[1]); string strTag[4]; string strReconFile (""); if (!cReadCfg.ExistFile()) { printf ("Specified file: %s not exist, maybe invalid path or parameter settting.\n", cReadCfg.GetFileName().c_str()); return 1; } while (!cReadCfg.EndOfFile()) { long nRd = cReadCfg.ReadLine (&strTag[0]); if (nRd > 0) { if (strTag[0].compare ("InputFile") == 0) { strInputFile = strTag[1]; } else if (strTag[0].compare ("OutputFile") == 0) { strOutputFile = strTag[1]; } else if (strTag[0].compare ("RestructionFile") == 0) { strReconFile = strTag[1]; int32_t iLen = (int32_t)strReconFile.length(); sDecParam.pFileNameRestructed = new char[iLen + 1]; if (sDecParam.pFileNameRestructed != NULL) { sDecParam.pFileNameRestructed[iLen] = 0; } strncpy (sDecParam.pFileNameRestructed, strReconFile.c_str(), iLen); //confirmed_safe_unsafe_usage } else if (strTag[0].compare ("TargetDQID") == 0) { sDecParam.uiTargetDqLayer = (uint8_t)atol (strTag[1].c_str()); } else if (strTag[0].compare ("OutColorFormat") == 0) { sDecParam.eOutputColorFormat = (EVideoFormatType) atoi (strTag[1].c_str()); } else if (strTag[0].compare ("ErrorConcealmentIdc") == 0) { sDecParam.eEcActiveIdc = (ERROR_CON_IDC)atol (strTag[1].c_str()); } else if (strTag[0].compare ("CPULoad") == 0) { sDecParam.uiCpuLoad = (uint32_t)atol (strTag[1].c_str()); } else if (strTag[0].compare ("VideoBitstreamType") == 0) { sDecParam.sVideoProperty.eVideoBsType = (VIDEO_BITSTREAM_TYPE)atol (strTag[1].c_str()); } } } if (strOutputFile.empty()) { printf ("No output file specified in configuration file.\n"); return 1; } } else if (strstr (pArgV[1], ".264")) { // no output dump yuv file, just try to render the decoded pictures //confirmed_safe_unsafe_usage strInputFile = pArgV[1]; sDecParam.eOutputColorFormat = videoFormatI420; sDecParam.uiTargetDqLayer = (uint8_t) - 1; sDecParam.eEcActiveIdc = ERROR_CON_SLICE_COPY; sDecParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT; } } else { //iArgC > 2 strInputFile = pArgV[1]; strOutputFile = pArgV[2]; sDecParam.eOutputColorFormat = videoFormatI420; sDecParam.uiTargetDqLayer = (uint8_t) - 1; sDecParam.eEcActiveIdc = ERROR_CON_SLICE_COPY; sDecParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT; if (iArgC > 3) { for (int i = 3; i < iArgC; i++) { char* cmd = pArgV[i]; if (!strcmp (cmd, "-options")) { if (i + 1 < iArgC) strOptionFile = pArgV[++i]; else { printf ("options file not specified.\n"); return 1; } } else if (!strcmp (cmd, "-trace")) { if (i + 1 < iArgC) iLevelSetting = atoi (pArgV[++i]); else { printf ("trace level not specified.\n"); return 1; } } } } if (strOutputFile.empty()) { printf ("No output file specified in configuration file.\n"); return 1; } } if (strInputFile.empty()) { printf ("No input file specified in configuration file.\n"); return 1; } if (WelsCreateDecoder (&pDecoder) || (NULL == pDecoder)) { printf ("Create Decoder failed.\n"); return 1; } if (iLevelSetting >= 0) { pDecoder->SetOption (DECODER_OPTION_TRACE_LEVEL, &iLevelSetting); } if (pDecoder->Initialize (&sDecParam)) { printf ("Decoder initialization failed.\n"); return 1; } int32_t iWidth = 0; int32_t iHeight = 0; H264DecodeInstance (pDecoder, strInputFile.c_str(), !strOutputFile.empty() ? strOutputFile.c_str() : NULL, iWidth, iHeight, (!strOptionFile.empty() ? strOptionFile.c_str() : NULL)); if (sDecParam.pFileNameRestructed != NULL) { delete []sDecParam.pFileNameRestructed; sDecParam.pFileNameRestructed = NULL; } if (pDecoder) { pDecoder->Uninitialize(); WelsDestroyDecoder (pDecoder); } return 0; }