Fix maxInputSize for AMR-NB

The `maxInputSize` for AMR-NB should be 32, not 61. The `maxInputSize` for AMR-WB is 61.

PiperOrigin-RevId: 650282516
This commit is contained in:
rohks 2024-07-08 09:50:09 -07:00 committed by Copybara-Service
parent 06d61ffaaa
commit 007c258ceb
9 changed files with 11 additions and 12 deletions

View File

@ -139,9 +139,6 @@ public final class AmrExtractor implements Extractor {
private static final byte[] amrSignatureNb = Util.getUtf8Bytes("#!AMR\n");
private static final byte[] amrSignatureWb = Util.getUtf8Bytes("#!AMR-WB\n");
/** Theoretical maximum frame size for a AMR frame. */
private static final int MAX_FRAME_SIZE_BYTES = frameSizeBytesByTypeWb[8];
/**
* The required number of samples in the stream with same sample size to classify the stream as a
* constant-bitrate-stream.
@ -284,10 +281,12 @@ public final class AmrExtractor implements Extractor {
hasOutputFormat = true;
String mimeType = isWideBand ? MimeTypes.AUDIO_AMR_WB : MimeTypes.AUDIO_AMR_NB;
int sampleRate = isWideBand ? SAMPLE_RATE_WB : SAMPLE_RATE_NB;
// Theoretical maximum frame size for a AMR frame.
int maxInputSize = isWideBand ? frameSizeBytesByTypeWb[8] : frameSizeBytesByTypeNb[7];
trackOutput.format(
new Format.Builder()
.setSampleMimeType(mimeType)
.setMaxInputSize(MAX_FRAME_SIZE_BYTES)
.setMaxInputSize(maxInputSize)
.setChannelCount(1)
.setSampleRate(sampleRate)
.build());

View File

@ -8,7 +8,7 @@ track 0:
sample count = 218
format 0:
sampleMimeType = audio/3gpp
maxInputSize = 61
maxInputSize = 32
channelCount = 1
sampleRate = 8000
sample 0:

View File

@ -8,7 +8,7 @@ track 0:
sample count = 218
format 0:
sampleMimeType = audio/3gpp
maxInputSize = 61
maxInputSize = 32
channelCount = 1
sampleRate = 8000
sample 0:

View File

@ -11,7 +11,7 @@ track 0:
sample count = 218
format 0:
sampleMimeType = audio/3gpp
maxInputSize = 61
maxInputSize = 32
channelCount = 1
sampleRate = 8000
sample 0:

View File

@ -11,7 +11,7 @@ track 0:
sample count = 146
format 0:
sampleMimeType = audio/3gpp
maxInputSize = 61
maxInputSize = 32
channelCount = 1
sampleRate = 8000
sample 0:

View File

@ -11,7 +11,7 @@ track 0:
sample count = 73
format 0:
sampleMimeType = audio/3gpp
maxInputSize = 61
maxInputSize = 32
channelCount = 1
sampleRate = 8000
sample 0:

View File

@ -11,7 +11,7 @@ track 0:
sample count = 1
format 0:
sampleMimeType = audio/3gpp
maxInputSize = 61
maxInputSize = 32
channelCount = 1
sampleRate = 8000
sample 0:

View File

@ -8,7 +8,7 @@ track 0:
sample count = 218
format 0:
sampleMimeType = audio/3gpp
maxInputSize = 61
maxInputSize = 32
channelCount = 1
sampleRate = 8000
sample 0:

View File

@ -1,6 +1,6 @@
format audio:
sampleMimeType = audio/3gpp
maxInputSize = 61
maxInputSize = 32
channelCount = 1
sampleRate = 8000
sample: