Changeset 608 in 3DVCSoftware for trunk/source/Lib/TLibCommon/TComBitStream.h


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/TLibCommon/TComBitStream.h

    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 *
     
    8383  std::vector<uint8_t> *m_fifo;
    8484
    85   unsigned int m_num_held_bits; /// number of bits not flushed to bytestream.
    86   unsigned char m_held_bits; /// the bits held and not flushed to bytestream.
     85  UInt m_num_held_bits; /// number of bits not flushed to bytestream.
     86  UChar m_held_bits; /// the bits held and not flushed to bytestream.
    8787                             /// this value is always msb-aligned, bigendian.
    88   UInt m_uiTileMarkerLocationCount;
    89   UInt *m_puiTileMarkerLocation;
    9088
    9189public:
     
    118116   * bytestream are stored in ascending addresses.
    119117   */
    120   char* getByteStream() const;
     118  Char* getByteStream() const;
    121119
    122120  /**
    123121   * Return the number of valid bytes available from  getByteStream()
    124122   */
    125   unsigned int getByteStreamLength();
     123  UInt getByteStreamLength();
    126124
    127125  /**
     
    139137   * Return the number of bits that have been written since the last clear()
    140138   */
    141   unsigned getNumberOfWrittenBits() const { return unsigned(m_fifo->size()) * 8 + m_num_held_bits; }
    142 
    143   void insertAt(const TComOutputBitstream& src, unsigned pos);
     139  UInt getNumberOfWrittenBits() const { return UInt(m_fifo->size()) * 8 + m_num_held_bits; }
     140
     141  void insertAt(const TComOutputBitstream& src, UInt pos);
    144142
    145143  /**
     
    151149
    152150  TComOutputBitstream& operator= (const TComOutputBitstream& src);
    153   UInt  getTileMarkerLocationCount   ( )                     { return m_uiTileMarkerLocationCount   ; }
    154   Void  setTileMarkerLocationCount   ( UInt i )              { m_uiTileMarkerLocationCount = i      ; } 
    155   UInt  getTileMarkerLocation        ( UInt i)               { return m_puiTileMarkerLocation[i]    ; }
    156   Void  setTileMarkerLocation        ( UInt i, UInt uiLOC )  { m_puiTileMarkerLocation[i] = uiLOC   ; }
    157151  /** Return a reference to the internal fifo */
    158152  std::vector<uint8_t>& getFIFO() const { return *m_fifo; }
    159153
    160154  Void          addSubstream    ( TComOutputBitstream* pcSubstream );
     155  Void writeByteAlignment();
     156
     157  //! returns the number of start code emulations contained in the current buffer
     158  Int countStartCodeEmulations();
    161159};
    162160
     
    168166{
    169167  std::vector<uint8_t> *m_fifo; /// FIFO for storage of complete bytes
     168  std::vector<UInt> m_emulationPreventionByteLocation;
    170169
    171170protected:
    172   unsigned int m_fifo_idx; /// Read index into m_fifo
    173 
    174   unsigned int m_num_held_bits;
    175   unsigned char m_held_bits;
    176   UInt m_uiTileMarkerLocationCount;
    177   UInt *m_puiTileMarkerLocation;
     171  UInt m_fifo_idx; /// Read index into m_fifo
     172
     173  UInt m_num_held_bits;
     174  UChar m_held_bits;
    178175  UInt  m_numBitsRead;
    179176
     
    190187  Void        pseudoRead      ( UInt uiNumberOfBits, UInt& ruiBits );
    191188  Void        read            ( UInt uiNumberOfBits, UInt& ruiBits );
    192 #if !OL_FLUSH_ALIGN
    193   Void        readByte        ( UInt &ruiBits )
    194   {
    195     // More expensive, but reads "bytes" that are not aligned.
    196     read(8, ruiBits);
    197   }
    198 #else
    199189  Void        readByte        ( UInt &ruiBits )
    200190  {
     
    202192    ruiBits = (*m_fifo)[m_fifo_idx++];
    203193  }
    204 #endif // OL_FLUSH && !OL_FLUSH_ALIGN
    205 
     194
     195  Void        peekPreviousByte( UInt &byte )
     196  {
     197    assert(m_fifo_idx > 0);
     198    byte = (*m_fifo)[m_fifo_idx - 1];
     199  }
     200 
    206201  Void        readOutTrailingBits ();
    207202  UChar getHeldBits  ()          { return m_held_bits;          }
    208203  TComOutputBitstream& operator= (const TComOutputBitstream& src);
    209   UInt  getTileMarkerLocationCount   ( )                     { return m_uiTileMarkerLocationCount   ; }
    210   Void  setTileMarkerLocationCount   ( UInt i )              { m_uiTileMarkerLocationCount = i      ; } 
    211   UInt  getTileMarkerLocation        ( UInt i)               { return m_puiTileMarkerLocation[i]    ; }
    212   Void  setTileMarkerLocation        ( UInt i, UInt uiLOC )  { m_puiTileMarkerLocation[i] = uiLOC   ; }
    213204  UInt  getByteLocation              ( )                     { return m_fifo_idx                    ; }
    214205
    215206  // Peek at bits in word-storage. Used in determining if we have completed reading of current bitstream and therefore slice in LCEC.
    216   UInt        peekBits (UInt uiBits) { unsigned tmp; pseudoRead(uiBits, tmp); return tmp; }
     207  UInt        peekBits (UInt uiBits) { UInt tmp; pseudoRead(uiBits, tmp); return tmp; }
    217208
    218209  // utility functions
    219   unsigned read(unsigned numberOfBits) { UInt tmp; read(numberOfBits, tmp); return tmp; }
     210  UInt read(UInt numberOfBits) { UInt tmp; read(numberOfBits, tmp); return tmp; }
    220211  UInt     readByte() { UInt tmp; readByte( tmp ); return tmp; }
    221   unsigned getNumBitsUntilByteAligned() { return m_num_held_bits & (0x7); }
    222   unsigned getNumBitsLeft() { return 8*((unsigned)m_fifo->size() - m_fifo_idx) + m_num_held_bits; }
     212  UInt getNumBitsUntilByteAligned() { return m_num_held_bits & (0x7); }
     213  UInt getNumBitsLeft() { return 8*((UInt)m_fifo->size() - m_fifo_idx) + m_num_held_bits; }
    223214  TComInputBitstream *extractSubstream( UInt uiNumBits ); // Read the nominated number of bits, and return as a bitstream.
    224215  Void                deleteFifo(); // Delete internal fifo of bitstream.
    225 #if !OL_FLUSH_ALIGN
    226   Void                backupByte() { m_fifo_idx--; }
     216  UInt  getNumBitsRead() { return m_numBitsRead; }
     217  Void readByteAlignment();
     218
     219  Void      pushEmulationPreventionByteLocation ( UInt pos )                  { m_emulationPreventionByteLocation.push_back( pos ); }
     220  UInt      numEmulationPreventionBytesRead     ()                            { return (UInt) m_emulationPreventionByteLocation.size();    }
     221  std::vector<UInt>  getEmulationPreventionByteLocation  ()                   { return m_emulationPreventionByteLocation;           }
     222  UInt      getEmulationPreventionByteLocation  ( UInt idx )                  { return m_emulationPreventionByteLocation[ idx ];    }
     223  Void      clearEmulationPreventionByteLocation()                            { m_emulationPreventionByteLocation.clear();          }
     224  Void      setEmulationPreventionByteLocation  ( std::vector<UInt> vec )     { m_emulationPreventionByteLocation = vec;            }
     225};
     226
     227//! \}
     228
    227229#endif
    228   UInt  getNumBitsRead() { return m_numBitsRead; }
    229 };
    230 
    231 //! \}
    232 
    233 #endif
Note: See TracChangeset for help on using the changeset viewer.