mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Merge pull request #8397 from equeim:avc-codecs
PiperOrigin-RevId: 350105847
This commit is contained in:
commit
a9a150a1d3
@ -39,6 +39,9 @@
|
||||
([#8349](https://github.com/google/ExoPlayer/issues/8349))
|
||||
* Add `DefaultHttpDataSource.Factory` and deprecate
|
||||
`DefaultHttpDataSourceFactory`.
|
||||
* Populate codecs string for H.264/AVC in MP4, Matroska and FLV streams to
|
||||
allow decoder capability checks based on codec profile/level
|
||||
([#8393](https://github.com/google/ExoPlayer/issues/8393)).
|
||||
* Track selection:
|
||||
* Add option to specify multiple preferred audio or text languages.
|
||||
* Forward `Timeline` and `MediaPeriodId` to `TrackSelection.Factory`.
|
||||
|
@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.google.android.exoplayer2.video;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import com.google.android.exoplayer2.Format;
|
||||
import com.google.android.exoplayer2.ParserException;
|
||||
import com.google.android.exoplayer2.util.CodecSpecificDataUtil;
|
||||
@ -34,13 +35,14 @@ public final class AvcConfig {
|
||||
public final int width;
|
||||
public final int height;
|
||||
public final float pixelWidthAspectRatio;
|
||||
@Nullable public final String codecs;
|
||||
|
||||
/**
|
||||
* Parses AVC configuration data.
|
||||
*
|
||||
* @param data A {@link ParsableByteArray}, whose position is set to the start of the AVC
|
||||
* configuration data to parse.
|
||||
* @return A parsed representation of the HEVC configuration data.
|
||||
* @return A parsed representation of the AVC configuration data.
|
||||
* @throws ParserException If an error occurred parsing the data.
|
||||
*/
|
||||
public static AvcConfig parse(ParsableByteArray data) throws ParserException {
|
||||
@ -63,6 +65,7 @@ public final class AvcConfig {
|
||||
int width = Format.NO_VALUE;
|
||||
int height = Format.NO_VALUE;
|
||||
float pixelWidthAspectRatio = 1;
|
||||
@Nullable String codecs = null;
|
||||
if (numSequenceParameterSets > 0) {
|
||||
byte[] sps = initializationData.get(0);
|
||||
SpsData spsData = NalUnitUtil.parseSpsNalUnit(initializationData.get(0),
|
||||
@ -70,21 +73,36 @@ public final class AvcConfig {
|
||||
width = spsData.width;
|
||||
height = spsData.height;
|
||||
pixelWidthAspectRatio = spsData.pixelWidthAspectRatio;
|
||||
codecs =
|
||||
CodecSpecificDataUtil.buildAvcCodecString(
|
||||
spsData.profileIdc, spsData.constraintsFlagsAndReservedZero2Bits, spsData.levelIdc);
|
||||
}
|
||||
return new AvcConfig(initializationData, nalUnitLengthFieldLength, width, height,
|
||||
pixelWidthAspectRatio);
|
||||
|
||||
return new AvcConfig(
|
||||
initializationData,
|
||||
nalUnitLengthFieldLength,
|
||||
width,
|
||||
height,
|
||||
pixelWidthAspectRatio,
|
||||
codecs);
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
throw new ParserException("Error parsing AVC config", e);
|
||||
}
|
||||
}
|
||||
|
||||
private AvcConfig(List<byte[]> initializationData, int nalUnitLengthFieldLength,
|
||||
int width, int height, float pixelWidthAspectRatio) {
|
||||
private AvcConfig(
|
||||
List<byte[]> initializationData,
|
||||
int nalUnitLengthFieldLength,
|
||||
int width,
|
||||
int height,
|
||||
float pixelWidthAspectRatio,
|
||||
@Nullable String codecs) {
|
||||
this.initializationData = initializationData;
|
||||
this.nalUnitLengthFieldLength = nalUnitLengthFieldLength;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.pixelWidthAspectRatio = pixelWidthAspectRatio;
|
||||
this.codecs = codecs;
|
||||
}
|
||||
|
||||
private static byte[] buildNalUnitForChild(ParsableByteArray data) {
|
||||
|
@ -93,6 +93,7 @@ import com.google.android.exoplayer2.video.AvcConfig;
|
||||
Format format =
|
||||
new Format.Builder()
|
||||
.setSampleMimeType(MimeTypes.VIDEO_H264)
|
||||
.setCodecs(avcConfig.codecs)
|
||||
.setWidth(avcConfig.width)
|
||||
.setHeight(avcConfig.height)
|
||||
.setPixelWidthHeightRatio(avcConfig.pixelWidthAspectRatio)
|
||||
|
@ -2086,6 +2086,7 @@ public class MatroskaExtractor implements Extractor {
|
||||
AvcConfig avcConfig = AvcConfig.parse(new ParsableByteArray(getCodecPrivate(codecId)));
|
||||
initializationData = avcConfig.initializationData;
|
||||
nalUnitLengthFieldLength = avcConfig.nalUnitLengthFieldLength;
|
||||
codecs = avcConfig.codecs;
|
||||
break;
|
||||
case CODEC_ID_H265:
|
||||
mimeType = MimeTypes.VIDEO_H265;
|
||||
|
@ -1058,6 +1058,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|
||||
if (!pixelWidthHeightRatioFromPasp) {
|
||||
pixelWidthHeightRatio = avcConfig.pixelWidthAspectRatio;
|
||||
}
|
||||
codecs = avcConfig.codecs;
|
||||
} else if (childAtomType == Atom.TYPE_hvcC) {
|
||||
Assertions.checkState(mimeType == null);
|
||||
mimeType = MimeTypes.VIDEO_H265;
|
||||
|
@ -11,6 +11,7 @@ track 9:
|
||||
sample count = 71
|
||||
format 0:
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.64000C
|
||||
width = 320
|
||||
height = 180
|
||||
initializationData:
|
||||
|
@ -11,6 +11,7 @@ track 9:
|
||||
sample count = 47
|
||||
format 0:
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.64000C
|
||||
width = 320
|
||||
height = 180
|
||||
initializationData:
|
||||
|
@ -11,6 +11,7 @@ track 9:
|
||||
sample count = 23
|
||||
format 0:
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.64000C
|
||||
width = 320
|
||||
height = 180
|
||||
initializationData:
|
||||
|
@ -11,6 +11,7 @@ track 9:
|
||||
sample count = 23
|
||||
format 0:
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.64000C
|
||||
width = 320
|
||||
height = 180
|
||||
initializationData:
|
||||
|
@ -11,6 +11,7 @@ track 9:
|
||||
sample count = 71
|
||||
format 0:
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.64000C
|
||||
width = 320
|
||||
height = 180
|
||||
initializationData:
|
||||
|
@ -198,6 +198,7 @@ track 9:
|
||||
sample count = 30
|
||||
format 0:
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.640034
|
||||
width = 1080
|
||||
height = 720
|
||||
initializationData:
|
||||
|
@ -198,6 +198,7 @@ track 9:
|
||||
sample count = 30
|
||||
format 0:
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.640034
|
||||
width = 1080
|
||||
height = 720
|
||||
initializationData:
|
||||
|
@ -12,6 +12,7 @@ track 1:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.640034
|
||||
width = 1080
|
||||
height = 720
|
||||
selectionFlags = 1
|
||||
|
@ -12,6 +12,7 @@ track 1:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.640034
|
||||
width = 1080
|
||||
height = 720
|
||||
selectionFlags = 1
|
||||
|
@ -12,6 +12,7 @@ track 1:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.640034
|
||||
width = 1080
|
||||
height = 720
|
||||
selectionFlags = 1
|
||||
|
@ -12,6 +12,7 @@ track 1:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.640034
|
||||
width = 1080
|
||||
height = 720
|
||||
selectionFlags = 1
|
||||
|
@ -12,6 +12,7 @@ track 1:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.640034
|
||||
width = 1080
|
||||
height = 720
|
||||
selectionFlags = 1
|
||||
|
@ -12,6 +12,7 @@ track 1:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.640034
|
||||
width = 1080
|
||||
height = 720
|
||||
rotationDegrees = 90
|
||||
|
@ -12,6 +12,7 @@ track 1:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.640034
|
||||
width = 1080
|
||||
height = 720
|
||||
rotationDegrees = 90
|
||||
|
@ -12,6 +12,7 @@ track 1:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.640034
|
||||
width = 1080
|
||||
height = 720
|
||||
rotationDegrees = 90
|
||||
|
@ -12,6 +12,7 @@ track 1:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.640034
|
||||
width = 1080
|
||||
height = 720
|
||||
rotationDegrees = 90
|
||||
|
@ -12,6 +12,7 @@ track 1:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.640034
|
||||
width = 1080
|
||||
height = 720
|
||||
rotationDegrees = 90
|
||||
|
@ -12,6 +12,7 @@ track 1:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.640034
|
||||
width = 1080
|
||||
height = 720
|
||||
selectionFlags = 1
|
||||
|
@ -12,6 +12,7 @@ track 1:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.640034
|
||||
width = 1080
|
||||
height = 720
|
||||
selectionFlags = 1
|
||||
|
@ -12,6 +12,7 @@ track 1:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.640034
|
||||
width = 1080
|
||||
height = 720
|
||||
selectionFlags = 1
|
||||
|
@ -12,6 +12,7 @@ track 1:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.640034
|
||||
width = 1080
|
||||
height = 720
|
||||
selectionFlags = 1
|
||||
|
@ -12,6 +12,7 @@ track 1:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.640034
|
||||
width = 1080
|
||||
height = 720
|
||||
selectionFlags = 1
|
||||
|
@ -12,6 +12,7 @@ track 1:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.640034
|
||||
width = 1080
|
||||
height = 720
|
||||
selectionFlags = 1
|
||||
|
@ -12,6 +12,7 @@ track 1:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.640034
|
||||
width = 1080
|
||||
height = 720
|
||||
selectionFlags = 1
|
||||
|
@ -12,6 +12,7 @@ track 1:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.640034
|
||||
width = 1080
|
||||
height = 720
|
||||
selectionFlags = 1
|
||||
|
@ -12,6 +12,7 @@ track 1:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.640034
|
||||
width = 1080
|
||||
height = 720
|
||||
selectionFlags = 1
|
||||
|
@ -12,6 +12,7 @@ track 1:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.640034
|
||||
width = 1080
|
||||
height = 720
|
||||
selectionFlags = 1
|
||||
|
@ -12,6 +12,7 @@ track 1:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.640034
|
||||
width = 1080
|
||||
height = 720
|
||||
selectionFlags = 1
|
||||
|
@ -12,6 +12,7 @@ track 1:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.640034
|
||||
width = 1080
|
||||
height = 720
|
||||
selectionFlags = 1
|
||||
|
@ -12,6 +12,7 @@ track 1:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.640034
|
||||
width = 1080
|
||||
height = 720
|
||||
selectionFlags = 1
|
||||
|
@ -12,6 +12,7 @@ track 1:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.640034
|
||||
width = 1080
|
||||
height = 720
|
||||
selectionFlags = 1
|
||||
|
@ -12,6 +12,7 @@ track 1:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.640034
|
||||
width = 1080
|
||||
height = 720
|
||||
selectionFlags = 1
|
||||
|
@ -12,6 +12,7 @@ track 1:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.640034
|
||||
width = 1080
|
||||
height = 720
|
||||
selectionFlags = 1
|
||||
|
@ -12,6 +12,7 @@ track 1:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.640034
|
||||
width = 1080
|
||||
height = 720
|
||||
selectionFlags = 1
|
||||
|
@ -12,6 +12,7 @@ track 1:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.640034
|
||||
width = 1080
|
||||
height = 720
|
||||
selectionFlags = 1
|
||||
|
@ -12,6 +12,7 @@ track 1:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.640034
|
||||
width = 1080
|
||||
height = 720
|
||||
selectionFlags = 1
|
||||
|
@ -12,6 +12,7 @@ track 1:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.640034
|
||||
width = 1080
|
||||
height = 720
|
||||
selectionFlags = 1
|
||||
|
@ -12,6 +12,7 @@ track 0:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.64001F
|
||||
maxInputSize = 36722
|
||||
width = 1080
|
||||
height = 720
|
||||
|
@ -12,6 +12,7 @@ track 0:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.64001F
|
||||
maxInputSize = 36722
|
||||
width = 1080
|
||||
height = 720
|
||||
|
@ -12,6 +12,7 @@ track 0:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.64001F
|
||||
maxInputSize = 36722
|
||||
width = 1080
|
||||
height = 720
|
||||
|
@ -12,6 +12,7 @@ track 0:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.64001F
|
||||
maxInputSize = 36722
|
||||
width = 1080
|
||||
height = 720
|
||||
|
@ -12,6 +12,7 @@ track 0:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.64001F
|
||||
maxInputSize = 36722
|
||||
width = 1080
|
||||
height = 720
|
||||
|
@ -12,6 +12,7 @@ track 0:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.640033
|
||||
maxInputSize = 34686
|
||||
width = 1280
|
||||
height = 720
|
||||
|
@ -12,6 +12,7 @@ track 0:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.640033
|
||||
maxInputSize = 34686
|
||||
width = 1280
|
||||
height = 720
|
||||
|
@ -12,6 +12,7 @@ track 0:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.640033
|
||||
maxInputSize = 34686
|
||||
width = 1280
|
||||
height = 720
|
||||
|
@ -12,6 +12,7 @@ track 0:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.640033
|
||||
maxInputSize = 34686
|
||||
width = 1280
|
||||
height = 720
|
||||
|
@ -12,6 +12,7 @@ track 0:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.640033
|
||||
maxInputSize = 34686
|
||||
width = 1280
|
||||
height = 720
|
||||
|
@ -9,6 +9,7 @@ track 0:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.64001F
|
||||
width = 1080
|
||||
height = 720
|
||||
initializationData:
|
||||
|
@ -9,6 +9,7 @@ track 0:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.64001F
|
||||
width = 1080
|
||||
height = 720
|
||||
initializationData:
|
||||
|
@ -12,6 +12,7 @@ track 0:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.64001F
|
||||
width = 1080
|
||||
height = 720
|
||||
initializationData:
|
||||
|
@ -12,6 +12,7 @@ track 0:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.64001F
|
||||
width = 1080
|
||||
height = 720
|
||||
initializationData:
|
||||
|
@ -12,6 +12,7 @@ track 0:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.64001F
|
||||
width = 1080
|
||||
height = 720
|
||||
initializationData:
|
||||
|
@ -12,6 +12,7 @@ track 0:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.64001F
|
||||
width = 1080
|
||||
height = 720
|
||||
initializationData:
|
||||
|
@ -12,6 +12,7 @@ track 0:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.64001F
|
||||
width = 1080
|
||||
height = 720
|
||||
initializationData:
|
||||
|
@ -9,6 +9,7 @@ track 0:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.64001F
|
||||
width = 1080
|
||||
height = 720
|
||||
initializationData:
|
||||
|
@ -9,6 +9,7 @@ track 0:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.64001F
|
||||
width = 1080
|
||||
height = 720
|
||||
initializationData:
|
||||
|
@ -12,6 +12,7 @@ track 0:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.64001F
|
||||
maxInputSize = 36722
|
||||
width = 1080
|
||||
height = 720
|
||||
|
@ -12,6 +12,7 @@ track 0:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.64001F
|
||||
maxInputSize = 36722
|
||||
width = 1080
|
||||
height = 720
|
||||
|
@ -12,6 +12,7 @@ track 0:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.64001F
|
||||
maxInputSize = 36722
|
||||
width = 1080
|
||||
height = 720
|
||||
|
@ -12,6 +12,7 @@ track 0:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.64001F
|
||||
maxInputSize = 36722
|
||||
width = 1080
|
||||
height = 720
|
||||
|
@ -12,6 +12,7 @@ track 0:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.64001F
|
||||
maxInputSize = 36722
|
||||
width = 1080
|
||||
height = 720
|
||||
|
@ -9,6 +9,7 @@ track 0:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.64001F
|
||||
width = 1080
|
||||
height = 720
|
||||
initializationData:
|
||||
|
@ -9,6 +9,7 @@ track 0:
|
||||
format 0:
|
||||
id = 1
|
||||
sampleMimeType = video/avc
|
||||
codecs = avc1.64001F
|
||||
width = 1080
|
||||
height = 720
|
||||
initializationData:
|
||||
|
Loading…
x
Reference in New Issue
Block a user