vdr-plugin-softhddevice-drm-gles 1.6.2
Miscellaneous

Miscellaneous Helper Functions. More...

Classes

class  cBufferFillLevelLowPassFilter
 Fill Level Low Pass Filter. More...
 
class  cGrabBuffer
 Grabbing Buffer. More...
 
class  cSoftHdGrab
 Grabbing Processor. More...
 
class  cH264Parser
 H.264 Parser. More...
 
class  cJitterTracker
 Jitter Tracker. More...
 
class  cSoftHdLogger
 Logger. More...
 
struct  CodecInfo
 Codec Information Structure. More...
 
class  cPes
 PES Packet Parser. More...
 
class  cPesVideo
 Video PES Packet Parser. More...
 
class  cPesAudio
 Audio PES Packet Parser. More...
 
class  cPtsTrackingBuffer
 PTS Tracking Buffer. More...
 
class  cReassemblyBuffer
 Base Class for Stream Reassembly Buffers. More...
 
class  cReassemblyBufferVideo
 Video Stream Reassembly Buffer. More...
 
struct  SyncWordInfo
 Information about a detected audio sync word. More...
 
class  cReassemblyBufferAudio
 Audio Stream Reassembly Buffer. More...
 

Macros

#define OPAQUE   0xff
 
#define TRANSPARENT   0x00
 
#define UNMULTIPLY(color, alpha)   ((0xff * color) / alpha)
 
#define BLEND(back, front, alpha)   ((front * alpha) + (back * (255 - alpha))) / 255
 
#define AV_LOGLEVEL   AV_LOG_INFO
 FFmpeg log level.
 
#define LOGFATAL   cSoftHdLogger::GetLogger()->LogFatal
 log to LOG_ERR and abort
 
#define LOGERROR   cSoftHdLogger::GetLogger()->LogError
 log to LOG_ERR
 
#define LOGWARNING   cSoftHdLogger::GetLogger()->LogWarning
 log to LOG_WARN
 
#define LOGINFO   cSoftHdLogger::GetLogger()->LogInfo
 log to LOG_INFO
 
#define LOGDEBUG   cSoftHdLogger::GetLogger()->LogDebug
 log to LOG_DEBUG
 
#define LOGDEBUG2   cSoftHdLogger::GetLogger()->LogDebug2
 log to LOG_DEBUG and add a prefix
 
#define GL_CHECK(stmt)
 glCheckError macro
 
#define EGL_CHECK(stmt)
 eglCheckError macro
 
#define AV_NOPTS_VALUE   INT64_C(0x8000000000000000)
 
#define VIDEO_SURFACES_MAX   3
 maximum video surfaces kept by the filter and render queues
 
#define av_err2str(err)   av_err2string(err)
 

Enumerations

enum  Grabtype { GRABVIDEO , GRABPIP , GRABOSD }
 
enum  NalUnitTypes {
  NALU_TYPE_NON_IDR = (1 << 0) , NALU_TYPE_PART_A = (1 << 1) , NALU_TYPE_PART_B = (1 << 2) , NALU_TYPE_PART_C = (1 << 3) ,
  NALU_TYPE_IDR = (1 << 4) , NALU_TYPE_SEI = (1 << 5) , NALU_TYPE_SPS = (1 << 6) , NALU_TYPE_PPS = (1 << 7) ,
  NALU_TYPE_AUD = (1 << 8)
}
 
enum  LogFlags {
  L_DEBUG = (1 << 0) , L_AV_SYNC = (1 << 1) , L_SOUND = (1 << 2) , L_OSD = (1 << 3) ,
  L_DRM = (1 << 4) , L_CODEC = (1 << 5) , L_STILL = (1 << 6) , L_TRICK = (1 << 7) ,
  L_MEDIA = (1 << 8) , L_OPENGL = (1 << 9) , L_OPENGL_TIME = (1 << 10) , L_OPENGL_TIME_ALL = (1 << 11) ,
  L_PACKET = (1 << 12) , L_GRAB = (1 << 13) , L_FFMPEG = (1 << 14)
}
 Logger Flags. More...
 

Functions

enum AVPixelFormat DrmFormatToAVFormat (cDrmBuffer *buf)
 Convert a DRM format to a ffmpeg AV format.
 
static uint8_tBufToRgb (cDrmBuffer *buf, int *size, int dstW, int dstH, enum AVPixelFormat dstPixFmt)
 Convert a DRM buffer to rgb format image.
 
static uint8_tScaleRgb24 (uint8_t *src, int *size, int srcW, int srcH, int dstW, int dstH)
 Scale an image.
 
static void AlphaBlend (uint8_t *result, uint8_t *front, uint8_t *back, const unsigned int width, const unsigned int height)
 Blend two images.
 
static int BlitVideo (uint8_t *dst, uint8_t *src, int dstW, int dstH, int dstX, int dstY, int srcW, int srcH)
 Blit the video on black background.
 
uint8_tCreateJpeg (uint8_t *image, int *size, int quality, int width, int height)
 Call rgb to jpeg for C Plugin.
 
const charGrabtypeToString (Grabtype t)
 
bool isValidStartCode (const uint8_t *data, int offset, int size, int &startCodeLength)
 Check for a 0x000001 or 0x00000001 start code.
 
static int NalUnitType (const uint8_t *data, int offset, int startCodeLength)
 Return the nal unit type.
 
static void glCheckError (const char *stmt, const char *fname, int line)
 Check for OpenGL errors and log them.
 
static void eglCheckError (const char *stmt, const char *fname, int line)
 Check for EGL errors and log them.
 
static bool isInterlacedFrame (AVFrame *frame)
 Check, if this is an interlaced frame.
 
static const charav_err2string (int errnum)
 Workaround for av_err2str() not working with C++.
 
static const charTimestamp2String (int64_t ts, uint8_t divisor)
 Nice time-stamp string.
 
static uint32_t ReadBytes (const uint8_t *data, int count)
 Return count amount of bytes from data
 
void cBufferFillLevelLowPassFilter::Reset ()
 Resets the filter state.
 
void cBufferFillLevelLowPassFilter::ResetFramesCounters ()
 Resets the received and written frames counters.
 
void cBufferFillLevelLowPassFilter::UpdateAvgBufferFillLevel (int)
 Updates the buffer fill level average.
 
const charcBufferFillLevelLowPassFilter::StateToString (State d)
 Converts the filter state to a string representation.
 
void cGrabBuffer::FreeDrmBuf (void)
 Free the grabbed drm buffer.
 
void cGrabBuffer::SetDrmBuf (cDrmBuffer *)
 Set the grab buffer and the dimensions how it is presented on the screen.
 
bool cSoftHdGrab::Start (bool, int, int, int, int, int)
 Start a grab in the video renderer.
 
uint8_tcSoftHdGrab::GetGrab (int *, int *, int *, int *, int *, Grabtype)
 Convert the cloned drm buffer data to RGB(void, pip) or ARGB (osd) and return a pointer to the raw data.
 
bool cSoftHdGrab::ProcessGrab (void)
 Start the conversion.
 
int cH264Parser::GetSPSOffset (void)
 Get the SPS offset.
 
