Fix nalu parsing for 3-byte & 4-byte start seqs #301
Merged
+49
−11
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.
Description
There is an issue in the current
emitNalu
function where the implementation can skip over 3-byte start sequences.The
emitNalu
function was changed in commit bfe92b9 which introduced this regression: bfe92b9#diff-5eca440e933baa4c5491dcd9ccc7c1f4d807994e6c5b54c304228c34fcc3c963L40From analysis of the current
emitNalu
function,rtp/codecs/h264_packet.go
Lines 45 to 67 in ee5524b
one can observe that NALUs with 3-byte start sequences may be skipped over if it is the first NALU, or if it is between two NALUs with 4-byte start sequences (in this case: at L52
end != -1
)This PR aims to resolve this issue by searching for 3-byte start sequences and accounting for 4-byte sequences afterward.