49 Tally( ): m_sum( 0.0 ), m_numSlices( 0 ) { }
52 void add(
double in ) { ++m_numSlices; m_sum += in; }
55 double average( )
const {
return m_sum / ( double )m_numSlices; }
59 unsigned long m_numSlices;
67 void ignoreUpTo(
const std::string& line, std::istream& iLine,
char character )
69 while( iLine.good( ) && character != iLine.get( ) )
81 std::map< unsigned char, double > extractBitratesForQPs( std::istream& i )
83 std::map< unsigned char, Tally > tallyMap;
89 std::getline( i, line );
90 std::istringstream iLine( line );
97 if( iLine.get( ) !=
'P' )
105 if( iLine.get( ) !=
'O' )
113 if( iLine.get( ) !=
'C' )
122 ignoreUpTo( line, iLine,
'(' );
124 if( iLine.get( ) !=
' ' )
133 if(
'I' == iLine.get( ) )
142 ignoreUpTo( line, iLine,
' ' );
143 ignoreUpTo( line, iLine,
' ' );
147 iLine >> qpIndexLong;
148 if( (
long )std::numeric_limits< unsigned char >::max( ) < qpIndexLong )
152 unsigned char qpIndex( (
unsigned char )qpIndexLong );
158 ignoreUpTo( line, iLine,
')' );
159 ignoreUpTo( line, iLine,
' ' );
162 unsigned long bitsULong;
170 std::map< unsigned char, Tally >::iterator iter( tallyMap.find( qpIndex ) );
171 if( tallyMap.end( ) == iter )
173 tallyMap[ qpIndex ] = Tally( );
174 iter = tallyMap.find( qpIndex );
176 assert( iter != tallyMap.end( ) );
178 iter->second.add( (
double )bitsULong );
182 std::map< unsigned char, double > result;
183 for( std::map< unsigned char, Tally >::const_iterator iter( tallyMap.begin( ) ); iter != tallyMap.end( ); ++iter )
185 result[ iter->first ] = iter->second.average( );
193 std::vector< double > result;
195 std::map< unsigned char, double > bitratesForQPsMap( extractBitratesForQPs( i ) );
196 if( !bitratesForQPsMap.empty( ) )
198 unsigned char expectedNextQPIndex( bitratesForQPsMap.begin( )->first );
200 for( std::map< unsigned char, double >::const_iterator i( bitratesForQPsMap.begin( ) ); i != bitratesForQPsMap.end( ); ++i )
202 if( i->first != expectedNextQPIndex )
206 ++expectedNextQPIndex;
207 result.push_back( i->second );
An error occured while parsing a POC line from within a log file.
The QP set from the log file was not contiguous. The QP set must be contiguous to be able to convert ...