Strip DVD private_stream_1 sub-stream header in PsExtractor#3328
Open
TsaiHao wants to merge 1 commit into
Open
Strip DVD private_stream_1 sub-stream header in PsExtractor#3328TsaiHao wants to merge 1 commit into
TsaiHao wants to merge 1 commit into
Conversation
In an MPEG Program Stream, AC-3 (and DTS/LPCM) audio is carried in private_stream_1 (PES stream id 0xBD). In DVD-style content each such PES packet begins with a 4-byte sub-stream header immediately after the PES header: sub_stream_id (0x80-0x87 AC-3, 0x88-0x8F DTS, 0xA0-0xA7 LPCM), number_of_frame_headers and first_access_unit_pointer. `PsExtractor.PesReader.consume()` stripped only the PES header and PTS/DTS extension, forwarding the sub-stream header straight into the audio reader as if it were elementary data. Because audio sync frames do not align to PES packet boundaries, these 4 bytes land inside the frame spanning each boundary and corrupt it, producing garbled audio (and decoder errors such as Dolby MS12 "UDC Node: Error extracting BSI metadata (err 1021)") when playing MPEG-PS content that VLC/ffmpeg play correctly. Skip the sub-stream header for private_stream_1 packets before handing the payload to the elementary stream reader, matching ffmpeg's mpegps demuxer. Adds a regression test with a small MPEG-PS asset whose AC-3 frames straddle PES boundaries (the existing single-packet sample_ac3.ps cannot expose this). Issue: androidx#3327
1 task
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.
In an MPEG Program Stream, AC-3 (and DTS/LPCM) audio is carried in private_stream_1 (PES stream id 0xBD). In DVD-style content each such PES packet begins with a 4-byte sub-stream header immediately after the PES header: sub_stream_id (0x80-0x87 AC-3, 0x88-0x8F DTS, 0xA0-0xA7 LPCM), number_of_frame_headers and first_access_unit_pointer.
PsExtractor.PesReader.consume()stripped only the PES header and PTS/DTS extension, forwarding the sub-stream header straight into the audio reader as if it were elementary data. Because audio sync frames do not align to PES packet boundaries, these 4 bytes land inside the frame spanning each boundary and corrupt it, producing garbled audio (and decoder errors such as Dolby MS12 "UDC Node: Error extracting BSI metadata (err 1021)") when playing MPEG-PS content that VLC/ffmpeg play correctly.Skip the sub-stream header for private_stream_1 packets before handing the payload to the elementary stream reader, matching ffmpeg's mpegps demuxer.
Adds a regression test with a small MPEG-PS asset whose AC-3 frames straddle PES boundaries (the existing single-packet sample_ac3.ps cannot expose this).
Issue: #3327