Changeset 1313 in 3DVCSoftware for trunk/source/Lib/TLibDecoder/NALread.cpp


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/NALread.cpp

    r1179 r1313  
    44 * granted under this license.
    55 *
    6 * Copyright (c) 2010-2015, ITU/ISO/IEC
     6 * Copyright (c) 2010-2015, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    3434/**
    3535 \file     NALread.cpp
    36  \brief    reading funtionality for NAL units
     36 \brief    reading functionality for NAL units
    3737 */
    3838
     
    4545#include "TLibCommon/NAL.h"
    4646#include "TLibCommon/TComBitStream.h"
     47#if RExt__DECODER_DEBUG_BIT_STATISTICS
     48#include "TLibCommon/TComCodingStatistics.h"
     49#endif
     50#if ENC_DEC_TRACE && DEC_NUH_TRACE
     51#include "TLibCommon/TComRom.h"
     52#endif
    4753
    4854using namespace std;
     
    5056//! \ingroup TLibDecoder
    5157//! \{
    52 static void convertPayloadToRBSP(vector<uint8_t>& nalUnitBuf, TComInputBitstream *bitstream, Bool isVclNalUnit)
     58static Void convertPayloadToRBSP(vector<uint8_t>& nalUnitBuf, TComInputBitstream *bitstream, Bool isVclNalUnit)
    5359{
    5460  UInt zeroCount = 0;
     
    6672      it_read++;
    6773      zeroCount = 0;
     74#if RExt__DECODER_DEBUG_BIT_STATISTICS
     75      TComCodingStatistics::IncrementStatisticEP(STATS__EMULATION_PREVENTION_3_BYTES, 8, 0);
     76#endif
    6877      if (it_read == nalUnitBuf.end())
    6978      {
     
    7685  }
    7786  assert(zeroCount == 0);
    78  
     87
    7988  if (isVclNalUnit)
    8089  {
    8190    // Remove cabac_zero_word from payload if present
    8291    Int n = 0;
    83    
     92
    8493    while (it_write[-1] == 0x00)
    8594    {
     
    8796      n++;
    8897    }
    89    
     98
    9099    if (n > 0)
    91100    {
    92       printf("\nDetected %d instances of cabac_zero_word", n/2);     
     101      printf("\nDetected %d instances of cabac_zero_word\n", n/2);
    93102    }
    94103  }
     
    97106}
    98107
     108#if ENC_DEC_TRACE && DEC_NUH_TRACE
     109void xTraceNalUnitHeader(InputNALUnit& nalu)
     110{
     111  fprintf( g_hTrace, "*********** NAL UNIT (%s) ***********\n", nalUnitTypeToString(nalu.m_nalUnitType) );
     112
     113  fprintf( g_hTrace, "%8lld  ", g_nSymbolCounter++ );
     114  fprintf( g_hTrace, "%-50s u(%d)  : %u\n", "forbidden_zero_bit", 1, 0 );
     115
     116  fprintf( g_hTrace, "%8lld  ", g_nSymbolCounter++ );
     117  fprintf( g_hTrace, "%-50s u(%d)  : %u\n", "nal_unit_type", 6, nalu.m_nalUnitType );
     118
     119  fprintf( g_hTrace, "%8lld  ", g_nSymbolCounter++ );
     120  fprintf( g_hTrace, "%-50s u(%d)  : %u\n", "nuh_layer_id", 6, nalu.m_nuhLayerId );
     121
     122  fprintf( g_hTrace, "%8lld  ", g_nSymbolCounter++ );
     123  fprintf( g_hTrace, "%-50s u(%d)  : %u\n", "nuh_temporal_id_plus1", 3, nalu.m_temporalId + 1 );
     124
     125  fflush ( g_hTrace );
     126}
     127#endif
     128
    99129Void readNalUnitHeader(InputNALUnit& nalu)
    100130{
    101   TComInputBitstream& bs = *nalu.m_Bitstream;
     131  TComInputBitstream& bs = nalu.getBitstream();
    102132
    103133  Bool forbidden_zero_bit = bs.read(1);           // forbidden_zero_bit
    104134  assert(forbidden_zero_bit == 0);
    105135  nalu.m_nalUnitType = (NalUnitType) bs.read(6);  // nal_unit_type
    106 #if H_MV
    107   nalu.m_layerId = bs.read(6);                 // layerId
     136#if NH_MV
     137  nalu.m_nuhLayerId = bs.read(6);                 // layerId
    108138#else
    109   nalu.m_reservedZero6Bits = bs.read(6);       // nuh_reserved_zero_6bits
    110   assert(nalu.m_reservedZero6Bits == 0);
     139  nalu.m_nuhLayerId = bs.read(6);                 // nuh_layer_id
    111140#endif
    112141  nalu.m_temporalId = bs.read(3) - 1;             // nuh_temporal_id_plus1
    113 
    114   if ( nalu.m_temporalId )
     142#if RExt__DECODER_DEBUG_BIT_STATISTICS
     143  TComCodingStatistics::IncrementStatisticEP(STATS__NAL_UNIT_HEADER_BITS, 1+6+6+3, 0);
     144#endif
     145
     146#if ENC_DEC_TRACE && DEC_NUH_TRACE
     147  xTraceNalUnitHeader(nalu);
     148#endif
     149
     150  // only check these rules for base layer
     151  if (nalu.m_nuhLayerId == 0)
    115152  {
    116     assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA_W_LP
    117          && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA_W_RADL
    118          && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA_N_LP
    119          && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_IDR_W_RADL
    120          && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_IDR_N_LP
    121          && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_CRA
    122          && nalu.m_nalUnitType != NAL_UNIT_VPS
    123          && nalu.m_nalUnitType != NAL_UNIT_SPS
    124          && nalu.m_nalUnitType != NAL_UNIT_EOS
    125          && nalu.m_nalUnitType != NAL_UNIT_EOB );
    126   }
    127   else
    128   {
    129 #if H_MV
    130 
     153    if ( nalu.m_temporalId )
     154    {
     155      assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA_W_LP
     156           && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA_W_RADL
     157           && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA_N_LP
     158           && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_IDR_W_RADL
     159           && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_IDR_N_LP
     160           && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_CRA
     161           && nalu.m_nalUnitType != NAL_UNIT_VPS
     162           && nalu.m_nalUnitType != NAL_UNIT_SPS
     163           && nalu.m_nalUnitType != NAL_UNIT_EOS
     164           && nalu.m_nalUnitType != NAL_UNIT_EOB );
     165    }
     166    else
     167    {
     168#if NH_MV
    131169    // If nal_unit_type is in the range of BLA_W_LP to RSV_IRAP_VCL23, inclusive, i.e. the coded
    132170    // slice segment belongs to an IRAP picture, TemporalId shall be equal to 0.
     
    139177         && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TSA_N    );
    140178
    141     assert( nalu.m_layerId > 0
     179    assert( nalu.m_nuhLayerId > 0
    142180      || ( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_STSA_R
    143181        && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_STSA_N ) );
    144182#else
    145     assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TSA_R
    146          && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TSA_N
    147          && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_STSA_R
    148          && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_STSA_N );
    149 #endif
     183      assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TSA_R
     184           && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TSA_N
     185           && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_STSA_R
     186           && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_STSA_N );
     187#endif
     188    }
    150189  }
    151190}
     
    154193 * a bitstream
    155194 */
    156 void read(InputNALUnit& nalu, vector<uint8_t>& nalUnitBuf)
    157 {
    158   /* perform anti-emulation prevention */
    159   TComInputBitstream *pcBitstream = new TComInputBitstream(NULL);
    160   convertPayloadToRBSP(nalUnitBuf, pcBitstream, (nalUnitBuf[0] & 64) == 0);
    161  
    162   nalu.m_Bitstream = new TComInputBitstream(&nalUnitBuf);
    163   nalu.m_Bitstream->setEmulationPreventionByteLocation(pcBitstream->getEmulationPreventionByteLocation());
    164   delete pcBitstream;
     195Void read(InputNALUnit& nalu)
     196{
     197  TComInputBitstream &bitstream = nalu.getBitstream();
     198  vector<uint8_t>& nalUnitBuf=bitstream.getFifo();
     199  // perform anti-emulation prevention
     200  convertPayloadToRBSP(nalUnitBuf, &bitstream, (nalUnitBuf[0] & 64) == 0);
     201  bitstream.resetToStart();
    165202  readNalUnitHeader(nalu);
    166203}
Note: See TracChangeset for help on using the changeset viewer.