65 , m_emulationPreventionByteLocation()
74 , m_emulationPreventionByteLocation(src.m_emulationPreventionByteLocation)
75 , m_fifo_idx(src.m_fifo_idx)
76 , m_num_held_bits(src.m_num_held_bits)
77 , m_held_bits(src.m_held_bits)
78 , m_numBitsRead(src.m_numBitsRead)
112 assert( uiNumberOfBits <= 32 );
113 assert( uiNumberOfBits == 32 || (uiBits & (~0 << uiNumberOfBits)) == 0 );
118 UInt next_num_held_bits = num_total_bits % 8;
126 UChar next_held_bits = uiBits << (8 - next_num_held_bits);
128 if (!(num_total_bits >> 3))
134 m_num_held_bits = next_num_held_bits;
139 UInt topword = (uiNumberOfBits - next_num_held_bits) & ~((1 << 3) -1);
140 UInt write_bits = (m_held_bits << topword) | (uiBits >> next_num_held_bits);
142 switch (num_total_bits >> 3)
144 case 4:
m_fifo.push_back(write_bits >> 24);
145 case 3:
m_fifo.push_back(write_bits >> 16);
146 case 2:
m_fifo.push_back(write_bits >> 8);
147 case 1:
m_fifo.push_back(write_bits);
151 m_num_held_bits = next_num_held_bits;
157 write((1 << num_bits) - 1, num_bits);
181 const vector<uint8_t>& rbsp = pcSubstream->
getFIFO();
182 for (vector<uint8_t>::const_iterator it = rbsp.begin(); it != rbsp.end();)
201 vector<uint8_t>& rbsp =
getFIFO();
202 for (vector<uint8_t>::iterator it = rbsp.begin(); it != rbsp.end();)
204 vector<uint8_t>::iterator found = it;
209 found = search_n(found, rbsp.end()-1, 2, 0);
212 if (found == rbsp.end())
222 if (found != rbsp.end())
245 read(num_bits_to_read, ruiBits);
246 ruiBits <<= (uiNumberOfBits - num_bits_to_read);
256 assert( uiNumberOfBits <= 32 );
268 retval &= ~(0xff << uiNumberOfBits);
281 retval <<= uiNumberOfBits;
291 UInt aligned_word = 0;
292 UInt num_bytes_to_load = (uiNumberOfBits - 1) >> 3;
295 switch (num_bytes_to_load)
304 UInt next_num_held_bits = (32 - uiNumberOfBits) % 8;
307 retval |= aligned_word >> next_num_held_bits;
323 assert(0 == src_bits % 8);
325 vector<uint8_t>::iterator at =
m_fifo.begin() + pos;
360 UInt uiNumBytes = uiNumBits/8;
363 std::vector<uint8_t> &buf = pResult->
getFifo();
364 buf.reserve((uiNumBits+7)>>3);
368 std::size_t currentOutputBufferSize=buf.size();
370 buf.resize(currentOutputBufferSize+uiNumBytes);
371 memcpy(&(buf[currentOutputBufferSize]), &(
m_fifo[
m_fifo_idx]), uiNumBytesToReadFromFifo); m_fifo_idx+=uiNumBytesToReadFromFifo;
372 if (uiNumBytesToReadFromFifo != uiNumBytes)
374 memset(&(buf[currentOutputBufferSize+uiNumBytesToReadFromFifo]), 0, uiNumBytes - uiNumBytesToReadFromFifo);
379 for (
UInt ui = 0; ui < uiNumBytes; ui++)
383 buf.push_back(uiByte);
389 read(uiNumBits&0x7, uiByte);
390 uiByte <<= 8-(uiNumBits&0x7);
391 buf.push_back(uiByte);
406 read( numBits, code );
Void insertAt(const TComOutputBitstream &src, UInt pos)
Void writeByteAlignment()
Int getNumBitsUntilByteAligned() const
Int countStartCodeEmulations()
returns the number of start code emulations contained in the current buffer
std::vector< uint8_t > & getFIFO()
UChar m_held_bits
number of bits not flushed to bytestream.
UInt getByteStreamLength()
UInt getNumberOfWrittenBits() const
std::vector< uint8_t > m_fifo
class for handling bitstream (header)
UChar * getByteStream() const
TComOutputBitstream()
this value is always msb-aligned, bigendian.
Void write(UInt uiBits, UInt uiNumberOfBits)
Void addSubstream(TComOutputBitstream *pcSubstream)