Fix MP4 parser issue in reading bitrates from esds boxes.
As per MP4 spec, bitrates in esds boxes can be a 32 bit number which doesn't fits in Java int type, so now reading it as a long value. Our class for holding media format, only allows bitrates value to be an int as we don't expect the bitrates to be greater than or equal to 2^31. So we're limiting the values for bitrates to Integer.MAX_VALUE. #minor-release PiperOrigin-RevId: 458423162
This commit is contained in:
parent
42f13c331f
commit
21638fa378
@ -12,6 +12,8 @@
|
|||||||
([#2092](https://github.com/google/ExoPlayer/issues/2092)).
|
([#2092](https://github.com/google/ExoPlayer/issues/2092)).
|
||||||
* Fix parsing of H265 short term reference picture sets
|
* Fix parsing of H265 short term reference picture sets
|
||||||
([#10316](https://github.com/google/ExoPlayer/issues/10316)).
|
([#10316](https://github.com/google/ExoPlayer/issues/10316)).
|
||||||
|
* Fix parsing of bitrates from `esds` boxes
|
||||||
|
([#10381](https://github.com/google/ExoPlayer/issues/10381)).
|
||||||
* Metadata:
|
* Metadata:
|
||||||
* `MetadataRenderer` can now be configured to render metadata as soon as
|
* `MetadataRenderer` can now be configured to render metadata as soon as
|
||||||
they are available. Create an instance with
|
they are available. Create an instance with
|
||||||
|
@ -45,6 +45,7 @@ import androidx.media3.extractor.OpusUtil;
|
|||||||
import androidx.media3.extractor.metadata.mp4.SmtaMetadataEntry;
|
import androidx.media3.extractor.metadata.mp4.SmtaMetadataEntry;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.primitives.Ints;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -1303,7 +1304,9 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (esdsData != null) {
|
if (esdsData != null) {
|
||||||
formatBuilder.setAverageBitrate(esdsData.bitrate).setPeakBitrate(esdsData.peakBitrate);
|
formatBuilder
|
||||||
|
.setAverageBitrate(Ints.saturatedCast(esdsData.bitrate))
|
||||||
|
.setPeakBitrate(Ints.saturatedCast(esdsData.peakBitrate));
|
||||||
}
|
}
|
||||||
|
|
||||||
out.format = formatBuilder.build();
|
out.format = formatBuilder.build();
|
||||||
@ -1609,7 +1612,9 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|
|||||||
.setLanguage(language);
|
.setLanguage(language);
|
||||||
|
|
||||||
if (esdsData != null) {
|
if (esdsData != null) {
|
||||||
formatBuilder.setAverageBitrate(esdsData.bitrate).setPeakBitrate(esdsData.peakBitrate);
|
formatBuilder
|
||||||
|
.setAverageBitrate(Ints.saturatedCast(esdsData.bitrate))
|
||||||
|
.setPeakBitrate(Ints.saturatedCast(esdsData.peakBitrate));
|
||||||
}
|
}
|
||||||
|
|
||||||
out.format = formatBuilder.build();
|
out.format = formatBuilder.build();
|
||||||
@ -1683,8 +1688,8 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|
|||||||
}
|
}
|
||||||
|
|
||||||
parent.skipBytes(4);
|
parent.skipBytes(4);
|
||||||
int peakBitrate = parent.readUnsignedIntToInt();
|
long peakBitrate = parent.readUnsignedInt();
|
||||||
int bitrate = parent.readUnsignedIntToInt();
|
long bitrate = parent.readUnsignedInt();
|
||||||
|
|
||||||
// Start of the DecoderSpecificInfo.
|
// Start of the DecoderSpecificInfo.
|
||||||
parent.skipBytes(1); // DecoderSpecificInfo tag
|
parent.skipBytes(1); // DecoderSpecificInfo tag
|
||||||
@ -1943,14 +1948,14 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|
|||||||
private static final class EsdsData {
|
private static final class EsdsData {
|
||||||
private final @NullableType String mimeType;
|
private final @NullableType String mimeType;
|
||||||
private final byte @NullableType [] initializationData;
|
private final byte @NullableType [] initializationData;
|
||||||
private final int bitrate;
|
private final long bitrate;
|
||||||
private final int peakBitrate;
|
private final long peakBitrate;
|
||||||
|
|
||||||
public EsdsData(
|
public EsdsData(
|
||||||
@NullableType String mimeType,
|
@NullableType String mimeType,
|
||||||
byte @NullableType [] initializationData,
|
byte @NullableType [] initializationData,
|
||||||
int bitrate,
|
long bitrate,
|
||||||
int peakBitrate) {
|
long peakBitrate) {
|
||||||
this.mimeType = mimeType;
|
this.mimeType = mimeType;
|
||||||
this.initializationData = initializationData;
|
this.initializationData = initializationData;
|
||||||
this.bitrate = bitrate;
|
this.bitrate = bitrate;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user