Parse initialization data from AV1 tracks
Initialization data is not passed to `MediaCodecRenderer` as it is not required for playing AV1 video. See: https://developer.android.com/reference/android/media/MediaCodec#CSD PiperOrigin-RevId: 629729301
This commit is contained in:
parent
1af86d4c4d
commit
e25bd07a81
@ -1544,6 +1544,15 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
|
|||||||
newFormat,
|
newFormat,
|
||||||
PlaybackException.ERROR_CODE_DECODING_FORMAT_UNSUPPORTED);
|
PlaybackException.ERROR_CODE_DECODING_FORMAT_UNSUPPORTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove the initialization data from the format if present when dealing with AV1, as it is not
|
||||||
|
// required for playing AV1 video.
|
||||||
|
// Reference: https://developer.android.com/reference/android/media/MediaCodec#CSD
|
||||||
|
if (Objects.equals(newFormat.sampleMimeType, MimeTypes.VIDEO_AV1)
|
||||||
|
&& !newFormat.initializationData.isEmpty()) {
|
||||||
|
newFormat = newFormat.buildUpon().setInitializationData(null).build();
|
||||||
|
}
|
||||||
|
|
||||||
setSourceDrmSession(formatHolder.drmSession);
|
setSourceDrmSession(formatHolder.drmSession);
|
||||||
inputFormat = newFormat;
|
inputFormat = newFormat;
|
||||||
|
|
||||||
|
@ -1227,6 +1227,12 @@ import java.util.Objects;
|
|||||||
ColorInfo.isoTransferCharacteristicsToColorTransfer(transferCharacteristics);
|
ColorInfo.isoTransferCharacteristicsToColorTransfer(transferCharacteristics);
|
||||||
} else if (childAtomType == Atom.TYPE_av1C) {
|
} else if (childAtomType == Atom.TYPE_av1C) {
|
||||||
mimeType = MimeTypes.VIDEO_AV1;
|
mimeType = MimeTypes.VIDEO_AV1;
|
||||||
|
|
||||||
|
int childAtomBodySize = childAtomSize - Atom.HEADER_SIZE;
|
||||||
|
byte[] initializationDataChunk = new byte[childAtomBodySize];
|
||||||
|
parent.readBytes(initializationDataChunk, /* offset= */ 0, childAtomBodySize);
|
||||||
|
initializationData = ImmutableList.of(initializationDataChunk);
|
||||||
|
|
||||||
parent.setPosition(childStartPosition + Atom.HEADER_SIZE);
|
parent.setPosition(childStartPosition + Atom.HEADER_SIZE);
|
||||||
ColorInfo colorInfo = parseAv1c(parent);
|
ColorInfo colorInfo = parseAv1c(parent);
|
||||||
|
|
||||||
|
@ -23,6 +23,8 @@ track 0:
|
|||||||
lumaBitdepth = 10
|
lumaBitdepth = 10
|
||||||
chromaBitdepth = 10
|
chromaBitdepth = 10
|
||||||
metadata = entries=[TSSE: description=null: values=[Lavf60.3.100], Mp4Timestamp: creation time=0, modification time=0, timescale=1000]
|
metadata = entries=[TSSE: description=null: values=[Lavf60.3.100], Mp4Timestamp: creation time=0, modification time=0, timescale=1000]
|
||||||
|
initializationData:
|
||||||
|
data = length 20, hash 3DFDDB0E
|
||||||
sample 0:
|
sample 0:
|
||||||
time = 0
|
time = 0
|
||||||
flags = 1
|
flags = 1
|
||||||
|
@ -23,6 +23,8 @@ track 0:
|
|||||||
lumaBitdepth = 10
|
lumaBitdepth = 10
|
||||||
chromaBitdepth = 10
|
chromaBitdepth = 10
|
||||||
metadata = entries=[TSSE: description=null: values=[Lavf60.3.100], Mp4Timestamp: creation time=0, modification time=0, timescale=1000]
|
metadata = entries=[TSSE: description=null: values=[Lavf60.3.100], Mp4Timestamp: creation time=0, modification time=0, timescale=1000]
|
||||||
|
initializationData:
|
||||||
|
data = length 20, hash 3DFDDB0E
|
||||||
sample 0:
|
sample 0:
|
||||||
time = 0
|
time = 0
|
||||||
flags = 1
|
flags = 1
|
||||||
|
@ -23,6 +23,8 @@ track 0:
|
|||||||
lumaBitdepth = 10
|
lumaBitdepth = 10
|
||||||
chromaBitdepth = 10
|
chromaBitdepth = 10
|
||||||
metadata = entries=[TSSE: description=null: values=[Lavf60.3.100], Mp4Timestamp: creation time=0, modification time=0, timescale=1000]
|
metadata = entries=[TSSE: description=null: values=[Lavf60.3.100], Mp4Timestamp: creation time=0, modification time=0, timescale=1000]
|
||||||
|
initializationData:
|
||||||
|
data = length 20, hash 3DFDDB0E
|
||||||
sample 0:
|
sample 0:
|
||||||
time = 0
|
time = 0
|
||||||
flags = 1
|
flags = 1
|
||||||
|
@ -23,6 +23,8 @@ track 0:
|
|||||||
lumaBitdepth = 10
|
lumaBitdepth = 10
|
||||||
chromaBitdepth = 10
|
chromaBitdepth = 10
|
||||||
metadata = entries=[TSSE: description=null: values=[Lavf60.3.100], Mp4Timestamp: creation time=0, modification time=0, timescale=1000]
|
metadata = entries=[TSSE: description=null: values=[Lavf60.3.100], Mp4Timestamp: creation time=0, modification time=0, timescale=1000]
|
||||||
|
initializationData:
|
||||||
|
data = length 20, hash 3DFDDB0E
|
||||||
sample 0:
|
sample 0:
|
||||||
time = 0
|
time = 0
|
||||||
flags = 1
|
flags = 1
|
||||||
|
@ -23,6 +23,8 @@ track 0:
|
|||||||
lumaBitdepth = 10
|
lumaBitdepth = 10
|
||||||
chromaBitdepth = 10
|
chromaBitdepth = 10
|
||||||
metadata = entries=[TSSE: description=null: values=[Lavf60.3.100], Mp4Timestamp: creation time=0, modification time=0, timescale=1000]
|
metadata = entries=[TSSE: description=null: values=[Lavf60.3.100], Mp4Timestamp: creation time=0, modification time=0, timescale=1000]
|
||||||
|
initializationData:
|
||||||
|
data = length 20, hash 3DFDDB0E
|
||||||
sample 0:
|
sample 0:
|
||||||
time = 0
|
time = 0
|
||||||
flags = 1
|
flags = 1
|
||||||
|
@ -24,6 +24,8 @@ track 0:
|
|||||||
lumaBitdepth = 10
|
lumaBitdepth = 10
|
||||||
chromaBitdepth = 10
|
chromaBitdepth = 10
|
||||||
metadata = entries=[TSSE: description=null: values=[Lavf58.76.100], Mp4Timestamp: creation time=0, modification time=0, timescale=1000]
|
metadata = entries=[TSSE: description=null: values=[Lavf58.76.100], Mp4Timestamp: creation time=0, modification time=0, timescale=1000]
|
||||||
|
initializationData:
|
||||||
|
data = length 20, hash 4DF5B288
|
||||||
sample 0:
|
sample 0:
|
||||||
time = 0
|
time = 0
|
||||||
flags = 1
|
flags = 1
|
||||||
|
@ -24,6 +24,8 @@ track 0:
|
|||||||
lumaBitdepth = 10
|
lumaBitdepth = 10
|
||||||
chromaBitdepth = 10
|
chromaBitdepth = 10
|
||||||
metadata = entries=[TSSE: description=null: values=[Lavf58.76.100], Mp4Timestamp: creation time=0, modification time=0, timescale=1000]
|
metadata = entries=[TSSE: description=null: values=[Lavf58.76.100], Mp4Timestamp: creation time=0, modification time=0, timescale=1000]
|
||||||
|
initializationData:
|
||||||
|
data = length 20, hash 4DF5B288
|
||||||
sample 0:
|
sample 0:
|
||||||
time = 0
|
time = 0
|
||||||
flags = 1
|
flags = 1
|
||||||
|
@ -24,6 +24,8 @@ track 0:
|
|||||||
lumaBitdepth = 10
|
lumaBitdepth = 10
|
||||||
chromaBitdepth = 10
|
chromaBitdepth = 10
|
||||||
metadata = entries=[TSSE: description=null: values=[Lavf58.76.100], Mp4Timestamp: creation time=0, modification time=0, timescale=1000]
|
metadata = entries=[TSSE: description=null: values=[Lavf58.76.100], Mp4Timestamp: creation time=0, modification time=0, timescale=1000]
|
||||||
|
initializationData:
|
||||||
|
data = length 20, hash 4DF5B288
|
||||||
sample 0:
|
sample 0:
|
||||||
time = 0
|
time = 0
|
||||||
flags = 1
|
flags = 1
|
||||||
|
@ -24,6 +24,8 @@ track 0:
|
|||||||
lumaBitdepth = 10
|
lumaBitdepth = 10
|
||||||
chromaBitdepth = 10
|
chromaBitdepth = 10
|
||||||
metadata = entries=[TSSE: description=null: values=[Lavf58.76.100], Mp4Timestamp: creation time=0, modification time=0, timescale=1000]
|
metadata = entries=[TSSE: description=null: values=[Lavf58.76.100], Mp4Timestamp: creation time=0, modification time=0, timescale=1000]
|
||||||
|
initializationData:
|
||||||
|
data = length 20, hash 4DF5B288
|
||||||
sample 0:
|
sample 0:
|
||||||
time = 0
|
time = 0
|
||||||
flags = 1
|
flags = 1
|
||||||
|
@ -24,6 +24,8 @@ track 0:
|
|||||||
lumaBitdepth = 10
|
lumaBitdepth = 10
|
||||||
chromaBitdepth = 10
|
chromaBitdepth = 10
|
||||||
metadata = entries=[TSSE: description=null: values=[Lavf58.76.100], Mp4Timestamp: creation time=0, modification time=0, timescale=1000]
|
metadata = entries=[TSSE: description=null: values=[Lavf58.76.100], Mp4Timestamp: creation time=0, modification time=0, timescale=1000]
|
||||||
|
initializationData:
|
||||||
|
data = length 20, hash 4DF5B288
|
||||||
sample 0:
|
sample 0:
|
||||||
time = 0
|
time = 0
|
||||||
flags = 1
|
flags = 1
|
||||||
|
@ -20,6 +20,8 @@ track 0:
|
|||||||
lumaBitdepth = 8
|
lumaBitdepth = 8
|
||||||
chromaBitdepth = 8
|
chromaBitdepth = 8
|
||||||
metadata = entries=[Mp4Timestamp: creation time=100000000, modification time=500000000, timescale=10000]
|
metadata = entries=[Mp4Timestamp: creation time=100000000, modification time=500000000, timescale=10000]
|
||||||
|
initializationData:
|
||||||
|
data = length 17, hash 54AC4E6D
|
||||||
sample 0:
|
sample 0:
|
||||||
time = 0
|
time = 0
|
||||||
flags = 1
|
flags = 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user