MythTV  master
Functions
ByteReader Namespace Reference

These functions are rewritten copies from FFmpeg's libavcodec, where find_start_code() is prefixed with avpriv_ . More...

Functions

bool start_code_is_valid (uint32_t start_code)
 Test whether a start code found by find_start_code() is valid. More...
 
const MTV_PUBLIC uint8_t * find_start_code (const uint8_t *p, const uint8_t *end, uint32_t *start_code)
 Find the first start code in the buffer p. More...
 
const MTV_PUBLIC uint8_t * find_start_code_truncated (const uint8_t *p, const uint8_t *end, uint32_t *start_code)
 By preserving the start_code value between subsequent calls, the caller can detect start codes across buffer boundaries. More...
 

Detailed Description

These functions are rewritten copies from FFmpeg's libavcodec, where find_start_code() is prefixed with avpriv_ .

Function Documentation

◆ start_code_is_valid()

bool ByteReader::start_code_is_valid ( uint32_t  start_code)
inline

Test whether a start code found by find_start_code() is valid.

Use this to test the validity of a start code especially if a start code can be at the end of the buffer, where testing the return value of find_start_code() would incorrectly imply that the start code is invalid (since the returned value equals end ).

Parameters
[in]start_codeThe start code to test.
Returns
A boolean that is true if and only if start_code is valid

Definition at line 54 of file bytereader.h.

Referenced by AVCParser::addBytes(), HEVCParser::addBytes(), find_start_code_truncated(), DTVRecorder::FindMPEG2Keyframes(), DTVRecorder::FindPSKeyFrames(), and PTSListener::ProcessTSPacket().

◆ find_start_code()

const uint8_t * ByteReader::find_start_code ( const uint8_t *  p,
const uint8_t *  end,
uint32_t *  start_code 
)

Find the first start code in the buffer p.

A start code is a sequence of 4 bytes with the hexadecimal value 00 00 01 XX , where XX represents any value and memory address increases left to right.

Parameters
[in]pA pointer to the start of the memory buffer to scan.
[in]endA pointer to the past-the-end memory address for the buffer given by p. p must be ≤ end.
[out]start_codeA pointer to a mutable uint32_t.
Set to the found start code if it exists or an invalid start code (the 4 bytes prior to the returned value or ~0 if $ end - p < 4 $).
Returns
A pointer to the memory address following the found start code, or end if no start code was found.

Definition at line 35 of file bytereader.cpp.

Referenced by find_start_code_truncated().

◆ find_start_code_truncated()

const uint8_t * ByteReader::find_start_code_truncated ( const uint8_t *  p,
const uint8_t *  end,
uint32_t *  start_code 
)

By preserving the start_code value between subsequent calls, the caller can detect start codes across buffer boundaries.

Parameters
[in,out]start_codeA pointer to a mutable uint32_t.
As input: For no history preset to ~0 , otherwise preset to the last returned start code to enable detecting start codes across buffer boundaries.
On output: Set to the found start code if it exists or an invalid start code (the 4 bytes prior to the returned value, using the input history if $ end - p < 4 $).
See also
find_start_code()

Definition at line 81 of file bytereader.cpp.

Referenced by AVCParser::addBytes(), HEVCParser::addBytes(), DTVRecorder::FindMPEG2Keyframes(), DTVRecorder::FindPSKeyFrames(), AvFormatDecoder::MpegPreProcessPkt(), and PTSListener::ProcessTSPacket().