Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HevcConfig.parse fails when first SPS contains the 0x000003 escape sequence #10367

Closed
1 task
rcombs opened this issue Jun 22, 2022 · 3 comments
Closed
1 task
Assignees

Comments

@rcombs
Copy link

rcombs commented Jun 22, 2022

ExoPlayer Version

2.18.0

Devices that reproduce the issue

N/A

Devices that do not reproduce the issue

N/A

Reproducible in the demo app?

Not tested

Reproduction steps

Attempt to play an MP4 or MKV file with an HEVC stream where the configuration record's first SPS NAL contains an 0x000003 escape sequence

Expected result

The configuration is parsed and the media plays successfully.

Actual result

HevcConfig.parse throws an exception when trying to parse the SPS because it fails to remove 0x000003 sequences. The error comes from parseH265SpsNalUnitPayload, called via parseH265SpsNalUnit:

public static H265SpsData parseH265SpsNalUnitPayload(

parseH265SpsNalUnitPayload only has this single caller, while parseH265SpsNalUnit has 2: HevcConfig.parse and RtspMediaTrack.processH264FmtpAttribute. As far as I can tell, both callers pass in escaped buffers, so it should be appropriate to put the unescape in parseH265SpsNalUnit. This can be easily solved by making a copy of the input buffer, then using the existing unescapeStream routine to remove the escape sequences before proceeding to actually parse the payload.

Media

1-frame MP4 example attached: escape-clip.mp4.zip

Bug Report

@rcombs
Copy link
Author

rcombs commented Jun 22, 2022

Please note this also appears to apply to AvcConfig.parse:

Same thing, just with parseSpsNalUnit and parseSpsNalUnitPayload. Note there that parseSpsNalUnit is also called from H264Reader, and I think the data passed there is also escaped, I'm not positive. I don't have an H264 sample with 0x000003 in SPS conveniently on-hand, but I've seen one in the past, and I can dig it up if needed.

@icbaker icbaker self-assigned this Jun 23, 2022
@icbaker icbaker assigned rohitjoins and unassigned icbaker Jul 6, 2022
@rohitjoins
Copy link
Contributor

@rcombs parseH265SpsNalUnitPayload uses ParsableNalUnitBitArray which unescapes the data and as such there is no requirement to call unescapeStream again.

ParsableNalUnitBitArray data = new ParsableNalUnitBitArray(nalData, nalOffset, nalLimit);

I tried playing the attached mp4 file using our demo app and it runs without throwing any exception. Can you please provide a media file which throws exception or explain more in detail on what exactly we are doing incorrectly here.

@rcombs
Copy link
Author

rcombs commented Jul 12, 2022

Ah, I see, I'd misinterpreted what was going on with the original sample file (it was actually #10316, which wasn't yet fixed in the version in the report I'd looked at). This does seem to be behaving fine now; apologies for the confusion!

@rcombs rcombs closed this as completed Jul 12, 2022
@google google locked and limited conversation to collaborators Sep 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants