Ignore:
Timestamp:
13 Aug 2015, 17:38:13 (9 years ago)
Author:
tech
Message:

Merged 14.1-update-dev1@1312.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/App/utils/BitrateTargeting/ExtractBitrates.cpp

    r872 r1313  
    22 * License, included below. This software may be subject to other third party
    33 * and contributor rights, including patent rights, and no such rights are
    4  * granted under this license. 
    5  *
    6  * Copyright (c) 2010-2014, ITU/ISO/IEC
     4 * granted under this license.
     5 *
     6 * Copyright (c) 2010-2015, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    4545  {
    4646    public:
    47      
     47
    4848      /// Contructs a new zeroed tally
    4949      Tally( ): m_sum( 0.0 ), m_numSlices( 0 ) { }
    50      
     50
    5151      /// Adds to the sum and increments the sample-count
    5252      void add( double in ) { ++m_numSlices; m_sum += in; }
    53      
     53
    5454      /// \return The calculated average
    5555      double average( ) const { return m_sum / ( double )m_numSlices; }
    56    
     56
    5757    private:
    5858      double m_sum;
    5959      unsigned long m_numSlices;
    6060  };
    61  
     61
    6262  /// Ignores all of the the characters up to and including a given character
    6363  /// \param line The line being read from
     
    6969    while( iLine.good( ) && character != iLine.get( ) )
    7070      ;
    71     if( !iLine.good( ) ) throw POCParseException( line );
     71    if( !iLine.good( ) )
     72    {
     73      throw POCParseException( line );
     74    }
    7275  }
    73  
     76
    7477  /// Extracts the average bitrates for each of the temporal layers from the given log
    7578  /// \param i The input stream that represents the log
     
    7982  {
    8083    std::map< unsigned char, Tally > tallyMap;
    81    
     84
    8285    while( i.good( ) )
    8386    {
     
    8689      std::getline( i, line );
    8790      std::istringstream iLine( line );
    88       if( !iLine.good( ) ) continue;
    89      
     91      if( !iLine.good( ) )
     92      {
     93        continue;
     94      }
     95
    9096      // Ignore the "POC"
    91       if( iLine.get( ) != 'P' ) continue;
    92       if( !iLine.good( ) ) continue;
    93       if( iLine.get( ) != 'O' ) continue;
    94       if( !iLine.good( ) ) continue;
    95       if( iLine.get( ) != 'C' ) continue;
    96       if( !iLine.good( ) ) throw POCParseException( line );
    97      
     97      if( iLine.get( ) != 'P' )
     98      {
     99        continue;
     100      }
     101      if( !iLine.good( ) )
     102      {
     103        continue;
     104      }
     105      if( iLine.get( ) != 'O' )
     106      {
     107        continue;
     108      }
     109      if( !iLine.good( ) )
     110      {
     111        continue;
     112      }
     113      if( iLine.get( ) != 'C' )
     114      {
     115        continue;
     116      }
     117      if( !iLine.good( ) )
     118      {
     119        throw POCParseException( line );
     120      }
     121
    98122      ignoreUpTo( line, iLine, '(' );
    99      
    100       if( iLine.get( ) != ' ' ) throw POCParseException( line );
    101       if( !iLine.good( ) ) throw POCParseException( line );
    102      
    103       if( 'I' == iLine.get( ) ) continue;
    104       if( !iLine.good( ) ) throw POCParseException( line );
    105      
     123
     124      if( iLine.get( ) != ' ' )
     125      {
     126        throw POCParseException( line );
     127      }
     128      if( !iLine.good( ) )
     129      {
     130        throw POCParseException( line );
     131      }
     132
     133      if( 'I' == iLine.get( ) )
     134      {
     135        continue;
     136      }
     137      if( !iLine.good( ) )
     138      {
     139        throw POCParseException( line );
     140      }
     141
    106142      ignoreUpTo( line, iLine, ' ' );
    107143      ignoreUpTo( line, iLine, ' ' );
    108      
     144
    109145      // Parse the qpIndex
    110146      long qpIndexLong;
    111147      iLine >> qpIndexLong;
    112       if( ( long )std::numeric_limits< unsigned char >::max( ) < qpIndexLong ) throw POCParseException( line );
     148      if( ( long )std::numeric_limits< unsigned char >::max( ) < qpIndexLong )
     149      {
     150        throw POCParseException( line );
     151      }
    113152      unsigned char qpIndex( ( unsigned char )qpIndexLong );
    114       if( !iLine.good( ) ) throw POCParseException( line );
    115      
     153      if( !iLine.good( ) )
     154      {
     155        throw POCParseException( line );
     156      }
     157
    116158      ignoreUpTo( line, iLine, ')' );
    117159      ignoreUpTo( line, iLine, ' ' );
    118      
     160
    119161      // Parse the number of bits
    120162      unsigned long bitsULong;
    121163      iLine >> bitsULong;
    122       if( !iLine.good( ) ) throw POCParseException( line );
    123      
     164      if( !iLine.good( ) )
     165      {
     166        throw POCParseException( line );
     167      }
     168
    124169      // Find the tally that corresponds to our QP.  If there is no such tally yet, then add a new one to the map.
    125170      std::map< unsigned char, Tally >::iterator iter( tallyMap.find( qpIndex ) );
     
    130175      }
    131176      assert( iter != tallyMap.end( ) );
    132      
     177
    133178      iter->second.add( ( double )bitsULong );
    134179    }
    135    
     180
    136181    // Populate and return the result based on all of the tallies
    137182    std::map< unsigned char, double > result;
     
    147192{
    148193  std::vector< double > result;
    149  
     194
    150195  std::map< unsigned char, double > bitratesForQPsMap( extractBitratesForQPs( i ) );
    151196  if( !bitratesForQPsMap.empty( ) )
    152197  {
    153198    unsigned char expectedNextQPIndex( bitratesForQPsMap.begin( )->first );
    154    
     199
    155200    for( std::map< unsigned char, double >::const_iterator i( bitratesForQPsMap.begin( ) ); i != bitratesForQPsMap.end( ); ++i )
    156201    {
    157       if( i->first != expectedNextQPIndex ) throw NonContiguousQPSetException( );
     202      if( i->first != expectedNextQPIndex )
     203      {
     204        throw NonContiguousQPSetException( );
     205      }
    158206      ++expectedNextQPIndex;
    159207      result.push_back( i->second );
    160208    }
    161209  }
    162  
     210
    163211  return result;
    164212}
Note: See TracChangeset for help on using the changeset viewer.