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

Add AV1 color space parsing in MP4 atom parser #692

Merged
merged 9 commits into from
Nov 2, 2023
Prev Previous commit
Next Next commit
Format files and add release note
  • Loading branch information
microkatz committed Nov 2, 2023
commit 918079059c77877a1dbc6cc09ff582ec5e150989
2 changes: 2 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
video track are available. The default value is `false` which means
selecting a video track is prioritized.
* Extractors:
* Add AV1C parsing to MP4 extractor
([#692](https://github.com/androidx/media/pull/692)).
* Audio:
* Video:
* Add workaround for a device issue on Galaxy Tab S7 FE, Chromecast with
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1243,9 +1243,8 @@ private static void parseVideoSampleEntry(
Av1BitstreamParser parser = new Av1BitstreamParser(parent);
if (parser.parseSequenceHeader() && parser.colorDescriptionPresentFlag == 1) {
colorSpace = ColorInfo.isoColorPrimariesToColorSpace(parser.colorPrimaries);
colorTransfer = ColorInfo.isoTransferCharacteristicsToColorTransfer(
parser.transferCharacteristics
);
colorTransfer =
ColorInfo.isoTransferCharacteristicsToColorTransfer(parser.transferCharacteristics);
colorRange = (parser.colorRange == 1) ? C.COLOR_RANGE_FULL : C.COLOR_RANGE_LIMITED;
}
} else if (childAtomType == Atom.TYPE_clli) {
Expand Down Expand Up @@ -2185,7 +2184,7 @@ public int readNextSampleSize() {
/**
* Helper class for parsing syntax elements from AV1 bitstream.
*
* Bitstream specification: https://aomediacodec.github.io/av1-spec/av1-spec.pdf
* <p>Bitstream specification: https://aomediacodec.github.io/av1-spec/av1-spec.pdf
*/
private static final class Av1BitstreamParser {
private static final String TAG = "Av1BitstreamParser";
Expand All @@ -2208,9 +2207,8 @@ public Av1BitstreamParser(ParsableByteArray data) {
/**
* Parses a fixed-length unsigned number.
*
* See AV1 bitstream spec 4.10.2.
* f(n): Unsigned n-bit number appearing directly in the bitstream.
* The bits are read from high to low order.
* <p>See AV1 bitstream spec 4.10.2. f(n): Unsigned n-bit number appearing directly in the
* bitstream. The bits are read from high to low order.
*
* @param length The length (in bits) of the number to decode.
* @return Parsed unsigned number.
Expand All @@ -2225,17 +2223,15 @@ private int parseF(int length) {
int newBitCount = min(length, bitCount);
bitCount -= newBitCount;
length -= newBitCount;
result = (result << newBitCount) |
((currentByte >> bitCount) & ((1 << newBitCount) - 1));
result = (result << newBitCount) | ((currentByte >> bitCount) & ((1 << newBitCount) - 1));
}
return result;
}

/**
* Parses the AV1 sequence header.
*
* See AV1 bitstream spec 5.5.1.
* This method can only be called once.
* <p>See AV1 bitstream spec 5.5.1. This method can only be called once.
*/
public boolean parseSequenceHeader() {
if (parseSequenceHeaderCalled) {
Expand Down