Changeset 1313 in 3DVCSoftware for trunk/source/Lib/TLibCommon/TComBitStream.h
- Timestamp:
- 13 Aug 2015, 17:38:13 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/Lib/TLibCommon/TComBitStream.h
r1179 r1313 2 2 * License, included below. This software may be subject to other third party 3 3 * and contributor rights, including patent rights, and no such rights are 4 * granted under this license. 5 * 6 * Copyright (c) 2010-2015, ITU/ISO/IEC4 * granted under this license. 5 * 6 * Copyright (c) 2010-2015, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 36 36 */ 37 37 38 #ifndef __ COMBITSTREAM__39 #define __ COMBITSTREAM__38 #ifndef __TCOMBITSTREAM__ 39 #define __TCOMBITSTREAM__ 40 40 41 41 #if _MSC_VER > 1000 … … 46 46 #include <vector> 47 47 #include <stdio.h> 48 #include <assert.h>49 48 #include "CommonDef.h" 50 49 … … 65 64 virtual Void resetBits () = 0; 66 65 virtual UInt getNumberOfWrittenBits() const = 0; 66 virtual Int getNumBitsUntilByteAligned() const = 0; 67 67 virtual ~TComBitIf() {} 68 68 }; … … 81 81 * NB, this pointer is only valid until the next push_back()/clear() 82 82 */ 83 std::vector<uint8_t> *m_fifo;83 std::vector<uint8_t> m_fifo; 84 84 85 85 UInt m_num_held_bits; /// number of bits not flushed to bytestream. 86 86 UChar m_held_bits; /// the bits held and not flushed to bytestream. 87 87 /// this value is always msb-aligned, bigendian. 88 89 88 public: 90 89 // create / destroy … … 106 105 107 106 /** this function should never be called */ 108 void resetBits() { assert(0); }107 Void resetBits() { assert(0); } 109 108 110 109 // utility functions … … 132 131 * achieve byte alignment. 133 132 */ 134 Int getNumBitsUntilByteAligned() { return (8 - m_num_held_bits) & 0x7; }133 Int getNumBitsUntilByteAligned() const { return (8 - m_num_held_bits) & 0x7; } 135 134 136 135 /** 137 136 * Return the number of bits that have been written since the last clear() 138 137 */ 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); 142 141 143 142 /** 144 143 * Return a reference to the internal fifo 145 144 */ 146 std::vector<uint8_t>& getFIFO() { return *m_fifo; }145 std::vector<uint8_t>& getFIFO() { return m_fifo; } 147 146 148 147 UChar getHeldBits () { return m_held_bits; } 149 148 150 TComOutputBitstream& operator= (const TComOutputBitstream& src);149 //TComOutputBitstream& operator= (const TComOutputBitstream& src); 151 150 /** 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; } 153 152 154 153 Void addSubstream ( TComOutputBitstream* pcSubstream ); … … 165 164 class TComInputBitstream 166 165 { 167 std::vector<uint8_t> *m_fifo; /// FIFO for storage of complete bytes 166 protected: 167 std::vector<uint8_t> m_fifo; /// FIFO for storage of complete bytes 168 168 std::vector<UInt> m_emulationPreventionByteLocation; 169 169 170 protected:171 170 UInt m_fifo_idx; /// Read index into m_fifo 172 171 … … 177 176 public: 178 177 /** 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(); 185 185 186 186 // interface for decoding … … 189 189 Void readByte ( UInt &ruiBits ) 190 190 { 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++]; 193 193 } 194 194 … … 196 196 { 197 197 assert(m_fifo_idx > 0); 198 byte = (*m_fifo)[m_fifo_idx - 1];198 byte = m_fifo[m_fifo_idx - 1]; 199 199 } 200 201 VoidreadOutTrailingBits ();200 201 UInt readOutTrailingBits (); 202 202 UChar getHeldBits () { return m_held_bits; } 203 203 TComOutputBitstream& operator= (const TComOutputBitstream& src); … … 211 211 UInt readByte() { UInt tmp; readByte( tmp ); return tmp; } 212 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; }213 UInt getNumBitsLeft() { return 8*((UInt)m_fifo.size() - m_fifo_idx) + m_num_held_bits; } 214 214 TComInputBitstream *extractSubstream( UInt uiNumBits ); // Read the nominated number of bits, and return as a bitstream. 215 Void deleteFifo(); // Delete internal fifo of bitstream.216 215 UInt getNumBitsRead() { return m_numBitsRead; } 217 VoidreadByteAlignment();216 UInt readByteAlignment(); 218 217 219 218 Void pushEmulationPreventionByteLocation ( UInt pos ) { m_emulationPreventionByteLocation.push_back( pos ); } 220 219 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; } 222 221 UInt getEmulationPreventionByteLocation ( UInt idx ) { return m_emulationPreventionByteLocation[ idx ]; } 223 222 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; } 225 227 }; 226 228
Note: See TracChangeset for help on using the changeset viewer.