-
Notifications
You must be signed in to change notification settings - Fork 6k
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
MP4: Parse initial PAR from H.265 SPS and include it in HevcConfig #9421
Conversation
…de the PAR for propagating it into the Format
library/common/src/main/java/com/google/android/exoplayer2/util/NalUnitUtil.java
Show resolved
Hide resolved
library/common/src/main/java/com/google/android/exoplayer2/util/NalUnitUtil.java
Show resolved
Hide resolved
library/common/src/main/java/com/google/android/exoplayer2/util/NalUnitUtil.java
Outdated
Show resolved
Hide resolved
library/common/src/main/java/com/google/android/exoplayer2/util/NalUnitUtil.java
Show resolved
Hide resolved
Re-added the methods now and reverted some changes that were required to adopt to the breaking change. Way cleaner now. 👍🏼 |
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/H265Reader.java
Show resolved
Hide resolved
@@ -105,6 +118,9 @@ public static HevcConfig parse(ParsableByteArray data) throws ParserException { | |||
@Nullable public final List<byte[]> initializationData; | |||
/** The length of the NAL unit length field in the bitstream's container, in bytes. */ | |||
public final int nalUnitLengthFieldLength; | |||
public final int width; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please could you Javadoc these three fields. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
public static H265SpsData parseH265SpsNalUnitPayload(byte[] nalData, int nalOffset, int nalLimit) { | ||
ParsableNalUnitBitArray data = new ParsableNalUnitBitArray(nalData, nalOffset, nalLimit); | ||
// Skip sps_video_parameter_set_id. | ||
data.skipBits(8 + 4); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was pointed out during internal review that sps_video_parameter_set_id
is only 4 bits long. Furthermore, it appears that the NAL unit header for H265 is 16 bits long, so L451 should be adding 2 to the offset rather than 1. We've fixed this as part of merging the change.
Please see the merge here and let us know if there are any problems! Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ojw28 Thanks for merging.
Furthermore, it appears that the NAL unit header for H265 is 16 bits long ...
Than makes sense, thanks for fixing. Interesting that it worked anyway. 😄
I just tested latest dev-v2
and everything looks fine. 👍🏼
Currently, the initial H.265 SPS from the
hvcC
atom/box is not parsed for its pixel aspect ratio which resulted in all content being played back with aspect ratio 1:1 if nopasp
box is present.This PR ...
parseH265SpsNalUnitPayload
method to parse a SPS NAL unit, just like it's done for H.264, too. The parsing code is derived fromH265Reader.parseMediaFormat
.HevcConfig
class to parse the initial SPS and propagate the PAR into the Format if nopasp
is present.buildHevcCodecStringFromSps
method to re-use the parsed SPS data - just like it's done for H.264.This PR was split up from #9318.