Commit da9c985c by andrewlewis Committed by Oliver Woodman

Fix byte order for HDR10+ static metadata

The implementation of writing HDR10+ static metadata assumed that the
application would use default (big endian) byte order for this metadata but
MediaCodec expects the order to match the specification CTA-861.3.

PiperOrigin-RevId: 281050806
parent 7f19b885
......@@ -10,6 +10,7 @@
[embedded in Matroska streams](https://matroska.org/technical/specs/subtitles/index.html).
* Use `ExoMediaDrm.Provider` in `OfflineLicenseHelper` to avoid `ExoMediaDrm`
leaks ([#4721](https://github.com/google/ExoPlayer/issues/4721)).
* Fix byte order of HDR10+ static metadata to match CTA-861.3.
### 2.11.0 (not yet released) ###
......
......@@ -1912,9 +1912,9 @@ public class MatroskaExtractor implements Extractor {
initializationData = new ArrayList<>(3);
initializationData.add(codecPrivate);
initializationData.add(
ByteBuffer.allocate(8).order(ByteOrder.nativeOrder()).putLong(codecDelayNs).array());
ByteBuffer.allocate(8).order(ByteOrder.LITTLE_ENDIAN).putLong(codecDelayNs).array());
initializationData.add(
ByteBuffer.allocate(8).order(ByteOrder.nativeOrder()).putLong(seekPreRollNs).array());
ByteBuffer.allocate(8).order(ByteOrder.LITTLE_ENDIAN).putLong(seekPreRollNs).array());
break;
case CODEC_ID_AAC:
mimeType = MimeTypes.AUDIO_AAC;
......@@ -2116,6 +2116,7 @@ public class MatroskaExtractor implements Extractor {
}
/** Returns the HDR Static Info as defined in CTA-861.3. */
@Nullable
private byte[] getHdrStaticInfo() {
// Are all fields present.
if (primaryRChromaticityX == Format.NO_VALUE || primaryRChromaticityY == Format.NO_VALUE
......@@ -2128,7 +2129,7 @@ public class MatroskaExtractor implements Extractor {
}
byte[] hdrStaticInfoData = new byte[25];
ByteBuffer hdrStaticInfo = ByteBuffer.wrap(hdrStaticInfoData);
ByteBuffer hdrStaticInfo = ByteBuffer.wrap(hdrStaticInfoData).order(ByteOrder.LITTLE_ENDIAN);
hdrStaticInfo.put((byte) 0); // Type.
hdrStaticInfo.putShort((short) ((primaryRChromaticityX * MAX_CHROMATICITY) + 0.5f));
hdrStaticInfo.putShort((short) ((primaryRChromaticityY * MAX_CHROMATICITY) + 0.5f));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment