Changeset 608 in 3DVCSoftware for trunk/source/Lib/TLibDecoder/TDecBinCoderCABAC.cpp
- Timestamp:
- 1 Sep 2013, 22:47:26 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/Lib/TLibDecoder/TDecBinCoderCABAC.cpp
r296 r608 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 2, ITU/ISO/IEC6 * Copyright (c) 2010-2013, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 37 37 38 38 #include "TDecBinCoderCABAC.h" 39 #include "../TLibCommon/TComRom.h" 39 40 40 41 //! \ingroup TLibDecoder … … 65 66 TDecBinCABAC::start() 66 67 { 67 #if OL_FLUSH_ALIGN68 68 assert( m_pcTComBitstream->getNumBitsUntilByteAligned() == 0 ); 69 #endif70 71 69 m_uiRange = 510; 72 70 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); 78 72 m_uiValue |= m_pcTComBitstream->readByte(); 79 #endif80 73 } 81 74 … … 83 76 TDecBinCABAC::finish() 84 77 { 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 ); 108 83 } 109 84 … … 120 95 m_uiValue = pcTDecBinCABAC->m_uiValue; 121 96 m_bitsNeeded= pcTDecBinCABAC->m_bitsNeeded; 122 #if !OL_FLUSH_ALIGN123 m_uiLastByte= pcTDecBinCABAC->m_uiLastByte;124 #endif125 97 } 126 98 … … 150 122 { 151 123 m_bitsNeeded = -8; 152 #if !OL_FLUSH_ALIGN153 m_uiLastByte = m_pcTComBitstream->readByte();154 m_uiValue += m_uiLastByte;155 #else156 124 m_uiValue += m_pcTComBitstream->readByte(); 157 #endif158 125 } 159 126 } … … 171 138 if ( m_bitsNeeded >= 0 ) 172 139 { 173 #if !OL_FLUSH_ALIGN174 m_uiLastByte = m_pcTComBitstream->readByte();175 m_uiValue += m_uiLastByte << m_bitsNeeded;176 #else177 140 m_uiValue += m_pcTComBitstream->readByte() << m_bitsNeeded; 178 #endif179 141 m_bitsNeeded -= 8; 180 142 } … … 190 152 { 191 153 m_bitsNeeded = -8; 192 #if !OL_FLUSH_ALIGN193 m_uiLastByte = m_pcTComBitstream->readByte();194 m_uiValue += m_uiLastByte;195 #else196 154 m_uiValue += m_pcTComBitstream->readByte(); 197 #endif198 155 } 199 156 … … 213 170 while ( numBins > 8 ) 214 171 { 215 #if !OL_FLUSH_ALIGN216 m_uiLastByte = m_pcTComBitstream->readByte();217 m_uiValue = ( m_uiValue << 8 ) + ( m_uiLastByte << ( 8 + m_bitsNeeded ) );218 #else219 172 m_uiValue = ( m_uiValue << 8 ) + ( m_pcTComBitstream->readByte() << ( 8 + m_bitsNeeded ) ); 220 #endif221 173 222 174 UInt scaledRange = m_uiRange << 15; … … 239 191 if ( m_bitsNeeded >= 0 ) 240 192 { 241 #if !OL_FLUSH_ALIGN242 m_uiLastByte = m_pcTComBitstream->readByte();243 m_uiValue += m_uiLastByte << m_bitsNeeded;244 #else245 193 m_uiValue += m_pcTComBitstream->readByte() << m_bitsNeeded; 246 #endif247 194 m_bitsNeeded -= 8; 248 195 } … … 283 230 { 284 231 m_bitsNeeded = -8; 285 #if !OL_FLUSH_ALIGN286 m_uiLastByte = m_pcTComBitstream->readByte();287 m_uiValue += m_uiLastByte;288 #else289 232 m_uiValue += m_pcTComBitstream->readByte(); 290 #endif291 233 } 292 234 } 293 235 } 294 }295 296 /** Reset BAC register values.297 * \returns Void298 */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 numSubseqIPCM308 * \returns Void309 */310 Void TDecBinCABAC::decodeNumSubseqIPCM( Int& numSubseqIPCM )311 {312 UInt bit = 0;313 314 numSubseqIPCM = 0;315 316 do317 {318 m_uiValue += m_uiValue;319 if ( ++m_bitsNeeded >= 0 )320 {321 m_bitsNeeded = -8;322 #if !OL_FLUSH_ALIGN323 m_uiLastByte = m_pcTComBitstream->readByte();324 m_uiValue += m_uiLastByte;325 #else326 m_uiValue += m_pcTComBitstream->readByte();327 #endif328 }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 Void344 */345 Void TDecBinCABAC::decodePCMAlignBits()346 {347 Int iNum = m_pcTComBitstream->getNumBitsUntilByteAligned();348 349 UInt uiBit = 0;350 m_pcTComBitstream->read( iNum, uiBit );351 236 } 352 237
Note: See TracChangeset for help on using the changeset viewer.