*** Original commit ***

Parse and set `peakBitrate` for Dolby TrueHD(AC-3) and (E-)AC-3

#minor-release

***

PiperOrigin-RevId: 490570517
(cherry picked from commit 427329175e87a7f3173791c59e6c2d4c4ed8dea4)
This commit is contained in:
rohks 2022-11-23 21:15:09 +00:00 committed by christosts
parent 101a2498a0
commit 32f7a8b807
31 changed files with 1 additions and 49 deletions

View File

@ -158,9 +158,6 @@ public final class Ac3Util {
if ((nextByte & 0x04) != 0) { // lfeon
channelCount++;
}
// bit_rate_code - 5 bits. 2 bits from previous byte and 3 bits from next.
int halfFrmsizecod = ((nextByte & 0x03) << 3) | ((data.readUnsignedByte() & 0xE0) >> 5);
int constantBitrate = BITRATE_BY_HALF_FRMSIZECOD[halfFrmsizecod];
return new Format.Builder()
.setId(trackId)
.setSampleMimeType(MimeTypes.AUDIO_AC3)
@ -168,8 +165,6 @@ public final class Ac3Util {
.setSampleRate(sampleRate)
.setDrmInitData(drmInitData)
.setLanguage(language)
.setAverageBitrate(constantBitrate)
.setPeakBitrate(constantBitrate)
.build();
}
@ -185,9 +180,7 @@ public final class Ac3Util {
*/
public static Format parseEAc3AnnexFFormat(
ParsableByteArray data, String trackId, String language, @Nullable DrmInitData drmInitData) {
// 13 bits for data_rate, 3 bits for num_ind_sub which are ignored.
int peakBitrate =
((data.readUnsignedByte() & 0xFF) << 5) | ((data.readUnsignedByte() & 0xF8) >> 3);
data.skipBytes(2); // data_rate, num_ind_sub
// Read the first independent substream.
int fscod = (data.readUnsignedByte() & 0xC0) >> 6;
@ -223,7 +216,6 @@ public final class Ac3Util {
.setSampleRate(sampleRate)
.setDrmInitData(drmInitData)
.setLanguage(language)
.setPeakBitrate(peakBitrate)
.build();
}

View File

@ -10,8 +10,6 @@ track 0:
total output bytes = 13824
sample count = 9
format 0:
averageBitrate = 384
peakBitrate = 384
id = 1
sampleMimeType = audio/ac3
maxInputSize = 1566

View File

@ -10,8 +10,6 @@ track 0:
total output bytes = 9216
sample count = 6
format 0:
averageBitrate = 384
peakBitrate = 384
id = 1
sampleMimeType = audio/ac3
maxInputSize = 1566

View File

@ -10,8 +10,6 @@ track 0:
total output bytes = 4608
sample count = 3
format 0:
averageBitrate = 384
peakBitrate = 384
id = 1
sampleMimeType = audio/ac3
maxInputSize = 1566

View File

@ -10,8 +10,6 @@ track 0:
total output bytes = 1536
sample count = 1
format 0:
averageBitrate = 384
peakBitrate = 384
id = 1
sampleMimeType = audio/ac3
maxInputSize = 1566

View File

@ -10,8 +10,6 @@ track 0:
total output bytes = 13824
sample count = 9
format 0:
averageBitrate = 384
peakBitrate = 384
id = 1
sampleMimeType = audio/ac3
maxInputSize = 1566

View File

@ -10,8 +10,6 @@ track 0:
total output bytes = 13824
sample count = 9
format 0:
averageBitrate = 384
peakBitrate = 384
id = 1
sampleMimeType = audio/ac3
channelCount = 6

View File

@ -10,8 +10,6 @@ track 0:
total output bytes = 10752
sample count = 7
format 0:
averageBitrate = 384
peakBitrate = 384
id = 1
sampleMimeType = audio/ac3
channelCount = 6

View File

@ -10,8 +10,6 @@ track 0:
total output bytes = 6144
sample count = 4
format 0:
averageBitrate = 384
peakBitrate = 384
id = 1
sampleMimeType = audio/ac3
channelCount = 6

View File

@ -10,8 +10,6 @@ track 0:
total output bytes = 1536
sample count = 1
format 0:
averageBitrate = 384
peakBitrate = 384
id = 1
sampleMimeType = audio/ac3
channelCount = 6

View File

@ -10,8 +10,6 @@ track 0:
total output bytes = 13824
sample count = 9
format 0:
averageBitrate = 384
peakBitrate = 384
id = 1
sampleMimeType = audio/ac3
channelCount = 6

View File

@ -10,7 +10,6 @@ track 0:
total output bytes = 216000
sample count = 54
format 0:
peakBitrate = 1000
id = 1
sampleMimeType = audio/eac3
maxInputSize = 4030

View File

@ -10,7 +10,6 @@ track 0:
total output bytes = 144000
sample count = 36
format 0:
peakBitrate = 1000
id = 1
sampleMimeType = audio/eac3
maxInputSize = 4030

View File

@ -10,7 +10,6 @@ track 0:
total output bytes = 72000
sample count = 18
format 0:
peakBitrate = 1000
id = 1
sampleMimeType = audio/eac3
maxInputSize = 4030

View File

@ -10,7 +10,6 @@ track 0:
total output bytes = 4000
sample count = 1
format 0:
peakBitrate = 1000
id = 1
sampleMimeType = audio/eac3
maxInputSize = 4030

View File

@ -10,7 +10,6 @@ track 0:
total output bytes = 216000
sample count = 54
format 0:
peakBitrate = 1000
id = 1
sampleMimeType = audio/eac3
maxInputSize = 4030

View File

@ -10,7 +10,6 @@ track 0:
total output bytes = 216000
sample count = 54
format 0:
peakBitrate = 1000
id = 1
sampleMimeType = audio/eac3
channelCount = 6

View File

@ -10,7 +10,6 @@ track 0:
total output bytes = 148000
sample count = 37
format 0:
peakBitrate = 1000
id = 1
sampleMimeType = audio/eac3
channelCount = 6

View File

@ -10,7 +10,6 @@ track 0:
total output bytes = 76000
sample count = 19
format 0:
peakBitrate = 1000
id = 1
sampleMimeType = audio/eac3
channelCount = 6

View File

@ -10,7 +10,6 @@ track 0:
total output bytes = 4000
sample count = 1
format 0:
peakBitrate = 1000
id = 1
sampleMimeType = audio/eac3
channelCount = 6

View File

@ -10,7 +10,6 @@ track 0:
total output bytes = 216000
sample count = 54
format 0:
peakBitrate = 1000
id = 1
sampleMimeType = audio/eac3
channelCount = 6

View File

@ -10,7 +10,6 @@ track 0:
total output bytes = 163840
sample count = 64
format 0:
peakBitrate = 640
id = 1
sampleMimeType = audio/eac3-joc
maxInputSize = 2590

View File

@ -10,7 +10,6 @@ track 0:
total output bytes = 110080
sample count = 43
format 0:
peakBitrate = 640
id = 1
sampleMimeType = audio/eac3-joc
maxInputSize = 2590

View File

@ -10,7 +10,6 @@ track 0:
total output bytes = 56320
sample count = 22
format 0:
peakBitrate = 640
id = 1
sampleMimeType = audio/eac3-joc
maxInputSize = 2590

View File

@ -10,7 +10,6 @@ track 0:
total output bytes = 2560
sample count = 1
format 0:
peakBitrate = 640
id = 1
sampleMimeType = audio/eac3-joc
maxInputSize = 2590

View File

@ -10,7 +10,6 @@ track 0:
total output bytes = 163840
sample count = 64
format 0:
peakBitrate = 640
id = 1
sampleMimeType = audio/eac3-joc
maxInputSize = 2590

View File

@ -10,7 +10,6 @@ track 0:
total output bytes = 163840
sample count = 64
format 0:
peakBitrate = 640
id = 1
sampleMimeType = audio/eac3-joc
channelCount = 6

View File

@ -10,7 +10,6 @@ track 0:
total output bytes = 110080
sample count = 43
format 0:
peakBitrate = 640
id = 1
sampleMimeType = audio/eac3-joc
channelCount = 6

View File

@ -10,7 +10,6 @@ track 0:
total output bytes = 56320
sample count = 22
format 0:
peakBitrate = 640
id = 1
sampleMimeType = audio/eac3-joc
channelCount = 6

View File

@ -10,7 +10,6 @@ track 0:
total output bytes = 2560
sample count = 1
format 0:
peakBitrate = 640
id = 1
sampleMimeType = audio/eac3-joc
channelCount = 6

View File

@ -10,7 +10,6 @@ track 0:
total output bytes = 163840
sample count = 64
format 0:
peakBitrate = 640
id = 1
sampleMimeType = audio/eac3-joc
channelCount = 6