Ignore:
Timestamp:
13 Nov 2015, 17:00:20 (9 years ago)
Author:
tech
Message:

Removed 3D.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HTM-16.0-MV-draft-5/source/Lib/TLibRenderer/TRenModSetupStrParser.cpp

    r1386 r1390  
    3737#include "TRenModSetupStrParser.h"
    3838
    39 #if NH_3D_VSO
    40 Int
    41 TRenModSetupStrParser::getNumOfModels()
    42 {
    43   return m_iNumberOfModels;
    44 }
    4539
    46 Int
    47 TRenModSetupStrParser::getNumOfBaseViews()
    48 {
    49   return (Int) m_aiAllBaseViewIdx  .size();
    50 }
    51 
    52 Int
    53 TRenModSetupStrParser::getNumOfModelsForView( Int iViewIdx, Int iContent )
    54 {
    55   return (Int) m_aaaiModelNums[iContent][iViewIdx].size();
    56 }
    57 
    58 Int
    59 TRenModSetupStrParser::getNumOfBaseViewsForView( Int iViewIdx, Int iContent )
    60 {
    61   return (Int) m_aaaiBaseViewsIdx[iContent][iViewIdx].size();
    62 }
    63 
    64 Void
    65 TRenModSetupStrParser::getSingleModelData( Int iSrcViewIdx,
    66                                            Int iSrcCnt,
    67                                            Int iCurModel,
    68                                            Int& riModelNum,
    69                                            Int& riBlendMode,
    70                                            Int& riLeftBaseViewIdx,
    71                                            Int& riRightBaseViewIdx,
    72                                            Int& riOrgRefBaseViewIdx,
    73                                            Int& riSynthViewRelNum )
    74 {
    75   Bool bExtrapolate    = m_aaabExtrapolate[iSrcCnt][iSrcViewIdx][iCurModel];
    76   Bool bOrgRef         = m_aaabOrgRef     [iSrcCnt][iSrcViewIdx][iCurModel];
    77 
    78   riOrgRefBaseViewIdx = bOrgRef ? m_aaaiSynthViewNums[iSrcCnt][iSrcViewIdx][iCurModel] / ( (Int) VIEW_NUM_PREC ) : -1;
    79   riSynthViewRelNum    = m_aaaiSynthViewNums[iSrcCnt][iSrcViewIdx][iCurModel];
    80   riModelNum           = m_aaaiModelNums    [iSrcCnt][iSrcViewIdx][iCurModel];
    81   riBlendMode          = m_aaaiBlendMode    [iSrcCnt][iSrcViewIdx][iCurModel];
    82 
    83 
    84   Int iSrcViewNum = iSrcViewIdx * ((Int) VIEW_NUM_PREC );
    85   if ( iSrcViewNum < riSynthViewRelNum )
    86   {
    87     riLeftBaseViewIdx  = iSrcViewIdx;
    88     riRightBaseViewIdx = -1;
    89   }
    90   else
    91   {
    92     riLeftBaseViewIdx = -1;
    93     riRightBaseViewIdx  = iSrcViewIdx;
    94   }
    95 
    96   if ( !bExtrapolate )
    97   {
    98     std::vector<Int> cCurBaseViews = m_aaaiBaseViewsIdx[iSrcCnt][iSrcViewIdx];
    99 
    100     Int iMinDist = MAX_INT;
    101     Int iNearestNum = -1;
    102 
    103     for (Int iCurBaseView = 0; iCurBaseView < cCurBaseViews.size(); iCurBaseView++ )
    104     {
    105       Int iCurBaseNum = m_aaaiBaseViewsIdx [iSrcCnt][iSrcViewIdx][iCurBaseView];
    106 
    107       if ( iCurBaseNum == iSrcViewNum )
    108         continue;
    109 
    110       Int iDist = iCurBaseNum - riSynthViewRelNum;
    111 
    112       if ( ( iDist <= 0  && riLeftBaseViewIdx == -1) || ( iDist >= 0  && riRightBaseViewIdx == -1 ) )
    113       {
    114         if ( abs(iDist) < iMinDist )
    115         {
    116           iMinDist = abs(iDist);
    117           iNearestNum = iCurBaseNum;
    118         }
    119       }
    120     }
    121     xError(iNearestNum == -1);
    122 
    123     if (riLeftBaseViewIdx == -1 )
    124     {
    125       riLeftBaseViewIdx = iNearestNum / (Int) (VIEW_NUM_PREC);
    126     }
    127     else
    128     {
    129       riRightBaseViewIdx = iNearestNum / (Int) (VIEW_NUM_PREC);
    130     }
    131 
    132     xError(riLeftBaseViewIdx  == -1 );
    133     xError(riRightBaseViewIdx == -1 );
    134     xError(riLeftBaseViewIdx  >= riRightBaseViewIdx );
    135   }
    136 }
    137 
    138 Void
    139 TRenModSetupStrParser::getBaseViewData( Int iSourceViewIdx, Int iSourceContent, Int iCurView, Int& riBaseViewSIdx, Int& riVideoDistMode, Int& riDepthDistMode )
    140 {
    141   riBaseViewSIdx = m_aaaiBaseViewsIdx  [iSourceContent][iSourceViewIdx][iCurView] / (Int) VIEW_NUM_PREC;
    142   riVideoDistMode            = m_aaaiVideoDistMode [iSourceContent][iSourceViewIdx][iCurView];
    143   riDepthDistMode            = m_aaaiDepthDistMode [iSourceContent][iSourceViewIdx][iCurView];
    144 }
    145 
    146 TRenModSetupStrParser::TRenModSetupStrParser()
    147 {
    148   m_pchSetStr       = NULL;
    149   m_iPosInStr       = 0;
    150   m_iNumberOfModels = 0;
    151   m_bCurrentViewSet = false;
    152 }
    153 
    154 Void
    155 TRenModSetupStrParser::setString( Int iNumOfBaseViews, TChar* pchSetStr )
    156 {
    157   for (Int iContent = 0; iContent < 2; iContent++)
    158   {
    159     m_aaaiBaseViewsIdx  [iContent].resize( iNumOfBaseViews );
    160     m_aaaiDepthDistMode [iContent].resize( iNumOfBaseViews );
    161     m_aaaiVideoDistMode [iContent].resize( iNumOfBaseViews );
    162     m_aaaiSynthViewNums [iContent].resize( iNumOfBaseViews );
    163     m_aaaiModelNums     [iContent].resize( iNumOfBaseViews );
    164     m_aaabOrgRef        [iContent].resize( iNumOfBaseViews );
    165     m_aaabExtrapolate   [iContent].resize( iNumOfBaseViews );
    166     m_aaaiBlendMode     [iContent].resize( iNumOfBaseViews );
    167   }
    168 
    169   AOT( m_pchSetStr );
    170   m_pchSetStr = pchSetStr;
    171   m_iPosInStr       = 0;
    172   m_bCurrentViewSet = false;
    173 
    174   xParseString();
    175 }
    176 
    177 Void
    178 TRenModSetupStrParser::xParseString()
    179 {
    180   TChar cChar;
    181   xGetNextChar(cChar);
    182   while(  cChar != '\0' )
    183   {
    184     xParseSourceView();
    185     xGetNextChar(cChar);
    186   }
    187   // CHECK
    188   size_t iNumOfSrcViews = m_aaaiBaseViewsIdx[0].size();
    189 
    190   for (Int iSrcView = 0; iSrcView < iNumOfSrcViews; iSrcView++)
    191   {
    192     for (Int iContent = 0; iContent < 2; iContent++ )
    193     {
    194       size_t iNumOfBase  = m_aaaiBaseViewsIdx  [iContent][iSrcView].size();
    195       AOF( iNumOfBase   == m_aaaiDepthDistMode [iContent][iSrcView].size());
    196       AOF( iNumOfBase   == m_aaaiVideoDistMode [iContent][iSrcView].size());
    197 
    198       size_t iNumOfModels = m_aaaiSynthViewNums[iContent][iSrcView].size();
    199       AOF( iNumOfModels == m_aaaiModelNums     [iContent][iSrcView].size());
    200       AOF( iNumOfModels == m_aaabOrgRef        [iContent][iSrcView].size());
    201       AOF( iNumOfModels == m_aaabExtrapolate   [iContent][iSrcView].size());
    202     }
    203   }
    204 
    205   // SORT
    206   std::vector<Int>::iterator cIterNewEnd;
    207 
    208   std::sort( m_aiAllBaseViewIdx.begin(), m_aiAllBaseViewIdx.end() );
    209   cIterNewEnd = std::unique( m_aiAllBaseViewIdx.begin(), m_aiAllBaseViewIdx.end() );
    210   m_aiAllBaseViewIdx.erase( cIterNewEnd, m_aiAllBaseViewIdx.end() );
    211 
    212   std::sort( m_aiAllSynthViewNums.begin(), m_aiAllSynthViewNums.end() );
    213   cIterNewEnd = std::unique( m_aiAllSynthViewNums.begin(), m_aiAllSynthViewNums.end() );
    214   m_aiAllSynthViewNums.erase( cIterNewEnd, m_aiAllSynthViewNums.end() );
    215 }
    216 
    217 Void
    218 TRenModSetupStrParser::xParseSourceView()
    219 {
    220   m_bCurrentViewSet = false;
    221 
    222   TChar cChar;
    223   xGetNextCharGoOn( cChar );
    224   xError( cChar != '[' );
    225   xReadViewInfo('B');
    226 
    227   Bool bContinueReading = true;
    228   while( bContinueReading )
    229   {
    230     xGetNextCharGoOn( cChar );
    231     switch ( cChar )
    232     {
    233     case 'B':
    234     case 'I':
    235     case 'E':
    236     case 'L':
    237     case 'R':
    238       xReadViews( cChar );
    239       break;
    240     case ']':
    241       bContinueReading = false;
    242       break;
    243     default:
    244       xError(true);
    245       break;
    246     }
    247   }
    248 }
    249 
    250 Void
    251 TRenModSetupStrParser::xReadViews( TChar cType )
    252 {
    253   TChar cChar;
    254   xGetNextCharGoOn( cChar );
    255   xError( cChar != '(' );
    256 
    257   Bool bContinue = true;
    258   while ( bContinue )
    259   {
    260     xGetNextChar( cChar );
    261     if (cChar == ')')
    262     {
    263       xGetNextCharGoOn( cChar );
    264       bContinue = false;
    265     }
    266     else
    267     {
    268       xReadViewInfo( cType );
    269     }
    270   }
    271 }
    272 
    273 Void
    274 TRenModSetupStrParser::xReadViewInfo( TChar cType )
    275 {
    276   std::vector<Int> aiViewNums;
    277   aiViewNums.clear();
    278 
    279   switch ( cType )
    280   {
    281   case 'B':
    282     TChar cVideoType;
    283     TChar cDepthType;
    284 
    285     xGetNextCharGoOn   ( cVideoType );
    286     xGetNextCharGoOn   ( cDepthType );
    287     xGetViewNumberRange( aiViewNums );
    288 
    289     if ( !m_bCurrentViewSet )
    290     {
    291       xError( aiViewNums.size() != 1 );
    292       m_iCurrentView = aiViewNums[0] / (Int) VIEW_NUM_PREC;
    293       if      ( cVideoType == 'x' )
    294       {
    295         m_iCurrentContent = 0;
    296         m_bCurrentViewSet = true;
    297       }
    298       else if ( cDepthType == 'x' )
    299       {
    300         m_iCurrentContent = 1;
    301         m_bCurrentViewSet = true;
    302       }
    303       else
    304       {
    305         xError( true );
    306       }
    307     }
    308 
    309     for ( Int iIdx = 0; iIdx < aiViewNums.size(); iIdx++ )
    310     {
    311       xAddBaseView( aiViewNums[iIdx], cVideoType, cDepthType );
    312     }
    313     break;
    314 
    315   case 'E':
    316   case 'I':
    317   case 'L':
    318   case 'R':
    319     TChar cRefType;
    320     xGetNextCharGoOn   ( cRefType   );
    321     xGetViewNumberRange( aiViewNums );
    322     for ( Int iIdx = 0; iIdx < aiViewNums.size(); iIdx++ )
    323     {
    324       xAddSynthView( aiViewNums[iIdx], cType, cRefType );
    325     }
    326   }
    327 }
    328 
    329 Void
    330 TRenModSetupStrParser::xAddBaseView( Int iViewIdx, TChar cVideoType, TChar cDepthType )
    331 {
    332   AOF( m_bCurrentViewSet );
    333 
    334   if ( cDepthType == 'x' ) cDepthType = 'o';
    335   if ( cVideoType == 'x' ) cVideoType = 'o';
    336  
    337   xError( cDepthType != 'o' && cDepthType != 'c' && cVideoType != 'r' );
    338   xError( cVideoType != 'o' && cVideoType != 'c' && cVideoType != 'r' );
    339   m_aiAllBaseViewIdx.push_back( iViewIdx );
    340   m_aaaiBaseViewsIdx  [m_iCurrentContent][m_iCurrentView].push_back( iViewIdx          );
    341   m_aaaiVideoDistMode [m_iCurrentContent][m_iCurrentView].push_back( ( cVideoType == 'c' ) ? 2 : ( (cVideoType == 'r') ? 1 :  0 ) );
    342   m_aaaiDepthDistMode [m_iCurrentContent][m_iCurrentView].push_back( ( cDepthType == 'c' ) ? 2 : ( (cDepthType == 'r') ? 1 :  0 ) );
    343 }
    344 
    345 Void
    346 TRenModSetupStrParser::xAddSynthView( Int iViewNum, TChar cType, TChar cRefType )
    347 {
    348   AOF( m_bCurrentViewSet );
    349 
    350   xError( cRefType != 's' && cRefType != 'o' );
    351 
    352   m_aiAllSynthViewNums.push_back( iViewNum );
    353 
    354   Int iBlendMode;
    355   switch ( cType )
    356   {
    357   case 'E':
    358     iBlendMode = BLEND_NONE;
    359     break;
    360   case 'I':
    361     iBlendMode = BLEND_AVRG;
    362     break;
    363   case 'L':
    364     iBlendMode = BLEND_LEFT;
    365     break;
    366   case 'R':
    367     iBlendMode = BLEND_RIGHT;
    368     break;
    369   default:
    370     xError(false);
    371     break;
    372   }
    373 
    374   m_aaaiBlendMode    [m_iCurrentContent][m_iCurrentView].push_back( iBlendMode        );
    375   m_aaaiSynthViewNums[m_iCurrentContent][m_iCurrentView].push_back( iViewNum          );
    376   m_aaabExtrapolate  [m_iCurrentContent][m_iCurrentView].push_back( cType    == 'E'   );
    377   m_aaabOrgRef       [m_iCurrentContent][m_iCurrentView].push_back( cRefType == 'o'   );
    378   m_aaaiModelNums    [m_iCurrentContent][m_iCurrentView].push_back( m_iNumberOfModels );
    379 
    380   m_iNumberOfModels++;
    381 }
    382 
    383 Void
    384 TRenModSetupStrParser::xError( Bool bIsError )
    385 {
    386   if ( bIsError )
    387   {
    388     std::cout << "RenModel setup string invalid. Last character read: " << m_iPosInStr << std::endl;
    389     AOF( false );
    390     exit(0);
    391   }
    392 }
    393 
    394 Void
    395 TRenModSetupStrParser::xGetViewNumberRange( std::vector<Int>& raiViewNumbers )
    396 {
    397   size_t iStartPos;
    398   size_t iEndPos;
    399   TChar cChar;
    400   xGetNextCharGoOn(cChar );
    401   if (cChar == '{')
    402   {
    403     iStartPos = m_iPosInStr;
    404     while( m_pchSetStr[m_iPosInStr] != '}' )
    405     {
    406       xError( m_iPosInStr == '\0' );
    407       m_iPosInStr++;
    408     }
    409     iEndPos = m_iPosInStr - 1;
    410     m_iPosInStr++;
    411   }
    412   else
    413   {
    414     iStartPos = m_iPosInStr - 1;
    415     while( m_pchSetStr[m_iPosInStr] != ' ' && m_pchSetStr[m_iPosInStr] != ',' && m_pchSetStr[m_iPosInStr] != ')' )
    416     {
    417       xError( m_iPosInStr == '\0' );
    418       m_iPosInStr++;
    419     }
    420     iEndPos = m_iPosInStr - 1;
    421   }
    422 
    423   size_t iNumElem = iEndPos - iStartPos + 1;
    424   TChar* pcTempBuffer = new TChar[  iNumElem + 1];
    425   strncpy( pcTempBuffer, m_pchSetStr + iStartPos, iNumElem );
    426   pcTempBuffer[iNumElem] = '\0';
    427 
    428   TAppComCamPara::convertNumberString( pcTempBuffer, raiViewNumbers, VIEW_NUM_PREC );
    429   delete[] pcTempBuffer;
    430 }
    431 
    432 Void
    433 TRenModSetupStrParser::xGetNextCharGoOn( TChar& rcNextChar )
    434 {
    435   while ( m_pchSetStr[m_iPosInStr] == ' ' || m_pchSetStr[m_iPosInStr] == ',' )
    436   {
    437     xError( m_pchSetStr[m_iPosInStr] == '\0' );
    438     m_iPosInStr++;
    439   }
    440   rcNextChar = m_pchSetStr[m_iPosInStr];
    441   m_iPosInStr++;
    442 }
    443 
    444 Void
    445 TRenModSetupStrParser::xGetNextChar( TChar& rcNextChar )
    446 {
    447   size_t iPos = m_iPosInStr;
    448   while ( ( m_pchSetStr[iPos] == ' ' || m_pchSetStr[iPos] == ',' ) && m_pchSetStr[iPos] != '\0' ) iPos++;
    449   rcNextChar = m_pchSetStr[iPos];
    450 }
    451 #endif // NH_3D
    452 
Note: See TracChangeset for help on using the changeset viewer.