Repository navigation
decoder: do not construct the access unit on the calling thread - #4059
Open
anabobillo3 wants to merge 1 commit into
Open
anabobillo3 wants to merge 1 commit into
anabobillo3 wants to merge 1 commit into
Conversation
With more than one thread, the calling thread only parses a DecodeFrameNoDelay() buffer into the access unit list and a worker constructs the access unit: the ConstructAccessUnit() calls on the parse path of WelsDecodeBs() are gated on GetThreadCount() <= 1. The one in CheckAndFinishLastPic(), which the NAL loop calls for every NAL but the last, is not: when a non-VCL NAL (an access unit delimiter, an SEI, an overwriting parameter set) ends the access unit in the middle of the buffer, the calling thread constructs it there, ahead of the worker hand-off. On the first call the picture buffer is not allocated yet and PrefetchPic() dereferences the NULL picture buffer; later calls decode the picture on the calling thread while workers use the same pictures. Gate that call on GetThreadCount() <= 1 like the others, so the access unit stays in the list for the worker, as it does when the buffer ends with the picture's last slice. The new test decodes a stream in which each call carries one frame followed by the next access unit's delimiter and SEI.
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.
With more than one decoding thread, the calling thread only parses a
DecodeFrameNoDelay()buffer into the access unit list, and a worker constructs the access unit. TheConstructAccessUnit()calls on the parse path ofWelsDecodeBs()are gated onGetThreadCount() <= 1for that reason, and so is theCheckAndFinishLastPic()call for the last NAL of the buffer.The
ConstructAccessUnit()insideCheckAndFinishLastPic()is not. The NAL loop callsCheckAndFinishLastPic()for every NAL but the last, so when a non-VCL NAL (an access unit delimiter, an SEI, an overwriting SPS/PPS) ends the access unit in the middle of the buffer, the calling thread constructs that access unit itself, ahead of the worker hand-off:PrefetchPic()dereferences the NULL picture buffer;Change
Gate that one call on
GetThreadCount() <= 1, like the other constructs on the parse path. The access unit then stays in the list for the worker, as it already does when the buffer ends with the picture's last slice. Single-threaded decoding is unchanged.The rest of
CheckAndFinishLastPic()(the error concealment and finish of a picture a worker left incomplete) still runs on the calling thread; the worker chain relies on it to signal that picture.Threaded decoding takes one picture per call. A buffer that carries two pictures split by a delimiter now decodes the same way two pictures in one call without a delimiter already do upstream.
Test
ThreadDecoderTrailingNonVclTest.DelimiterAndSeiAfterSlicesDecodeAllFramesdecodesres/Adobe_PDF_sample_a_1024x768_50Frms.264with two threads, each call carrying one frame followed by the next access unit's delimiter and SEI, and expects every call to return without error and all 50 frames to be decoded.PrefetchPic().ThreadDecoderNalListBoundsTestand the rest ofThread*pass, and the fullcodec_unittestpasses (484 tests).