int cH264Parser::GetPPSOffset (void)
 Get the PPS offset.
 
int cH264Parser::GetSliceOffset (void)
 Get the slice offset.
 
 cH264Parser::cH264Parser (AVPacket *, int, int, int)
 Init the h264 parser and detect the nalu types.
 
void cH264Parser::AddInvalidReference (int, int)
 Adds an invalid reference.
 
void cH264Parser::AddValidReference (int)
 Adds a valid reference.
 
void cH264Parser::BuildInvalidReferenceString (int)
 Add a whitespace-separated list of all invalid references to the log output string.
 
void cH264Parser::BuildValidReferenceString (void)
 Add a whitespace-separated list of all valid references to the log output string.
 
void cH264Parser::AddFrameNumber (int)
 Add the frame number to the log output string.
 
void cH264Parser::PrintStreamData (void)
 Print raw stream data of the first 35 bytes.
 
void cH264Parser::PrintNalUnits (void)
 Print the previously created log output string.
 
unsigned int cH264Parser::ReadBit (void)
 Read the next bit of a stream.
 
unsigned int cH264Parser::ReadBits (int)
 Read n number of bits of a stream.
 
unsigned int cH264Parser::ReadExponentialGolombCode (void)
 Read an unsigned exponential-golomb coded integer.
 
unsigned int cH264Parser::ReadSE (void)
 Read a signed exponential-golomb coded integer.
 
void cH264Parser::ConvertEBSPtoRBSP (const uint8_t *, int)
 
void cJitterTracker::PacketReceived (void)
 Called each time a packet is received.
 
void cJitterTracker::Reset (void)
 Resets the jitter tracker.
 
static std::shared_ptr< cSoftHdLoggercSoftHdLogger::GetLogger ()
 Get an instance to the global logger.
 
void cSoftHdLogger::SetLogLevel (int level)
 Set the loglevel.
 
void cSoftHdLogger::LogFatal (const char *format,...)
 Log to syslog LOG_ERR and abort.
 
void cSoftHdLogger::LogError (const char *format,...)
 Log to syslog LOG_ERR.
 
void cSoftHdLogger::LogWarning (const char *format,...)
 Log to syslog LOG_WARNING.
 
void cSoftHdLogger::LogInfo (const char *format,...)
 Log to syslog LOG_INFO.
 
void cSoftHdLogger::LogDebug (const char *format,...)
 Log to syslog LOG_DEBUG.
 
void cSoftHdLogger::LogDebug2 (const int cat, const char *format,...)
 Log to syslog LOG_DEBUG and add logging category to output.
 
void cSoftHdLogger::LogFFmpeg (const char *, va_list)
 Log to syslog LOG_DEBUG and add prefix [FFMpeg] to output.
 
static void cSoftHdLogger::LogFFmpegCallback (void *, int, const char *, va_list)
 Callback for ffmpeg logs.
 
 cPes::cPes (const uint8_t *, int)
 Create a PES packet parser.
 
void cPes::Init (void)
 Initialize and validate the PES packet.
 
bool cPes::IsValid (void)
 Check if the PES packet is valid.
 
bool cPes::IsHeaderValid (void)
 Check if the PES header is valid.
 
bool cPes::HasPts (void)
 Check if the PES packet contains a Presentation Time Stamp (PTS)
 
int64_t cPes::GetPts (void)
 Get the Presentation Time Stamp (PTS) from the PES header.
 
const uint8_tcPes::GetPayload (void)
 Get a pointer to the PES payload data.
 
int cPes::GetPayloadSize (void)
 Get the size of the PES payload.
 
int cPes::GetPacketLength (void)
 Get the total length of the PES packet.
 
AVPacketcReassemblyBuffer::PopAvPacket (int)
 Pop an AVPacket from the reassembly buffer.
 
bool cReassemblyBufferVideo::ParseCodecHeader (const uint8_t *, int)
 Parse video codec header to detect codec type.
 
bool cReassemblyBufferVideo::HasLeadingZero (const uint8_t *, int)
 Check if video data has a leading zero byte before the start code.
 
AVPacketcReassemblyBufferAudio::PopAvPacket (void) override
 Pop an audio AVPacket from the reassembly buffer.
 
AVCodecID cReassemblyBufferAudio::TruncateBufferUntilFirstValidData (void)
 Truncate buffer until the first valid audio frame.
 
SyncWordInfo cReassemblyBufferAudio::FindTwoConsecutiveFramesWithSameSyncWord ()
 Find two consecutive audio frames with the same sync word.
 
SyncWordInfo cReassemblyBufferAudio::FindSyncWord (const uint8_t *, int)
 Find the first audio sync word in data.
 
AVCodecID cReassemblyBufferAudio::DetectCodecFromSyncWord (const uint8_t *, int)
 Detect audio codec from sync word pattern.
 
int cReassemblyBufferAudio::GetFrameSizeForCodec (AVCodecID, const uint8_t *)
 Get the frame size for a given codec and frame header.
 
void cReassemblyBuffer::Reset (void)
 Reset the reassembly buffer.
 
void cPtsTrackingBuffer::Push (const uint8_t *, int, int64_t)
 Push data into the PTS tracking buffer.
 
void cPtsTrackingBuffer::Erase (size_t)
 Erase data from the beginning of the buffer.
 
int64_t cPtsTrackingBuffer::GetPts (void)
 Get the PTS value for the current buffer position.
 

Variables

static const std::map< AVCodecID, CodecInfoAudioCodecMap
 Map of Audio Codec Information.
 

Detailed Description

Miscellaneous Helper Functions.

{

H.264 Parser.

Event Handler.

Controls the state machine.

{@

Macro Definition Documentation

◆ av_err2str

#define av_err2str (   err)    av_err2string(err)

Definition at line 112 of file misc.h.

◆ AV_LOGLEVEL

#define AV_LOGLEVEL   AV_LOG_INFO

FFmpeg log level.

Definition at line 25 of file logger.h.

◆ AV_NOPTS_VALUE

#define AV_NOPTS_VALUE   INT64_C(0x8000000000000000)

Definition at line 74 of file misc.h.

◆ BLEND

#define BLEND (   back,
  front,
  alpha 
)    ((front * alpha) + (back * (255 - alpha))) / 255

Definition at line 40 of file grab.cpp.

◆ EGL_CHECK

#define EGL_CHECK (   stmt)
Value:
do { \
} while (0)

eglCheckError macro

Definition at line 62 of file misc.h.

◆ GL_CHECK

#define GL_CHECK (   stmt)
Value:
do { \
} while (0)

glCheckError macro

Definition at line 56 of file misc.h.

◆ LOGDEBUG

#define LOGDEBUG   cSoftHdLogger::GetLogger()->LogDebug

log to LOG_DEBUG

Definition at line 40 of file logger.h.

◆ LOGDEBUG2

#define LOGDEBUG2   cSoftHdLogger::GetLogger()->LogDebug2

log to LOG_DEBUG and add a prefix

Definition at line 42 of file logger.h.

◆ LOGERROR

#define LOGERROR   cSoftHdLogger::GetLogger()->LogError

log to LOG_ERR

Definition at line 34 of file logger.h.

◆ LOGFATAL

#define LOGFATAL   cSoftHdLogger::GetLogger()->LogFatal

log to LOG_ERR and abort

Definition at line 32 of file logger.h.

◆ LOGINFO

#define LOGINFO   cSoftHdLogger::GetLogger()->LogInfo

log to LOG_INFO

Definition at line 38 of file logger.h.

◆ LOGWARNING

#define LOGWARNING   cSoftHdLogger::GetLogger()->LogWarning

log to LOG_WARN

Definition at line 36 of file logger.h.

◆ OPAQUE

#define OPAQUE   0xff

Definition at line 37 of file grab.cpp.

◆ TRANSPARENT

#define TRANSPARENT   0x00

Definition at line 38 of file grab.cpp.

◆ UNMULTIPLY

#define UNMULTIPLY (   color,
  alpha 
)    ((0xff * color) / alpha)

