Hard-code channel count and sample rate for AMR-NB and AMR-WB

AMR-NB and AMR-WB are inherently mono, so channel count is set to 1. Sample rate is also hard-coded to adhere to codec standards.

Also removed unused parameter `hasAdditionalViews` in `StriData`.

#cherrypick

PiperOrigin-RevId: 707606245
This commit is contained in:
rohks 2024-12-18 11:00:21 -08:00 committed by Copybara-Service
parent 44aa87c832
commit ca58867816
5 changed files with 20 additions and 16 deletions

View file

@ -98,6 +98,9 @@ public final class BoxParser {
@SuppressWarnings("ConstantCaseForConstants") @SuppressWarnings("ConstantCaseForConstants")
private static final int TYPE_vide = 0x76696465; private static final int TYPE_vide = 0x76696465;
private static final int SAMPLE_RATE_AMR_NB = 8_000;
private static final int SAMPLE_RATE_AMR_WB = 16_000;
/** /**
* The threshold number of samples to trim from the start/end of an audio track when applying an * The threshold number of samples to trim from the start/end of an audio track when applying an
* edit below which gapless info can be used (rather than removing samples from the sample table). * edit below which gapless info can be used (rather than removing samples from the sample table).
@ -1859,12 +1862,20 @@ public final class BoxParser {
return; return;
} }
// As per the IAMF spec (https://aomediacodec.github.io/iamf/#iasampleentry-section),
// channelCount and sampleRate SHALL be set to 0 and ignored. We ignore it by using
// Format.NO_VALUE instead of 0.
if (atomType == Mp4Box.TYPE_iamf) { if (atomType == Mp4Box.TYPE_iamf) {
// As per the IAMF spec (https://aomediacodec.github.io/iamf/#iasampleentry-section),
// channelCount and sampleRate SHALL be set to 0 and ignored. We ignore it by using
// Format.NO_VALUE instead of 0.
channelCount = Format.NO_VALUE; channelCount = Format.NO_VALUE;
sampleRate = Format.NO_VALUE; sampleRate = Format.NO_VALUE;
} else if (atomType == Mp4Box.TYPE_samr) {
// AMR NB audio is always mono, 8kHz
channelCount = 1;
sampleRate = SAMPLE_RATE_AMR_NB;
} else if (atomType == Mp4Box.TYPE_sawb) {
// AMR WB audio is always mono, 16kHz
channelCount = 1;
sampleRate = SAMPLE_RATE_AMR_WB;
} }
int childPosition = parent.getPosition(); int childPosition = parent.getPosition();
@ -2235,8 +2246,7 @@ public final class BoxParser {
new StriData( new StriData(
((striInfo & 0x01) == 0x01), ((striInfo & 0x01) == 0x01),
((striInfo & 0x02) == 0x02), ((striInfo & 0x02) == 0x02),
((striInfo & 0x08) == 0x08), ((striInfo & 0x08) == 0x08)));
((striInfo & 0x04) == 0x04)));
} }
childPosition += childAtomSize; childPosition += childAtomSize;
} }
@ -2506,17 +2516,11 @@ public final class BoxParser {
private final boolean hasLeftEyeView; private final boolean hasLeftEyeView;
private final boolean hasRightEyeView; private final boolean hasRightEyeView;
private final boolean eyeViewsReversed; private final boolean eyeViewsReversed;
private final boolean hasAdditionalViews;
public StriData( public StriData(boolean hasLeftEyeView, boolean hasRightEyeView, boolean eyeViewsReversed) {
boolean hasLeftEyeView,
boolean hasRightEyeView,
boolean eyeViewsReversed,
boolean hasAdditionalViews) {
this.hasLeftEyeView = hasLeftEyeView; this.hasLeftEyeView = hasLeftEyeView;
this.hasRightEyeView = hasRightEyeView; this.hasRightEyeView = hasRightEyeView;
this.eyeViewsReversed = eyeViewsReversed; this.eyeViewsReversed = eyeViewsReversed;
this.hasAdditionalViews = hasAdditionalViews;
} }
} }

View file

@ -15,7 +15,7 @@ track 0:
containerMimeType = audio/mp4 containerMimeType = audio/mp4
sampleMimeType = audio/amr-wb sampleMimeType = audio/amr-wb
maxInputSize = 89 maxInputSize = 89
channelCount = 2 channelCount = 1
sampleRate = 16000 sampleRate = 16000
language = und language = und
metadata = entries=[Mp4Timestamp: creation time=100000000, modification time=500000000, timescale=10000] metadata = entries=[Mp4Timestamp: creation time=100000000, modification time=500000000, timescale=10000]

View file

@ -15,7 +15,7 @@ track 0:
containerMimeType = audio/mp4 containerMimeType = audio/mp4
sampleMimeType = audio/3gpp sampleMimeType = audio/3gpp
maxInputSize = 62 maxInputSize = 62
channelCount = 2 channelCount = 1
sampleRate = 8000 sampleRate = 8000
language = und language = und
metadata = entries=[Mp4Timestamp: creation time=100000000, modification time=500000000, timescale=10000] metadata = entries=[Mp4Timestamp: creation time=100000000, modification time=500000000, timescale=10000]

View file

@ -15,7 +15,7 @@ track 0:
containerMimeType = audio/mp4 containerMimeType = audio/mp4
sampleMimeType = audio/amr-wb sampleMimeType = audio/amr-wb
maxInputSize = 89 maxInputSize = 89
channelCount = 2 channelCount = 1
sampleRate = 16000 sampleRate = 16000
language = und language = und
metadata = entries=[Mp4Timestamp: creation time=3000000000, modification time=4000000000, timescale=10000] metadata = entries=[Mp4Timestamp: creation time=3000000000, modification time=4000000000, timescale=10000]

View file

@ -15,7 +15,7 @@ track 0:
containerMimeType = audio/mp4 containerMimeType = audio/mp4
sampleMimeType = audio/3gpp sampleMimeType = audio/3gpp
maxInputSize = 62 maxInputSize = 62
channelCount = 2 channelCount = 1
sampleRate = 8000 sampleRate = 8000
language = und language = und
metadata = entries=[Mp4Timestamp: creation time=3000000000, modification time=4000000000, timescale=10000] metadata = entries=[Mp4Timestamp: creation time=3000000000, modification time=4000000000, timescale=10000]