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/Lib/TLibDecoder/SyntaxElementParser.cpp

    r1179 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. 
     4* granted under this license.
    55*
    66* Copyright (c) 2010-2015, ITU/ISO/IEC
     
    4343#include "TLibCommon/TComBitStream.h"
    4444#include "SyntaxElementParser.h"
     45#if RExt__DECODER_DEBUG_BIT_STATISTICS
     46#include "TLibCommon/TComCodingStatistics.h"
     47#endif
    4548
    4649#if ENC_DEC_TRACE
     
    4851Void  SyntaxElementParser::xReadCodeTr           (UInt length, UInt& rValue, const Char *pSymbolName)
    4952{
     53#if RExt__DECODER_DEBUG_BIT_STATISTICS
     54  xReadCode (length, rValue, pSymbolName);
     55#else
    5056  xReadCode (length, rValue);
     57#endif
    5158#if H_MV_ENC_DEC_TRAC
    5259  if ( g_disableHLSTrace || !g_HLSTraceEnable )
     
    5663  if ( !g_disableNumbering )
    5764  {
    58 #endif
     65    incSymbolCounter();
     66    fprintf( g_hTrace, "%8lld  ", g_nSymbolCounter );
     67  }
     68#else
     69    fprintf( g_hTrace, "%8lld  ", g_nSymbolCounter++ );
     70#endif
     71  if (length < 10)
     72  {
     73    fprintf( g_hTrace, "%-50s u(%d)  : %u\n", pSymbolName, length, rValue );
     74  }
     75  else
     76  {
     77    fprintf( g_hTrace, "%-50s u(%d) : %u\n", pSymbolName, length, rValue );
     78  }
     79  fflush ( g_hTrace );
     80}
     81
     82Void  SyntaxElementParser::xReadUvlcTr           (UInt& rValue, const Char *pSymbolName)
     83{
     84#if RExt__DECODER_DEBUG_BIT_STATISTICS
     85  xReadUvlc (rValue, pSymbolName);
     86#else
     87  xReadUvlc (rValue);
     88#endif
     89#if H_MV_ENC_DEC_TRAC
     90  if ( g_disableHLSTrace || !g_HLSTraceEnable )
     91  {
     92    return;
     93  }
     94  if ( !g_disableNumbering )
     95  {
     96  incSymbolCounter();
     97  fprintf( g_hTrace, "%8lld  ", g_nSymbolCounter );
     98  }
     99#else
    59100  fprintf( g_hTrace, "%8lld  ", g_nSymbolCounter++ );
     101#endif
     102  fprintf( g_hTrace, "%-50s ue(v) : %u\n", pSymbolName, rValue );
     103  fflush ( g_hTrace );
     104}
     105
     106Void  SyntaxElementParser::xReadSvlcTr           (Int& rValue, const Char *pSymbolName)
     107{
     108#if RExt__DECODER_DEBUG_BIT_STATISTICS
     109  xReadSvlc (rValue, pSymbolName);
     110#else
     111  xReadSvlc (rValue);
     112#endif
    60113#if H_MV_ENC_DEC_TRAC
    61   }
    62 #endif
    63 
    64   if (length < 10)
    65   {
    66     fprintf( g_hTrace, "%-50s u(%d)  : %u\n", pSymbolName, length, rValue );
    67   }
    68   else
    69   {
    70     fprintf( g_hTrace, "%-50s u(%d) : %u\n", pSymbolName, length, rValue );
    71   }
     114  if ( g_disableHLSTrace || !g_HLSTraceEnable )
     115  {
     116    return;
     117  }
     118  if ( !g_disableNumbering )
     119  { 
     120    incSymbolCounter();
     121    fprintf( g_hTrace, "%8lld  ", g_nSymbolCounter );
     122  }
     123#else
     124    fprintf( g_hTrace, "%8lld  ", g_nSymbolCounter++ );
     125#endif
     126  fprintf( g_hTrace, "%-50s se(v) : %d\n", pSymbolName, rValue );
    72127  fflush ( g_hTrace );
    73128}
    74129
    75 Void  SyntaxElementParser::xReadUvlcTr           (UInt& rValue, const Char *pSymbolName)
    76 {
    77   xReadUvlc (rValue);
     130Void  SyntaxElementParser::xReadFlagTr           (UInt& rValue, const Char *pSymbolName)
     131{
     132#if RExt__DECODER_DEBUG_BIT_STATISTICS
     133  xReadFlag (rValue, pSymbolName);
     134#else
     135  xReadFlag (rValue);
     136#endif
    78137#if H_MV_ENC_DEC_TRAC
    79   if ( g_disableHLSTrace  || !g_HLSTraceEnable )
     138  if ( g_disableHLSTrace || !g_HLSTraceEnable )
    80139  {
    81140    return;
     
    83142  if ( !g_disableNumbering )
    84143  {
    85 #endif
     144    incSymbolCounter();
     145    fprintf( g_hTrace, "%8lld  ", g_nSymbolCounter );
     146  }
     147#else
    86148  fprintf( g_hTrace, "%8lld  ", g_nSymbolCounter++ );
    87 #if H_MV_ENC_DEC_TRAC
    88   }
    89 #endif
    90   fprintf( g_hTrace, "%-50s ue(v) : %u\n", pSymbolName, rValue );
     149#endif
     150  fprintf( g_hTrace, "%-50s u(1)  : %d\n", pSymbolName, rValue );
    91151  fflush ( g_hTrace );
    92152}
    93153
    94 Void  SyntaxElementParser::xReadSvlcTr           (Int& rValue, const Char *pSymbolName)
    95 {
    96   xReadSvlc(rValue);
    97 #if H_MV_ENC_DEC_TRAC
    98   if ( g_disableHLSTrace  || !g_HLSTraceEnable  )
    99   {
    100     return;
    101   }
    102   if ( !g_disableNumbering )
    103   {
    104 #endif
    105   fprintf( g_hTrace, "%8lld  ", g_nSymbolCounter++ );
    106 #if H_MV_ENC_DEC_TRAC
    107   }
    108 #endif
    109 
    110   fprintf( g_hTrace, "%-50s se(v) : %d\n", pSymbolName, rValue );
    111   fflush ( g_hTrace );
    112 }
    113 
    114 Void  SyntaxElementParser::xReadFlagTr           (UInt& rValue, const Char *pSymbolName)
    115 {
    116   xReadFlag(rValue);
    117 #if H_MV_ENC_DEC_TRAC
    118   if ( g_disableHLSTrace  || !g_HLSTraceEnable )
    119   {
    120     return;
    121   }
    122   if ( !g_disableNumbering )
    123   {
    124 #endif
    125   fprintf( g_hTrace, "%8lld  ", g_nSymbolCounter++ );
    126 #if H_MV_ENC_DEC_TRAC
    127   }
    128 #endif
    129   fprintf( g_hTrace, "%-50s u(1)  : %d\n", pSymbolName, rValue );
    130   fflush ( g_hTrace );
     154Void  xTraceAccessUnitDelimiter ()
     155{
     156  fprintf( g_hTrace, "=========== Access Unit Delimiter ===========\n");
     157}
     158
     159Void xTraceFillerData ()
     160{
     161  fprintf( g_hTrace, "=========== Filler Data ===========\n");
    131162}
    132163
     
    137168// Protected member functions
    138169// ====================================================================================================================
    139 
     170#if RExt__DECODER_DEBUG_BIT_STATISTICS
     171Void SyntaxElementParser::xReadCode (UInt uiLength, UInt& ruiCode, const Char *pSymbolName)
     172#else
    140173Void SyntaxElementParser::xReadCode (UInt uiLength, UInt& ruiCode)
     174#endif
    141175{
    142176  assert ( uiLength > 0 );
    143177  m_pcBitstream->read (uiLength, ruiCode);
    144 }
    145 
     178#if RExt__DECODER_DEBUG_BIT_STATISTICS
     179  TComCodingStatistics::IncrementStatisticEP(pSymbolName, uiLength, ruiCode);
     180#endif
     181}
     182
     183#if RExt__DECODER_DEBUG_BIT_STATISTICS
     184Void SyntaxElementParser::xReadUvlc( UInt& ruiVal, const Char *pSymbolName)
     185#else
    146186Void SyntaxElementParser::xReadUvlc( UInt& ruiVal)
     187#endif
    147188{
    148189  UInt uiVal = 0;
     
    150191  UInt uiLength;
    151192  m_pcBitstream->read( 1, uiCode );
     193#if RExt__DECODER_DEBUG_BIT_STATISTICS
     194  UInt totalLen=1;
     195#endif
    152196
    153197  if( 0 == uiCode )
     
    164208
    165209    uiVal += (1 << uiLength)-1;
     210#if RExt__DECODER_DEBUG_BIT_STATISTICS
     211    totalLen+=uiLength+uiLength;
     212#endif
    166213  }
    167214
    168215  ruiVal = uiVal;
    169 }
    170 
     216#if RExt__DECODER_DEBUG_BIT_STATISTICS
     217  TComCodingStatistics::IncrementStatisticEP(pSymbolName, Int(totalLen), ruiVal);
     218#endif
     219}
     220
     221#if RExt__DECODER_DEBUG_BIT_STATISTICS
     222Void SyntaxElementParser::xReadSvlc( Int& riVal, const Char *pSymbolName)
     223#else
    171224Void SyntaxElementParser::xReadSvlc( Int& riVal)
     225#endif
    172226{
    173227  UInt uiBits = 0;
    174228  m_pcBitstream->read( 1, uiBits );
     229#if RExt__DECODER_DEBUG_BIT_STATISTICS
     230  UInt totalLen=1;
     231#endif
    175232  if( 0 == uiBits )
    176233  {
     
    187244    uiBits += (1 << uiLength);
    188245    riVal = ( uiBits & 1) ? -(Int)(uiBits>>1) : (Int)(uiBits>>1);
     246#if RExt__DECODER_DEBUG_BIT_STATISTICS
     247    totalLen+=uiLength+uiLength;
     248#endif
    189249  }
    190250  else
     
    192252    riVal = 0;
    193253  }
    194 }
    195 
     254#if RExt__DECODER_DEBUG_BIT_STATISTICS
     255  TComCodingStatistics::IncrementStatisticEP(pSymbolName, Int(totalLen), riVal);
     256#endif
     257}
     258
     259#if RExt__DECODER_DEBUG_BIT_STATISTICS
     260Void SyntaxElementParser::xReadFlag (UInt& ruiCode, const Char *pSymbolName)
     261#else
    196262Void SyntaxElementParser::xReadFlag (UInt& ruiCode)
     263#endif
    197264{
    198265  m_pcBitstream->read( 1, ruiCode );
     266#if RExt__DECODER_DEBUG_BIT_STATISTICS
     267  TComCodingStatistics::IncrementStatisticEP(pSymbolName, 1, Int(ruiCode));
     268#endif
     269}
     270
     271Void SyntaxElementParser::xReadRbspTrailingBits()
     272{
     273  UInt bit;
     274  READ_FLAG( bit, "rbsp_stop_one_bit");
     275  assert (bit==1);
     276  Int cnt = 0;
     277  while (m_pcBitstream->getNumBitsUntilByteAligned())
     278  {
     279    READ_FLAG( bit, "rbsp_alignment_zero_bit");
     280    assert (bit==0);
     281    cnt++;
     282  }
     283  assert(cnt<8);
     284}
     285
     286Void AUDReader::parseAccessUnitDelimiter(TComInputBitstream* bs, UInt &picType)
     287{
     288  setBitstream(bs);
     289
     290#if ENC_DEC_TRACE
     291  xTraceAccessUnitDelimiter();
     292#endif
     293
     294  READ_CODE (3, picType, "pic_type");
     295  xReadRbspTrailingBits();
     296}
     297
     298Void FDReader::parseFillerData(TComInputBitstream* bs, UInt &fdSize)
     299{
     300  setBitstream(bs);
     301#if ENC_DEC_TRACE
     302  xTraceFillerData();
     303#endif
     304  UInt ffByte;
     305  fdSize = 0;
     306  while( m_pcBitstream->getNumBitsLeft() >8 )
     307  {
     308    READ_CODE (8, ffByte, "ff_byte");
     309    assert (ffByte==0xff);
     310    fdSize++;
     311  }
     312  xReadRbspTrailingBits();
    199313}
    200314
Note: See TracChangeset for help on using the changeset viewer.