Definition at line 39 of file grab.cpp.

◆ VIDEO_SURFACES_MAX

#define VIDEO_SURFACES_MAX   3

maximum video surfaces kept by the filter and render queues

Definition at line 77 of file misc.h.

Enumeration Type Documentation

◆ Grabtype

Enumerator
GRABVIDEO 
GRABPIP 
GRABOSD 

Definition at line 27 of file grab.h.

◆ LogFlags

Logger Flags.

depending on the flag used in the macro, logging is enabled and gets a nice prefix in the syslog.

Enumerator
L_DEBUG 

common debug logs

L_AV_SYNC 

audio/video sync logs

L_SOUND 

sound logs

L_OSD 

osd logs

L_DRM 

drm logs

L_CODEC 

codec logs

L_STILL 

stillpicture logs

L_TRICK 

trickspeed logs

L_MEDIA 

mediaplayer logs

L_OPENGL 

opengl osd logs

L_OPENGL_TIME 

opengl osd flush time measurement

L_OPENGL_TIME_ALL 

opengl osd all commands time measurement

L_PACKET 

decoder packet/frame tracking logs

L_GRAB 

grabbing logs

L_FFMPEG 

ffmpeg logs

Definition at line 50 of file logger.h.

◆ NalUnitTypes

Enumerator
NALU_TYPE_NON_IDR 
NALU_TYPE_PART_A 
NALU_TYPE_PART_B 
NALU_TYPE_PART_C 
NALU_TYPE_IDR 
NALU_TYPE_SEI 
NALU_TYPE_SPS 
NALU_TYPE_PPS 
NALU_TYPE_AUD 

Definition at line 28 of file h264parser.h.

Function Documentation

◆ AddFrameNumber()

void cH264Parser::AddFrameNumber ( int  num)

Add the frame number to the log output string.

Parameters
numframe number to add to the string

Definition at line 600 of file h264parser.cpp.

References cH264Parser::m_naluString.

◆ AddInvalidReference()

void cH264Parser::AddInvalidReference ( int  modRef,
int  frameNumber 
)

Adds an invalid reference.

Parameters
modRefnumber of the reference frame
frameNumbernumber of the frame to add

Definition at line 541 of file h264parser.cpp.

References cH264Parser::m_hasInvalidBackwardReferences, cH264Parser::m_hasInvalidReferences, and cH264Parser::m_invalidReferences.

◆ AddValidReference()

void cH264Parser::AddValidReference ( int  modRef)

Adds a valid reference.

Parameters
modRefnumber of the reference frame

Definition at line 555 of file h264parser.cpp.

References cH264Parser::m_hasValidReferences, and cH264Parser::m_validReferences.

◆ AlphaBlend()

static void AlphaBlend ( uint8_t result,
uint8_t front,
uint8_t back,
const unsigned int  width,
const unsigned int  height 
)
static

Blend two images.

Both, front and back image data have to be same size front is the OSD (ARGB) back is the video (RGB) result is RGB

Parameters
[out]resultpointer to the resulting image data
[in]frontpointer to the upper image data
[in]backpointer to the lower image data
[in]widthimage width
[in]heightimage height

Definition at line 204 of file grab.cpp.

References BLEND, OPAQUE, TRANSPARENT, and UNMULTIPLY.

Referenced by cSoftHdGrab::ProcessGrab().

◆ av_err2string()

static const char * av_err2string ( int  errnum)
inlinestatic

Workaround for av_err2str() not working with C++.

Definition at line 100 of file misc.h.

◆ BlitVideo()

static int BlitVideo ( uint8_t dst,
uint8_t src,
int  dstW,
int  dstH,
int  dstX,
int  dstY,
int  srcW,
int  srcH 
)
static

Blit the video on black background.

Parameters
[in]dstpointer to the destination video
[in]srcpointer to the source video
[in]dstWdestination width of the image
[in]dstHdestination height of the image
[in]dstXx offset of the (already scaled) video on the image
[in]dstYy offset of the (already scaled) video on the image
[in]srcWsource video width
[in]srcHsource video height
Returns
0 on success, -1 on error

Definition at line 265 of file grab.cpp.

References L_GRAB, and LOGDEBUG2.

Referenced by cSoftHdGrab::ProcessGrab().

◆ BufToRgb()

static uint8_t * BufToRgb ( cDrmBuffer buf,
int size,
int  dstW,
int  dstH,
enum AVPixelFormat  dstPixFmt 
)
static

Convert a DRM buffer to rgb format image.

Conversion is done with ffmpegs swscale

Parameters
[in]bufpointer to the source drm buffer struct
[out]sizesize of the return data
[in]dstWwidth of the returned image
[in]dstHheight of the returned image
[in]dstPixFmtpixel format of the returned image
Returns
a pointer to the image data

Definition at line 75 of file grab.cpp.

References DrmFormatToAVFormat(), L_GRAB, LOGDEBUG2, and LOGERROR.

Referenced by cSoftHdGrab::GetGrab().

◆ BuildInvalidReferenceString()

void cH264Parser::BuildInvalidReferenceString ( int  frameNumber)

Add a whitespace-separated list of all invalid references to the log output string.

Parameters
frameNumberonly build the string up to the given frameNumber

Definition at line 566 of file h264parser.cpp.

References cH264Parser::m_hasInvalidReferences, cH264Parser::m_invalidReferences, and cH264Parser::m_naluString.

◆ BuildValidReferenceString()

void cH264Parser::BuildValidReferenceString ( void  )

Add a whitespace-separated list of all valid references to the log output string.

Definition at line 583 of file h264parser.cpp.

References cH264Parser::m_hasValidReferences, cH264Parser::m_naluString, and cH264Parser::m_validReferences.

◆ cH264Parser()

cH264Parser::cH264Parser ( AVPacket avpkt,
int  maxFrameNum,
int  refIdxL0,
int  refIdxL1 
)

Init the h264 parser and detect the nalu types.

Parameters
avpktAVPacket to parse
maxFrameNumlog2MaxFrameNumMinus4 from a previous SPS parsing, will be overwritten if this packet contains SPS
refIdxL0ppsNumRefIdxL0DefaultActiveMinus1 from a previous PPS parsing, will be overwritten if this packet contains PPS
refIdxL1ppsNumRefIdxL1DefaultActiveMinus1 from a previous PPS parsing, will be overwritten if this packet contains PPS

