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


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

    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. 
    5  *
    6 * Copyright (c) 2010-2015, ITU/ISO/IEC
     4 * granted under this license.
     5 *
     6 * Copyright (c) 2010-2015, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    3636*/
    3737
    38 #ifndef __COMBITSTREAM__
    39 #define __COMBITSTREAM__
     38#ifndef __TCOMBITSTREAM__
     39#define __TCOMBITSTREAM__
    4040
    4141#if _MSC_VER > 1000
     
    4646#include <vector>
    4747#include <stdio.h>
    48 #include <assert.h>
    4948#include "CommonDef.h"
    5049
     
    6564  virtual Void        resetBits             ()                                    = 0;
    6665  virtual UInt getNumberOfWrittenBits() const = 0;
     66  virtual Int         getNumBitsUntilByteAligned() const = 0;
    6767  virtual ~TComBitIf() {}
    6868};
     
    8181   *    NB, this pointer is only valid until the next push_back()/clear()
    8282   */
    83   std::vector<uint8_t> *m_fifo;
     83  std::vector<uint8_t> m_fifo;
    8484
    8585  UInt m_num_held_bits; /// number of bits not flushed to bytestream.
    8686  UChar m_held_bits; /// the bits held and not flushed to bytestream.
    8787                             /// this value is always msb-aligned, bigendian.
    88 
    8988public:
    9089  // create / destroy
     
    106105
    107106  /** this function should never be called */
    108   void resetBits() { assert(0); }
     107  Void resetBits() { assert(0); }
    109108
    110109  // utility functions
     
    132131   * achieve byte alignment.
    133132   */
    134   Int getNumBitsUntilByteAligned() { return (8 - m_num_held_bits) & 0x7; }
     133  Int getNumBitsUntilByteAligned() const { return (8 - m_num_held_bits) & 0x7; }
    135134
    136135  /**
    137136   * Return the number of bits that have been written since the last clear()
    138137   */
    139   UInt getNumberOfWrittenBits() const { return UInt(m_fifo->size()) * 8 + m_num_held_bits; }
    140 
    141   void insertAt(const TComOutputBitstream& src, UInt pos);
     138  UInt getNumberOfWrittenBits() const { return UInt(m_fifo.size()) * 8 + m_num_held_bits; }
     139
     140  Void insertAt(const TComOutputBitstream& src, UInt pos);
    142141
    143142  /**
    144143   * Return a reference to the internal fifo
    145144   */
    146   std::vector<uint8_t>& getFIFO() { return *m_fifo; }
     145  std::vector<uint8_t>& getFIFO() { return m_fifo; }
    147146
    148147  UChar getHeldBits  ()          { return m_held_bits;          }
    149148
    150   TComOutputBitstream& operator= (const TComOutputBitstream& src);
     149  //TComOutputBitstream& operator= (const TComOutputBitstream& src);
    151150  /** Return a reference to the internal fifo */
    152   std::vector<uint8_t>& getFIFO() const { return *m_fifo; }
     151  const std::vector<uint8_t>& getFIFO() const { return m_fifo; }
    153152
    154153  Void          addSubstream    ( TComOutputBitstream* pcSubstream );
     
    165164class TComInputBitstream
    166165{
    167   std::vector<uint8_t> *m_fifo; /// FIFO for storage of complete bytes
     166protected:
     167  std::vector<uint8_t> m_fifo; /// FIFO for storage of complete bytes
    168168  std::vector<UInt> m_emulationPreventionByteLocation;
    169169
    170 protected:
    171170  UInt m_fifo_idx; /// Read index into m_fifo
    172171
     
    177176public:
    178177  /**
    179    * Create a new bitstream reader object that reads from #buf#.  Ownership
    180    * of #buf# remains with the callee, although the constructed object
    181    * will hold a reference to #buf#
    182    */
    183   TComInputBitstream(std::vector<uint8_t>* buf);
    184   ~TComInputBitstream();
     178   * Create a new bitstream reader object that reads from buf.
     179   */
     180  TComInputBitstream();
     181  virtual ~TComInputBitstream() { }
     182  TComInputBitstream(const TComInputBitstream &src);
     183
     184  Void resetToStart();
    185185
    186186  // interface for decoding
     
    189189  Void        readByte        ( UInt &ruiBits )
    190190  {
    191     assert(m_fifo_idx < m_fifo->size());
    192     ruiBits = (*m_fifo)[m_fifo_idx++];
     191    assert(m_fifo_idx < m_fifo.size());
     192    ruiBits = m_fifo[m_fifo_idx++];
    193193  }
    194194
     
    196196  {
    197197    assert(m_fifo_idx > 0);
    198     byte = (*m_fifo)[m_fifo_idx - 1];
     198    byte = m_fifo[m_fifo_idx - 1];
    199199  }
    200  
    201   Void        readOutTrailingBits ();
     200
     201  UInt        readOutTrailingBits ();
    202202  UChar getHeldBits  ()          { return m_held_bits;          }
    203203  TComOutputBitstream& operator= (const TComOutputBitstream& src);
     
    211211  UInt     readByte() { UInt tmp; readByte( tmp ); return tmp; }
    212212  UInt getNumBitsUntilByteAligned() { return m_num_held_bits & (0x7); }
    213   UInt getNumBitsLeft() { return 8*((UInt)m_fifo->size() - m_fifo_idx) + m_num_held_bits; }
     213  UInt getNumBitsLeft() { return 8*((UInt)m_fifo.size() - m_fifo_idx) + m_num_held_bits; }
    214214  TComInputBitstream *extractSubstream( UInt uiNumBits ); // Read the nominated number of bits, and return as a bitstream.
    215   Void                deleteFifo(); // Delete internal fifo of bitstream.
    216215  UInt  getNumBitsRead() { return m_numBitsRead; }
    217   Void readByteAlignment();
     216  UInt readByteAlignment();
    218217
    219218  Void      pushEmulationPreventionByteLocation ( UInt pos )                  { m_emulationPreventionByteLocation.push_back( pos ); }
    220219  UInt      numEmulationPreventionBytesRead     ()                            { return (UInt) m_emulationPreventionByteLocation.size();    }
    221   std::vector<UInt>  getEmulationPreventionByteLocation  ()                   { return m_emulationPreventionByteLocation;           }
     220  const std::vector<UInt> &getEmulationPreventionByteLocation  () const              { return m_emulationPreventionByteLocation;           }
    222221  UInt      getEmulationPreventionByteLocation  ( UInt idx )                  { return m_emulationPreventionByteLocation[ idx ];    }
    223222  Void      clearEmulationPreventionByteLocation()                            { m_emulationPreventionByteLocation.clear();          }
    224   Void      setEmulationPreventionByteLocation  ( std::vector<UInt> vec )     { m_emulationPreventionByteLocation = vec;            }
     223  Void      setEmulationPreventionByteLocation  ( const std::vector<UInt> &vec )     { m_emulationPreventionByteLocation = vec;            }
     224
     225  const std::vector<uint8_t> &getFifo() const { return m_fifo; }
     226        std::vector<uint8_t> &getFifo()       { return m_fifo; }
    225227};
    226228
Note: See TracChangeset for help on using the changeset viewer.