Commit 13cf2360 by kimvde Committed by Oliver Woodman

Compute format maxInputSize in FlacReader

Use the maximum frame size as the maximum sample size if provided.

PiperOrigin-RevId: 279722820
parent 03511776
...@@ -72,6 +72,8 @@ import java.util.List; ...@@ -72,6 +72,8 @@ import java.util.List;
byte[] data = packet.data; byte[] data = packet.data;
if (streamMetadata == null) { if (streamMetadata == null) {
streamMetadata = new FlacStreamMetadata(data, 17); streamMetadata = new FlacStreamMetadata(data, 17);
int maxInputSize =
streamMetadata.maxFrameSize == 0 ? Format.NO_VALUE : streamMetadata.maxFrameSize;
byte[] metadata = Arrays.copyOfRange(data, 9, packet.limit()); byte[] metadata = Arrays.copyOfRange(data, 9, packet.limit());
metadata[4] = (byte) 0x80; // Set the last metadata block flag, ignore the other blocks metadata[4] = (byte) 0x80; // Set the last metadata block flag, ignore the other blocks
List<byte[]> initializationData = Collections.singletonList(metadata); List<byte[]> initializationData = Collections.singletonList(metadata);
...@@ -81,7 +83,7 @@ import java.util.List; ...@@ -81,7 +83,7 @@ import java.util.List;
MimeTypes.AUDIO_FLAC, MimeTypes.AUDIO_FLAC,
/* codecs= */ null, /* codecs= */ null,
streamMetadata.bitRate(), streamMetadata.bitRate(),
/* maxInputSize= */ Format.NO_VALUE, maxInputSize,
streamMetadata.channels, streamMetadata.channels,
streamMetadata.sampleRate, streamMetadata.sampleRate,
initializationData, initializationData,
......
...@@ -9,7 +9,7 @@ track 0: ...@@ -9,7 +9,7 @@ track 0:
id = null id = null
containerMimeType = null containerMimeType = null
sampleMimeType = audio/flac sampleMimeType = audio/flac
maxInputSize = -1 maxInputSize = 5776
width = -1 width = -1
height = -1 height = -1
frameRate = -1.0 frameRate = -1.0
......
...@@ -9,7 +9,7 @@ track 0: ...@@ -9,7 +9,7 @@ track 0:
id = null id = null
containerMimeType = null containerMimeType = null
sampleMimeType = audio/flac sampleMimeType = audio/flac
maxInputSize = -1 maxInputSize = 5776
width = -1 width = -1
height = -1 height = -1
frameRate = -1.0 frameRate = -1.0
......
...@@ -9,7 +9,7 @@ track 0: ...@@ -9,7 +9,7 @@ track 0:
id = null id = null
containerMimeType = null containerMimeType = null
sampleMimeType = audio/flac sampleMimeType = audio/flac
maxInputSize = -1 maxInputSize = 5776
width = -1 width = -1
height = -1 height = -1
frameRate = -1.0 frameRate = -1.0
......
...@@ -9,7 +9,7 @@ track 0: ...@@ -9,7 +9,7 @@ track 0:
id = null id = null
containerMimeType = null containerMimeType = null
sampleMimeType = audio/flac sampleMimeType = audio/flac
maxInputSize = -1 maxInputSize = 5776
width = -1 width = -1
height = -1 height = -1
frameRate = -1.0 frameRate = -1.0
......
...@@ -9,7 +9,7 @@ track 0: ...@@ -9,7 +9,7 @@ track 0:
id = null id = null
containerMimeType = null containerMimeType = null
sampleMimeType = audio/flac sampleMimeType = audio/flac
maxInputSize = -1 maxInputSize = 5776
width = -1 width = -1
height = -1 height = -1
frameRate = -1.0 frameRate = -1.0
......
...@@ -9,7 +9,7 @@ track 0: ...@@ -9,7 +9,7 @@ track 0:
id = null id = null
containerMimeType = null containerMimeType = null
sampleMimeType = audio/flac sampleMimeType = audio/flac
maxInputSize = -1 maxInputSize = 5776
width = -1 width = -1
height = -1 height = -1
frameRate = -1.0 frameRate = -1.0
......
...@@ -9,7 +9,7 @@ track 0: ...@@ -9,7 +9,7 @@ track 0:
id = null id = null
containerMimeType = null containerMimeType = null
sampleMimeType = audio/flac sampleMimeType = audio/flac
maxInputSize = -1 maxInputSize = 5776
width = -1 width = -1
height = -1 height = -1
frameRate = -1.0 frameRate = -1.0
......
...@@ -9,7 +9,7 @@ track 0: ...@@ -9,7 +9,7 @@ track 0:
id = null id = null
containerMimeType = null containerMimeType = null
sampleMimeType = audio/flac sampleMimeType = audio/flac
maxInputSize = -1 maxInputSize = 5776
width = -1 width = -1
height = -1 height = -1
frameRate = -1.0 frameRate = -1.0
......
...@@ -9,7 +9,7 @@ track 0: ...@@ -9,7 +9,7 @@ track 0:
id = null id = null
containerMimeType = null containerMimeType = null
sampleMimeType = audio/flac sampleMimeType = audio/flac
maxInputSize = -1 maxInputSize = 5776
width = -1 width = -1
height = -1 height = -1
frameRate = -1.0 frameRate = -1.0
......
...@@ -9,7 +9,7 @@ track 0: ...@@ -9,7 +9,7 @@ track 0:
id = null id = null
containerMimeType = null containerMimeType = null
sampleMimeType = audio/flac sampleMimeType = audio/flac
maxInputSize = -1 maxInputSize = 5776
width = -1 width = -1
height = -1 height = -1
frameRate = -1.0 frameRate = -1.0
......
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