Definition at line 159 of file h264parser.cpp.

References cH264Parser::ConvertEBSPtoRBSP(), cH264Parser::GetPPSOffset(), cH264Parser::GetSliceOffset(), cH264Parser::GetSPSOffset(), isValidStartCode(), cH264Parser::m_frameNum, cH264Parser::m_hasPPS, cH264Parser::m_hasSPS, cH264Parser::m_height, cH264Parser::m_isIDR, cH264Parser::m_isReference, cH264Parser::m_log2MaxFrameNumMinus4, cH264Parser::m_mbaff, cH264Parser::m_nalRefIdc, cH264Parser::m_naluString, cH264Parser::m_nalutype, cH264Parser::m_nCurrentBit, cH264Parser::m_nLength, cH264Parser::m_numRefIdxL0Active, cH264Parser::m_numRefIdxL1Active, cH264Parser::m_parseError, cH264Parser::m_pAvpkt, cH264Parser::m_ppsNumRefIdxL0DefaultActiveMinus1, cH264Parser::m_ppsNumRefIdxL1DefaultActiveMinus1, cH264Parser::m_pStart, cH264Parser::m_rbsp, cH264Parser::m_refMods, cH264Parser::m_sliceType, cH264Parser::m_width, NALU_TYPE_AUD, NALU_TYPE_IDR, NALU_TYPE_NON_IDR, NALU_TYPE_PART_A, NALU_TYPE_PART_B, NALU_TYPE_PART_C, NALU_TYPE_PPS, NALU_TYPE_SEI, NALU_TYPE_SPS, NalUnitType(), cH264Parser::ReadBit(), cH264Parser::ReadBits(), cH264Parser::ReadExponentialGolombCode(), and cH264Parser::ReadSE().

◆ ConvertEBSPtoRBSP()

void cH264Parser::ConvertEBSPtoRBSP ( const uint8_t src,
int  length 
)
private

Definition at line 722 of file h264parser.cpp.

References cH264Parser::m_rbsp.

Referenced by cH264Parser::cH264Parser().

◆ cPes()

cPes::cPes ( const uint8_t data,
int  size 
)

Create a PES packet parser.

Initializes the parser with a pointer to PES packet data and its size. The actual validation is performed by calling Init() in derived classes.

Parameters
dataPointer to the raw PES packet data
sizeSize of the PES packet in bytes

Definition at line 203 of file pes.cpp.

◆ CreateJpeg()

uint8_t * CreateJpeg ( uint8_t image,
int size,
int  quality,
int  width,
int  height 
)

Call rgb to jpeg for C Plugin.

Definition at line 428 of file grab.cpp.

Referenced by cSoftHdGrab::ProcessGrab().

◆ DetectCodecFromSyncWord()

AVCodecID cReassemblyBufferAudio::DetectCodecFromSyncWord ( const uint8_t syncWord,
int  size 
)

Detect audio codec from sync word pattern.

Checks if the data starts with a valid sync word for any supported audio codec. Uses the AudioCodecMap to test sync word patterns for MP2, AAC LATM, AAC ADTS, AC3, and E-AC3.

Parameters
syncWordPointer to potential sync word data
sizeSize of available data
Returns
Detected AVCodecID, or AV_CODEC_ID_NONE if no match

Definition at line 590 of file pes.cpp.

References AudioCodecMap.

Referenced by cReassemblyBufferAudio::FindSyncWord(), cReassemblyBufferAudio::FindTwoConsecutiveFramesWithSameSyncWord(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), and TEST_CASE().

◆ DrmFormatToAVFormat()

enum AVPixelFormat DrmFormatToAVFormat ( cDrmBuffer buf)

Convert a DRM format to a ffmpeg AV format.

Definition at line 45 of file grab.cpp.

Referenced by BufToRgb().

◆ eglCheckError()

static void eglCheckError ( const char stmt,
const char fname,
int  line 
)
inlinestatic

Check for EGL errors and log them.

Definition at line 49 of file misc.h.

References LOGERROR.

◆ Erase()

void cPtsTrackingBuffer::Erase ( size_t  amount)

Erase data from the beginning of the buffer.

Removes the specified number of bytes from the front of the buffer and adjusts all PTS positions accordingly. The PTS value for the new position 0 is preserved by finding the last PTS value before the erase point.

This ensures that when frames are popped from the buffer, they retain the PTS of the PES packet where the frame started, even if that PES packet has been partially consumed.

Parameters
amountNumber of bytes to erase from the beginning

Definition at line 666 of file pes.cpp.

References AV_NOPTS_VALUE, LOGFATAL, cPtsTrackingBuffer::m_data, cPtsTrackingBuffer::m_identifier, and cPtsTrackingBuffer::m_pts.

Referenced by cReassemblyBufferAudio::FindTwoConsecutiveFramesWithSameSyncWord(), cReassemblyBuffer::PopAvPacket(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), and cReassemblyBufferAudio::TruncateBufferUntilFirstValidData().

◆ FindSyncWord()

SyncWordInfo cReassemblyBufferAudio::FindSyncWord ( const uint8_t data,
int  size 
)

Find the first audio sync word in data.

Scans the data byte-by-byte looking for any recognized audio sync word pattern. Checks all supported audio codecs (MP2, AAC LATM, AAC ADTS, AC3, E-AC3).

Parameters
dataPointer to audio data
sizeSize of the data in bytes
Returns
SyncWordInfo with detected codec and position, or AV_CODEC_ID_NONE if not found

Definition at line 568 of file pes.cpp.

References cReassemblyBufferAudio::DetectCodecFromSyncWord().

Referenced by cReassemblyBufferAudio::FindTwoConsecutiveFramesWithSameSyncWord(), TEST_CASE(), TEST_CASE(), TEST_CASE(), and TEST_CASE().

◆ FindTwoConsecutiveFramesWithSameSyncWord()

SyncWordInfo cReassemblyBufferAudio::FindTwoConsecutiveFramesWithSameSyncWord ( void  )
private

Find two consecutive audio frames with the same sync word.

Searches the buffer for a valid audio frame followed immediately by another frame of the same codec. This validates that the sync word and frame header are genuine and not false positives in random data.

The function modifies the buffer internally by erasing false positives as it searches. When no sync word is found, it keeps the last MAX_HEADER_SIZE bytes.

Returns
SyncWordInfo with codec ID and position, or AV_CODEC_ID_NONE if not found

Definition at line 521 of file pes.cpp.

References AudioCodecMap, cReassemblyBufferAudio::DetectCodecFromSyncWord(), cPtsTrackingBuffer::Erase(), cReassemblyBufferAudio::FindSyncWord(), cPtsTrackingBuffer::GetSize(), cReassemblyBuffer::m_buffer, cReassemblyBufferAudio::MAX_HEADER_SIZE, and cPtsTrackingBuffer::Peek().

Referenced by cReassemblyBufferAudio::TruncateBufferUntilFirstValidData().

◆ FreeDrmBuf()

void cGrabBuffer::FreeDrmBuf ( void  )

Free the grabbed drm buffer.

Definition at line 290 of file grab.cpp.

References L_GRAB, LOGDEBUG2, cGrabBuffer::m_pBuf, and plane.

