Ignore:
Timestamp:
1 Sep 2013, 22:47:26 (11 years ago)
Author:
tech
Message:

Merged DEV-2.0-dev0@604.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/Lib/TLibDecoder/TDecBinCoderCABAC.cpp

    r296 r608  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    3737
    3838#include "TDecBinCoderCABAC.h"
     39#include "../TLibCommon/TComRom.h"
    3940
    4041//! \ingroup TLibDecoder
     
    6566TDecBinCABAC::start()
    6667{
    67 #if OL_FLUSH_ALIGN
    6868  assert( m_pcTComBitstream->getNumBitsUntilByteAligned() == 0 );
    69 #endif
    70  
    7169  m_uiRange    = 510;
    7270  m_bitsNeeded = -8;
    73   m_uiValue    = m_pcTComBitstream->readByte() << 8;
    74 #if !OL_FLUSH_ALIGN
    75   m_uiLastByte = m_pcTComBitstream->readByte();
    76   m_uiValue   |= m_uiLastByte;
    77 #else
     71  m_uiValue    = (m_pcTComBitstream->readByte() << 8);
    7872  m_uiValue   |= m_pcTComBitstream->readByte();
    79 #endif
    8073}
    8174
     
    8376TDecBinCABAC::finish()
    8477{
    85 }
    86 
    87 Void
    88 TDecBinCABAC::flush()
    89 {
    90 #if OL_FLUSH_ALIGN
    91   while (m_pcTComBitstream->getNumBitsLeft() > 0 && m_pcTComBitstream->getNumBitsUntilByteAligned() != 0)
    92   {
    93     UInt uiBits;
    94     m_pcTComBitstream->read ( 1, uiBits );
    95   }
    96   start();
    97 #else
    98   m_uiRange    = 510;
    99   Int iExtra = 16+m_bitsNeeded+1; // m_bitsNeeded is -ve: iExtra is many bits to read to make up 16.
    100   UInt uiExtraBits;
    101   m_pcTComBitstream->read(iExtra, uiExtraBits);
    102   m_uiValue = (m_uiLastByte << iExtra) | uiExtraBits;
    103   m_uiValue &= 0xffff;
    104   m_uiLastByte = m_uiValue;
    105   m_uiLastByte &= 0xff;
    106   m_bitsNeeded = -8;
    107 #endif // OL_FLUSH_ALIGN
     78  UInt lastByte;
     79
     80  m_pcTComBitstream->peekPreviousByte( lastByte );
     81  // Check for proper stop/alignment pattern
     82  assert( ((lastByte << (8 + m_bitsNeeded)) & 0xff) == 0x80 );
    10883}
    10984
     
    12095  m_uiValue   = pcTDecBinCABAC->m_uiValue;
    12196  m_bitsNeeded= pcTDecBinCABAC->m_bitsNeeded;
    122 #if !OL_FLUSH_ALIGN
    123   m_uiLastByte= pcTDecBinCABAC->m_uiLastByte;
    124 #endif
    12597}
    12698
     
    150122    {
    151123      m_bitsNeeded = -8;
    152 #if !OL_FLUSH_ALIGN
    153       m_uiLastByte = m_pcTComBitstream->readByte();
    154       m_uiValue += m_uiLastByte;   
    155 #else
    156124      m_uiValue += m_pcTComBitstream->readByte();     
    157 #endif
    158125    }
    159126  }
     
    171138    if ( m_bitsNeeded >= 0 )
    172139    {
    173 #if !OL_FLUSH_ALIGN
    174       m_uiLastByte = m_pcTComBitstream->readByte();
    175       m_uiValue += m_uiLastByte << m_bitsNeeded;
    176 #else
    177140      m_uiValue += m_pcTComBitstream->readByte() << m_bitsNeeded;
    178 #endif
    179141      m_bitsNeeded -= 8;
    180142    }
     
    190152  {
    191153    m_bitsNeeded = -8;
    192 #if !OL_FLUSH_ALIGN
    193     m_uiLastByte = m_pcTComBitstream->readByte();
    194     m_uiValue += m_uiLastByte;
    195 #else
    196154    m_uiValue += m_pcTComBitstream->readByte();
    197 #endif
    198155  }
    199156 
     
    213170  while ( numBins > 8 )
    214171  {
    215 #if !OL_FLUSH_ALIGN
    216     m_uiLastByte = m_pcTComBitstream->readByte();
    217     m_uiValue = ( m_uiValue << 8 ) + ( m_uiLastByte << ( 8 + m_bitsNeeded ) );
    218 #else
    219172    m_uiValue = ( m_uiValue << 8 ) + ( m_pcTComBitstream->readByte() << ( 8 + m_bitsNeeded ) );
    220 #endif
    221173   
    222174    UInt scaledRange = m_uiRange << 15;
     
    239191  if ( m_bitsNeeded >= 0 )
    240192  {
    241 #if !OL_FLUSH_ALIGN
    242     m_uiLastByte = m_pcTComBitstream->readByte();
    243     m_uiValue += m_uiLastByte << m_bitsNeeded;
    244 #else
    245193    m_uiValue += m_pcTComBitstream->readByte() << m_bitsNeeded;
    246 #endif
    247194    m_bitsNeeded -= 8;
    248195  }
     
    283230      {
    284231        m_bitsNeeded = -8;
    285 #if !OL_FLUSH_ALIGN
    286         m_uiLastByte = m_pcTComBitstream->readByte();
    287         m_uiValue += m_uiLastByte;   
    288 #else
    289232        m_uiValue += m_pcTComBitstream->readByte();     
    290 #endif
    291233      }
    292234    }
    293235  }
    294 }
    295 
    296 /** Reset BAC register values.
    297  * \returns Void
    298  */
    299 Void TDecBinCABAC::resetBac()
    300 {
    301   m_uiRange    = 510;
    302   m_bitsNeeded = -8;
    303   m_uiValue    = m_pcTComBitstream->read( 16 );
    304 }
    305 
    306 /** Decode subsequent_pcm_num.
    307  * \param numSubseqIPCM
    308  * \returns Void
    309  */
    310 Void TDecBinCABAC::decodeNumSubseqIPCM( Int& numSubseqIPCM )
    311 {
    312   UInt bit = 0;
    313 
    314   numSubseqIPCM = 0;
    315 
    316   do
    317   {
    318     m_uiValue += m_uiValue;
    319     if ( ++m_bitsNeeded >= 0 )
    320     {
    321       m_bitsNeeded = -8;
    322 #if !OL_FLUSH_ALIGN
    323       m_uiLastByte = m_pcTComBitstream->readByte();
    324       m_uiValue += m_uiLastByte;
    325 #else
    326       m_uiValue += m_pcTComBitstream->readByte();
    327 #endif
    328     }
    329     bit = ((m_uiValue&128)>>7);
    330     numSubseqIPCM++;
    331   }
    332   while( bit && (numSubseqIPCM < 3 ));
    333 
    334   if( bit && (numSubseqIPCM == 3 ))
    335   {
    336     numSubseqIPCM++;
    337   }
    338 
    339   numSubseqIPCM --;
    340 }
    341 
    342 /** Decode PCM alignment zero bits.
    343  * \returns Void
    344  */
    345 Void TDecBinCABAC::decodePCMAlignBits()
    346 {
    347   Int iNum = m_pcTComBitstream->getNumBitsUntilByteAligned();
    348  
    349   UInt uiBit = 0;
    350   m_pcTComBitstream->read( iNum, uiBit );
    351236}
    352237
Note: See TracChangeset for help on using the changeset viewer.