Repository navigation
Preprocess video packets only once right before processing them - #1553
Open
ulmus-scott wants to merge 7 commits into
Open
ulmus-scott wants to merge 7 commits into
ulmus-scott wants to merge 7 commits into
Conversation
…Packet While av_packet_move_ref() does not guarantee the AVPacket is reference counted, all of the AVPackets added to m_storedPackets are already reference counted, so Pkt is still always reference counted. This avoids potential unnecessary memory allocations and atomic increments and decrements. Use av_packet_free() to ensure the AVPacket is always freed properly, instead of duplicating the code.
Since 8e34e6e in 2018, ProcessVideoPacket() will not call avcodec_send_packet() until avcodec_receive_frame() (called via MythCodecContext::FilteredReceiveFrame()) does not return an AVFrame. However, this means that the same AVPacket will be pre-processesed repeatedly until all frames are recieved from the decoder. For software decoding, this means that after the first AVPacket is pre-processed and sent, every AVPacket will be processed twice since it will be pre-processed, the previous frame received, pre-processed again, and then sent to the decoder. If a decoder returns multiple frames at a time, one packet will be pre-processed the number of returned frames plus one times. Note that the AVPacket is still pre-processed before the previous frame is returned.
This helps reasoning about what the function does. Also improve documentation. I'm not really satisfied with the return documentation, but it is only used by MythCommFlagPlayer and MythCCExtractorPlayer to seemingly see if a frame was output.
This simplifies some of the branching logic. gotpicture was always 0 for the log messages, so it has been removed from them. That sentPacket is only true when avcodec_send_packet() returns 0 doesn't change the behavior since the function will return early on errors.
This should help enable preprocessing video packets immediately before they are sent to the decoder, instead of preprocessing them before the previous frame is received. Note: MythDVDDecoder::ProcessVideoPacket() is now called once per packet instead of twice, but I don't anticipate this being an issue.
copying the preceeding code into the if statement. No functional change since it breaks early.
… before ProcessVideoPacket()
6 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is preliminary work for extracting A/53 embedded captions from the video frames.
Instead of preprocessing a video packet multiple times until all frames are received from the decoder, preprocess each packet exactly once and modify GetFrame() to preprocess the packet immediately before sending it to the decoder.
Checklist