Referenced by cVideoRender::ClearGrabBuffers().

◆ GetFrameSizeForCodec()

int cReassemblyBufferAudio::GetFrameSizeForCodec ( AVCodecID  codec,
const uint8_t data 
)

Get the frame size for a given codec and frame header.

Calculates the frame size by parsing the codec-specific frame header. Only used for testing purposes to expose the AudioCodecMap frame size calculation.

Parameters
codecThe audio codec ID
dataPointer to the frame header data
Returns
Frame size in bytes
Exceptions
std::out_of_rangeif codec is not in AudioCodecMap
std::invalid_argumentif frame header is invalid

Definition at line 614 of file pes.cpp.

References AudioCodecMap.

Referenced by TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), and TEST_CASE().

◆ GetGrab()

uint8_t * cSoftHdGrab::GetGrab ( int size,
int width,
int height,
int x,
int y,
Grabtype  type 
)
private

Convert the cloned drm buffer data to RGB(void, pip) or ARGB (osd) and return a pointer to the raw data.

Parameters
[out]sizesize of the grabbed buffer
[out]widthwidth of the grabbed buffer
[out]heightheight of the grabbed buffer
[out]xx offset of the grabbed buffer
[out]yy offset of the grabbed buffer
[in]buffertype buffer type (Grabtype)
Returns
a pointer to the raw buffer data

Definition at line 373 of file grab.cpp.

References BufToRgb(), cVideoRender::GetGrabbedOsdBuffer(), cVideoRender::GetGrabbedPipBuffer(), cVideoRender::GetGrabbedVideoBuffer(), GRABOSD, GRABPIP, GrabtypeToString(), GRABVIDEO, L_GRAB, LOGDEBUG2, LOGFATAL, cSoftHdGrab::m_pRender, and plane.

Referenced by cSoftHdGrab::ProcessGrab().

◆ GetLogger()

std::shared_ptr< cSoftHdLogger > cSoftHdLogger::GetLogger ( )
static

Get an instance to the global logger.

Returns
pointer to the logger instance

Definition at line 50 of file logger.cpp.

References cSoftHdLogger::cSoftHdLogger().

Referenced by cSoftHdLogger::LogFFmpegCallback(), cSoftHdConfig::SetupParse(), and cMenuSetupSoft::Store().

◆ GetPacketLength()

int cPes::GetPacketLength ( void  )

Get the total length of the PES packet.

Returns the complete size of the PES packet including both header and payload. The length is read from the PES packet header (bytes 4-5).

For packets with a specified length field (common for audio):

  • Returns the actual PES packet length from the header
  • Calculated as 6 + length_field (per H.222.0 standard)
  • The length_field specifies bytes after the 6-byte header prefix (3 bytes start code + 1 byte stream ID + 2 bytes length field)

For unbounded packets (length field = 0, common for video streams):

  • Returns the input buffer size (m_size)
Returns
Total size in bytes: actual packet length if specified, otherwise input buffer size

Definition at line 336 of file pes.cpp.

References cPes::m_data, and cPes::m_size.

◆ GetPayload()

const uint8_t * cPes::GetPayload ( void  )

Get a pointer to the PES payload data.

Returns a pointer to the start of the payload data, skipping the PES header. For H.264/HEVC streams with a leading zero byte, the leading zero is also skipped.

Returns
Pointer to the payload data

Definition at line 301 of file pes.cpp.

References cPes::m_data.

◆ GetPayloadSize()

int cPes::GetPayloadSize ( void  )

Get the size of the PES payload.

Calculates the size of the payload by subtracting the header size (and optional leading zero for H.264/HEVC) from the total packet size.

Returns
Size of the payload in bytes

Definition at line 314 of file pes.cpp.

References cPes::m_data, and cPes::m_size.

◆ GetPPSOffset()

int cH264Parser::GetPPSOffset ( void  )
private

Get the PPS offset.

Return values
positivevalue PPS offset in the data stream
-1if there is no PPS

Definition at line 107 of file h264parser.cpp.

References isValidStartCode(), cH264Parser::m_pAvpkt, and NalUnitType().

Referenced by cH264Parser::cH264Parser().

◆ GetPts() [1/2]

int64_t cPes::GetPts ( void  )

Get the Presentation Time Stamp (PTS) from the PES header.

Extracts the PTS value from the PES packet header if present. The PTS indicates when the decoded content should be presented.

Returns
The PTS value in 90 kHz units, or AV_NOPTS_VALUE if no PTS is present

Definition at line 285 of file pes.cpp.

References AV_NOPTS_VALUE, cPes::HasPts(), and cPes::m_data.

◆ GetPts() [2/2]

int64_t cPtsTrackingBuffer::GetPts ( void  )

Get the PTS value for the current buffer position.

Returns the PTS associated with position 0 in the buffer, which represents the presentation timestamp for the data at the front of the buffer.

Returns
PTS value, or AV_NOPTS_VALUE if no PTS is available

Definition at line 704 of file pes.cpp.

References AV_NOPTS_VALUE, and cPtsTrackingBuffer::m_pts.

Referenced by cReassemblyBuffer::PopAvPacket(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), and TEST_CASE().

◆ GetSliceOffset()

int cH264Parser::GetSliceOffset ( void  )
private

Get the slice offset.

Return values
positivevalue slice offset in the data stream
-1if there is no slice

Definition at line 132 of file h264parser.cpp.

References isValidStartCode(), cH264Parser::m_pAvpkt, and NalUnitType().

Referenced by cH264Parser::cH264Parser().

◆ GetSPSOffset()

int cH264Parser::GetSPSOffset ( void  )
private

Get the SPS offset.

Return values
positivevalue SPS offset in the data stream
-1if there is no SPS

Definition at line 82 of file h264parser.cpp.

References isValidStartCode(), cH264Parser::m_pAvpkt, and NalUnitType().

Referenced by cH264Parser::cH264Parser().

◆ glCheckError()

static void glCheckError ( const char stmt,
const char fname,
int  line 
)
inlinestatic

Check for OpenGL errors and log them.

Definition at line 40 of file misc.h.

References LOGERROR.

◆ GrabtypeToString()

const char * GrabtypeToString ( Grabtype  t)
inline

Definition at line 33 of file grab.h.

References GRABOSD, GRABPIP, and GRABVIDEO.

Referenced by cSoftHdGrab::GetGrab().

◆ HasLeadingZero()

bool cReassemblyBufferVideo::HasLeadingZero ( const uint8_t data,
int  size 
)

Check if video data has a leading zero byte before the start code.

Some H.264/HEVC streams include a leading zero byte (0x00) before the standard start code (0x000001). This method detects that pattern.

Parameters
dataPointer to video data
sizeSize of the data in bytes
Returns
true if a leading zero is present, false otherwise

Definition at line 438 of file pes.cpp.

References ReadBytes(), cReassemblyBufferVideo::VIDEO_FRAME_START_CODE, and cReassemblyBufferVideo::VIDEO_FRAME_START_CODE_LEN.

Referenced by cReassemblyBufferVideo::ParseCodecHeader(), cSoftHdDevice::PlayVideoInternal(), and TEST_CASE().

◆ HasPts()

bool cPes::HasPts ( void  )

Check if the PES packet contains a Presentation Time Stamp (PTS)

Examines the PES header flags to determine if a PTS is present in the packet. The PTS presence is indicated by specific bits in the PES header flags field.

Returns
true if the PES packet contains a PTS, false otherwise

Definition at line 272 of file pes.cpp.

References cPes::m_data.

Referenced by cPes::GetPts().

◆ Init()

void cPes::Init ( void  )
protected

Initialize and validate the PES packet.

Performs validation checks on the PES packet structure:

  • Validates the PES header (start code prefix)
  • Checks if the stream ID matches the expected type (audio/video)
  • Ensures the packet has sufficient size for the header
  • Verifies the payload offset is within bounds

Sets m_valid to true if all checks pass. Called by derived class constructors.

Definition at line 219 of file pes.cpp.

References cPes::GetStreamId(), cPes::IsHeaderValid(), cPes::IsStreamIdValid(), LOGDEBUG, LOGWARNING, cPes::m_data, cPes::m_size, and cPes::m_valid.

Referenced by cPesAudio::cPesAudio(), and cPesVideo::cPesVideo().

◆ IsHeaderValid()

bool cPes::IsHeaderValid ( void  )
protected

Check if the PES header is valid.

Validates that the PES packet has a valid header by checking:

  • The packet is long enough to contain a header
  • The start code prefix (0x000001) is present
Returns
true if the header is valid, false otherwise

Definition at line 259 of file pes.cpp.

References cPes::m_data, cPes::m_size, cPes::PES_PACKET_START_CODE_PREFIX, and ReadBytes().

Referenced by cPes::Init().

◆ isInterlacedFrame()

static bool isInterlacedFrame ( AVFrame frame)
inlinestatic

Check, if this is an interlaced frame.

Parameters
frameAVFrame
Returns
true, if this frame is an interlaced frame

Definition at line 86 of file misc.h.

Referenced by cVideoFilter::Action(), cVideoDecoder::ReceiveFrame(), and cVideoStream::RenderFrame().

◆ IsValid()

bool cPes::IsValid ( void  )

Check if the PES packet is valid.

Validates that the PES packet is well-formed and matches the expected stream type by checking:

  • The PES header is valid
  • The stream ID matches the expected stream type (video or audio)

The stream ID is masked with 0xF0 to check the stream type category (e.g., 0xE0 for video, 0xC0 for audio) while ignoring the low nibble which indicates the specific stream number.

Video streams have stream IDs in the range 0xE0-0xEF according to H.222.0 03/2017 Table 2-22, audio streams have IDs in the range 0xC0-0xCF.

Returns
true if the packet is valid and matches the expected stream type, false otherwise

Definition at line 245 of file pes.cpp.

References cPes::m_valid.

◆ isValidStartCode()

bool isValidStartCode ( const uint8_t data,
int  offset,
int  size,
int startCodeLength 
)

Check for a 0x000001 or 0x00000001 start code.

Parameters
[in]datapointer to the data stream
[in]offsetstart parsing at offset
[in]sizesize of data
[out]startCodeLengthstart code length (3 or 4)
Return values
trueif a valid start code was detected
falseno valid startcode was detected

Definition at line 47 of file h264parser.cpp.

References ReadBytes().

Referenced by cH264Parser::cH264Parser(), cH264Parser::GetPPSOffset(), cH264Parser::GetSliceOffset(), and cH264Parser::GetSPSOffset().

◆ LogDebug()

void cSoftHdLogger::LogDebug ( const char format,
  ... 
)

Log to syslog LOG_DEBUG.

Definition at line 147 of file logger.cpp.

References cSoftHdLogger::m_logLevel, and cSoftHdLogger::MAX_LOGMESSAGE_SIZE.

◆ LogDebug2()

void cSoftHdLogger::LogDebug2 ( const int  cat,
const char format,
  ... 
)

Log to syslog LOG_DEBUG and add logging category to output.

Definition at line 166 of file logger.cpp.

References L_AV_SYNC, L_CODEC, L_DEBUG, L_DRM, L_GRAB, L_MEDIA, L_OPENGL, L_OPENGL_TIME, L_OPENGL_TIME_ALL, L_OSD, L_PACKET, L_SOUND, L_STILL, L_TRICK, cSoftHdLogger::m_logLevel, and cSoftHdLogger::MAX_LOGMESSAGE_SIZE.

◆ LogError()

void cSoftHdLogger::LogError ( const char format,
  ... 
)

Log to syslog LOG_ERR.

Definition at line 90 of file logger.cpp.

References cSoftHdLogger::MAX_LOGMESSAGE_SIZE, and SysLogLevel.

◆ LogFatal()

void cSoftHdLogger::LogFatal ( const char format,
  ... 
)

Log to syslog LOG_ERR and abort.

Definition at line 69 of file logger.cpp.

References cSoftHdLogger::MAX_LOGMESSAGE_SIZE, and SysLogLevel.

◆ LogFFmpeg()

void cSoftHdLogger::LogFFmpeg ( const char fmt,
va_list  vl 
)

Log to syslog LOG_DEBUG and add prefix [FFMpeg] to output.

Definition at line 226 of file logger.cpp.

References AV_LOGLEVEL, L_FFMPEG, cSoftHdLogger::m_logLevel, and cSoftHdLogger::MAX_LOGMESSAGE_SIZE.

◆ LogFFmpegCallback()

void cSoftHdLogger::LogFFmpegCallback ( void ptr,
int  level,
const char fmt,
va_list  vl 
)
static

Callback for ffmpeg logs.

Log to LOG_DEBUG and add prefix to output

Definition at line 248 of file logger.cpp.

References cSoftHdLogger::GetLogger().

Referenced by cVideoDecoder::cVideoDecoder().

◆ LogInfo()

void cSoftHdLogger::LogInfo ( const char format,
  ... 
)

Log to syslog LOG_INFO.

Definition at line 128 of file logger.cpp.

References cSoftHdLogger::MAX_LOGMESSAGE_SIZE, and SysLogLevel.

◆ LogWarning()

void cSoftHdLogger::LogWarning ( const char format,
  ... 
)

Log to syslog LOG_WARNING.

Definition at line 109 of file logger.cpp.

References cSoftHdLogger::MAX_LOGMESSAGE_SIZE, and SysLogLevel.

◆ NalUnitType()

static int NalUnitType ( const uint8_t data,
int  offset,
int  startCodeLength 
)
static

Return the nal unit type.

Parameters
datapointer to the data stream
offsetstart parsing at offset
startCodeLengthstart code length (3 or 4)
Returns
the nal unit type

Definition at line 71 of file h264parser.cpp.

Referenced by cH264Parser::cH264Parser(), cH264Parser::GetPPSOffset(), cH264Parser::GetSliceOffset(), and cH264Parser::GetSPSOffset().

◆ PacketReceived()

void cJitterTracker::PacketReceived ( void  )

Called each time a packet is received.

Calculates the diff in PTS to the last received packet and compares that to the diff of the wall clock time of the last received packet to now.

Definition at line 27 of file jittertracker.cpp.

