TSDuck v3.38-3699
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
ts::AVCParser Class Reference

Parser for Advanced Video Coding data. More...

#include <tsAVCParser.h>

Public Member Functions

 AVCParser (const void *data, size_t size_in_bytes)
 Constructor.
 
bool byteAligned () const
 Check if the current bit pointer is on a byte boundary.
 
bool endOfStream () const
 Check end of stream.
 
template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr, typename std::enable_if< std::is_signed< INT >::value >::type * = nullptr>
bool i (INT &val, size_t n)
 Read the next signed integer using n bits and advance the bitstream pointer.
 
template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr>
bool nextBits (INT &val, size_t n)
 Provide the next n bits without advancing the bitstream pointer.
 
bool rbspTrailingBits ()
 Skip an rbsp_trailing_bits() as defined by ISO/EIC 14496-10 7.3.2.11.
 
template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr>
bool readBits (INT &val, size_t n)
 Read the next n bits and advance the bitstream pointer.
 
size_t remainingBits () const
 Get number of remaining bits.
 
size_t remainingBytes () const
 Get number of remaining bytes (rounded down).
 
void reset (const void *data, size_t size_in_bytes)
 Reset with a new memory area.
 
void reset (size_t byte_offset=0, size_t bit_offset=0)
 Reset parsing at the specified point.
 
template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr, typename std::enable_if< std::is_signed< INT >::value >::type * = nullptr>
bool se (INT &val)
 Read the next Exp-Golomb-coded signed integer and advance the bitstream pointer.
 
template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr, typename std::enable_if< std::is_unsigned< INT >::value >::type * = nullptr>
bool u (INT &val, size_t n)
 Read the next unsigned integer using n bits and advance the bitstream pointer.
 
template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr, typename std::enable_if< std::is_unsigned< INT >::value >::type * = nullptr>
bool ue (INT &val)
 Read the next Exp-Golomb-coded unsigned integer and advance the bitstream pointer.
 

Detailed Description

Parser for Advanced Video Coding data.

Originally defined for AVC, it is now used in:

  • AVC, Advanced Video Coding, ISO 14496-10, ITU-T Rec. H.264.
  • HEVC, High Efficiency Video Coding, ITU-T Rec. H.265.
  • VVC, Versatile Video Coding, ITU-T Rec. H.266.

The naming of methods such as readBits(), i(), u(), etc. is directly transposed from ISO/IEC 14496-10, ITU-T Rec. H.264.

Constructor & Destructor Documentation

◆ AVCParser()

ts::AVCParser::AVCParser ( const void *  data,
size_t  size_in_bytes 
)

Constructor.

Parameters
[in]dataAddress of a memory area to parse. It must remain valid as long as the AVCParser object is used.
[in]size_in_bytesSize in bytes of the memory area to parse.

Member Function Documentation

◆ reset() [1/2]

void ts::AVCParser::reset ( const void *  data,
size_t  size_in_bytes 
)

Reset with a new memory area.

Parameters
[in]dataAddress of a memory area to parse. It must remain valid as long as the AVCParser object is used.
[in]size_in_bytesSize in bytes of the memory area to parse.

◆ reset() [2/2]

void ts::AVCParser::reset ( size_t  byte_offset = 0,
size_t  bit_offset = 0 
)

Reset parsing at the specified point.

Parameters
[in]byte_offsetOffset of first byte to analyze.
[in]bit_offsetOffset of first bit in first byte. The bit offset zero is the most significant bit.

◆ remainingBytes()

size_t ts::AVCParser::remainingBytes ( ) const

Get number of remaining bytes (rounded down).

This is the remaining bytes in the input raw binary data. The remaining number of bytes to read can be lower, especially in case of "start code emulation prevention".

Returns
The number of remaining bytes (rounded down).

◆ remainingBits()

size_t ts::AVCParser::remainingBits ( ) const

Get number of remaining bits.

This is the remaining bits in the input raw binary data. The remaining number of bits to read can be lower, especially in case of "start code emulation prevention".

Returns
The number of remaining bits.

◆ endOfStream()

bool ts::AVCParser::endOfStream ( ) const
inline

Check end of stream.

Returns
True if at end of stream.

◆ byteAligned()

bool ts::AVCParser::byteAligned ( ) const
inline

Check if the current bit pointer is on a byte boundary.

Returns
True if the current bit pointer is on a byte boundary.

◆ rbspTrailingBits()

bool ts::AVCParser::rbspTrailingBits ( )

Skip an rbsp_trailing_bits() as defined by ISO/EIC 14496-10 7.3.2.11.

Returns
True if one was found and skipped.

◆ nextBits()

template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * >
bool ts::AVCParser::nextBits ( INT val,
size_t  n 
)

Provide the next n bits without advancing the bitstream pointer.

Template Parameters
INTAn integer type for the returned data.
Parameters
[out]valReturned integer value.
[in]nNumber of bits to read.
Returns
True on success, false on error.

◆ readBits()

template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * >
bool ts::AVCParser::readBits ( INT val,
size_t  n 
)

Read the next n bits and advance the bitstream pointer.

Template Parameters
INTAn integer type for the returned data.
Parameters
[out]valReturned integer value.
[in]nNumber of bits to read.
Returns
True on success, false on error.

◆ u()

template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr, typename std::enable_if< std::is_unsigned< INT >::value >::type * = nullptr>
bool ts::AVCParser::u ( INT val,
size_t  n 
)
inline

Read the next unsigned integer using n bits and advance the bitstream pointer.

Template Parameters
INTAn integer type for the returned data.
Parameters
[out]valReturned integer value.
[in]nNumber of bits to read.
Returns
True on success, false on error.

◆ i()

template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr, typename std::enable_if< std::is_signed< INT >::value >::type * = nullptr>
bool ts::AVCParser::i ( INT val,
size_t  n 
)
inline

Read the next signed integer using n bits and advance the bitstream pointer.

Template Parameters
INTAn integer type for the returned data.
Parameters
[out]valReturned integer value.
[in]nNumber of bits to read.
Returns
True on success, false on error.

◆ ue()

template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr, typename std::enable_if< std::is_unsigned< INT >::value >::type * = nullptr>
bool ts::AVCParser::ue ( INT val)
inline

Read the next Exp-Golomb-coded unsigned integer and advance the bitstream pointer.

Template Parameters
INTAn integer type for the returned data.
Parameters
[out]valReturned integer value.
Returns
True on success, false on error.

◆ se()

template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * , typename std::enable_if< std::is_signed< INT >::value >::type * >
bool ts::AVCParser::se ( INT val)

Read the next Exp-Golomb-coded signed integer and advance the bitstream pointer.

Template Parameters
INTAn integer type for the returned data.
Parameters
[out]valReturned integer value.
Returns
True on success, false on error.

The documentation for this class was generated from the following file: