vdr-plugin-softhddevice-drm-gles 1.6.7
Miscellaneous

Miscellaneous Helper Functions. More...

Classes

struct  PlayEvent
 
struct  PauseEvent
 
struct  StopEvent
 
struct  TrickSpeedEvent
 
struct  StillPictureEvent
 
struct  DetachEvent
 
struct  AttachEvent
 
struct  BufferUnderrunEvent
 
struct  BufferingThresholdReachedEvent
 
struct  ScheduleResyncAtPtsMsEvent
 
struct  ResyncEvent
 
struct  DisplayChangeEvent
 
class  IEventReceiver
 Event Receiver. More...
 
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  cHardwareDevice
 Hardware device. 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...
 
class  cPool< T >
 Pool Implementation Template Class. More...
 
class  cQueue< T >
 Thread-safe Queue. 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)
 

Typedefs

using Event = std::variant< PlayEvent, PauseEvent, StopEvent, TrickSpeedEvent, StillPictureEvent, DetachEvent, AttachEvent, BufferUnderrunEvent, BufferingThresholdReachedEvent, ScheduleResyncAtPtsMsEvent, ResyncEvent, DisplayChangeEvent >
 

Enumerations

enum  BufferUnderrunType { VIDEO , AUDIO }
 
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)
}
 H.264 Nal unit types. More...
 
enum  HardwareQuirks {
  QUIRK_NO_HW_DEINT = 1 << 0 , QUIRK_CODEC_FLUSH_WORKAROUND = 1 << 1 , QUIRK_CODEC_NEEDS_DIMENSION_PARSE = 1 << 2 , QUIRK_CODEC_SKIP_FIRST_FRAMES = 1 << 3 ,
  QUIRK_CODEC_SKIP_NUM_FRAMES = 2
}
 Hardware dependent quirks. More...
 
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

void Sand128ToPlanarY8 (uint8_t *dst, const unsigned int dstStride, const uint8_t *src, unsigned int stride1, unsigned int stride2, unsigned int w, unsigned int h)
 Convert the luma (Y plane) from SAND to linear buffer (8bit)
 
static void Sand30ToPlanarY16 (uint8_t *dst, const unsigned int dstStride, const uint8_t *src, unsigned int stride1, unsigned int stride2, unsigned int w, unsigned int h)
 Convert the luma (Y plane) from SAND to linear buffer (10bit)
 
static void Sand30ToPlanarC16 (uint8_t *dstU, const unsigned int dstStrideU, uint8_t *dstV, const unsigned int dstStrideV, const uint8_t *src, unsigned int stride1, unsigned int stride2, unsigned int w, unsigned int h)
 Convert the chroma (UV plane) from SAND to linear buffer (10bit)
 
enum AVPixelFormat DrmFormatToAVFormat (uint32_t pixFmt)
 Convert a DRM format to a ffmpeg AV format.
 
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.
 
bool isValidStartCode (const uint8_t *data, int offset, int size, int &startCodeLength)
 H.264 Parser Helper to check for a 0x000001 or 0x00000001 start code.
 
static int NalUnitType (const uint8_t *data, int offset, int startCodeLength)
 H.264 Parser Helper to get the nal unit type.
 
static size_t ReadLineFromFile (char *buf, size_t size, const char *file)
 Helper function to read a line from a given file.
 
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
 

Variables

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

Detailed Description

Miscellaneous Helper Functions.

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 30 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 75 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 45 of file logger.h.

◆ LOGDEBUG2

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

log to LOG_DEBUG and add a prefix

Definition at line 47 of file logger.h.

◆ LOGERROR

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

log to LOG_ERR

Definition at line 39 of file logger.h.

◆ LOGFATAL

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

log to LOG_ERR and abort

Definition at line 37 of file logger.h.

◆ LOGINFO

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

log to LOG_INFO

Definition at line 43 of file logger.h.

◆ LOGWARNING

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

log to LOG_WARN

Definition at line 41 of file logger.h.

◆ OPAQUE

#define OPAQUE   0xff

Definition at line 72 of file grab.cpp.

◆ TRANSPARENT

#define TRANSPARENT   0x00

Definition at line 73 of file grab.cpp.

◆ UNMULTIPLY

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

Definition at line 74 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.

Typedef Documentation

◆ Event

Enumeration Type Documentation

◆ BufferUnderrunType