References cJitterTracker::m_firstPacket, cJitterTracker::m_lastDiffMs, cJitterTracker::m_lastTime, cJitterTracker::m_longTermMaxJitterMs, cJitterTracker::m_packetCounter, cJitterTracker::m_secondPacket, and cJitterTracker::m_shortTermMaxJitterMs.

Referenced by cSoftHdDevice::PlayAudio(), and cSoftHdDevice::PlayVideoInternal().

◆ ParseCodecHeader()

bool cReassemblyBufferVideo::ParseCodecHeader ( const uint8_t fragment,
int  size 
)

Parse video codec header to detect codec type.

Analyzes video frame start codes and stream type bytes to identify the codec. Supports MPEG2, H.264, and HEVC video codecs.

Parameters
fragmentPointer to video frame data
sizeSize of the fragment in bytes
Returns
true if a codec was detected, false otherwise

Definition at line 404 of file pes.cpp.

References cReassemblyBufferVideo::H264_STREAM_TYPE, cReassemblyBufferVideo::HasLeadingZero(), cReassemblyBufferVideo::HEVC_STREAM_TYPE, cReassemblyBuffer::m_codec, cReassemblyBufferVideo::MPEG2_STREAM_TYPE, ReadBytes(), cReassemblyBufferVideo::VIDEO_FRAME_START_CODE, and cReassemblyBufferVideo::VIDEO_FRAME_START_CODE_LEN.

Referenced by cSoftHdDevice::PlayVideoInternal(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), and TEST_CASE().

◆ PopAvPacket() [1/2]

AVPacket * cReassemblyBuffer::PopAvPacket ( int  size)
protected

Pop an AVPacket from the reassembly buffer.

Creates an AVPacket containing the specified amount of data from the buffer.

Parameters
sizeNumber of bytes to pop from the buffer
Returns
Allocated AVPacket with data, or nullptr if size is 0

Definition at line 357 of file pes.cpp.

References AV_NOPTS_VALUE, cPtsTrackingBuffer::Erase(), cPtsTrackingBuffer::GetPts(), LOGFATAL, cReassemblyBuffer::m_buffer, cReassemblyBuffer::m_lastPoppedPts, and cPtsTrackingBuffer::Peek().

◆ PopAvPacket() [2/2]

AVPacket * cReassemblyBufferAudio::PopAvPacket ( void  )
overridevirtual

Pop an audio AVPacket from the reassembly buffer.

Truncates the buffer to the first valid audio frame, detects the codec, and pops a complete audio frame as an AVPacket.

Returns
Allocated AVPacket with one audio frame, or nullptr if no valid frame found

Implements cReassemblyBuffer.

Definition at line 455 of file pes.cpp.

References AudioCodecMap, AV_NOPTS_VALUE, LOGERROR, LOGWARNING, cReassemblyBuffer::m_buffer, cReassemblyBuffer::m_codec, cReassemblyBufferAudio::m_ptsInvalid, cPtsTrackingBuffer::Peek(), cReassemblyBuffer::PopAvPacket(), and cReassemblyBufferAudio::TruncateBufferUntilFirstValidData().

Referenced by cSoftHdDevice::PlayAudio().

◆ PrintNalUnits()

void cH264Parser::PrintNalUnits ( void  )

Print the previously created log output string.

Definition at line 634 of file h264parser.cpp.

References L_CODEC, LOGDEBUG2, cH264Parser::m_height, cH264Parser::m_naluString, and cH264Parser::m_width.

◆ PrintStreamData()

void cH264Parser::PrintStreamData ( void  )

Print raw stream data of the first 35 bytes.

Definition at line 618 of file h264parser.cpp.

References LOGDEBUG, and cH264Parser::m_pAvpkt.

◆ ProcessGrab()

bool cSoftHdGrab::ProcessGrab ( void  )
private

Start the conversion.

This does the following: 1) Get grabbed video data if available, otherwise create a black screen for video 2) Get grabbed pip data if available 3) Get grabbed osd data if available 4) Blit the video data into a black background image if it is scaled 5) If available, blit the pip data onto it 6) If available, blit the osd data onto it respecting alpha values 7) Scale the result to the user requested size 8) Create a jpg or pnm image as requested

Definition at line 447 of file grab.cpp.

References AlphaBlend(), BlitVideo(), CreateJpeg(), cSoftHdGrab::GetGrab(), GRABOSD, GRABPIP, GRABVIDEO, L_GRAB, LOGDEBUG2, cSoftHdGrab::m_grabbedHeight, cSoftHdGrab::m_grabbedImage, cSoftHdGrab::m_grabbedSize, cSoftHdGrab::m_grabbedWidth, cSoftHdGrab::m_isActive, cSoftHdGrab::m_isJpeg, cSoftHdGrab::m_quality, cSoftHdGrab::m_screenHeight, cSoftHdGrab::m_screenWidth, and ScaleRgb24().

Referenced by cSoftHdGrab::Start().

◆ Push()

void cPtsTrackingBuffer::Push ( const uint8_t data,
int  size,
int64_t  pts 
)

Push data into the PTS tracking buffer.

Appends data to the buffer and associates the PTS with the current buffer position if a valid PTS is provided.

Parameters
dataPointer to data to append
sizeSize of data in bytes
ptsPresentation timestamp, or AV_NOPTS_VALUE if not available

Definition at line 645 of file pes.cpp.

References AV_NOPTS_VALUE, cPtsTrackingBuffer::m_data, and cPtsTrackingBuffer::m_pts.

Referenced by cReassemblyBuffer::Push(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), and TEST_CASE().

◆ ReadBit()

unsigned int cH264Parser::ReadBit ( void  )
private

◆ ReadBits()

unsigned int cH264Parser::ReadBits ( int  n)
private

◆ ReadBytes()

static uint32_t ReadBytes ( const uint8_t data,
int  count 
)
inlinestatic

Return count amount of bytes from data

Definition at line 149 of file misc.h.

Referenced by cReassemblyBufferVideo::HasLeadingZero(), cPes::IsHeaderValid(), isValidStartCode(), and cReassemblyBufferVideo::ParseCodecHeader().

◆ ReadExponentialGolombCode()

unsigned int cH264Parser::ReadExponentialGolombCode ( void  )
private

Read an unsigned exponential-golomb coded integer.

Definition at line 679 of file h264parser.cpp.

References cH264Parser::m_nCurrentBit, cH264Parser::m_nLength, cH264Parser::m_parseError, cH264Parser::ReadBit(), and cH264Parser::ReadBits().

Referenced by cH264Parser::cH264Parser(), and cH264Parser::ReadSE().

◆ ReadSE()

unsigned int cH264Parser::ReadSE ( void  )
private

Read a signed exponential-golomb coded integer.

Definition at line 710 of file h264parser.cpp.

References cH264Parser::ReadExponentialGolombCode().

Referenced by cH264Parser::cH264Parser().

◆ Reset() [1/3]

◆ Reset() [2/3]

◆ Reset() [3/3]

void cReassemblyBuffer::Reset ( void  )

◆ ResetFramesCounters()

void cBufferFillLevelLowPassFilter::ResetFramesCounters ( void  )

Resets the received and written frames counters.

Definition at line 33 of file filllevel.cpp.

