Changeset 1386 in 3DVCSoftware for trunk/source/Lib/TAppCommon
- Timestamp:
- 13 Nov 2015, 16:29:39 (9 years ago)
- Location:
- trunk/source/Lib/TAppCommon
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/Lib/TAppCommon/TAppComCamPara.cpp
r1313 r1386 49 49 #include <functional> 50 50 #include <string> 51 #if NH_3D 51 #if NH_3D_VSO 52 52 53 53 … … 115 115 116 116 Void 117 TAppComCamPara::convertNumberString( Char* pchViewNumberString, std::vector<Int>& raiViewNumbers, Double dViewNumPrec )117 TAppComCamPara::convertNumberString( TChar* pchViewNumberString, std::vector<Int>& raiViewNumbers, Double dViewNumPrec ) 118 118 { 119 119 Bool bStringIsRange = false; … … 131 131 } 132 132 133 Char* pcNextStart = pchViewNumberString;134 Char* pcEnd = pcNextStart + iIdx;135 Char* pcOldStart = 0;133 TChar* pcNextStart = pchViewNumberString; 134 TChar* pcEnd = pcNextStart + iIdx; 135 TChar* pcOldStart = 0; 136 136 137 137 while( pcNextStart < pcEnd ) … … 192 192 193 193 Void 194 TAppComCamPara::xReadCameraParameterFile( Char* pchCfgFileName ) 195 { 194 TAppComCamPara::xReadCameraParameterFile( TChar* pchCfgFileName ) 195 { 196 assert( pchCfgFileName != NULL ); 197 196 198 std::ifstream cCfgStream( pchCfgFileName, std::ifstream::in ); 197 199 if( !cCfgStream ) … … 220 222 } 221 223 222 Char* pcNextStart = (Char*) cLine.data();223 Char* pcEnd = pcNextStart + cLine.length();224 TChar* pcNextStart = (TChar*) cLine.data(); 225 TChar* pcEnd = pcNextStart + cLine.length(); 224 226 225 227 std::vector<Double> caNewLine; 226 228 caNewLine.clear(); 227 229 228 Char* pcOldStart = 0;230 TChar* pcOldStart = 0; 229 231 while( pcNextStart < pcEnd ) 230 232 { … … 880 882 881 883 // maximum deviation 882 #if H_3D_REN_MAX_DEV_OUT884 #if NH_3D_REN_MAX_DEV_OUT 883 885 m_dMaxShiftDeviation = std::max( m_dMaxShiftDeviation, fabs( Double( (Int) iShiftLuma ) - dShiftLuma ) / Double( 1 << m_iLog2Precision ) ); 884 886 #endif … … 981 983 m_bCamParsCodedPrecSet = false; 982 984 983 #if H_3D_REN_MAX_DEV_OUT985 #if NH_3D_REN_MAX_DEV_OUT 984 986 m_dMaxShiftDeviation = -1; 985 987 #endif … … 1094 1096 } 1095 1097 1096 Void TAppComCamPara::xSetupBaseViews( Char* pchBaseViewNumbers, UInt uiNumBaseViews )1098 Void TAppComCamPara::xSetupBaseViews( TChar* pchBaseViewNumbers, UInt uiNumBaseViews ) 1097 1099 { 1098 1100 // init list … … 1142 1144 UInt uiStartFrameId, 1143 1145 UInt uiNumFrames, 1144 Char*pchCfgFileName,1145 Char*pchBaseViewNumbers,1146 Char*pchSynthViewNumbers,1146 TChar* pchCfgFileName, 1147 TChar* pchBaseViewNumbers, 1148 TChar* pchSynthViewNumbers, 1147 1149 std::vector<Int>* paiSynthViewNumbers, 1148 1150 Int iLog2Precision ) -
trunk/source/Lib/TAppCommon/TAppComCamPara.h
r1313 r1386 67 67 Bool m_bCamParsCodedPrecSet; ///< Coded Cam Para precision set for current frame; 68 68 69 #if H_3D_REN_MAX_DEV_OUT69 #if NH_3D_REN_MAX_DEV_OUT 70 70 Double m_dMaxShiftDeviation; ///< Maximum deviation of shifts with integer precision compare to double precision 71 71 #endif … … 113 113 114 114 // functions for reading, initialization, sorting, getting data, etc. 115 Void xReadCameraParameterFile ( Char* pchCfgFileName );115 Void xReadCameraParameterFile ( TChar* pchCfgFileName ); 116 116 Bool xGetCameraDataRow ( Int iView, UInt uiFrame, UInt& ruiFoundLine ); 117 117 … … 129 129 #endif 130 130 Void xSetupBaseViewsFromCoded (); 131 Void xSetupBaseViews ( Char* pchBaseViewNumbers, UInt uiNumBaseViews );131 Void xSetupBaseViews ( TChar* pchBaseViewNumbers, UInt uiNumBaseViews ); 132 132 Bool xIsIn ( std::vector<Int>& rVec, Int iNumber); 133 133 … … 156 156 UInt uiStartFrameId, 157 157 UInt uiNumFrames, 158 Char* pchCfgFileName,159 Char* pchBaseViewNumbers,160 Char* pchSynthViewNumbers,158 TChar* pchCfgFileName, 159 TChar* pchBaseViewNumbers, 160 TChar* pchSynthViewNumbers, 161 161 std::vector<Int>* paiSynthViewNumbers, 162 162 Int iLog2Precision ); … … 165 165 UInt uiStartFrameId, 166 166 UInt uiNumFrames, 167 Char* pchCfgFileName,168 Char* pchSynthViewNumbers,167 TChar* pchCfgFileName, 168 TChar* pchSynthViewNumbers, 169 169 std::vector<Int>* paiSynthViewNumbers, 170 170 Int iLog2Precision … … 183 183 Int getRelDistLeft ( Int iSynthViewIdx, Int iLeftViewIdx, Int iRightViewIdx ); 184 184 UInt getCurFrameId () { return m_iCurrentFrameId; } 185 static Void convertNumberString ( Char* pchViewNumberString, std::vector<Int>& raiViewNumbers, Double dViewNumPrec );186 #if H_3D_REN_MAX_DEV_OUT185 static Void convertNumberString ( TChar* pchViewNumberString, std::vector<Int>& raiViewNumbers, Double dViewNumPrec ); 186 #if NH_3D_REN_MAX_DEV_OUT 187 187 Double getMaxShiftDeviation () { return m_dMaxShiftDeviation; }; 188 188 #endif -
trunk/source/Lib/TAppCommon/program_options_lite.cpp
r1356 r1386 111 111 } 112 112 113 #if NH_MV _SEI113 #if NH_MV 114 114 static void setOptions(Options::NamesPtrList& opt_list, const std::vector<int> idcs, const string& value, ErrorReporter& error_reporter) 115 115 #else … … 121 121 for (Options::NamesPtrList::iterator it = opt_list.begin(); it != opt_list.end(); ++it) 122 122 { 123 #if NH_MV_SEI 123 #if NH_MV 124 124 Bool doParsing = (*it)->opt->checkDim( idcs, error_reporter ); 125 125 if ( doParsing ) … … 127 127 (*it)->opt->parse(value, idcs, error_reporter); 128 128 } 129 130 #else 129 #else 131 130 (*it)->opt->parse(value, error_reporter); 132 131 #endif 133 132 } 134 133 } … … 290 289 bool OptionWriter::storePair(bool allow_long, bool allow_short, const string& name, const string& value) 291 290 { 292 #if NH_MV _SEI291 #if NH_MV 293 292 std::vector<int> idcs; 294 293 … … 324 323 found = true; 325 324 } 326 #if NH_MV _SEI325 #if NH_MV 327 326 if ( idcs.size() > 0 ) 328 327 { … … 347 346 found = true; 348 347 } 349 #if NH_MV _SEI348 #if NH_MV 350 349 if ( idcs.size() > 0 ) 351 350 { … … 362 361 } 363 362 364 #if NH_MV _SEI363 #if NH_MV 365 364 if ( !found_idcs ) 366 365 { … … 370 369 if (!found) 371 370 { 372 #if NH_MV _SEI371 #if NH_MV 373 372 if (error_reporter.output_on_unknow_parameter ) 374 373 { … … 377 376 error_reporter.error(where()) 378 377 << "Unknown option `" << name << "' (value:`" << value << "')\n"; 379 #if NH_MV _SEI378 #if NH_MV 380 379 } 381 380 #endif … … 383 382 } 384 383 385 #if NH_MV _SEI384 #if NH_MV 386 385 setOptions((*opt_it).second, idcs, value, error_reporter); 387 386 #else -
trunk/source/Lib/TAppCommon/program_options_lite.h
r1356 r1386 37 37 #include <map> 38 38 #include "../TLibCommon/CommonDef.h" 39 40 39 #if NH_MV 41 40 #include <vector> … … 78 77 struct ErrorReporter 79 78 { 80 #if NH_MV _SEI79 #if NH_MV 81 80 ErrorReporter() : is_errored(0), output_on_unknow_parameter(true) {} 82 81 #else … … 87 86 virtual std::ostream& warn(const std::string& where); 88 87 bool is_errored; 89 #if NH_MV _SEI88 #if NH_MV 90 89 bool output_on_unknow_parameter; 91 90 #endif … … 105 104 { 106 105 #if NH_MV 107 #if NH_MV_SEI108 106 OptionBase(const std::string& name, const std::string& desc, bool duplicate = false, std::vector< int > maxdim = std::vector< int >(0) ) 109 107 : opt_string(name), opt_desc(desc), opt_duplicate(duplicate), max_dim( maxdim ) 110 108 #else 111 OptionBase(const std::string& name, const std::string& desc, bool duplicate = false)112 : opt_string(name), opt_desc(desc), opt_duplicate(duplicate)113 #endif114 #else115 109 OptionBase(const std::string& name, const std::string& desc) 116 110 : opt_string(name), opt_desc(desc) … … 121 115 122 116 /* parse argument arg, to obtain a value for the option */ 123 #if NH_MV _SEI117 #if NH_MV 124 118 virtual void parse(const std::string& arg, const std::vector<int>& idcs, ErrorReporter&) = 0; 125 119 … … 221 215 #if NH_MV 222 216 bool opt_duplicate; 223 #if NH_MV_SEI224 217 std::vector<int> max_dim; 225 #endif226 218 #endif 227 219 }; … … 232 224 { 233 225 #if NH_MV 234 #if NH_MV_SEI235 226 Option(const std::string& name, T& storage, T default_val, const std::string& desc, bool duplicate = false, std::vector< int > maxdim = std::vector< int >(0) ) 236 227 : OptionBase(name, desc, duplicate, maxdim), opt_storage(storage), opt_default_val(default_val) 237 228 #else 238 Option(const std::string& name, T& storage, T default_val, const std::string& desc, bool duplicate = false)239 : OptionBase(name, desc, duplicate), opt_storage(storage), opt_default_val(default_val)240 #endif241 #else242 229 Option(const std::string& name, T& storage, T default_val, const std::string& desc) 243 230 : OptionBase(name, desc), opt_storage(storage), opt_default_val(default_val) … … 245 232 {} 246 233 247 #if NH_MV _SEI234 #if NH_MV 248 235 void parse(const std::string& arg, const std::vector<int>& idcs, ErrorReporter&); 249 236 #else … … 263 250 template<typename T> 264 251 inline void 265 #if NH_MV _SEI252 #if NH_MV 266 253 Option<T>::parse(const std::string& arg, const std::vector<int>& idcs, ErrorReporter&) 267 254 #else … … 269 256 #endif 270 257 { 271 #if NH_MV _SEI258 #if NH_MV 272 259 assert( idcs.size() == 0 ); 273 260 #endif … … 289 276 template<> 290 277 inline void 291 #if NH_MV _SEI278 #if NH_MV 292 279 Option<std::string>::parse(const std::string& arg, const std::vector<int>& idcs, ErrorReporter&) 293 #else 294 Option<std::string>::parse(const std::string& arg, ErrorReporter&) 295 #endif 296 { 297 #if NH_MV_SEI 280 { 298 281 assert( idcs.size() == 0 ); 299 #endif300 282 opt_storage = arg; 301 283 } 284 #else 285 Option<std::string>::parse(const std::string& arg, ErrorReporter&) 286 { 287 opt_storage = arg; 288 } 289 #endif 302 290 303 291 #if NH_MV 304 292 template<> 305 293 inline void 306 #if NH_MV_SEI307 294 Option<char*>::parse(const std::string& arg, const std::vector<int>& idcs, ErrorReporter&) 308 #else 309 Option<char*>::parse(const std::string& arg, ErrorReporter&) 310 #endif 311 { 312 #if NH_MV_SEI 295 { 313 296 assert( idcs.size() == 0 ); 314 #endif315 297 opt_storage = arg.empty() ? NULL : strdup(arg.c_str()) ; 316 298 } 317 299 318 #if !NH_MV_SEI319 320 template<>321 inline void322 Option< std::vector<char*> >::parse(const std::string& arg, ErrorReporter&)323 {324 opt_storage.clear();325 326 char* pcStart = (char*) arg.data();327 char* pcEnd = strtok (pcStart," ");328 329 while (pcEnd != NULL)330 {331 size_t uiStringLength = pcEnd - pcStart;332 char* pcNewStr = (char*) malloc( uiStringLength + 1 );333 strncpy( pcNewStr, pcStart, uiStringLength);334 pcNewStr[uiStringLength] = '\0';335 pcStart = pcEnd+1;336 pcEnd = strtok (NULL, " ,.-");337 opt_storage.push_back( pcNewStr );338 }339 }340 #endif341 342 300 template<> 343 301 inline void 344 #if NH_MV_SEI345 302 Option< std::vector<double> >::parse(const std::string& arg, const std::vector< int > & idcs, ErrorReporter&) 346 #else 347 Option< std::vector<double> >::parse(const std::string& arg, ErrorReporter&) 348 #endif 349 { 350 #if NH_MV_SEI 303 { 351 304 assert( idcs.size() == 0 ); 352 #endif353 305 char* pcNextStart = (char*) arg.data(); 354 306 char* pcEnd = pcNextStart + arg.length(); … … 384 336 385 337 386 #if NH_MV_SEI387 338 template<> 388 339 inline void … … 405 356 xParseVec ( arg, opt_storage[ idcs[0] ][ idcs[1] ] ); 406 357 }; 407 #if SEI_DRI_F0169 358 408 359 template<> 409 360 inline void … … 439 390 while( (pcNextStart < pcEnd) && ( *pcNextStart == ' ' || *pcNextStart == '\t' || *pcNextStart == '\r' ) ) pcNextStart++; 440 391 pcOldStart = pcNextStart; 441 442 } 443 444 392 } 445 393 } 446 #endif 447 #else 448 template<> 449 inline void 450 Option< std::vector<int> >::parse(const std::string& arg, ErrorReporter&) 451 { 452 opt_storage.clear(); 453 454 455 char* pcNextStart = (char*) arg.data(); 456 char* pcEnd = pcNextStart + arg.length(); 457 458 char* pcOldStart = 0; 459 460 size_t iIdx = 0; 461 462 463 while (pcNextStart < pcEnd) 464 { 465 466 if ( iIdx < opt_storage.size() ) 467 { 468 opt_storage[iIdx] = (int) strtol(pcNextStart, &pcNextStart,10); 469 } 470 else 471 { 472 opt_storage.push_back( (int) strtol(pcNextStart, &pcNextStart,10)) ; 473 } 474 iIdx++; 475 if ( errno == ERANGE || (pcNextStart == pcOldStart) ) 476 { 477 std::cerr << "Error Parsing Integers: `" << arg << "'" << std::endl; 478 exit(EXIT_FAILURE); 479 }; 480 while( (pcNextStart < pcEnd) && ( *pcNextStart == ' ' || *pcNextStart == '\t' || *pcNextStart == '\r' ) ) pcNextStart++; 481 pcOldStart = pcNextStart; 482 } 483 } 484 #endif 485 486 #if NH_MV_SEI 394 487 395 488 396 template<> … … 531 439 xParseVec( arg, opt_storage[idcs[0]][idcs[1]] ); 532 440 }; 533 #else534 template<>535 inline void536 Option< std::vector<bool> >::parse(const std::string& arg, ErrorReporter&)537 {538 char* pcNextStart = (char*) arg.data();539 char* pcEnd = pcNextStart + arg.length();540 541 char* pcOldStart = 0;542 543 size_t iIdx = 0;544 545 while (pcNextStart < pcEnd)546 {547 if ( iIdx < opt_storage.size() )548 {549 opt_storage[iIdx] = (strtol(pcNextStart, &pcNextStart,10) != 0);550 }551 else552 {553 opt_storage.push_back(strtol(pcNextStart, &pcNextStart,10) != 0) ;554 }555 iIdx++;556 557 if ( errno == ERANGE || (pcNextStart == pcOldStart) )558 {559 std::cerr << "Error Parsing Bools: `" << arg << "'" << std::endl;560 exit(EXIT_FAILURE);561 };562 while( (pcNextStart < pcEnd) && ( *pcNextStart == ' ' || *pcNextStart == '\t' || *pcNextStart == '\r' ) ) pcNextStart++;563 pcOldStart = pcNextStart;564 }565 }566 #endif567 441 #endif 568 442 /** Option class for argument handling using a user provided function */ … … 575 449 {} 576 450 577 #if NH_MV _SEI451 #if NH_MV 578 452 void parse(const std::string& arg, const std::vector<int>& idcs, ErrorReporter& error_reporter) 579 453 #else … … 651 525 operator()(const std::string& name, std::vector<T>& storage, T default_val, unsigned uiMaxNum, const std::string& desc = "" ) 652 526 { 653 #if NH_MV_SEI654 527 std::vector<T> defVal; 655 528 defVal.resize( uiMaxNum, default_val ); … … 679 552 return *this; 680 553 } 681 #else682 std::string cNameBuffer;683 std::string cDescBuffer;684 685 storage.resize(uiMaxNum);686 for ( unsigned int uiK = 0; uiK < uiMaxNum; uiK++ )687 {688 cNameBuffer .resize( name.size() + 10 );689 cDescBuffer.resize( desc.size() + 10 );690 691 Bool duplicate = (uiK != 0);692 // isn't there are sprintf function for string??693 sprintf((char*) cNameBuffer.c_str() ,name.c_str(),uiK,uiK);694 695 if ( !duplicate )696 {697 sprintf((char*) cDescBuffer.c_str(),desc.c_str(),uiK,uiK);698 }699 700 cNameBuffer.resize( std::strlen(cNameBuffer.c_str()) );701 cDescBuffer.resize( std::strlen(cDescBuffer.c_str()) );702 703 704 parent.addOption(new Option<T>( cNameBuffer, (storage[uiK]), default_val, cDescBuffer, duplicate ));705 }706 707 return *this;708 }709 #endif710 554 #endif 711 555 /**
Note: See TracChangeset for help on using the changeset viewer.