Enumerator
VIDEO 
AUDIO 

Definition at line 29 of file event.h.

◆ HardwareQuirks

Hardware dependent quirks.

Enumerator
QUIRK_NO_HW_DEINT 

set, if no hw deinterlacer available

QUIRK_CODEC_FLUSH_WORKAROUND 

set, if we have to close and reopen the codec instead of avcodec_flush_buffers (rpi)

QUIRK_CODEC_NEEDS_DIMENSION_PARSE 

set, if codec needs some infos for init (coded_width and coded_height)

QUIRK_CODEC_SKIP_FIRST_FRAMES 

set, if codec should skip first I-Frames

QUIRK_CODEC_SKIP_NUM_FRAMES 

skip QUIRK_CODEC_SKIP_NUM_FRAMES, in case QUIRK_CODEC_SKIP_FIRST_FRAMES is set

Definition at line 27 of file hardwaredevice.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 55 of file logger.h.

◆ NalUnitTypes

H.264 Nal unit types.

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

◆ 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 300 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 361 of file grab.cpp.

References L_GRAB, and LOGDEBUG2.

Referenced by cSoftHdGrab::ProcessGrab().

◆ 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 382 of file grab.cpp.

Referenced by cSoftHdGrab::ProcessGrab().

◆ DrmFormatToAVFormat()

enum AVPixelFormat DrmFormatToAVFormat ( uint32_t  pixFmt)

Convert a DRM format to a ffmpeg AV format.

Definition at line 217 of file grab.cpp.

Referenced by cGrabBuffer::ConvertToRgb().

◆ 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.

◆ 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.

◆ 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().

◆ isValidStartCode()

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

H.264 Parser Helper to 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 42 of file h264parser.cpp.

References ReadBytes().

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

◆ NalUnitType()

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

H.264 Parser Helper to get 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 68 of file h264parser.cpp.

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

◆ 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().

◆ ReadLineFromFile()

static size_t ReadLineFromFile ( char buf,
size_t  size,
const char file 
)
inlinestatic

Helper function to read a line from a given file.

Parameters
[out]bufpointer to the data
[out]sizesize of the data at buf
[in]filethe filepointer to be read on
Returns
the number of characters read

Definition at line 46 of file hardwaredevice.h.

References LOGERROR.

Referenced by cHardwareDevice::cHardwareDevice().

◆ Sand128ToPlanarY8()

void Sand128ToPlanarY8 ( uint8_t dst,
const unsigned int  dstStride,
const uint8_t src,
unsigned int  stride1,
unsigned int  stride2,
unsigned int  w,
unsigned int  h 
)

Convert the luma (Y plane) from SAND to linear buffer (8bit)

Definition at line 82 of file grab.cpp.

Referenced by cGrabBuffer::ConvertToRgb().

◆ Sand30ToPlanarC16()

static void Sand30ToPlanarC16 ( uint8_t dstU,
const unsigned int  dstStrideU,
uint8_t dstV,
const unsigned int  dstStrideV,
const uint8_t src,
unsigned int  stride1,
unsigned int  stride2,
unsigned int  w,
unsigned int  h 
)
static

Convert the chroma (UV plane) from SAND to linear buffer (10bit)

Definition at line 162 of file grab.cpp.

Referenced by cGrabBuffer::ConvertToRgb().

◆ Sand30ToPlanarY16()

static void Sand30ToPlanarY16 ( uint8_t dst,
const unsigned int  dstStride,
const uint8_t src,
unsigned int  stride1,
unsigned int  stride2,
unsigned int  w,
unsigned int  h 
)
static

Convert the luma (Y plane) from SAND to linear buffer (10bit)

Definition at line 119 of file grab.cpp.

Referenced by cGrabBuffer::ConvertToRgb().

◆ 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 249 of file grab.cpp.

References L_GRAB, LOGDEBUG2, and LOGERROR.

Referenced by cSoftHdGrab::ProcessGrab().

◆ 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 cSoftHdAudio::DropSamplesOlderThanPtsMs(), cSoftHdAudio::Enqueue(), cVideoRender::FrameDropNecessary(), cSoftHdDevice::IsBufferingThresholdReached(), cVideoRender::LogDroppedDuped(), cVideoRender::PageFlip(), cVideoDecoder::ReceiveFrame(), and cVideoDecoder::SendPacket().

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().