References cBufferFillLevelLowPassFilter::m_receivedFrames, and cBufferFillLevelLowPassFilter::m_writtenToAlsaFrames.

Referenced by cSoftHdAudio::FlushBuffers().

◆ ScaleRgb24()

static uint8_t * ScaleRgb24 ( uint8_t src,
int size,
int  srcW,
int  srcH,
int  dstW,
int  dstH 
)
static

Scale an image.

Conversion is done with ffmpegs swscale

Parameters
[in]srcpointer to the source data
[out]sizesize of the return data
[in]srcWsource width
[in]srcHsource height
[in]dstWwidth of the returned image
[in]dstHheight of the returned image
Returns
a pointer to the converted image data

Definition at line 153 of file grab.cpp.

References L_GRAB, LOGDEBUG2, and LOGERROR.

Referenced by cSoftHdGrab::ProcessGrab().

◆ SetDrmBuf()

void cGrabBuffer::SetDrmBuf ( cDrmBuffer buf)

Set the grab buffer and the dimensions how it is presented on the screen.

Definition at line 309 of file grab.cpp.

References cGrabBuffer::m_pBuf, and cGrabBuffer::m_rect.

Referenced by cVideoRender::CreateGrabBuffers().

◆ SetLogLevel()

void cSoftHdLogger::SetLogLevel ( int  level)

Set the loglevel.

Parameters
levelnew loglevel

Definition at line 61 of file logger.cpp.

References cSoftHdLogger::m_logLevel.

◆ Start()

bool cSoftHdGrab::Start ( bool  jpeg,
int  quality,
int  width,
int  height,
int  screenWidth,
int  screenHeight 
)

Start a grab in the video renderer.

Parameters
jpegflag true, create JPEG data
qualityJPEG quality
widthwidth of requested grab image
heightheight of requested grab image
screenWidthcurrent screen width
screenHeightcurrent screen height

Definition at line 329 of file grab.cpp.

References cVideoRender::ClearGrabBuffers(), L_GRAB, LOGDEBUG2, cSoftHdGrab::m_grabbedHeight, cSoftHdGrab::m_grabbedImage, cSoftHdGrab::m_grabbedWidth, cSoftHdGrab::m_isActive, cSoftHdGrab::m_isJpeg, cSoftHdGrab::m_pRender, cSoftHdGrab::m_quality, cSoftHdGrab::m_screenHeight, cSoftHdGrab::m_screenWidth, cSoftHdGrab::ProcessGrab(), and cVideoRender::TriggerGrab().

Referenced by cSoftHdDevice::GrabImage().

◆ StateToString()

const char * cBufferFillLevelLowPassFilter::StateToString ( State  state)
private

Converts the filter state to a string representation.

Parameters
stateThe state to convert
Returns
String representation of the state

Definition at line 89 of file filllevel.cpp.

References cBufferFillLevelLowPassFilter::SETTLED, cBufferFillLevelLowPassFilter::SETTLING, and cBufferFillLevelLowPassFilter::UNINITIALIZED.

◆ Timestamp2String()

static const char * Timestamp2String ( int64_t  ts,
uint8_t  divisor 
)
inlinestatic

Nice time-stamp string.

Parameters
tstime stamp
divisoroptional divisor for the given timestamp int (must be > 0)
Returns
nice formatted timestamp string

Definition at line 127 of file misc.h.

References AV_NOPTS_VALUE.

Referenced by cVideoRender::DisplayFrame(), cSoftHdAudio::DropSamplesOlderThanPtsMs(), cSoftHdAudio::Enqueue(), cSoftHdDevice::IsBufferingThresholdReached(), cVideoRender::LogDroppedDuped(), cVideoRender::PageFlip(), cVideoDecoder::ReceiveFrame(), and cVideoDecoder::SendPacket().

◆ TruncateBufferUntilFirstValidData()

AVCodecID cReassemblyBufferAudio::TruncateBufferUntilFirstValidData ( void  )

Truncate buffer until the first valid audio frame.

Searches for two consecutive audio frames with the same sync word to validate the frame header, then erases all data before the first valid frame. This removes garbage data and synchronizes to the audio stream.

Returns
Detected codec ID, or AV_CODEC_ID_NONE if no valid frames found

Definition at line 493 of file pes.cpp.

References cPtsTrackingBuffer::Erase(), cReassemblyBufferAudio::FindTwoConsecutiveFramesWithSameSyncWord(), cPtsTrackingBuffer::GetSize(), LOGDEBUG, cReassemblyBuffer::m_buffer, and cReassemblyBufferAudio::m_ptsInvalid.

Referenced by cReassemblyBufferAudio::PopAvPacket(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), and TEST_CASE().

◆ UpdateAvgBufferFillLevel()

void cBufferFillLevelLowPassFilter::UpdateAvgBufferFillLevel ( int  hardwareBufferFillLevelFrames)

Updates the buffer fill level average.

Calculates the current buffer fill level based on received frames, written frames, and the hardware buffer fill level. Applies a low-pass filter (exponential moving average) to smooth the value. This is necessary, because the packets coming from VDR have a few milliseconds jitter.

Handles state transitions:

  • UNINITIALIZED -> SETTLING: Initializes the average and sets a faster alpha.
  • SETTLING -> SETTLED: After a duration, switches to a slower alpha and fixes the target value.
Parameters
hardwareBufferFillLevelFramesCurrent fill level reported by the hardware (ALSA)

Definition at line 53 of file filllevel.cpp.

References cBufferFillLevelLowPassFilter::FLOATING_AVERAGE_ALPHA_NORMAL, cBufferFillLevelLowPassFilter::FLOATING_AVERAGE_ALPHA_SETTLING, cBufferFillLevelLowPassFilter::m_bufferFillLevelFramesAvg, cBufferFillLevelLowPassFilter::m_bufferFillLevelFramesTargetValue, cBufferFillLevelLowPassFilter::m_floatingAverageAlpha, cBufferFillLevelLowPassFilter::m_frameCounter, cBufferFillLevelLowPassFilter::m_minBufferSizeFrames, cBufferFillLevelLowPassFilter::m_mutex, cBufferFillLevelLowPassFilter::m_receivedFrames, cBufferFillLevelLowPassFilter::m_state, cBufferFillLevelLowPassFilter::m_writtenToAlsaFrames, cBufferFillLevelLowPassFilter::SETTLED, cBufferFillLevelLowPassFilter::SETTLING, cBufferFillLevelLowPassFilter::SETTLING_DURATION_PACKETS, and cBufferFillLevelLowPassFilter::UNINITIALIZED.

Referenced by cSoftHdAudio::ClockDriftCompensation().

Variable Documentation

◆ AudioCodecMap

const std::map<AVCodecID, CodecInfo> AudioCodecMap
static

Map of Audio Codec Information.

Key: AVCodecID Value: CodecInfo with sync word detection and frame size calculation lambdas

Definition at line 47 of file pes.cpp.

Referenced by cReassemblyBufferAudio::DetectCodecFromSyncWord(), cReassemblyBufferAudio::FindTwoConsecutiveFramesWithSameSyncWord(), cReassemblyBufferAudio::GetFrameSizeForCodec(), and cReassemblyBufferAudio::PopAvPacket().