hypercube
14th May 2003, 09:27
I made my own API to parse bitstream like MPEG or DTS, and may be
it could be interest some of yours ? It was in C++
BistreamReader can read 1 to 32 bits, the interesting thing is
that it can TEST next bits, this functionnality is required by
MPEG spec...
I use a buffer to read the file, so performance are very good.
an EOFBSException is raised when end of stream is reached.
the BitStreamWriter is also simple, it can write 1 to 32 bits.
I use also a buffer.
some examples:
if (m_bsr.TestNextBits("0000 0000 0000 0000 0000 0001 1011 1010"))
{
...
}
int pack_start_code = m_bsr.ReadBits(32);
int _01_ = m_bsr.ReadBits(2);
int system_clock_reference_base1 = m_bsr.ReadBits(3);
int marker_bit1 = m_bsr.ReadBits(1);
int system_clock_reference_base2 = m_bsr.ReadBits(15);
int marker_bit2 = m_bsr.ReadBits(1);
if (streamid == BitStreamReader::GetValue("1011 1110"))
return "padding stream";
it could be interest some of yours ? It was in C++
BistreamReader can read 1 to 32 bits, the interesting thing is
that it can TEST next bits, this functionnality is required by
MPEG spec...
I use a buffer to read the file, so performance are very good.
an EOFBSException is raised when end of stream is reached.
the BitStreamWriter is also simple, it can write 1 to 32 bits.
I use also a buffer.
some examples:
if (m_bsr.TestNextBits("0000 0000 0000 0000 0000 0001 1011 1010"))
{
...
}
int pack_start_code = m_bsr.ReadBits(32);
int _01_ = m_bsr.ReadBits(2);
int system_clock_reference_base1 = m_bsr.ReadBits(3);
int marker_bit1 = m_bsr.ReadBits(1);
int system_clock_reference_base2 = m_bsr.ReadBits(15);
int marker_bit2 = m_bsr.ReadBits(1);
if (streamid == BitStreamReader::GetValue("1011 1110"))
return "padding stream";