|
vdr-plugin-softhddevice-drm-gles 1.6.2
|
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_t * | BufToRgb (cDrmBuffer *buf, int *size, int dstW, int dstH, enum AVPixelFormat dstPixFmt) |
| Convert a DRM buffer to rgb format image. | |
| static uint8_t * | ScaleRgb24 (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_t * | CreateJpeg (uint8_t *image, int *size, int quality, int width, int height) |
| Call rgb to jpeg for C Plugin. | |
| const char * | GrabtypeToString (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 char * | av_err2string (int errnum) |
| Workaround for av_err2str() not working with C++. | |
| static const char * | Timestamp2String (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 char * | cBufferFillLevelLowPassFilter::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_t * | cSoftHdGrab::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< cSoftHdLogger > | cSoftHdLogger::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_t * | cPes::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. | |
| AVPacket * | cReassemblyBuffer::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. | |
| AVPacket * | cReassemblyBufferAudio::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, CodecInfo > | AudioCodecMap |
| Map of Audio Codec Information. | |
Miscellaneous Helper Functions.
{
H.264 Parser.
Event Handler.
Controls the state machine.
{@
| #define AV_LOGLEVEL AV_LOG_INFO |
eglCheckError macro
| #define LOGDEBUG cSoftHdLogger::GetLogger()->LogDebug |
| #define LOGDEBUG2 cSoftHdLogger::GetLogger()->LogDebug2 |
| #define LOGERROR cSoftHdLogger::GetLogger()->LogError |
| #define LOGFATAL cSoftHdLogger::GetLogger()->LogFatal |
| #define LOGINFO cSoftHdLogger::GetLogger()->LogInfo |
| #define LOGWARNING cSoftHdLogger::GetLogger()->LogWarning |
| #define VIDEO_SURFACES_MAX 3 |
Logger Flags.
depending on the flag used in the macro, logging is enabled and gets a nice prefix in the syslog.
| 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.
Add the frame number to the log output string.
| num | frame number to add to the string |
Definition at line 600 of file h264parser.cpp.
References cH264Parser::m_naluString.
Adds an invalid reference.
| modRef | number of the reference frame |
| frameNumber | number of the frame to add |
Definition at line 541 of file h264parser.cpp.
References cH264Parser::m_hasInvalidBackwardReferences, cH264Parser::m_hasInvalidReferences, and cH264Parser::m_invalidReferences.
Adds a valid reference.
| modRef | number of the reference frame |
Definition at line 555 of file h264parser.cpp.
References cH264Parser::m_hasValidReferences, and cH264Parser::m_validReferences.
|
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
| [out] | result | pointer to the resulting image data |
| [in] | front | pointer to the upper image data |
| [in] | back | pointer to the lower image data |
| [in] | width | image width |
| [in] | height | image height |
Definition at line 204 of file grab.cpp.
References BLEND, OPAQUE, TRANSPARENT, and UNMULTIPLY.
Referenced by cSoftHdGrab::ProcessGrab().
Workaround for av_err2str() not working with C++.
|
static |
Blit the video on black background.
| [in] | dst | pointer to the destination video |
| [in] | src | pointer to the source video |
| [in] | dstW | destination width of the image |
| [in] | dstH | destination height of the image |
| [in] | dstX | x offset of the (already scaled) video on the image |
| [in] | dstY | y offset of the (already scaled) video on the image |
| [in] | srcW | source video width |
| [in] | srcH | source video height |
Definition at line 265 of file grab.cpp.
References L_GRAB, and LOGDEBUG2.
Referenced by cSoftHdGrab::ProcessGrab().
|
static |
Convert a DRM buffer to rgb format image.
Conversion is done with ffmpegs swscale
| [in] | buf | pointer to the source drm buffer struct |
| [out] | size | size of the return data |
| [in] | dstW | width of the returned image |
| [in] | dstH | height of the returned image |
| [in] | dstPixFmt | pixel format of the returned image |
Definition at line 75 of file grab.cpp.
References DrmFormatToAVFormat(), L_GRAB, LOGDEBUG2, and LOGERROR.
Referenced by cSoftHdGrab::GetGrab().
Add a whitespace-separated list of all invalid references to the log output string.
| frameNumber | only 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.
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.
Init the h264 parser and detect the nalu types.
| avpkt | AVPacket to parse |
| maxFrameNum | log2MaxFrameNumMinus4 from a previous SPS parsing, will be overwritten if this packet contains SPS |
| refIdxL0 | ppsNumRefIdxL0DefaultActiveMinus1 from a previous PPS parsing, will be overwritten if this packet contains PPS |
| refIdxL1 | ppsNumRefIdxL1DefaultActiveMinus1 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().
Definition at line 722 of file h264parser.cpp.
References cH264Parser::m_rbsp.
Referenced by cH264Parser::cH264Parser().
Call rgb to jpeg for C Plugin.
Definition at line 428 of file grab.cpp.
Referenced by cSoftHdGrab::ProcessGrab().
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.
| syncWord | Pointer to potential sync word data |
| size | Size of available data |
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().
| 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().
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.
| amount | Number 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().
| 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).
| data | Pointer to audio data |
| size | Size of the data in bytes |
Definition at line 568 of file pes.cpp.
References cReassemblyBufferAudio::DetectCodecFromSyncWord().
Referenced by cReassemblyBufferAudio::FindTwoConsecutiveFramesWithSameSyncWord(), TEST_CASE(), TEST_CASE(), TEST_CASE(), and TEST_CASE().
|
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.
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().
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().
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.
| codec | The audio codec ID |
| data | Pointer to the frame header data |
| std::out_of_range | if codec is not in AudioCodecMap |
| std::invalid_argument | if 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().
|
private |
Convert the cloned drm buffer data to RGB(void, pip) or ARGB (osd) and return a pointer to the raw data.
| [out] | size | size of the grabbed buffer |
| [out] | width | width of the grabbed buffer |
| [out] | height | height of the grabbed buffer |
| [out] | x | x offset of the grabbed buffer |
| [out] | y | y offset of the grabbed buffer |
| [in] | buffer | type buffer type (Grabtype) |
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().
|
static |
Get an instance to the global logger.
Definition at line 50 of file logger.cpp.
References cSoftHdLogger::cSoftHdLogger().
Referenced by cSoftHdLogger::LogFFmpegCallback(), cSoftHdConfig::SetupParse(), and cMenuSetupSoft::Store().
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):
For unbounded packets (length field = 0, common for video streams):
Definition at line 336 of file pes.cpp.
References cPes::m_data, and cPes::m_size.
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.
Definition at line 301 of file pes.cpp.
References cPes::m_data.
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.
Definition at line 314 of file pes.cpp.
References cPes::m_data, and cPes::m_size.
Get the PPS offset.
| positive | value PPS offset in the data stream |
| -1 | if there is no PPS |
Definition at line 107 of file h264parser.cpp.
References isValidStartCode(), cH264Parser::m_pAvpkt, and NalUnitType().
Referenced by cH264Parser::cH264Parser().
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.
Definition at line 285 of file pes.cpp.
References AV_NOPTS_VALUE, cPes::HasPts(), and cPes::m_data.
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.
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().
Get the slice offset.
| positive | value slice offset in the data stream |
| -1 | if there is no slice |
Definition at line 132 of file h264parser.cpp.
References isValidStartCode(), cH264Parser::m_pAvpkt, and NalUnitType().
Referenced by cH264Parser::cH264Parser().
Get the SPS offset.
| positive | value SPS offset in the data stream |
| -1 | if there is no SPS |
Definition at line 82 of file h264parser.cpp.
References isValidStartCode(), cH264Parser::m_pAvpkt, and NalUnitType().
Referenced by cH264Parser::cH264Parser().
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.
| data | Pointer to video data |
| size | Size of the data in bytes |
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().
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.
Definition at line 272 of file pes.cpp.
References cPes::m_data.
Referenced by cPes::GetPts().
Initialize and validate the PES packet.
Performs validation checks on the PES packet structure:
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().
Check if the PES header is valid.
Validates that the PES packet has a valid header by checking:
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().
Check, if this is an interlaced frame.
| frame | AVFrame |
Definition at line 86 of file misc.h.
Referenced by cVideoFilter::Action(), cVideoDecoder::ReceiveFrame(), and cVideoStream::RenderFrame().
Check if the PES packet is valid.
Validates that the PES packet is well-formed and matches the expected stream type by checking:
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.
Definition at line 245 of file pes.cpp.
References cPes::m_valid.
Check for a 0x000001 or 0x00000001 start code.
| [in] | data | pointer to the data stream |
| [in] | offset | start parsing at offset |
| [in] | size | size of data |
| [out] | startCodeLength | start code length (3 or 4) |
| true | if a valid start code was detected |
| false | no 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().
Log to syslog LOG_DEBUG.
Definition at line 147 of file logger.cpp.
References cSoftHdLogger::m_logLevel, and cSoftHdLogger::MAX_LOGMESSAGE_SIZE.
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.
Log to syslog LOG_ERR.
Definition at line 90 of file logger.cpp.
References cSoftHdLogger::MAX_LOGMESSAGE_SIZE, and SysLogLevel.
Log to syslog LOG_ERR and abort.
Definition at line 69 of file logger.cpp.
References cSoftHdLogger::MAX_LOGMESSAGE_SIZE, and SysLogLevel.
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.
|
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().
Log to syslog LOG_INFO.
Definition at line 128 of file logger.cpp.
References cSoftHdLogger::MAX_LOGMESSAGE_SIZE, and SysLogLevel.
Log to syslog LOG_WARNING.
Definition at line 109 of file logger.cpp.
References cSoftHdLogger::MAX_LOGMESSAGE_SIZE, and SysLogLevel.
Return the nal unit type.
| data | pointer to the data stream |
| offset | start parsing at offset |
| startCodeLength | start code length (3 or 4) |
Definition at line 71 of file h264parser.cpp.
Referenced by cH264Parser::cH264Parser(), cH264Parser::GetPPSOffset(), cH264Parser::GetSliceOffset(), and cH264Parser::GetSPSOffset().
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().
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.
| fragment | Pointer to video frame data |
| size | Size of the fragment in bytes |
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().
Pop an AVPacket from the reassembly buffer.
Creates an AVPacket containing the specified amount of data from the buffer.
| size | Number of bytes to pop from the buffer |
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().
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.
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().
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.
Print raw stream data of the first 35 bytes.
Definition at line 618 of file h264parser.cpp.
References LOGDEBUG, and cH264Parser::m_pAvpkt.
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 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.
| data | Pointer to data to append |
| size | Size of data in bytes |
| pts | Presentation 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().
Read the next bit of a stream.
Definition at line 643 of file h264parser.cpp.
References cH264Parser::m_nCurrentBit, cH264Parser::m_nLength, cH264Parser::m_parseError, and cH264Parser::m_pStart.
Referenced by cH264Parser::cH264Parser(), cH264Parser::ReadBits(), and cH264Parser::ReadExponentialGolombCode().
Read n number of bits of a stream.
Definition at line 660 of file h264parser.cpp.
References cH264Parser::m_nCurrentBit, cH264Parser::m_nLength, cH264Parser::m_parseError, and cH264Parser::ReadBit().
Referenced by cH264Parser::cH264Parser(), and cH264Parser::ReadExponentialGolombCode().
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().
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().
Read a signed exponential-golomb coded integer.
Definition at line 710 of file h264parser.cpp.
References cH264Parser::ReadExponentialGolombCode().
Referenced by cH264Parser::cH264Parser().
Resets the filter state.
Definition at line 23 of file filllevel.cpp.
References cBufferFillLevelLowPassFilter::m_bufferFillLevelFramesAvg, cBufferFillLevelLowPassFilter::m_frameCounter, cBufferFillLevelLowPassFilter::m_state, and cBufferFillLevelLowPassFilter::UNINITIALIZED.
Referenced by cSoftHdAudio::DropSamplesOlderThanPtsMs(), and cSoftHdAudio::FlushBuffers().
Resets the jitter tracker.
Definition at line 73 of file jittertracker.cpp.
References cJitterTracker::m_firstPacket, cJitterTracker::m_lastDiffMs, cJitterTracker::m_longTermMaxJitterMs, cJitterTracker::m_packetCounter, cJitterTracker::m_secondPacket, and cJitterTracker::m_shortTermMaxJitterMs.
Referenced by cSoftHdDevice::OnEnteringState().
Reset the reassembly buffer.
Clears all buffered data, PTS tracking, and resets codec detection state.
Definition at line 624 of file pes.cpp.
References AV_NOPTS_VALUE, cReassemblyBuffer::m_buffer, cReassemblyBuffer::m_codec, cReassemblyBuffer::m_lastPoppedPts, and cPtsTrackingBuffer::Reset().
Referenced by cSoftHdDevice::Clear(), cSoftHdDevice::FlushAudio(), cSoftHdDevice::OnEnteringState(), cSoftHdDevice::PlayAudio(), cSoftHdDevice::PlayVideoInternal(), and cSoftHdDevice::ResetPipStream().
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().
|
static |
Scale an image.
Conversion is done with ffmpegs swscale
| [in] | src | pointer to the source data |
| [out] | size | size of the return data |
| [in] | srcW | source width |
| [in] | srcH | source height |
| [in] | dstW | width of the returned image |
| [in] | dstH | height of the returned image |
Definition at line 153 of file grab.cpp.
References L_GRAB, LOGDEBUG2, and LOGERROR.
Referenced by cSoftHdGrab::ProcessGrab().
| 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().
Set the loglevel.
| level | new loglevel |
Definition at line 61 of file logger.cpp.
References cSoftHdLogger::m_logLevel.
| bool cSoftHdGrab::Start | ( | bool | jpeg, |
| int | quality, | ||
| int | width, | ||
| int | height, | ||
| int | screenWidth, | ||
| int | screenHeight | ||
| ) |
Start a grab in the video renderer.
| jpeg | flag true, create JPEG data |
| quality | JPEG quality |
| width | width of requested grab image |
| height | height of requested grab image |
| screenWidth | current screen width |
| screenHeight | current 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().
Converts the filter state to a string representation.
| state | The state to convert |
Definition at line 89 of file filllevel.cpp.
References cBufferFillLevelLowPassFilter::SETTLED, cBufferFillLevelLowPassFilter::SETTLING, and cBufferFillLevelLowPassFilter::UNINITIALIZED.
Nice time-stamp string.
| ts | time stamp |
| divisor | optional divisor for the given timestamp int (must be > 0) |
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().
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.
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().
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:
| hardwareBufferFillLevelFrames | Current 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().
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().