|
vdr-plugin-softhddevice-drm-gles 1.6.4-d0291bb
|
Video Input Stream. More...
#include <videostream.h>
Protected Member Functions | |
| cVideoStream (cVideoRender *, int, cQueue< cDrmBuffer > *, cSoftHdConfig *, bool, std::function< void(AVFrame *)>) | |
| Create a video stream. | |
| virtual void | Action (void) |
| Decoding thread loop, which periodically tries to decode input. | |
Private Member Functions | |
| void | RenderFrame (AVFrame *) |
| Render a frame. | |
| void | CheckForcingFrameDecode (void) |
| Check, if we need to force the decoder to decode the frame (force a decoder drain) | |
| void | OpenDecoder (void) |
| Open the decoder including an H.264 parsing if needed. | |
| bool | ParseH264Packet (AVPacket *) |
| Parse an H.264 packet. | |
Private Attributes | |
| cSoftHdConfig * | m_pConfig |
| plugin config | |
| cVideoDecoder * | m_pDecoder |
| video decoder | |
| cVideoRender * | m_pRender |
| video renderer | |
| const char * | m_identifier |
| identifier string for logging | |
| std::function< void(AVFrame *)> | m_frameOutput |
| function to output the frame | |
| cQueue< cDrmBuffer > * | m_pDrmBufferQueue |
| pointer to renderer's DRM buffer queue | |
| cVideoFilter | m_videoFilter |
| pointer to deinterlace/scaling video filter thread | |
| std::mutex | m_mutex |
| mutex for decoding thread control | |
| bool | m_checkFilterThreadNeeded |
| set, if we have to check, if filter thread is needed at start of playback | |
| int | m_hardwareQuirks |
| hardware specific quirks | |
| bool | m_userDisabledDeinterlacer = false |
| set, if the user configured the deinterlace to be disabled | |
| bool | m_deinterlacerDeactivated |
| set, if the deinterlacer should be disabled temporarily (trickspeed, stillpicture, pip) | |
| bool | m_startDecodingWithIFrame = false |
| wait for an I-Frame to start h264 decoding | |
| bool | m_parseH264Dimensions = false |
| parse width and height when starting an h264 stream | |
| int | m_decoderFallbackToSwNumPkts = 22 |
| fallback to sw decoder if hw decoder fails after the given number of packets sent | |
| cQueue< AVPacket > | m_packets {VIDEO_PACKET_MAX} |
| AVPackets queue. | |
| enum AVCodecID | m_codecId = AV_CODEC_ID_NONE |
| current codec id | |
| AVCodecParameters * | m_pPar = nullptr |
| current codec parameters | |
| std::atomic< struct AVRational > | m_timebase |
| current codec timebase | |
| int | m_trickpkts |
| how many avpkt does the decoder need in trickspeed mode? | |
| int | m_sentTrickPkts = 0 |
| how many avpkt have been sent to the decoder in trickspeed mode? | |
| volatile bool | m_newStream = false |
| flag for new stream | |
| bool | m_interlaced |
| flag for interlaced stream | |
| int64_t | m_inputPts = AV_NOPTS_VALUE |
| PTS of the first packet in the input buffer. | |
| std::vector< std::string > | m_naluTypesAtStart |
| array of strings to log the H.264 frames at stream start | |
| int | m_numIFrames = 0 |
| counter for the arriving I-Frames at H.264 stream start | |
| int | m_logPackets = 0 |
| parse and log all frames until the number of given I-Frames arrived | |
| int | m_dropInvalidPackets = 0 |
| drop P-Frames with invalid references until the given number of I-Frames arrived | |
| std::set< int > | m_dpbFrames |
| private set of reference frames (internal short-time decoded picture buffer) | |
| int | m_maxFrameNum = 1 |
| = 1 << Log2MaxFrameNumMinus4 + 4 | |
| int | m_log2MaxFrameNumMinus4 = -4 |
| cache Log2MaxFrameNumMinus4 from a previous SPS parsing | |
| int | m_ppsNumRefIdxL0DefaultActiveMinus1 = -1 |
| cache NumRefIdxL0DefaultActiveMinuns1 from a previous PPS parsing | |
| int | m_ppsNumRefIdxL1DefaultActiveMinus1 = -1 |
| cache NumRefIdxL1DefaultActiveMinuns1 from a previous PPS parsing | |
| bool | m_isResend = false |
| track, if we already tried to send the AVPacket to the decoder if so, skip the parsing | |
Static Private Attributes | |
| static constexpr int | VIDEO_PACKET_MAX = 192 |
| max number of video packets held in the buffer | |
Video Input Stream.
Definition at line 47 of file videostream.h.
|
virtual |
Definition at line 70 of file videostream.cpp.
References LOGDEBUG.
|
protected |
Create a video stream.
Definition at line 48 of file videostream.cpp.
References cSoftHdConfig::ConfigDecoderFallbackToSw, cSoftHdConfig::ConfigDecoderFallbackToSwNumPkts, L_CODEC, LOGDEBUG, LOGDEBUG2, m_decoderFallbackToSwNumPkts, and m_identifier.
Decoding thread loop, which periodically tries to decode input.
Definition at line 459 of file videostream.cpp.
References DecodeInput(), LOGDEBUG, and m_mutex.
Stop filter thread.
Definition at line 489 of file videostream.cpp.
References m_checkFilterThreadNeeded, m_videoFilter, SetDeinterlacerDeactivated(), and cVideoFilter::Stop().
Referenced by cSoftHdDevice::Clear(), cSoftHdDevice::OnEnteringState(), cSoftHdDevice::OnLeavingState(), and cSoftHdDevice::ResetPipStream().
Check, if we need to force the decoder to decode the frame (force a decoder drain)
Get the number of packets we need to have in the buffer while in interlaced trickspeed mode, in order to get a decoded frameout of the decoder.
In a normal interlaced h264 stream we need to force decoding after sending 2 packets in backwards trickspeed to get a decoded frame, in an mpeg2 stream 1 packet is enough.
This minPkts magic guarantees, that we don't drain the decoder too early, but exactly after the right amount of packets was sent in trickspeed mode.
Definition at line 202 of file videostream.cpp.
References cVideoRender::IsForwardTrickspeed(), m_interlaced, m_pDecoder, m_pRender, m_sentTrickPkts, m_trickpkts, and cVideoDecoder::SendPacket().
Referenced by DecodeInput().
Clears all video stream data, which is buffered to be decoded.
Definition at line 130 of file videostream.cpp.
References AV_NOPTS_VALUE, cQueue< T >::IsEmpty(), LOGDEBUG, m_identifier, m_inputPts, m_packets, cQueue< T >::Pop(), and cQueue< T >::Size().
Referenced by cSoftHdDevice::Clear(), Exit(), cSoftHdDevice::OnEnteringState(), and cSoftHdDevice::ResetPipStream().
Close the decoder.
Definition at line 159 of file videostream.cpp.
References cVideoDecoder::Close(), L_CODEC, LOGDEBUG2, m_codecId, m_dpbFrames, m_identifier, m_maxFrameNum, m_naluTypesAtStart, m_numIFrames, m_pDecoder, and m_pPar.
Referenced by cSoftHdDevice::OnEnteringState(), and cSoftHdDevice::ResetPipStream().
Decodes a reassembled codec packet.
Definition at line 345 of file videostream.cpp.
References CheckForcingFrameDecode(), FlushDecoder(), cSoftHdConfig::GetDecoderNeedsMaxPackets(), cVideoDecoder::GetFramesReceived(), cVideoDecoder::GetPacketsSent(), cQueue< T >::IsEmpty(), cQueue< T >::IsFull(), cVideoDecoder::IsHardwareDecoder(), cVideoFilter::IsInputBufferFull(), cVideoRender::IsTrickSpeed(), LOGDEBUG, LOGFATAL, LOGWARNING, m_codecId, m_decoderFallbackToSwNumPkts, m_dropInvalidPackets, m_identifier, m_isResend, m_logPackets, m_naluTypesAtStart, m_newStream, m_numIFrames, m_packets, m_pConfig, m_pDecoder, m_pDrmBufferQueue, m_pPar, m_pRender, m_sentTrickPkts, m_timebase, m_videoFilter, OpenDecoder(), ParseH264Packet(), cQueue< T >::Peek(), cQueue< T >::Pop(), cVideoDecoder::ReceiveFrame(), RenderFrame(), cVideoDecoder::ReopenCodec(), cVideoDecoder::SendPacket(), and cSoftHdConfig::SetDecoderNeedsMaxPackets().
Referenced by Action().
|
inline |
Definition at line 68 of file videostream.h.
References m_pDecoder.
Definition at line 87 of file videostream.h.
References m_userDisabledDeinterlacer.
Referenced by cSoftHdDevice::SetDisableDeint().
Exit video stream.
Definition at line 112 of file videostream.cpp.
References ClearVdrCoreToDecoderQueue(), cVideoDecoder::Close(), LOGDEBUG, m_identifier, m_pDecoder, and Stop().
Referenced by cSoftHdDevice::OnEnteringState().
Flushes the video stream by finalizing any pending data.
This function completes processing of any remaining PES fragments in the fragmentation buffer, then pushes a nullptr packet to the queue to signal a flush operation to the decoder.
Definition at line 81 of file videostream.cpp.
References m_packets, and cQueue< T >::Push().
Referenced by cSoftHdDevice::HandleStillPicture().
Flush the decoder.
Some hardware (RPI) needs a reopen workaround (close/open) here, because hardware doesn't do the hardware flush right.
Definition at line 178 of file videostream.cpp.
References cVideoDecoder::FlushBuffers(), cVideoDecoder::IsHardwareDecoder(), L_CODEC, LOGDEBUG2, LOGFATAL, m_codecId, m_hardwareQuirks, m_identifier, m_pDecoder, m_pPar, m_timebase, QUIRK_CODEC_FLUSH_WORKAROUND, and cVideoDecoder::ReopenCodec().
Referenced by cSoftHdDevice::Clear(), and DecodeInput().
Definition at line 70 of file videostream.h.
References m_packets, and cQueue< T >::Size().
Referenced by cVideoRender::DisplayFrame(), cSoftHdDevice::Flush(), cVideoRender::LogDroppedDuped(), and cSoftHdDevice::PlayVideoPkts().
Definition at line 72 of file videostream.h.
References m_codecId.
Definition at line 76 of file videostream.h.
References m_inputPts.
Definition at line 104 of file videostream.cpp.
References m_inputPts, and m_timebase.
Referenced by cSoftHdDevice::IsBufferingThresholdReached().
Definition at line 79 of file videostream.h.
References VIDEO_PACKET_MAX.
Referenced by cSoftHdDevice::PlayVideoPkts().
Get video size and aspect ratio.
| [out] | width | video stream width |
| [out] | height | video stream height |
| [out] | aspect_ratio | video stream aspect ratio (is currently width/ height) |
Definition at line 422 of file videostream.cpp.
References cVideoDecoder::GetContext(), and m_pDecoder.
Referenced by cSoftHdDevice::GetVideoSize().
Definition at line 64 of file videostream.h.
References m_mutex.
Referenced by cSoftHdDevice::Clear(), cSoftHdDevice::OnEventReceived(), and cSoftHdDevice::ResetPipStream().
Definition at line 74 of file videostream.h.
References AV_NOPTS_VALUE, and m_inputPts.
Referenced by cSoftHdDevice::IsBufferingThresholdReached(), and cSoftHdDevice::OnEventReceived().
Definition at line 86 of file videostream.h.
References m_deinterlacerDeactivated.
Definition at line 71 of file videostream.h.
References m_packets, cQueue< T >::Size(), and VIDEO_PACKET_MAX.
Referenced by cSoftHdDevice::PlayPipVideo(), and cSoftHdDevice::Poll().
Definition at line 52 of file videostream.h.
| void cVideoStream::Open | ( | AVCodecID | codecId, |
| AVCodecParameters * | par = nullptr, |
||
| AVRational | timebase = { .num = 1, .den = 90000 } |
||
| ) |
Open a video codec.
| codecId | video codec id |
| par | video codec parameters |
| timebase | timebase |
Definition at line 444 of file videostream.cpp.
References m_codecId, m_newStream, m_pPar, m_timebase, and m_trickpkts.
Referenced by cSoftHdDevice::SetVideoCodec().
Open the decoder including an H.264 parsing if needed.
Definition at line 218 of file videostream.cpp.
References cSoftHdConfig::ConfigDropInvalidH264PFrames, cSoftHdConfig::ConfigParseH264StreamStart, cSoftHdConfig::CurrentDecoderName, cSoftHdConfig::CurrentDecoderType, cVideoDecoder::IsHardwareDecoder(), L_CODEC, LOGDEBUG2, LOGFATAL, m_codecId, m_dropInvalidPackets, m_hardwareQuirks, m_identifier, m_log2MaxFrameNumMinus4, m_logPackets, m_newStream, m_packets, m_parseH264Dimensions, m_pConfig, m_pDecoder, m_pPar, m_ppsNumRefIdxL0DefaultActiveMinus1, m_ppsNumRefIdxL1DefaultActiveMinus1, m_startDecodingWithIFrame, m_timebase, cVideoDecoder::Name(), cVideoDecoder::Open(), cQueue< T >::Peek(), cQueue< T >::Pop(), and QUIRK_CODEC_NEEDS_DIMENSION_PARSE.
Referenced by DecodeInput().
Parse an H.264 packet.
Definition at line 267 of file videostream.cpp.
References L_CODEC, LOGDEBUG2, m_dpbFrames, m_dropInvalidPackets, m_identifier, m_log2MaxFrameNumMinus4, m_maxFrameNum, m_naluTypesAtStart, m_numIFrames, m_ppsNumRefIdxL0DefaultActiveMinus1, and m_ppsNumRefIdxL1DefaultActiveMinus1.
Referenced by DecodeInput().
Pushes a pre-assembled AVPacket directly to the processing queue.
This function bypasses the PES fragmentation/reassembly mechanism and directly pushes an already-complete AVPacket to the m_packets queue for decoding. Used when packets are received from sources that don't require fragmentation handling.
| avpkt | The AVPacket to push to the queue |
Definition at line 96 of file videostream.cpp.
References AV_NOPTS_VALUE, m_inputPts, m_packets, and cQueue< T >::Push().
Referenced by cSoftHdDevice::HandleStillPicture(), and cSoftHdDevice::PlayVideoPkts().
Render a frame.
Frames either go through the filter thread or directly into the render buffer.
| videoCtx | ffmpeg video codec context |
| frame | frame to render |
Definition at line 505 of file videostream.cpp.
References cVideoDecoder::GetContext(), cVideoFilter::GetNumFramesToFilter(), cVideoFilter::InitAndStart(), isInterlacedFrame(), LOGDEBUG, LOGWARNING, m_checkFilterThreadNeeded, m_deinterlacerDeactivated, m_frameOutput, m_hardwareQuirks, m_identifier, m_interlaced, m_pDecoder, m_timebase, m_userDisabledDeinterlacer, m_videoFilter, cVideoFilter::PushFrame(), and QUIRK_NO_HW_DEINT.
Referenced by DecodeInput().
|
inline |
Definition at line 83 of file videostream.h.
References m_checkFilterThreadNeeded.
Referenced by cSoftHdDevice::OnEventReceived(), and cSoftHdDevice::OnLeavingState().
Definition at line 77 of file videostream.h.
References AV_NOPTS_VALUE, and m_inputPts.
Referenced by cSoftHdDevice::HandleStillPicture().
Definition at line 73 of file videostream.h.
References m_sentTrickPkts.
Referenced by cSoftHdDevice::OnLeavingState().
Definition at line 65 of file videostream.h.
References m_mutex.
Referenced by cSoftHdDevice::Clear(), cSoftHdDevice::OnEnteringState(), cSoftHdDevice::OnEventReceived(), and cSoftHdDevice::ResetPipStream().
Definition at line 90 of file videostream.h.
References m_decoderFallbackToSwNumPkts.
Referenced by cSoftHdDevice::SetDecoderFallbackToSw().
Reimplemented in cPipVideoStream.
Definition at line 85 of file videostream.h.
References m_deinterlacerDeactivated.
Referenced by CancelFilterThread(), cSoftHdDevice::HandleStillPicture(), cSoftHdDevice::OnEnteringState(), and cSoftHdDevice::OnLeavingState().
Definition at line 89 of file videostream.h.
References m_parseH264Dimensions.
Referenced by cSoftHdDevice::SetParseH264Dimensions().
Definition at line 88 of file videostream.h.
References m_startDecodingWithIFrame.
Referenced by cSoftHdDevice::SetDecoderNeedsIFrame().
| void cVideoStream::StartDecoder | ( | ) |
Start the decoder.
Definition at line 145 of file videostream.cpp.
References L_CODEC, LOGDEBUG2, m_hardwareQuirks, m_identifier, m_pDecoder, QUIRK_CODEC_SKIP_FIRST_FRAMES, QUIRK_CODEC_SKIP_NUM_FRAMES, and cVideoDecoder::SetSkipKeyFramesNum().
Referenced by cSoftHdDevice::OnLeavingState().
Stop the decoding thread.
Definition at line 477 of file videostream.cpp.
References LOGDEBUG.
Referenced by Exit().
|
private |
set, if we have to check, if filter thread is needed at start of playback
Definition at line 106 of file videostream.h.
Referenced by CancelFilterThread(), RenderFrame(), and ResetFilterThreadNeededCheck().
|
private |
current codec id
Definition at line 117 of file videostream.h.
Referenced by CloseDecoder(), DecodeInput(), FlushDecoder(), GetCodecId(), Open(), and OpenDecoder().
|
private |
fallback to sw decoder if hw decoder fails after the given number of packets sent
Definition at line 112 of file videostream.h.
Referenced by cVideoStream(), DecodeInput(), and SetDecoderFallbackToSwNumPkts().
|
private |
set, if the deinterlacer should be disabled temporarily (trickspeed, stillpicture, pip)
Definition at line 109 of file videostream.h.
Referenced by IsDeinterlacerDeactivated(), RenderFrame(), and SetDeinterlacerDeactivated().
|
private |
private set of reference frames (internal short-time decoded picture buffer)
Definition at line 132 of file videostream.h.
Referenced by CloseDecoder(), and ParseH264Packet().
|
private |
drop P-Frames with invalid references until the given number of I-Frames arrived
Definition at line 131 of file videostream.h.
Referenced by DecodeInput(), OpenDecoder(), and ParseH264Packet().
function to output the frame
Definition at line 101 of file videostream.h.
Referenced by RenderFrame().
|
private |
hardware specific quirks
Definition at line 107 of file videostream.h.
Referenced by FlushDecoder(), OpenDecoder(), RenderFrame(), and StartDecoder().
identifier string for logging
Definition at line 100 of file videostream.h.
Referenced by ClearVdrCoreToDecoderQueue(), CloseDecoder(), cVideoStream(), DecodeInput(), Exit(), FlushDecoder(), OpenDecoder(), ParseH264Packet(), RenderFrame(), and StartDecoder().
|
private |
PTS of the first packet in the input buffer.
Definition at line 125 of file videostream.h.
Referenced by ClearVdrCoreToDecoderQueue(), GetInputPts(), GetInputPtsMs(), HasInputPts(), PushAvPacket(), and ResetInputPts().
|
private |
flag for interlaced stream
Definition at line 123 of file videostream.h.
Referenced by CheckForcingFrameDecode(), and RenderFrame().
track, if we already tried to send the AVPacket to the decoder if so, skip the parsing
Definition at line 137 of file videostream.h.
Referenced by DecodeInput().
|
private |
cache Log2MaxFrameNumMinus4 from a previous SPS parsing
Definition at line 134 of file videostream.h.
Referenced by OpenDecoder(), and ParseH264Packet().
|
private |
parse and log all frames until the number of given I-Frames arrived
Definition at line 130 of file videostream.h.
Referenced by DecodeInput(), and OpenDecoder().
|
private |
= 1 << Log2MaxFrameNumMinus4 + 4
Definition at line 133 of file videostream.h.
Referenced by CloseDecoder(), and ParseH264Packet().
|
private |
mutex for decoding thread control
Definition at line 104 of file videostream.h.
|
private |
array of strings to log the H.264 frames at stream start
Definition at line 128 of file videostream.h.
Referenced by CloseDecoder(), DecodeInput(), and ParseH264Packet().
flag for new stream
Definition at line 122 of file videostream.h.
Referenced by DecodeInput(), Open(), and OpenDecoder().
|
private |
counter for the arriving I-Frames at H.264 stream start
Definition at line 129 of file videostream.h.
Referenced by CloseDecoder(), DecodeInput(), and ParseH264Packet().
|
private |
AVPackets queue.
Definition at line 115 of file videostream.h.
Referenced by ClearVdrCoreToDecoderQueue(), DecodeInput(), Flush(), GetAvPacketsFilled(), IsInputBufferFull(), OpenDecoder(), and PushAvPacket().
parse width and height when starting an h264 stream
Definition at line 111 of file videostream.h.
Referenced by OpenDecoder(), and SetParseH264Dimensions().
|
private |
plugin config
Definition at line 97 of file videostream.h.
Referenced by DecodeInput(), and OpenDecoder().
|
private |
video decoder
Definition at line 98 of file videostream.h.
Referenced by CheckForcingFrameDecode(), CloseDecoder(), DecodeInput(), Decoder(), Exit(), FlushDecoder(), GetVideoSize(), OpenDecoder(), RenderFrame(), and StartDecoder().
|
private |
pointer to renderer's DRM buffer queue
Definition at line 102 of file videostream.h.
Referenced by DecodeInput().
|
private |
current codec parameters
Definition at line 118 of file videostream.h.
Referenced by CloseDecoder(), DecodeInput(), FlushDecoder(), Open(), and OpenDecoder().
|
private |
cache NumRefIdxL0DefaultActiveMinuns1 from a previous PPS parsing
Definition at line 135 of file videostream.h.
Referenced by OpenDecoder(), and ParseH264Packet().
|
private |
cache NumRefIdxL1DefaultActiveMinuns1 from a previous PPS parsing
Definition at line 136 of file videostream.h.
Referenced by OpenDecoder(), and ParseH264Packet().
|
private |
video renderer
Definition at line 99 of file videostream.h.
Referenced by CheckForcingFrameDecode(), and DecodeInput().
|
private |
how many avpkt have been sent to the decoder in trickspeed mode?
Definition at line 121 of file videostream.h.
Referenced by CheckForcingFrameDecode(), DecodeInput(), and ResetTrickSpeedFramesSentCounter().
wait for an I-Frame to start h264 decoding
Definition at line 110 of file videostream.h.
Referenced by OpenDecoder(), and SetStartDecodingWithIFrame().
|
private |
current codec timebase
Definition at line 119 of file videostream.h.
Referenced by DecodeInput(), FlushDecoder(), GetInputPtsMs(), Open(), OpenDecoder(), and RenderFrame().
|
private |
how many avpkt does the decoder need in trickspeed mode?
Definition at line 120 of file videostream.h.
Referenced by CheckForcingFrameDecode(), and Open().
set, if the user configured the deinterlace to be disabled
Definition at line 108 of file videostream.h.
Referenced by DisableDeint(), and RenderFrame().
|
private |
pointer to deinterlace/scaling video filter thread
Definition at line 103 of file videostream.h.
Referenced by CancelFilterThread(), DecodeInput(), and RenderFrame().
max number of video packets held in the buffer
Definition at line 114 of file videostream.h.
Referenced by GetVideoPacketMax(), and IsInputBufferFull().