[5] | 1 | /* The copyright in this software is being made available under the BSD |
---|
| 2 | * License, included below. This software may be subject to other third party |
---|
| 3 | * and contributor rights, including patent rights, and no such rights are |
---|
| 4 | * granted under this license. |
---|
| 5 | * |
---|
| 6 | * Copyright (c) 2010-2011, ISO/IEC |
---|
| 7 | * All rights reserved. |
---|
| 8 | * |
---|
| 9 | * Redistribution and use in source and binary forms, with or without |
---|
| 10 | * modification, are permitted provided that the following conditions are met: |
---|
| 11 | * |
---|
| 12 | * * Redistributions of source code must retain the above copyright notice, |
---|
| 13 | * this list of conditions and the following disclaimer. |
---|
| 14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
| 15 | * this list of conditions and the following disclaimer in the documentation |
---|
| 16 | * and/or other materials provided with the distribution. |
---|
| 17 | * * Neither the name of the ISO/IEC nor the names of its contributors may |
---|
| 18 | * be used to endorse or promote products derived from this software without |
---|
| 19 | * specific prior written permission. |
---|
| 20 | * |
---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
| 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
| 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
| 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
| 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
| 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
| 31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 32 | */ |
---|
[2] | 33 | |
---|
[5] | 34 | |
---|
[2] | 35 | #include "TEncFormattedStringParser.h" |
---|
| 36 | #include <sstream> |
---|
| 37 | #include <algorithm> |
---|
| 38 | |
---|
| 39 | const std::string TEncFormattedStringParser::sm_cSetOfTypes ("AIPBNipbn"); |
---|
| 40 | const std::string TEncFormattedStringParser::sm_cSetOfDigits ("0123456789"); |
---|
| 41 | const std::string TEncFormattedStringParser::sm_cSetOfPartStart ("AIPBNipbn*"); |
---|
| 42 | |
---|
| 43 | ErrVal TEncFormattedStringParser::extractFrameType( const std::string &rcString, |
---|
| 44 | SliceType& reSliceType, |
---|
| 45 | bool &rbStoreForRef, |
---|
| 46 | bool &rbIsIDR, |
---|
| 47 | std::string::size_type &ruiStartPos ) |
---|
| 48 | { |
---|
| 49 | ROT( rcString.length() <= ruiStartPos ); |
---|
| 50 | |
---|
| 51 | rbIsIDR = rcString[ruiStartPos] == 'A'; |
---|
| 52 | rbStoreForRef = isupper( rcString[ruiStartPos] ) != 0; |
---|
| 53 | |
---|
| 54 | const char cType = rcString[ruiStartPos++]; |
---|
| 55 | switch( toupper( cType ) ) |
---|
| 56 | { |
---|
| 57 | case 'A': |
---|
| 58 | case 'I': |
---|
| 59 | reSliceType = I_SLICE ; |
---|
| 60 | break; |
---|
| 61 | case 'P': |
---|
| 62 | reSliceType = P_SLICE ; |
---|
| 63 | break; |
---|
| 64 | case 'B': |
---|
| 65 | reSliceType = B_SLICE ; |
---|
| 66 | break; |
---|
| 67 | default: |
---|
| 68 | ROT( 1 ); |
---|
| 69 | } |
---|
| 70 | |
---|
| 71 | return Err::m_nOK; |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | |
---|
| 75 | |
---|
| 76 | |
---|
| 77 | ErrVal TEncFormattedStringParser::extractFrameIncrement( const std::string &rcString, |
---|
| 78 | UInt &ruiIncrement, |
---|
| 79 | std::string::size_type &ruiStartPos ) |
---|
| 80 | { |
---|
| 81 | RNOK( xExtractUInt( rcString, ruiIncrement, ruiStartPos ) ); |
---|
| 82 | return Err::m_nOK; |
---|
| 83 | } |
---|
| 84 | |
---|
| 85 | ErrVal TEncFormattedStringParser::extractFrameLayer( const std::string &rcString, |
---|
| 86 | UInt &ruiLayer, |
---|
| 87 | std::string::size_type &ruiStartPos ) |
---|
| 88 | { |
---|
| 89 | ruiLayer = 0; |
---|
| 90 | ROTRS( std::string::npos == ruiStartPos, Err::m_nOK ); |
---|
| 91 | ROTRS( rcString.length() <= ruiStartPos, Err::m_nOK ); |
---|
| 92 | ROTRS( rcString[ruiStartPos] != 'L', Err::m_nOK ); |
---|
| 93 | ruiStartPos++; |
---|
| 94 | RNOK( xExtractUInt( rcString, ruiLayer, ruiStartPos ) ); |
---|
| 95 | return Err::m_nOK; |
---|
| 96 | } |
---|
| 97 | |
---|
| 98 | ErrVal TEncFormattedStringParser::xExtractRelRefPocAndRefViewIdx( const std::string &rcString, |
---|
| 99 | std::vector<int> &raiAllowedRelativeRefPocs, |
---|
| 100 | std::vector<int> &raiAllowedReferenceViewIdx, |
---|
| 101 | std::string::size_type &ruiStartPos ) |
---|
| 102 | { |
---|
| 103 | if( rcString[ruiStartPos] == 'v' || rcString[ruiStartPos] == 'V' ) |
---|
| 104 | { |
---|
| 105 | ruiStartPos++; |
---|
| 106 | int iRefViewIdx = 0; |
---|
| 107 | RNOK( xExtractInt( rcString, iRefViewIdx, ruiStartPos ) ); |
---|
| 108 | assert( iRefViewIdx >= 0 ); |
---|
| 109 | ROF( raiAllowedReferenceViewIdx.end() == std::find( raiAllowedReferenceViewIdx.begin(), raiAllowedReferenceViewIdx.end(), iRefViewIdx ) ); |
---|
| 110 | raiAllowedReferenceViewIdx.push_back( iRefViewIdx ); |
---|
| 111 | raiAllowedRelativeRefPocs.push_back( 0 ); |
---|
| 112 | } |
---|
| 113 | else |
---|
| 114 | { |
---|
| 115 | int iRelRefPoc = 0; |
---|
| 116 | RNOK( xExtractInt( rcString, iRelRefPoc, ruiStartPos ) ); |
---|
| 117 | ROF( raiAllowedRelativeRefPocs.end() == std::find( raiAllowedRelativeRefPocs.begin(), raiAllowedRelativeRefPocs.end(), iRelRefPoc ) ); |
---|
| 118 | raiAllowedRelativeRefPocs.push_back( iRelRefPoc ); |
---|
| 119 | raiAllowedReferenceViewIdx.push_back( -1 ); |
---|
| 120 | } |
---|
| 121 | return Err::m_nOK; |
---|
| 122 | } |
---|
| 123 | |
---|
| 124 | ErrVal TEncFormattedStringParser::extractAllowedRelativeRefPocs( const std::string &rcString, |
---|
| 125 | std::vector<int> &raiAllowedRelativeRefPocs, |
---|
| 126 | std::vector<int> &raiAllowedReferenceViewIdx, |
---|
| 127 | std::string::size_type &ruiStartPos ) |
---|
| 128 | { |
---|
| 129 | ROF( raiAllowedRelativeRefPocs.empty() ); |
---|
| 130 | ROTRS( std::string::npos == ruiStartPos, Err::m_nOK ); |
---|
| 131 | ROTRS( rcString.length() <= ruiStartPos, Err::m_nOK ); |
---|
| 132 | RNOK( xEatChar( rcString, '(', ruiStartPos ) ); |
---|
| 133 | |
---|
| 134 | do |
---|
| 135 | { |
---|
| 136 | RNOK( xExtractRelRefPocAndRefViewIdx( rcString, raiAllowedRelativeRefPocs, raiAllowedReferenceViewIdx, ruiStartPos ) ); |
---|
| 137 | } |
---|
| 138 | while( xEatChar( rcString, ',', ruiStartPos ) == Err::m_nOK ); |
---|
| 139 | RNOK( xEatChar( rcString, ')', ruiStartPos ) ); |
---|
| 140 | |
---|
| 141 | return Err::m_nOK; |
---|
| 142 | } |
---|
| 143 | |
---|
| 144 | ErrVal TEncFormattedStringParser::extractAllowedRelativeRefPocs( const std::string &rcString, |
---|
| 145 | std::vector<int> &raiAllowedRelativeRefPocsL0, |
---|
| 146 | std::vector<int> &raiAllowedRelativeRefPocsL1, |
---|
| 147 | std::vector<int> &raiAllowedReferenceViewIdxL0, |
---|
| 148 | std::vector<int> &raiAllowedReferenceViewIdxL1, |
---|
| 149 | std::string::size_type &ruiStartPos ) |
---|
| 150 | { |
---|
| 151 | ROF( raiAllowedRelativeRefPocsL0.empty() ); |
---|
| 152 | ROF( raiAllowedRelativeRefPocsL1.empty() ); |
---|
| 153 | |
---|
| 154 | ROTRS( std::string::npos == ruiStartPos, Err::m_nOK ); |
---|
| 155 | ROTRS( rcString.length() <= ruiStartPos, Err::m_nOK ); |
---|
| 156 | |
---|
| 157 | RNOK( xEatChar( rcString, '(', ruiStartPos ) ); |
---|
| 158 | do |
---|
| 159 | { |
---|
| 160 | RNOK( xExtractRelRefPocAndRefViewIdx( rcString, raiAllowedRelativeRefPocsL0, raiAllowedReferenceViewIdxL0, ruiStartPos ) ); |
---|
| 161 | } |
---|
| 162 | while( xEatChar( rcString, ',', ruiStartPos ) == Err::m_nOK ); |
---|
| 163 | RNOK( xEatChar( rcString, ';', ruiStartPos ) ); |
---|
| 164 | do |
---|
| 165 | { |
---|
| 166 | RNOK( xExtractRelRefPocAndRefViewIdx( rcString, raiAllowedRelativeRefPocsL1, raiAllowedReferenceViewIdxL1, ruiStartPos ) ); |
---|
| 167 | } |
---|
| 168 | while( xEatChar( rcString, ',', ruiStartPos ) == Err::m_nOK ); |
---|
| 169 | RNOK( xEatChar( rcString, ')', ruiStartPos ) ); |
---|
| 170 | return Err::m_nOK; |
---|
| 171 | } |
---|
| 172 | |
---|
| 173 | |
---|
| 174 | |
---|
| 175 | |
---|
| 176 | |
---|
| 177 | |
---|
| 178 | ErrVal TEncFormattedStringParser::xEatChar( const std::string &rcString, |
---|
| 179 | char cChar, |
---|
| 180 | std::string::size_type &ruiStartPos ) |
---|
| 181 | { |
---|
| 182 | ROTS( std::string::npos == ruiStartPos ); |
---|
| 183 | ROTS( rcString.length() <= ruiStartPos ); |
---|
| 184 | ROFS( rcString[ruiStartPos] == cChar ); |
---|
| 185 | ruiStartPos++; |
---|
| 186 | return Err::m_nOK; |
---|
| 187 | } |
---|
| 188 | |
---|
| 189 | ErrVal TEncFormattedStringParser::xExtractUInt( const std::string &rcString, |
---|
| 190 | UInt &ruiVal, |
---|
| 191 | std::string::size_type &ruiStartPos ) |
---|
| 192 | { |
---|
| 193 | ROT( std::string::npos == ruiStartPos ); |
---|
| 194 | ROT( rcString.length() <= ruiStartPos ); |
---|
| 195 | const std::string::size_type uiPos = rcString.find_first_not_of( sm_cSetOfDigits, ruiStartPos + ( rcString[ruiStartPos] == '+' ? 1 : 0 ) ); |
---|
| 196 | ROT( ruiStartPos == uiPos ); |
---|
| 197 | std::stringstream( rcString.substr( ruiStartPos, std::string::npos == uiPos ? std::string::npos : uiPos - ruiStartPos ) ) >> ruiVal; |
---|
| 198 | ruiStartPos = uiPos; |
---|
| 199 | return Err::m_nOK; |
---|
| 200 | } |
---|
| 201 | |
---|
| 202 | ErrVal TEncFormattedStringParser::xExtractInt( const std::string &rcString, |
---|
| 203 | int &riVal, |
---|
| 204 | std::string::size_type &ruiStartPos ) |
---|
| 205 | { |
---|
| 206 | ROT( std::string::npos == ruiStartPos ); |
---|
| 207 | ROT( rcString.length() <= ruiStartPos ); |
---|
| 208 | const std::string::size_type uiPos = rcString.find_first_not_of( sm_cSetOfDigits, ruiStartPos + ( rcString[ruiStartPos] == '+' || rcString[ruiStartPos] == '-' ? 1 : 0 ) ); |
---|
| 209 | ROT( ruiStartPos == uiPos ); |
---|
| 210 | std::stringstream( rcString.substr( ruiStartPos, std::string::npos == uiPos ? std::string::npos : uiPos - ruiStartPos ) ) >> riVal; |
---|
| 211 | ruiStartPos = uiPos; |
---|
| 212 | return Err::m_nOK; |
---|
| 213 | } |
---|
| 214 | |
---|
| 215 | |
---|
| 216 | ErrVal |
---|
| 217 | TEncFormattedStringParser::separatString ( const std::string& rcString, |
---|
| 218 | std::string& rcFDString, |
---|
| 219 | std::string& rcMmcoString, |
---|
| 220 | std::string& rcRplrStringL0, |
---|
| 221 | std::string& rcRplrStringL1) |
---|
| 222 | { |
---|
| 223 | size_t uiMPos = rcString.find_first_of( "M" ); |
---|
| 224 | size_t uiR1Pos = rcString.find_first_of( "R" ); |
---|
| 225 | size_t uiR2Pos = rcString.find_last_of ( "R" ); |
---|
| 226 | |
---|
| 227 | size_t uiSize = rcString.size(); |
---|
| 228 | |
---|
| 229 | if( std::string::npos == uiMPos ) |
---|
| 230 | { |
---|
| 231 | rcMmcoString = ""; |
---|
| 232 | if( std::string::npos == uiR1Pos ) |
---|
| 233 | { |
---|
| 234 | rcFDString = rcString; |
---|
| 235 | rcRplrStringL0 = ""; |
---|
| 236 | rcRplrStringL1 = ""; |
---|
| 237 | } |
---|
| 238 | else |
---|
| 239 | { |
---|
| 240 | rcFDString = rcString.substr( 0, uiR1Pos ); |
---|
| 241 | if( uiR1Pos == uiR2Pos ) |
---|
| 242 | { |
---|
| 243 | rcRplrStringL0 = rcString.substr( uiR1Pos, uiSize - uiR1Pos ); |
---|
| 244 | rcRplrStringL1 = ""; |
---|
| 245 | } |
---|
| 246 | else |
---|
| 247 | { |
---|
| 248 | rcRplrStringL0 = rcString.substr( uiR1Pos, uiR2Pos - uiR1Pos ); |
---|
| 249 | rcRplrStringL1 = rcString.substr( uiR2Pos, uiSize - uiR2Pos ); |
---|
| 250 | } |
---|
| 251 | } |
---|
| 252 | } |
---|
| 253 | else |
---|
| 254 | { |
---|
| 255 | if( std::string::npos == uiR1Pos ) |
---|
| 256 | { |
---|
| 257 | rcFDString = rcString.substr( 0, uiMPos ); |
---|
| 258 | rcMmcoString = rcString.substr( uiMPos, uiSize - uiMPos ); |
---|
| 259 | rcRplrStringL0 = ""; |
---|
| 260 | rcRplrStringL1 = ""; |
---|
| 261 | } |
---|
| 262 | else |
---|
| 263 | { |
---|
| 264 | if( uiMPos < uiR1Pos ) |
---|
| 265 | { |
---|
| 266 | rcFDString = rcString.substr( 0, uiMPos ); |
---|
| 267 | rcMmcoString = rcString.substr( uiMPos, uiR1Pos - uiMPos ); |
---|
| 268 | if( uiR1Pos == uiR2Pos ) |
---|
| 269 | { |
---|
| 270 | rcRplrStringL0 = rcString.substr( uiR1Pos, uiSize - uiR1Pos ); |
---|
| 271 | rcRplrStringL1 = ""; |
---|
| 272 | } |
---|
| 273 | else |
---|
| 274 | { |
---|
| 275 | rcRplrStringL0 = rcString.substr( uiR1Pos, uiR2Pos - uiR1Pos ); |
---|
| 276 | rcRplrStringL1 = rcString.substr( uiR2Pos, uiSize - uiR2Pos ); |
---|
| 277 | } |
---|
| 278 | } |
---|
| 279 | else |
---|
| 280 | { |
---|
| 281 | rcFDString = rcString.substr( 0, uiR1Pos ); |
---|
| 282 | |
---|
| 283 | if( uiR1Pos == uiR2Pos ) |
---|
| 284 | { |
---|
| 285 | rcRplrStringL0 = rcString.substr( uiR1Pos, uiMPos - uiR1Pos ); |
---|
| 286 | rcRplrStringL1 = ""; |
---|
| 287 | rcMmcoString = rcString.substr( uiMPos, uiSize - uiMPos ); |
---|
| 288 | } |
---|
| 289 | else |
---|
| 290 | { |
---|
| 291 | if( uiMPos < uiR2Pos ) |
---|
| 292 | { |
---|
| 293 | rcRplrStringL0 = rcString.substr( uiR1Pos, uiMPos - uiR1Pos ); |
---|
| 294 | rcMmcoString = rcString.substr( uiMPos, uiR2Pos - uiMPos ); |
---|
| 295 | rcRplrStringL1 = rcString.substr( uiR2Pos, uiSize - uiR2Pos ); |
---|
| 296 | |
---|
| 297 | } |
---|
| 298 | else |
---|
| 299 | { |
---|
| 300 | rcRplrStringL0 = rcString.substr( uiR1Pos, uiR2Pos - uiR1Pos ); |
---|
| 301 | rcRplrStringL1 = rcString.substr( uiR2Pos, uiMPos - uiR2Pos ); |
---|
| 302 | rcMmcoString = rcString.substr( uiMPos, uiSize - uiMPos ); |
---|
| 303 | } |
---|
| 304 | } |
---|
| 305 | } |
---|
| 306 | } |
---|
| 307 | } |
---|
| 308 | |
---|
| 309 | if( rcRplrStringL0.size() == 1 ) |
---|
| 310 | { |
---|
| 311 | rcRplrStringL0 = ""; |
---|
| 312 | } |
---|
| 313 | |
---|
| 314 | if( rcRplrStringL1.size() == 1 ) |
---|
| 315 | { |
---|
| 316 | rcRplrStringL1 = ""; |
---|
| 317 | } |
---|
| 318 | |
---|
| 319 | return Err::m_nOK; |
---|
| 320 | } |
---|
| 321 | |
---|
| 322 | bool |
---|
| 323 | TEncFormattedStringParser::isFrameSequencePart( const std::string& rcString ) |
---|
| 324 | { |
---|
| 325 | return ( rcString.find( '*', 1 ) == std::string::npos ); |
---|
| 326 | } |
---|
| 327 | |
---|
| 328 | |
---|
| 329 | ErrVal |
---|
| 330 | TEncFormattedStringParser::extractRepetitions( const std::string& rcString, |
---|
| 331 | std::string& rcNoRepString, |
---|
| 332 | UInt& ruiNumberOfRepetitions ) |
---|
| 333 | { |
---|
| 334 | ROT( rcString.empty() ); |
---|
| 335 | if( rcString[0] != '*' ) |
---|
| 336 | { |
---|
| 337 | ruiNumberOfRepetitions = 1; |
---|
| 338 | rcNoRepString = rcString; |
---|
| 339 | } |
---|
| 340 | else |
---|
| 341 | { |
---|
| 342 | size_t uiLastPos = rcString.length () - 1; |
---|
| 343 | size_t uiOpenPos = rcString.find ( '{' ); |
---|
| 344 | size_t uiClosePos = rcString.rfind ( '}' ); |
---|
| 345 | |
---|
| 346 | ROTS( uiOpenPos == std::string::npos ); |
---|
| 347 | ROFS( uiClosePos == uiLastPos ); |
---|
| 348 | |
---|
| 349 | rcNoRepString = rcString.substr( uiOpenPos+1, uiClosePos-uiOpenPos-1 ); //GT: abc if rcString = *n100{abc} |
---|
| 350 | std::string cNStr = rcString.substr( 1, uiOpenPos - 1 ); //GT n100 if rcString = *n100{abc} |
---|
| 351 | ROT( cNStr.empty() ); |
---|
| 352 | |
---|
| 353 | if( uiOpenPos==2 && cNStr[0]=='n' ) |
---|
| 354 | { |
---|
| 355 | // ruiNumberOfRepetitions = TypeLimits<UInt>::m_iMax; // reserved value representing "infinity" |
---|
| 356 | ruiNumberOfRepetitions = MAX_UINT; // reserved value representing "infinity" |
---|
| 357 | } |
---|
| 358 | else |
---|
| 359 | { |
---|
| 360 | ROFS( cNStr.find_first_not_of( sm_cSetOfDigits ) == std::string::npos ); |
---|
| 361 | ruiNumberOfRepetitions = atoi( cNStr.c_str() ); |
---|
| 362 | } |
---|
| 363 | } |
---|
| 364 | |
---|
| 365 | return Err::m_nOK; |
---|
| 366 | } |
---|
| 367 | |
---|
| 368 | ErrVal |
---|
| 369 | TEncFormattedStringParser::getNumberOfFrames( const std::string& rcString, |
---|
| 370 | UInt& ruiNumberOfFrames ) |
---|
| 371 | { |
---|
| 372 | size_t uiPos = rcString.find_first_of( sm_cSetOfTypes ); |
---|
| 373 | size_t uiUnderScorePos = 0 ; |
---|
| 374 | ruiNumberOfFrames = 0; |
---|
| 375 | |
---|
| 376 | |
---|
| 377 | while( uiPos != std::string::npos ) |
---|
| 378 | { |
---|
| 379 | ruiNumberOfFrames++; |
---|
| 380 | uiUnderScorePos = rcString.find_first_of( std::string("_"), uiPos+1 ) ; |
---|
| 381 | ROT( uiUnderScorePos == std::string::npos ) ; |
---|
| 382 | uiPos = rcString.find_first_of( sm_cSetOfTypes, uiUnderScorePos+1 ); |
---|
| 383 | } |
---|
| 384 | |
---|
| 385 | return Err::m_nOK; |
---|
| 386 | } |
---|
| 387 | |
---|
| 388 | ErrVal |
---|
| 389 | TEncFormattedStringParser::extractNextFrameDescription( const std::string& rcString, |
---|
| 390 | std::string& rcFDString, |
---|
| 391 | size_t& ruiStartPos ) |
---|
| 392 | { |
---|
| 393 | ROTS( ruiStartPos >= rcString.length()-1 ); |
---|
| 394 | size_t uiUnderScorePos = rcString.find_first_of( std::string("_"), ruiStartPos+1 ) ; |
---|
| 395 | ROT( uiUnderScorePos == std::string::npos ) ; |
---|
| 396 | size_t uiEndPos = rcString.find_first_of( sm_cSetOfTypes, uiUnderScorePos+1 ); |
---|
| 397 | |
---|
| 398 | rcFDString = rcString.substr( ruiStartPos, uiEndPos - ruiStartPos ); |
---|
| 399 | ruiStartPos = uiEndPos; |
---|
| 400 | |
---|
| 401 | return Err::m_nOK; |
---|
| 402 | } |
---|
| 403 | |
---|
| 404 | ErrVal |
---|
| 405 | TEncFormattedStringParser::getNumberOfParts( const std::string& rcString, |
---|
| 406 | UInt& ruiNumberOfParts ) |
---|
| 407 | { |
---|
| 408 | size_t uiPos = rcString.find_first_of( sm_cSetOfPartStart ); |
---|
| 409 | ruiNumberOfParts = 0; |
---|
| 410 | |
---|
| 411 | while( uiPos != std::string::npos ) |
---|
| 412 | { |
---|
| 413 | ruiNumberOfParts++; |
---|
| 414 | |
---|
| 415 | if( rcString[uiPos] == '*' ) //GT: Exclude sub-parts |
---|
| 416 | { |
---|
| 417 | size_t uiEndPos = rcString.find( '{', uiPos+1 ); |
---|
| 418 | UInt uiOpenBrackets = 1; |
---|
| 419 | ROTS( uiEndPos == std::string::npos ); |
---|
| 420 | |
---|
| 421 | while( uiOpenBrackets ) |
---|
| 422 | { |
---|
| 423 | uiEndPos = rcString.find_first_of( "{}", uiEndPos+1 ); |
---|
| 424 | ROTS( uiEndPos == std::string::npos ); |
---|
| 425 | |
---|
| 426 | if( rcString[uiEndPos] == '{' ) uiOpenBrackets++; |
---|
| 427 | else uiOpenBrackets--; |
---|
| 428 | } |
---|
| 429 | |
---|
| 430 | uiPos = rcString.find_first_of( sm_cSetOfPartStart, uiEndPos + 1 ); |
---|
| 431 | } |
---|
| 432 | else |
---|
| 433 | { |
---|
| 434 | uiPos = rcString.find( '*', uiPos+1 ); |
---|
| 435 | } |
---|
| 436 | } |
---|
| 437 | |
---|
| 438 | return Err::m_nOK; |
---|
| 439 | } |
---|
| 440 | |
---|
| 441 | ErrVal |
---|
| 442 | TEncFormattedStringParser::extractPart( const std::string& rcString, |
---|
| 443 | std::string& rcPartString, |
---|
| 444 | size_t& ruiStartPos ) |
---|
| 445 | { |
---|
| 446 | ROTS( ruiStartPos >= rcString.length()-1 ); |
---|
| 447 | |
---|
| 448 | size_t uiNextStartPos; |
---|
| 449 | |
---|
| 450 | if( rcString[ruiStartPos] == '*' ) |
---|
| 451 | { |
---|
| 452 | size_t uiEndPos = rcString.find( '{', ruiStartPos+1 ); |
---|
| 453 | UInt uiOpenBrackets = 1; |
---|
| 454 | ROTS( uiEndPos == std::string::npos ); |
---|
| 455 | |
---|
| 456 | while( uiOpenBrackets ) |
---|
| 457 | { |
---|
| 458 | uiEndPos = rcString.find_first_of( "{}", uiEndPos+1 ); |
---|
| 459 | ROTS( uiEndPos == std::string::npos ); |
---|
| 460 | |
---|
| 461 | if( rcString[uiEndPos] == '{' ) uiOpenBrackets++; |
---|
| 462 | else uiOpenBrackets--; |
---|
| 463 | } |
---|
| 464 | |
---|
| 465 | uiNextStartPos = rcString.find_first_of( sm_cSetOfPartStart, uiEndPos + 1 ); |
---|
| 466 | } |
---|
| 467 | else |
---|
| 468 | { |
---|
| 469 | uiNextStartPos = rcString.find( '*', ruiStartPos+1 ); |
---|
| 470 | } |
---|
| 471 | |
---|
| 472 | rcPartString = rcString.substr( ruiStartPos, uiNextStartPos - ruiStartPos ); |
---|
| 473 | ruiStartPos = uiNextStartPos; |
---|
| 474 | |
---|
| 475 | return Err::m_nOK; |
---|
| 476 | } |
---|
| 477 | |
---|
| 478 | ErrVal TEncFormattedStringParser::extractHighestLayerOfGOPString( const std::string &rcString, UInt &ruiLayer ) |
---|
| 479 | { |
---|
| 480 | std::string::size_type uiPos = 0; |
---|
| 481 | ruiLayer = 0; |
---|
| 482 | |
---|
| 483 | while( ( uiPos = rcString.find_first_of( 'L', uiPos ) ) != std::string::npos ) |
---|
| 484 | { |
---|
| 485 | uiPos++; |
---|
| 486 | |
---|
| 487 | UInt ui = 0; |
---|
| 488 | RNOK( xExtractUInt( rcString, ui, uiPos ) ); |
---|
| 489 | if( ui > ruiLayer ) |
---|
| 490 | ruiLayer = ui; |
---|
| 491 | } |
---|
| 492 | return Err::m_nOK; |
---|
| 493 | } |
---|
| 494 | |
---|
| 495 | |
---|