Changeset 1246 in SHVCSoftware for branches/SHM-dev/source/App


Ignore:
Timestamp:
14 Jul 2015, 00:26:07 (9 years ago)
Author:
seregin
Message:

port rev 4240

Location:
branches/SHM-dev/source/App
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • branches/SHM-dev/source/App/TAppDecoder/TAppDecCfg.cpp

    r1203 r1246  
    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. 
     4 * granted under this license.
    55 *
    66 * Copyright (c) 2010-2014, ITU/ISO/IEC
     
    123123  ("ForceDecodeBitDepth",       m_forceDecodeBitDepth,                 0U,         "Force the decoder to operate at a particular bit-depth (best effort decoding)")
    124124#endif
     125  ("OutputDecodedSEIMessagesFilename",  m_outputDecodedSEIMessagesFilename,    string(""), "When non empty, output decoded SEI messages to the indicated file. If file is '-', then output to stdout\n")
    125126#if Q0074_COLOUR_REMAPPING_SEI
    126127  ("SEIColourRemappingInfo,-cri", m_colourRemapSEIEnabled, false, "Control handling of Colour Remapping Information SEI messages\n"
     
    249250      }
    250251      fclose (targetDecLayerIdSetFile);
     252      if ( m_targetDecLayerIdSet.size() > 0 && !isLayerIdZeroIncluded )
     253      {
     254        fprintf(stderr, "TargetDecLayerIdSet must contain LayerId=0, aborting" );
     255        return false;
     256      }
    251257    }
    252258    else
  • branches/SHM-dev/source/App/TAppDecoder/TAppDecCfg.h

    r1203 r1246  
    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. 
     4 * granted under this license.
    55 *
    66 * Copyright (c) 2010-2014, ITU/ISO/IEC
     
    116116  {
    117117    for (UInt channelTypeIndex = 0; channelTypeIndex < MAX_NUM_CHANNEL_TYPE; channelTypeIndex++)
     118    {
    118119      m_outputBitDepth[channelTypeIndex] = 0;
     120    }
    119121  }
    120122
  • branches/SHM-dev/source/App/TAppDecoder/TAppDecTop.cpp

    r1237 r1246  
    324324        for (UInt channelType = 0; channelType < MAX_NUM_CHANNEL_TYPE; channelType++)
    325325        {
    326           if (m_outputBitDepth[channelType] == 0) m_outputBitDepth[channelType] = g_bitDepth[channelType];
     326          if (m_outputBitDepth[channelType] == 0)
     327          {
     328            m_outputBitDepth[channelType] = g_bitDepth[channelType];
     329          }
    327330        }
    328331        m_acTVideoIOYuvReconFile[curLayerId].open( m_pchReconFile[curLayerId], true, m_outputBitDepth, m_outputBitDepth, g_bitDepth ); // write mode
     
    540543        for (UInt channelType = 0; channelType < MAX_NUM_CHANNEL_TYPE; channelType++)
    541544        {
    542           if (m_outputBitDepth[channelType] == 0) m_outputBitDepth[channelType] = g_bitDepth[channelType];
     545          if (m_outputBitDepth[channelType] == 0)
     546          {
     547            m_outputBitDepth[channelType] = g_bitDepth[channelType];
     548          }
    543549        }
    544550
  • branches/SHM-dev/source/App/TAppDecoder/decmain.cpp

    r1029 r1246  
    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. 
     4 * granted under this license.
    55 *
    66 * Copyright (c) 2010-2014, ITU/ISO/IEC
  • branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.cpp

    r1235 r1246  
    558558      pStr=eptr;
    559559      for(;isspace(*pStr);pStr++);
    560       if (*pStr == ',') pStr++;
     560      if (*pStr == ',')
     561      {
     562        pStr++;
     563      }
    561564      for(;isspace(*pStr);pStr++);
    562565    }
     
    604607      pStr=eptr;
    605608      for(;isspace(*pStr);pStr++);
    606       if (*pStr == ',') pStr++;
     609      if (*pStr == ',')
     610      {
     611        pStr++;
     612      }
    607613      for(;isspace(*pStr);pStr++);
    608614    }
     
    650656      pStr=eptr;
    651657      for(;isspace(*pStr);pStr++);
    652       if (*pStr == ',') pStr++;
     658      if (*pStr == ',')
     659      {
     660        pStr++;
     661      }
    653662      for(;isspace(*pStr);pStr++);
    654663    }
     
    673682  // Try to choose profile, according to table in Q1013.
    674683  UInt trialBitDepthConstraint=maxBitDepth;
    675   if (trialBitDepthConstraint<8) trialBitDepthConstraint=8;
    676   else if (trialBitDepthConstraint==9 || trialBitDepthConstraint==11) trialBitDepthConstraint++;
    677   else if (trialBitDepthConstraint>12) trialBitDepthConstraint=16;
     684  if (trialBitDepthConstraint<8)
     685  {
     686    trialBitDepthConstraint=8;
     687  }
     688  else if (trialBitDepthConstraint==9 || trialBitDepthConstraint==11)
     689  {
     690    trialBitDepthConstraint++;
     691  }
     692  else if (trialBitDepthConstraint>12)
     693  {
     694    trialBitDepthConstraint=16;
     695  }
    678696
    679697  // both format and bit depth constraints are unspecified
     
    713731    bitDepthConstraint = trialBitDepthConstraint;
    714732    chromaFormatConstraint = chromaFormat;
    715     if (bUsingChromaQPAdjustment && chromaFormat == CHROMA_420) chromaFormatConstraint = CHROMA_422; // 4:2:0 cannot use the chroma qp tool.
    716     if (chromaFormatConstraint == CHROMA_422 && bitDepthConstraint == 8) bitDepthConstraint = 10; // there is no 8-bit 4:2:2 profile.
    717     if (chromaFormatConstraint == CHROMA_420 && !bIntraConstraintFlag) bitDepthConstraint = 12; // there is no 8 or 10-bit 4:2:0 inter RExt profile.
     733    if (bUsingChromaQPAdjustment && chromaFormat == CHROMA_420)
     734    {
     735      chromaFormatConstraint = CHROMA_422; // 4:2:0 cannot use the chroma qp tool.
     736    }
     737    if (chromaFormatConstraint == CHROMA_422 && bitDepthConstraint == 8)
     738    {
     739      bitDepthConstraint = 10; // there is no 8-bit 4:2:2 profile.
     740    }
     741    if (chromaFormatConstraint == CHROMA_420 && !bIntraConstraintFlag)
     742    {
     743      bitDepthConstraint = 12; // there is no 8 or 10-bit 4:2:0 inter RExt profile.
     744    }
    718745  }
    719746}
     
    16511678  ;
    16521679
    1653   for(Int i=1; i<MAX_GOP+1; i++) {
     1680  for(Int i=1; i<MAX_GOP+1; i++)
     1681  {
    16541682    std::ostringstream cOSS;
    16551683    cOSS<<"Frame"<<i;
     
    17661794      m_tileColumnWidth.resize(m_numTileColumnsMinus1);
    17671795      for(UInt i=0; i<cfg_ColumnWidth.values.size(); i++)
     1796      {
    17681797        m_tileColumnWidth[i]=cfg_ColumnWidth.values[i];
     1798      }
    17691799    }
    17701800  }
     
    17901820      m_tileRowHeight.resize(m_numTileRowsMinus1);
    17911821      for(UInt i=0; i<cfg_RowHeight.values.size(); i++)
     1822      {
    17921823        m_tileRowHeight[i]=cfg_RowHeight.values[i];
     1824      }
    17931825    }
    17941826  }
     
    19271959#else
    19281960 /* rules for input, output and internal bitdepths as per help text */
    1929   if (m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA  ] == 0) { m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA  ] = m_inputBitDepth      [CHANNEL_TYPE_LUMA  ]; }
    1930   if (m_MSBExtendedBitDepth[CHANNEL_TYPE_CHROMA] == 0) { m_MSBExtendedBitDepth[CHANNEL_TYPE_CHROMA] = m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA  ]; }
    1931   if (m_internalBitDepth   [CHANNEL_TYPE_LUMA  ] == 0) { m_internalBitDepth   [CHANNEL_TYPE_LUMA  ] = m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA  ]; }
    1932   if (m_internalBitDepth   [CHANNEL_TYPE_CHROMA] == 0) { m_internalBitDepth   [CHANNEL_TYPE_CHROMA] = m_internalBitDepth   [CHANNEL_TYPE_LUMA  ]; }
    1933   if (m_inputBitDepth      [CHANNEL_TYPE_CHROMA] == 0) { m_inputBitDepth      [CHANNEL_TYPE_CHROMA] = m_inputBitDepth      [CHANNEL_TYPE_LUMA  ]; }
    1934   if (m_outputBitDepth     [CHANNEL_TYPE_LUMA  ] == 0) { m_outputBitDepth     [CHANNEL_TYPE_LUMA  ] = m_internalBitDepth   [CHANNEL_TYPE_LUMA  ]; }
    1935   if (m_outputBitDepth     [CHANNEL_TYPE_CHROMA] == 0) { m_outputBitDepth     [CHANNEL_TYPE_CHROMA] = m_internalBitDepth   [CHANNEL_TYPE_CHROMA]; }
     1961  if (m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA  ] == 0)
     1962  {
     1963    m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA  ] = m_inputBitDepth      [CHANNEL_TYPE_LUMA  ];
     1964  }
     1965  if (m_MSBExtendedBitDepth[CHANNEL_TYPE_CHROMA] == 0)
     1966  {
     1967    m_MSBExtendedBitDepth[CHANNEL_TYPE_CHROMA] = m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA  ];
     1968  }
     1969  if (m_internalBitDepth   [CHANNEL_TYPE_LUMA  ] == 0)
     1970  {
     1971    m_internalBitDepth   [CHANNEL_TYPE_LUMA  ] = m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA  ];
     1972  }
     1973  if (m_internalBitDepth   [CHANNEL_TYPE_CHROMA] == 0)
     1974  {
     1975    m_internalBitDepth   [CHANNEL_TYPE_CHROMA] = m_internalBitDepth   [CHANNEL_TYPE_LUMA  ];
     1976  }
     1977  if (m_inputBitDepth      [CHANNEL_TYPE_CHROMA] == 0)
     1978  {
     1979    m_inputBitDepth      [CHANNEL_TYPE_CHROMA] = m_inputBitDepth      [CHANNEL_TYPE_LUMA  ];
     1980  }
     1981  if (m_outputBitDepth     [CHANNEL_TYPE_LUMA  ] == 0)
     1982  {
     1983    m_outputBitDepth     [CHANNEL_TYPE_LUMA  ] = m_internalBitDepth   [CHANNEL_TYPE_LUMA  ];
     1984  }
     1985  if (m_outputBitDepth     [CHANNEL_TYPE_CHROMA] == 0)
     1986  {
     1987    m_outputBitDepth     [CHANNEL_TYPE_CHROMA] = m_internalBitDepth   [CHANNEL_TYPE_CHROMA];
     1988  }
    19361989
    19371990  m_InputChromaFormatIDC = numberToChromaFormat(tmpInputChromaFormat);
     
    19632016  if (m_profile == Profile::HIGHTHROUGHPUTREXT )
    19642017  {
    1965     if (m_bitDepthConstraint == 0) m_bitDepthConstraint = 16;
     2018    if (m_bitDepthConstraint == 0)
     2019    {
     2020      m_bitDepthConstraint = 16;
     2021    }
    19662022    m_chromaFormatConstraint = (tmpConstraintChromaFormat == 0) ? CHROMA_444 : numberToChromaFormat(tmpConstraintChromaFormat);
    19672023  }
     
    25812637      while ( iPOC < m_framesToBeEncoded )
    25822638      {
    2583         if ( fscanf(fpt, "%d", &iValue ) == EOF ) break;
     2639        if ( fscanf(fpt, "%d", &iValue ) == EOF )
     2640        {
     2641          break;
     2642        }
    25842643        m_aidQP[ iPOC ] = iValue;
    25852644        iPOC++;
     
    31943253    ui >>= 1;
    31953254    if( (ui & 1) == 1)
     3255    {
    31963256      xConfirmPara( ui != 1 , "Width should be 2^n");
     3257    }
    31973258  }
    31983259  ui = m_uiMaxCUHeight;
     
    32013262    ui >>= 1;
    32023263    if( (ui & 1) == 1)
     3264    {
    32033265      xConfirmPara( ui != 1 , "Height should be 2^n");
     3266    }
    32043267  }
    32053268#endif
     
    40074070  {
    40084071    xConfirmPara( m_kneeSEINumKneePointsMinus1 < 0 || m_kneeSEINumKneePointsMinus1 > 998, "SEIKneeFunctionNumKneePointsMinus1 must be in the range of 0 to 998");
    4009     for ( UInt i=0; i<=m_kneeSEINumKneePointsMinus1; i++ ){
     4072    for ( UInt i=0; i<=m_kneeSEINumKneePointsMinus1; i++ )
     4073    {
    40104074      xConfirmPara( m_kneeSEIInputKneePoint[i] < 1 || m_kneeSEIInputKneePoint[i] > 999, "SEIKneeFunctionInputKneePointValue must be in the range of 1 to 999");
    40114075      xConfirmPara( m_kneeSEIOutputKneePoint[i] < 0 || m_kneeSEIOutputKneePoint[i] > 1000, "SEIKneeFunctionInputKneePointValue must be in the range of 0 to 1000");
     
    42434307  // compute actual CU depth with respect to config depth and max transform size
    42444308  g_uiAddCUDepth  = 0;
    4245   while( (m_uiMaxCUWidth>>m_uiMaxCUDepth) > ( 1 << ( m_uiQuadtreeTULog2MinSize + g_uiAddCUDepth )  ) ) g_uiAddCUDepth++;
     4309  while( (m_uiMaxCUWidth>>m_uiMaxCUDepth) > ( 1 << ( m_uiQuadtreeTULog2MinSize + g_uiAddCUDepth )  ) )
     4310  {
     4311    g_uiAddCUDepth++;
     4312  }
    42464313
    42474314  g_uiAddCUDepth+=getMaxCUDepthOffset(m_chromaFormatIDC, m_uiQuadtreeTULog2MinSize); // if minimum TU larger than 4x4, allow for additional part indices for 4:2:2 SubTUs.
     
    42614328#endif
    42624329    g_PCMBitDepth[channelType] = m_bPCMInputBitDepthFlag ? m_MSBExtendedBitDepth[channelType] : m_internalBitDepth[channelType];
    4263 
    4264     if (m_useExtendedPrecision) g_maxTrDynamicRange[channelType] = std::max<Int>(15, (g_bitDepth[channelType] + 6));
    4265     else                        g_maxTrDynamicRange[channelType] = 15;
     4330    g_maxTrDynamicRange[channelType] = m_useExtendedPrecision? std::max<Int>(15, (g_bitDepth[channelType] + 6)) : 15;
    42664331  }
    42674332
     
    42754340  for (UInt profileIndex = 0; profileIndex < numberOfProfiles; profileIndex++)
    42764341  {
    4277     if (strToProfile[profileIndex].value == profile) return strToProfile[profileIndex].str;
     4342    if (strToProfile[profileIndex].value == profile)
     4343    {
     4344      return strToProfile[profileIndex].str;
     4345    }
    42784346  }
    42794347
     
    43454413    const ExtendedProfileName validProfileName = (bitDepthIdx > 3 || chromaFormatIdx>3) ? NONE : validRExtProfileNames[intraIdx][bitDepthIdx][chromaFormatIdx];
    43464414    std::string rextSubProfile;
    4347     if (validProfileName!=NONE) rextSubProfile=enumToString(strToExtendedProfile, sizeof(strToExtendedProfile)/sizeof(*strToExtendedProfile), validProfileName);
    4348     if (rextSubProfile == "main_444_16") rextSubProfile="main_444_16 [NON STANDARD]";
     4415    if (validProfileName!=NONE)
     4416    {
     4417      rextSubProfile=enumToString(strToExtendedProfile, sizeof(strToExtendedProfile)/sizeof(*strToExtendedProfile), validProfileName);
     4418    }
     4419    if (rextSubProfile == "main_444_16")
     4420    {
     4421      rextSubProfile="main_444_16 [NON STANDARD]";
     4422    }
    43494423    printf("Profile                           : %s (%s)\n", profileToString(m_profile), (rextSubProfile.empty())?"INVALID REXT PROFILE":rextSubProfile.c_str() );
    43504424  }
     
    45114585{
    45124586  if (!bflag)
     4587  {
    45134588    return false;
     4589  }
    45144590
    45154591  printf("Error: %s\n",message);
  • branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp

    r1237 r1246  
    571571    m_acTEncTop[layer].setTimeCodeSEIEnabled                                ( m_timeCodeSEIEnabled );
    572572    m_acTEncTop[layer].setNumberOfTimeSets                                  ( m_timeCodeSEINumTs );
    573     for(Int i = 0; i < m_timeCodeSEINumTs; i++) { m_acTEncTop[layer].setTimeSet(m_timeSetArray[i], i); }
     573    for(Int i = 0; i < m_timeCodeSEINumTs; i++)
     574    {
     575      m_acTEncTop[layer].setTimeSet(m_timeSetArray[i], i);
     576    }
    574577    m_acTEncTop[layer].setKneeSEIEnabled                                    ( m_kneeSEIEnabled );
    575578    m_acTEncTop[layer].setKneeSEIId                                         ( m_kneeSEIId );
     
    979982  m_cTEncTop.setTimeCodeSEIEnabled                                ( m_timeCodeSEIEnabled );
    980983  m_cTEncTop.setNumberOfTimeSets                                  ( m_timeCodeSEINumTs );
    981   for(Int i = 0; i < m_timeCodeSEINumTs; i++) { m_cTEncTop.setTimeSet(m_timeSetArray[i], i); }
     984  for(Int i = 0; i < m_timeCodeSEINumTs; i++)
     985  {
     986    m_cTEncTop.setTimeSet(m_timeSetArray[i], i);
     987  }
    982988  m_cTEncTop.setKneeSEIEnabled                                    ( m_kneeSEIEnabled );
    983989  m_cTEncTop.setKneeSEIId                                         ( m_kneeSEIId );
     
    18321838#endif
    18331839        // call encoding function for one frame
    1834         if ( m_isField ) m_acTEncTop[layer].encode( flush ? 0 : pcPicYuvOrg[layer], snrCSC, m_acListPicYuvRec[layer], outputAccessUnits, iPicIdInGOP, m_isTopFieldFirst );
    1835         else             m_acTEncTop[layer].encode( flush ? 0 : pcPicYuvOrg[layer], snrCSC, m_acListPicYuvRec[layer], outputAccessUnits, iPicIdInGOP );
     1840        if ( m_isField )
     1841        {
     1842          m_acTEncTop[layer].encode( flush ? 0 : pcPicYuvOrg[layer], snrCSC, m_acListPicYuvRec[layer], outputAccessUnits, iPicIdInGOP, m_isTopFieldFirst );
     1843        }
     1844        else
     1845        {
     1846          m_acTEncTop[layer].encode( flush ? 0 : pcPicYuvOrg[layer], snrCSC, m_acListPicYuvRec[layer], outputAccessUnits, iPicIdInGOP );
     1847        }
    18361848      }
    18371849    }
     
    20932105
    20942106    // call encoding function for one frame
    2095     if ( m_isField ) m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, flush ? 0 : &cPicYuvTrueOrg, snrCSC, m_cListPicYuvRec, outputAccessUnits, iNumEncoded, m_isTopFieldFirst );
    2096     else             m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, flush ? 0 : &cPicYuvTrueOrg, snrCSC, m_cListPicYuvRec, outputAccessUnits, iNumEncoded );
     2107    if ( m_isField )
     2108    {
     2109      m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, flush ? 0 : &cPicYuvTrueOrg, snrCSC, m_cListPicYuvRec, outputAccessUnits, iNumEncoded, m_isTopFieldFirst );
     2110    }
     2111    else
     2112    {
     2113      m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, flush ? 0 : &cPicYuvTrueOrg, snrCSC, m_cListPicYuvRec, outputAccessUnits, iNumEncoded );
     2114    }
    20972115
    20982116    // write bistream to file if necessary
  • branches/SHM-dev/source/App/utils/BitrateTargeting/ExtractBitrates.cpp

    r595 r1246  
    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. 
     4 * granted under this license.
    55 *
    66 * Copyright (c) 2010-2014, ITU/ISO/IEC
     
    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}
  • branches/SHM-dev/source/App/utils/BitrateTargeting/ExtractBitrates.h

    r1029 r1246  
    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. 
     4 * granted under this license.
    55 *
    66 * Copyright (c) 2010-2014, ITU/ISO/IEC
     
    4444    POCParseException( const std::string& pocLine ): m_pocLine( pocLine ) { }
    4545    virtual ~POCParseException( ) throw ( ) { }
    46  
     46
    4747  protected:
    4848    void outputWhat( std::ostream& o ) const { o << "POC parse exception: " << m_pocLine; }
    49  
     49
    5050  private:
    5151    std::string m_pocLine;
     
    5757  public:
    5858    virtual ~NonContiguousQPSetException( ) throw( ) { }
    59  
     59
    6060  protected:
    6161    void outputWhat( std::ostream& o ) const { o << "Non-contiguous QP set exception"; }
  • branches/SHM-dev/source/App/utils/BitrateTargeting/ExtractBitratesMain.cpp

    r595 r1246  
    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. 
     4 * granted under this license.
    55 *
    66 * Copyright (c) 2010-2014, ITU/ISO/IEC
     
    4444  assert( 2 == toFind.size( ) );
    4545  assert( 'e' == toFind[ 0 ] );
    46  
     46
    4747  std::string::size_type pos( out.find( toFind ) );
    4848  assert( pos != std::string::npos );
     
    5757  oss << std::scientific << right;
    5858  std::string s( oss.str( ) );
    59  
     59
    6060  replaceWithE( s, "e+" );
    6161  replaceWithE( s, "e0" );
    62  
     62
    6363  left << s;
    6464}
     
    6969  {
    7070    std::vector< double > result( extractBitratesForTemporalLayers( std::cin ) );  // Extract the bitrate vector
    71    
     71
    7272    // Output the bitrate vector
    7373    if( 0 < result.size( ) )
     
    8989      }
    9090    }
    91    
     91
    9292    return 0;
    9393  }
  • branches/SHM-dev/source/App/utils/BitrateTargeting/GuessLambdaModifiers.cpp

    r595 r1246  
    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. 
     4 * granted under this license.
    55 *
    66 * Copyright (c) 2010-2014, ITU/ISO/IEC
     
    4646  {
    4747    assert( right.empty( ) );
    48    
     48
    4949    for( ; ; )
    5050    {
    5151      assert( left.good( ) );
    52      
     52
    5353      double bitrate;
    5454      left >> bitrate;
    55       if( left.fail( ) ) break;
     55      if( left.fail( ) )
     56      {
     57        break;
     58      }
    5659      if( bitrate <= ( double )0.0 )
    5760      {
     
    6265        right.push_back( bitrate );
    6366      }
    64       if( !left.good( ) ) break;
    65      
     67      if( !left.good( ) )
     68      {
     69        break;
     70      }
     71
    6672      if( left.peek( ) == ' ' )
    6773      {
     
    7480    }
    7581  }
    76  
     82
    7783  /// Makes a next guess for a single Lambda-modifier based on only one previous guess
    7884  /// \param initialAdjustmentParameter The proportionality to use between the target bitrate and the previous guess
     
    8894    assert( ( double )0.0 < previousPoint.lambdaModifier );
    8995    assert( ( double )0.0 < previousPoint.bitrate );
    90    
     96
    9197    double extrapolated( previousPoint.lambdaModifier * targetBitrate / previousPoint.bitrate );
    9298    return previousPoint.lambdaModifier + initialAdjustmentParameter * ( extrapolated - previousPoint.lambdaModifier );
     
    102108  assert( point1.lambdaModifier != point2.lambdaModifier );
    103109  assert( point1.bitrate != point2.bitrate );
    104  
     110
    105111  // Calculate and return the result
    106112  double denominator( point1.bitrate - point2.bitrate );
     
    119125  assert( interDampeningFactor <= ( double )1.0 );
    120126  assert( !pointList.empty( ) );
    121  
     127
    122128  double preliminaryResult;
    123  
     129
    124130  if( 1 == pointList.size( ) )  // If there is only one prevous point, then we cannot interpolate, so we call incrementLambdaModifier
    125131  {
     
    132138    ++i;
    133139    Point point2 = *i;
    134    
     140
    135141    // If the slope is either horizontal or vertical, we cannot interpolate
    136142    if( point1.lambdaModifier == point2.lambdaModifier || point1.bitrate == point2.bitrate )
     
    143149    }
    144150  }
    145  
     151
    146152  double previousResult( pointList.back( ).lambdaModifier );
    147  
     153
    148154  // Apply "intra dampening"
    149155  {
     
    159165    }
    160166  }
    161  
     167
    162168  // Apply "inter dampening factor".  If necessary, reduce the factor until a positive result is acheived.
    163169  double result;
     
    180186    return result;
    181187  }
    182  
     188
    183189  /// Calculates the inter dampening factor based
    184190  /// \param parameter The inter dampening parameter which determines how severely the inter dampening factor is affected by Lambda-modifier changes at previous temporal layers
     
    202208  assert( !targetBitrateVector.empty( ) );
    203209  assert( !metaLogEntryList.empty( ) );
    204  
     210
    205211  double cumulativeDelta( 0.0 );
    206212  std::vector< double > resultVector;
     
    212218    pointList.push_front( pointFromFullMetaLogEntry( i, *j ) );
    213219    ++j;
    214     if( j != metaLogEntryList.rend( ) ) pointList.push_front( pointFromFullMetaLogEntry( i, *j ) );
    215    
     220    if( j != metaLogEntryList.rend( ) )
     221    {
     222      pointList.push_front( pointFromFullMetaLogEntry( i, *j ) );
     223    }
     224
    216225    // Calculate the new Lambda-modifier guess and add it to the result vector
    217226    const double newLambdaModifier( guessLambdaModifier(
     
    221230        interDampeningFactor( 50.0, cumulativeDelta ) ) );
    222231    resultVector.push_back( newLambdaModifier );
    223    
     232
    224233    // Increment the cumulativeDelta
    225234    const double oldLambdaModifier( pointList.back( ).lambdaModifier );
    226235    cumulativeDelta += std::abs( newLambdaModifier - oldLambdaModifier ) / oldLambdaModifier;
    227236  }
    228  
     237
    229238  return resultVector;
    230239}
     
    240249    while( i.good( ) && character != i.get( ) )
    241250      ;
    242     if( !i.good( ) ) throw MetaLogParseException( );
    243   }
    244  
     251    if( !i.good( ) )
     252    {
     253      throw MetaLogParseException( );
     254    }
     255  }
     256
    245257  /// Parses a Lambda-modifier map
    246258  /// \param right The map to write the output to
     
    250262    {
    251263      assert( left.good( ) );
    252      
     264
    253265      // Ignore the "-LM"
    254       if( '-' != left.get( ) ) left.setstate( std::istream::failbit );
    255       if( !left.good( ) ) break;
    256       if( 'L' != left.get( ) ) left.setstate( std::istream::failbit );
    257       if( !left.good( ) ) break;
    258       if( 'M' != left.get( ) ) left.setstate( std::istream::failbit );
    259       if( !left.good( ) ) break;
    260      
     266      if( '-' != left.get( ) )
     267      {
     268        left.setstate( std::istream::failbit );
     269      }
     270      if( !left.good( ) )
     271      {
     272        break;
     273      }
     274      if( 'L' != left.get( ) )
     275      {
     276        left.setstate( std::istream::failbit );
     277      }
     278      if( !left.good( ) )
     279      {
     280        break;
     281      }
     282      if( 'M' != left.get( ) )
     283      {
     284        left.setstate( std::istream::failbit );
     285      }
     286      if( !left.good( ) )
     287      {
     288        break;
     289      }
     290
    261291      // Parse the index
    262292      long indexLong;
    263293      left >> indexLong;
    264       if( !left.good( ) ) break;
    265       if( indexLong < std::numeric_limits< unsigned char >::min( ) ) left.setstate( std::istream::failbit );
    266       if( std::numeric_limits< unsigned char >::max( ) < indexLong ) left.setstate( std::istream::failbit );
    267       if( !left.good( ) ) break;
     294      if( !left.good( ) )
     295      {
     296        break;
     297      }
     298      if( indexLong < std::numeric_limits< unsigned char >::min( ) )
     299      {
     300        left.setstate( std::istream::failbit );
     301      }
     302      if( std::numeric_limits< unsigned char >::max( ) < indexLong )
     303      {
     304        left.setstate( std::istream::failbit );
     305      }
     306      if( !left.good( ) )
     307      {
     308        break;
     309      }
    268310      unsigned char index( ( unsigned char )indexLong );
    269      
    270       if( ' ' != left.get( ) ) left.setstate( std::istream::failbit );
    271       if( !left.good( ) ) break;
    272      
     311
     312      if( ' ' != left.get( ) )
     313      {
     314        left.setstate( std::istream::failbit );
     315      }
     316      if( !left.good( ) )
     317      {
     318        break;
     319      }
     320
    273321      // Parse the Lambda-modifier
    274322      double lambdaModifier;
     
    282330        right[ index ] = lambdaModifier;
    283331      }
    284       if( !left.good( ) ) break;
    285      
     332      if( !left.good( ) )
     333      {
     334        break;
     335      }
     336
    286337      // If we peek and see a space, then there should be more Lambda-modifiers to parse.  Otherwise, we are finished.
    287338      if( left.peek( ) == ' ' )
     
    295346    }
    296347  }
    297  
     348
    298349  /// Extracts the indexes from the given maps
    299350  /// \return The set of indexes
     
    322373    throw InitialAdjustmentParameterParseException( );
    323374  }
    324  
     375
    325376  // Parse the targets
    326377  std::vector< double > targetVector;
    327378  parseBitrateVector( targetsIstream, targetVector );
    328   if( targetVector.empty( ) || targetsIstream.fail( ) || targetsIstream.good( ) ) throw TargetsParseException( );
    329  
     379  if( targetVector.empty( ) || targetsIstream.fail( ) || targetsIstream.good( ) )
     380  {
     381    throw TargetsParseException( );
     382  }
     383
    330384  // Parse the metalog
    331385  std::list< MetaLogEntry< std::map< unsigned char, double > > > metaLogEntryList;
     
    335389    MetaLogEntry< std::map< unsigned char, double > > entry;
    336390    parseLambdaModifierMap( metaLogIstream, entry.lambdaModifiers );
    337     if( !metaLogIstream.good( ) ) throw MetaLogParseException( );
    338    
     391    if( !metaLogIstream.good( ) )
     392    {
     393      throw MetaLogParseException( );
     394    }
     395
    339396    // Skip the ';'
    340     if( ';' != metaLogIstream.get( ) ) throw MetaLogParseException( );
    341     if( !metaLogIstream.good( ) ) throw MetaLogParseException( );
    342    
     397    if( ';' != metaLogIstream.get( ) )
     398    {
     399      throw MetaLogParseException( );
     400    }
     401    if( !metaLogIstream.good( ) )
     402    {
     403      throw MetaLogParseException( );
     404    }
     405
    343406    // Parse the bitrates
    344407    parseBitrateVector( metaLogIstream, entry.bitrateVector );
    345     if( metaLogIstream.fail( ) ) throw MetaLogParseException( );
     408    if( metaLogIstream.fail( ) )
     409    {
     410      throw MetaLogParseException( );
     411    }
    346412    metaLogEntryList.push_back( entry );
    347    
    348     if( !metaLogIstream.good( ) ) break;
    349     if( metaLogIstream.get( ) != '\n' ) throw MetaLogParseException( );
     413
     414    if( !metaLogIstream.good( ) )
     415    {
     416      break;
     417    }
     418    if( metaLogIstream.get( ) != '\n' )
     419    {
     420      throw MetaLogParseException( );
     421    }
    350422    metaLogIstream.peek( );
    351423  } while( metaLogIstream.good( ) );
    352   if( metaLogEntryList.empty( ) ) throw MetaLogParseException( );  // The meta-log should not be empty
    353  
     424  if( metaLogEntryList.empty( ) )
     425  {
     426    throw MetaLogParseException( );  // The meta-log should not be empty
     427  }
     428
    354429  // Initialize firstIndexVector and check that the sizes and indexes match
    355430  std::set< unsigned char > firstIndexSet( indexSetFromMap( metaLogEntryList.front( ).lambdaModifiers ) );
    356   if( firstIndexSet.size( ) != targetVector.size( ) ) throw MismatchedIndexesException( );
     431  if( firstIndexSet.size( ) != targetVector.size( ) )
     432  {
     433    throw MismatchedIndexesException( );
     434  }
    357435  for( std::list< MetaLogEntry< std::map< unsigned char, double > > >::const_iterator i( metaLogEntryList.begin( ) );
    358436      i != metaLogEntryList.end( );
    359437      ++i )
    360438  {
    361     if( indexSetFromMap( i->lambdaModifiers ) != firstIndexSet ) throw MismatchedIndexesException( );
    362     if( i->bitrateVector.size( ) != targetVector.size( ) ) throw MismatchedIndexesException( );
    363   }
    364  
     439    if( indexSetFromMap( i->lambdaModifiers ) != firstIndexSet )
     440    {
     441      throw MismatchedIndexesException( );
     442    }
     443    if( i->bitrateVector.size( ) != targetVector.size( ) )
     444    {
     445      throw MismatchedIndexesException( );
     446    }
     447  }
     448
    365449  // Initialize simplifiedMetaLogEntryList
    366450  std::list< MetaLogEntry< std::vector< double > > > simplifiedMetaLogEntryList;
     
    376460    simplifiedMetaLogEntryList.back( ).bitrateVector = i->bitrateVector;
    377461  }
    378  
     462
    379463  // Run the calculations
    380464  std::vector< double > resultVector( guessLambdaModifiers( initialAdjustmentParameter, targetVector, simplifiedMetaLogEntryList ) );
    381  
     465
    382466  // Output the results
    383467  std::set< unsigned char >::const_iterator indexIter( firstIndexSet.begin( ) );
     
    385469  do
    386470  {
    387     if( indexIter != firstIndexSet.begin( ) ) o << " ";
     471    if( indexIter != firstIndexSet.begin( ) )
     472    {
     473      o << " ";
     474    }
    388475    o << "-LM" << ( long )( *indexIter ) << " ";
    389476    o.setf( std::ostream::fixed, std::ostream::floatfield );
    390477    o.precision( 7 );
    391478    o << ( *resultIter );
    392    
     479
    393480    ++indexIter;
    394481    ++resultIter;
  • branches/SHM-dev/source/App/utils/BitrateTargeting/GuessLambdaModifiers.h

    r1029 r1246  
    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. 
     4 * granted under this license.
    55 *
    66 * Copyright (c) 2010-2014, ITU/ISO/IEC
  • branches/SHM-dev/source/App/utils/BitrateTargeting/GuessLambdaModifiersMain.cpp

    r595 r1246  
    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. 
     4 * granted under this license.
    55 *
    66 * Copyright (c) 2010-2014, ITU/ISO/IEC
     
    4949  try
    5050  {
    51     if( argc != 3 ) throw WrongNumberOfArgumentsException( );
    52    
     51    if( argc != 3 )
     52    {
     53      throw WrongNumberOfArgumentsException( );
     54    }
     55
    5356    std::string initialAdjustmentParameterString( ppArgv[ 1 ] );
    5457    std::istringstream initialAdjustmentParameterIstream( initialAdjustmentParameterString );
    55    
     58
    5659    std::string targetBitratesString( ppArgv[ 2 ] );
    5760    std::istringstream targetBitratesIstream( targetBitratesString );
    58    
     61
    5962    guessLambdaModifiers( std::cout, initialAdjustmentParameterIstream, targetBitratesIstream, std::cin );
    6063    return 0;
    61  
     64
    6265  }
    6366  catch( std::exception& e )
  • branches/SHM-dev/source/App/utils/BitrateTargeting/RuntimeError.h

    r1029 r1246  
    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. 
     4 * granted under this license.
    55 *
    66 * Copyright (c) 2010-2014, ITU/ISO/IEC
     
    4444    RuntimeError( ): std::runtime_error( "" ), m_firstWhat( true ) { }
    4545    virtual ~RuntimeError( ) throw ( ) { }
    46    
     46
    4747    /// Implementation of the std::exception::what method
    4848    const char * what( ) const throw( )
     
    5757      return m_what.c_str( );
    5858    }
    59    
     59
    6060  protected:
    6161    /// The implementing class implements this method to customize the what output
    6262    /// \param o The what stream is outputted to this parameter
    6363    virtual void outputWhat( std::ostream & o ) const =0;
    64  
     64
    6565  private:
    6666    mutable bool m_firstWhat;  ///< True i.f.f. the what method has not yet been called
  • branches/SHM-dev/source/App/utils/annexBbytecount.cpp

    r595 r1246  
    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. 
     4 * granted under this license.
    55 *
    66 * Copyright (c) 2010-2014, ITU/ISO/IEC
     
    8686      cout << hex << (unsigned int)tests[i].data[j] << dec;
    8787      if (j < tests[i].data_len-1)
     88      {
    8889        cout << ",";
     90      }
    8991    }
    9092    cout << "} ";
     
    103105#undef VERIFY
    104106    if (ok)
     107    {
    105108      cout << "OK";
     109    }
    106110    cout << endl;
    107111  }
     
    113117
    114118  if (argc != 2)
     119  {
    115120    return 0;
     121  }
    116122
    117123  ifstream in(argv[1], ifstream::in | ifstream::binary);
     
    150156
    151157    if (!annexBStatsSingle.m_numBytesInNALUnit)
     158    {
    152159      continue;
     160    }
    153161
    154162    /* identify the NAL unit type and add stats to the correct
  • branches/SHM-dev/source/App/utils/convert_NtoMbit_YCbCr.cpp

    r1029 r1246  
    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. 
     4 * granted under this license.
    55 *
    66 * Copyright (c) 2010-2014, ITU/ISO/IEC
     
    113113
    114114  UInt num_frames_processed = 0;
    115   while (!input.isEof()) 
     115  while (!input.isEof())
    116116  {
    117117    if (! input.read(&frame, &cPicYuvTrueOrg, IPCOLOURSPACE_UNCHANGED, pad))
     
    124124    {
    125125      for (Int x = 0; x < height; x++)
     126      {
    126127        img[x] = 0;
     128      }
    127129      img += frame.getStride();
    128130    }
     
    134136    num_frames_processed++;
    135137    if (num_frames_processed == num_frames)
     138    {
    136139      break;
     140    }
    137141  }
    138142
Note: See TracChangeset for help on using the changeset viewer.