Search in sources :

Example 1 with ColorInfo

use of com.google.android.exoplayer2.video.ColorInfo in project ExoPlayer by google.

the class FormatTest method createTestFormat.

private static Format createTestFormat() {
    byte[] initData1 = new byte[] { 1, 2, 3 };
    byte[] initData2 = new byte[] { 4, 5, 6 };
    List<byte[]> initializationData = new ArrayList<>();
    initializationData.add(initData1);
    initializationData.add(initData2);
    DrmInitData.SchemeData drmData1 = new DrmInitData.SchemeData(WIDEVINE_UUID, VIDEO_MP4, buildTestData(128, 1));
    DrmInitData.SchemeData drmData2 = new DrmInitData.SchemeData(C.UUID_NIL, VIDEO_WEBM, buildTestData(128, 1));
    DrmInitData drmInitData = new DrmInitData(drmData1, drmData2);
    byte[] projectionData = new byte[] { 1, 2, 3 };
    Metadata metadata = new Metadata(new FakeMetadataEntry("id1"), new FakeMetadataEntry("id2"));
    ColorInfo colorInfo = new ColorInfo(C.COLOR_SPACE_BT709, C.COLOR_RANGE_LIMITED, C.COLOR_TRANSFER_SDR, new byte[] { 1, 2, 3, 4, 5, 6, 7 });
    return new Format.Builder().setId("id").setLabel("label").setLanguage("language").setSelectionFlags(C.SELECTION_FLAG_DEFAULT).setRoleFlags(C.ROLE_FLAG_MAIN).setAverageBitrate(1024).setPeakBitrate(2048).setCodecs("codec").setMetadata(metadata).setContainerMimeType(VIDEO_MP4).setSampleMimeType(MimeTypes.VIDEO_H264).setMaxInputSize(5000).setInitializationData(initializationData).setDrmInitData(drmInitData).setSubsampleOffsetUs(Format.OFFSET_SAMPLE_RELATIVE).setWidth(1920).setHeight(1080).setFrameRate(24).setRotationDegrees(90).setPixelWidthHeightRatio(4).setProjectionData(projectionData).setStereoMode(C.STEREO_MODE_TOP_BOTTOM).setColorInfo(colorInfo).setChannelCount(6).setSampleRate(44100).setPcmEncoding(C.ENCODING_PCM_24BIT).setEncoderDelay(1001).setEncoderPadding(1002).setAccessibilityChannel(2).setCryptoType(C.CRYPTO_TYPE_CUSTOM_BASE).build();
}
Also used : DrmInitData(com.google.android.exoplayer2.drm.DrmInitData) FakeMetadataEntry(com.google.android.exoplayer2.testutil.FakeMetadataEntry) ArrayList(java.util.ArrayList) Metadata(com.google.android.exoplayer2.metadata.Metadata) ColorInfo(com.google.android.exoplayer2.video.ColorInfo)

Example 2 with ColorInfo

use of com.google.android.exoplayer2.video.ColorInfo in project ExoPlayer by google.

the class MediaFormatUtilTest method createMediaFormatFromFormat_withPopulatedFormat_generatesExpectedEntries.

@Test
public void createMediaFormatFromFormat_withPopulatedFormat_generatesExpectedEntries() {
    Format format = new Format.Builder().setAverageBitrate(1).setChannelCount(2).setColorInfo(new ColorInfo(/* colorSpace= */
    C.COLOR_SPACE_BT601, /* colorRange= */
    C.COLOR_RANGE_FULL, /* colorTransfer= */
    C.COLOR_TRANSFER_HLG, new byte[] { 3 })).setSampleMimeType(MimeTypes.VIDEO_H264).setCodecs("avc.123").setFrameRate(4).setWidth(5).setHeight(6).setInitializationData(ImmutableList.of(new byte[] { 7 }, new byte[] { 8 })).setPcmEncoding(C.ENCODING_PCM_8BIT).setLanguage("en").setMaxInputSize(9).setRotationDegrees(10).setSampleRate(11).setAccessibilityChannel(12).setSelectionFlags(C.SELECTION_FLAG_AUTOSELECT | C.SELECTION_FLAG_DEFAULT | C.SELECTION_FLAG_FORCED).setEncoderDelay(13).setEncoderPadding(14).setPixelWidthHeightRatio(.5f).build();
    MediaFormat mediaFormat = MediaFormatUtil.createMediaFormatFromFormat(format);
    assertThat(mediaFormat.getInteger(MediaFormat.KEY_BIT_RATE)).isEqualTo(format.bitrate);
    assertThat(mediaFormat.getInteger(MediaFormat.KEY_CHANNEL_COUNT)).isEqualTo(format.channelCount);
    ColorInfo colorInfo = Assertions.checkNotNull(format.colorInfo);
    assertThat(mediaFormat.getInteger(MediaFormat.KEY_COLOR_TRANSFER)).isEqualTo(colorInfo.colorTransfer);
    assertThat(mediaFormat.getInteger(MediaFormat.KEY_COLOR_RANGE)).isEqualTo(colorInfo.colorRange);
    assertThat(mediaFormat.getInteger(MediaFormat.KEY_COLOR_STANDARD)).isEqualTo(colorInfo.colorSpace);
    assertThat(mediaFormat.getByteBuffer(MediaFormat.KEY_HDR_STATIC_INFO).array()).isEqualTo(colorInfo.hdrStaticInfo);
    assertThat(mediaFormat.getString(MediaFormat.KEY_MIME)).isEqualTo(format.sampleMimeType);
    assertThat(mediaFormat.getString(MediaFormat.KEY_CODECS_STRING)).isEqualTo(format.codecs);
    assertThat(mediaFormat.getFloat(MediaFormat.KEY_FRAME_RATE)).isEqualTo(format.frameRate);
    assertThat(mediaFormat.getInteger(MediaFormat.KEY_WIDTH)).isEqualTo(format.width);
    assertThat(mediaFormat.getInteger(MediaFormat.KEY_HEIGHT)).isEqualTo(format.height);
    assertThat(mediaFormat.getByteBuffer("csd-0").array()).isEqualTo(format.initializationData.get(0));
    assertThat(mediaFormat.getByteBuffer("csd-1").array()).isEqualTo(format.initializationData.get(1));
    assertThat(mediaFormat.getInteger(MediaFormat.KEY_PCM_ENCODING)).isEqualTo(format.pcmEncoding);
    assertThat(mediaFormat.getInteger(MediaFormatUtil.KEY_PCM_ENCODING_EXTENDED)).isEqualTo(format.pcmEncoding);
    assertThat(mediaFormat.getString(MediaFormat.KEY_LANGUAGE)).isEqualTo(format.language);
    assertThat(mediaFormat.getInteger(MediaFormat.KEY_MAX_INPUT_SIZE)).isEqualTo(format.maxInputSize);
    assertThat(mediaFormat.getInteger(MediaFormat.KEY_ROTATION)).isEqualTo(format.rotationDegrees);
    assertThat(mediaFormat.getInteger(MediaFormat.KEY_SAMPLE_RATE)).isEqualTo(format.sampleRate);
    assertThat(mediaFormat.getInteger(MediaFormat.KEY_CAPTION_SERVICE_NUMBER)).isEqualTo(format.accessibilityChannel);
    assertThat(mediaFormat.getInteger(MediaFormat.KEY_IS_AUTOSELECT)).isNotEqualTo(0);
    assertThat(mediaFormat.getInteger(MediaFormat.KEY_IS_DEFAULT)).isNotEqualTo(0);
    assertThat(mediaFormat.getInteger(MediaFormat.KEY_IS_FORCED_SUBTITLE)).isNotEqualTo(0);
    assertThat(mediaFormat.getInteger(MediaFormat.KEY_ENCODER_DELAY)).isEqualTo(format.encoderDelay);
    assertThat(mediaFormat.getInteger(MediaFormat.KEY_ENCODER_PADDING)).isEqualTo(format.encoderPadding);
    float calculatedPixelAspectRatio = (float) mediaFormat.getInteger(MediaFormat.KEY_PIXEL_ASPECT_RATIO_WIDTH) / mediaFormat.getInteger(MediaFormat.KEY_PIXEL_ASPECT_RATIO_HEIGHT);
    assertThat(calculatedPixelAspectRatio).isWithin(.0001f).of(format.pixelWidthHeightRatio);
    assertThat(mediaFormat.getFloat(MediaFormatUtil.KEY_PIXEL_WIDTH_HEIGHT_RATIO_FLOAT)).isEqualTo(format.pixelWidthHeightRatio);
}
Also used : MediaFormat(android.media.MediaFormat) Format(com.google.android.exoplayer2.Format) MediaFormat(android.media.MediaFormat) ColorInfo(com.google.android.exoplayer2.video.ColorInfo) Test(org.junit.Test)

Example 3 with ColorInfo

use of com.google.android.exoplayer2.video.ColorInfo in project ExoPlayer by google.

the class DumpableFormat method dump.

@Override
public void dump(Dumper dumper) {
    dumper.startBlock("format " + index);
    addIfNonDefault(dumper, "averageBitrate", format -> format.averageBitrate);
    addIfNonDefault(dumper, "peakBitrate", format -> format.peakBitrate);
    addIfNonDefault(dumper, "id", format -> format.id);
    addIfNonDefault(dumper, "containerMimeType", format -> format.containerMimeType);
    addIfNonDefault(dumper, "sampleMimeType", format -> format.sampleMimeType);
    addIfNonDefault(dumper, "codecs", format -> format.codecs);
    addIfNonDefault(dumper, "maxInputSize", format -> format.maxInputSize);
    addIfNonDefault(dumper, "width", format -> format.width);
    addIfNonDefault(dumper, "height", format -> format.height);
    addIfNonDefault(dumper, "frameRate", format -> format.frameRate);
    addIfNonDefault(dumper, "rotationDegrees", format -> format.rotationDegrees);
    addIfNonDefault(dumper, "pixelWidthHeightRatio", format -> format.pixelWidthHeightRatio);
    @Nullable ColorInfo colorInfo = format.colorInfo;
    if (colorInfo != null) {
        dumper.startBlock("colorInfo");
        dumper.add("colorSpace", colorInfo.colorSpace);
        dumper.add("colorRange", colorInfo.colorRange);
        dumper.add("colorTransfer", colorInfo.colorTransfer);
        dumper.add("hdrStaticInfo", colorInfo.hdrStaticInfo);
        dumper.endBlock();
    }
    addIfNonDefault(dumper, "channelCount", format -> format.channelCount);
    addIfNonDefault(dumper, "sampleRate", format -> format.sampleRate);
    addIfNonDefault(dumper, "pcmEncoding", format -> format.pcmEncoding);
    addIfNonDefault(dumper, "encoderDelay", format -> format.encoderDelay);
    addIfNonDefault(dumper, "encoderPadding", format -> format.encoderPadding);
    addIfNonDefault(dumper, "subsampleOffsetUs", format -> format.subsampleOffsetUs);
    addIfNonDefault(dumper, "selectionFlags", format -> format.selectionFlags);
    addIfNonDefault(dumper, "language", format -> format.language);
    addIfNonDefault(dumper, "label", format -> format.label);
    if (format.drmInitData != null) {
        dumper.add("drmInitData", format.drmInitData.hashCode());
    }
    addIfNonDefault(dumper, "metadata", format -> format.metadata);
    if (!format.initializationData.isEmpty()) {
        dumper.startBlock("initializationData");
        for (int i = 0; i < format.initializationData.size(); i++) {
            dumper.add("data", format.initializationData.get(i));
        }
        dumper.endBlock();
    }
    dumper.endBlock();
}
Also used : Nullable(androidx.annotation.Nullable) ColorInfo(com.google.android.exoplayer2.video.ColorInfo)

Example 4 with ColorInfo

use of com.google.android.exoplayer2.video.ColorInfo in project ExoPlayer by google.

the class MediaCodecUtilTest method getCodecProfileAndLevel_handlesAv1ProfileMain10HDRWithHdrInfoSet.

@Test
public void getCodecProfileAndLevel_handlesAv1ProfileMain10HDRWithHdrInfoSet() {
    ColorInfo colorInfo = new ColorInfo(/* colorSpace= */
    C.COLOR_SPACE_BT709, /* colorRange= */
    C.COLOR_RANGE_LIMITED, /* colorTransfer= */
    C.COLOR_TRANSFER_SDR, /* hdrStaticInfo= */
    new byte[] { 1, 2, 3, 4, 5, 6, 7 });
    Format format = new Format.Builder().setSampleMimeType(MimeTypes.VIDEO_AV1).setCodecs("av01.0.21M.10").setColorInfo(colorInfo).build();
    assertCodecProfileAndLevelForFormat(format, MediaCodecInfo.CodecProfileLevel.AV1ProfileMain10HDR10, MediaCodecInfo.CodecProfileLevel.AV1Level71);
}
Also used : Format(com.google.android.exoplayer2.Format) ColorInfo(com.google.android.exoplayer2.video.ColorInfo) Test(org.junit.Test)

Example 5 with ColorInfo

use of com.google.android.exoplayer2.video.ColorInfo in project ExoPlayer by google.

the class MediaCodecUtilTest method getCodecProfileAndLevel_handlesAv1ProfileMain10HDRWithoutHdrInfoSet.

@Test
public void getCodecProfileAndLevel_handlesAv1ProfileMain10HDRWithoutHdrInfoSet() {
    ColorInfo colorInfo = new ColorInfo(/* colorSpace= */
    C.COLOR_SPACE_BT709, /* colorRange= */
    C.COLOR_RANGE_LIMITED, /* colorTransfer= */
    C.COLOR_TRANSFER_HLG, /* hdrStaticInfo= */
    null);
    Format format = new Format.Builder().setSampleMimeType(MimeTypes.VIDEO_AV1).setCodecs("av01.0.21M.10").setColorInfo(colorInfo).build();
    assertCodecProfileAndLevelForFormat(format, MediaCodecInfo.CodecProfileLevel.AV1ProfileMain10HDR10, MediaCodecInfo.CodecProfileLevel.AV1Level71);
}
Also used : Format(com.google.android.exoplayer2.Format) ColorInfo(com.google.android.exoplayer2.video.ColorInfo) Test(org.junit.Test)

Aggregations

ColorInfo (com.google.android.exoplayer2.video.ColorInfo)7 Format (com.google.android.exoplayer2.Format)4 Nullable (androidx.annotation.Nullable)3 Test (org.junit.Test)3 ByteBuffer (java.nio.ByteBuffer)2 SuppressLint (android.annotation.SuppressLint)1 MediaFormat (android.media.MediaFormat)1 DrmInitData (com.google.android.exoplayer2.drm.DrmInitData)1 SeekPoint (com.google.android.exoplayer2.extractor.SeekPoint)1 Metadata (com.google.android.exoplayer2.metadata.Metadata)1 FakeMetadataEntry (com.google.android.exoplayer2.testutil.FakeMetadataEntry)1 AvcConfig (com.google.android.exoplayer2.video.AvcConfig)1 DolbyVisionConfig (com.google.android.exoplayer2.video.DolbyVisionConfig)1 HevcConfig (com.google.android.exoplayer2.video.HevcConfig)1 ArrayList (java.util.ArrayList)1