Commit e0511809 by huangdarwin Committed by Ian Baker

Effects: Allow BT2020 colors with SDR transfers

Previously, I assumed that SDR contents must be BT709, and HDR contents must be
BT2020. Turns out BT2020 is just wide-gamut, and SDR contents / transfers may be
represented in BT2020 color spaces.

Relax the check, so that we don't throw when valid BT2020 SMPTE 170M contents
are input into effects.

PiperOrigin-RevId: 526668347
parent d4c0a051
...@@ -1065,8 +1065,8 @@ public final class C { ...@@ -1065,8 +1065,8 @@ public final class C {
// LINT.IfChange(color_space) // LINT.IfChange(color_space)
/** /**
* Video colorspaces. One of {@link Format#NO_VALUE}, {@link #COLOR_SPACE_BT601}, {@link * Video color spaces, also referred to as color standards. One of {@link Format#NO_VALUE}, {@link
* #COLOR_SPACE_BT709} or {@link #COLOR_SPACE_BT2020}. * #COLOR_SPACE_BT601}, {@link #COLOR_SPACE_BT709} or {@link #COLOR_SPACE_BT2020}.
*/ */
@Documented @Documented
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
......
...@@ -365,9 +365,6 @@ import java.util.List; ...@@ -365,9 +365,6 @@ import java.util.List;
glProgram.setIntUniform("uOutputColorTransfer", outputColorTransfer); glProgram.setIntUniform("uOutputColorTransfer", outputColorTransfer);
} else { } else {
glProgram.setIntUniform("uEnableColorTransfer", enableColorTransfers ? GL_TRUE : GL_FALSE); glProgram.setIntUniform("uEnableColorTransfer", enableColorTransfers ? GL_TRUE : GL_FALSE);
checkArgument(
outputColorInfo.colorSpace != C.COLOR_SPACE_BT2020,
"Converting from SDR to HDR is not supported.");
checkArgument(inputColorInfo.colorSpace == outputColorInfo.colorSpace); checkArgument(inputColorInfo.colorSpace == outputColorInfo.colorSpace);
checkArgument( checkArgument(
outputColorTransfer == C.COLOR_TRANSFER_SDR outputColorTransfer == C.COLOR_TRANSFER_SDR
......
...@@ -101,6 +101,22 @@ public final class AndroidTestUtil { ...@@ -101,6 +101,22 @@ public final class AndroidTestUtil {
.setCodecs("avc1.64000D") .setCodecs("avc1.64000D")
.build(); .build();
public static final String MP4_ASSET_BT2020_SDR = "asset:///media/mp4/bt2020-sdr.mp4";
public static final Format MP4_ASSET_BT2020_SDR_FORMAT =
new Format.Builder()
.setSampleMimeType(VIDEO_H264)
.setWidth(3840)
.setHeight(2160)
.setFrameRate(29.822f)
.setColorInfo(
new ColorInfo.Builder()
.setColorSpace(C.COLOR_SPACE_BT2020)
.setColorRange(C.COLOR_RANGE_LIMITED)
.setColorTransfer(C.COLOR_TRANSFER_SDR)
.build())
.setCodecs("avc1.640033")
.build();
public static final String MP4_ASSET_1080P_5_SECOND_HLG10 = "asset:///media/mp4/hlg-1080p.mp4"; public static final String MP4_ASSET_1080P_5_SECOND_HLG10 = "asset:///media/mp4/hlg-1080p.mp4";
public static final Format MP4_ASSET_1080P_5_SECOND_HLG10_FORMAT = public static final Format MP4_ASSET_1080P_5_SECOND_HLG10_FORMAT =
new Format.Builder() new Format.Builder()
......
...@@ -17,6 +17,8 @@ package com.google.android.exoplayer2.transformer.mh; ...@@ -17,6 +17,8 @@ package com.google.android.exoplayer2.transformer.mh;
import static com.google.android.exoplayer2.transformer.AndroidTestUtil.MP4_ASSET_4K60_PORTRAIT_FORMAT; import static com.google.android.exoplayer2.transformer.AndroidTestUtil.MP4_ASSET_4K60_PORTRAIT_FORMAT;
import static com.google.android.exoplayer2.transformer.AndroidTestUtil.MP4_ASSET_4K60_PORTRAIT_URI_STRING; import static com.google.android.exoplayer2.transformer.AndroidTestUtil.MP4_ASSET_4K60_PORTRAIT_URI_STRING;
import static com.google.android.exoplayer2.transformer.AndroidTestUtil.MP4_ASSET_BT2020_SDR;
import static com.google.android.exoplayer2.transformer.AndroidTestUtil.MP4_ASSET_BT2020_SDR_FORMAT;
import static com.google.android.exoplayer2.transformer.AndroidTestUtil.MP4_ASSET_SEF_URI_STRING; import static com.google.android.exoplayer2.transformer.AndroidTestUtil.MP4_ASSET_SEF_URI_STRING;
import static com.google.android.exoplayer2.transformer.AndroidTestUtil.MP4_ASSET_URI_STRING; import static com.google.android.exoplayer2.transformer.AndroidTestUtil.MP4_ASSET_URI_STRING;
import static com.google.android.exoplayer2.transformer.AndroidTestUtil.MP4_ASSET_WITH_INCREASING_TIMESTAMPS_FORMAT; import static com.google.android.exoplayer2.transformer.AndroidTestUtil.MP4_ASSET_WITH_INCREASING_TIMESTAMPS_FORMAT;
...@@ -253,4 +255,29 @@ public class ExportTest { ...@@ -253,4 +255,29 @@ public class ExportTest {
.build() .build()
.run(testId, editedMediaItem); .run(testId, editedMediaItem);
} }
@Test
public void exportTranscodeBt2020Sdr() throws Exception {
String testId = TAG + "exportBt2020Sdr";
Context context = ApplicationProvider.getApplicationContext();
if (AndroidTestUtil.skipAndLogIfFormatsUnsupported(
context,
testId,
/* inputFormat= */ MP4_ASSET_BT2020_SDR_FORMAT,
/* outputFormat= */ null)) {
return;
}
Transformer transformer = new Transformer.Builder(context).build();
MediaItem mediaItem = MediaItem.fromUri(Uri.parse(MP4_ASSET_BT2020_SDR));
ImmutableList<Effect> videoEffects =
ImmutableList.of(new ScaleAndRotateTransformation.Builder().setRotationDegrees(45).build());
Effects effects = new Effects(/* audioProcessors= */ ImmutableList.of(), videoEffects);
EditedMediaItem editedMediaItem =
new EditedMediaItem.Builder(mediaItem).setEffects(effects).build();
new TransformerAndroidTestRunner.Builder(context, transformer)
.build()
.run(testId, editedMediaItem);
}
} }
The file could not be displayed because it is too large.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment