Skip to content

Commit b395f8f

Browse files
clainclycopybara-github
authored andcommitted
Force output SDR_BT709_LIMITED when the input is SRGB
PiperOrigin-RevId: 790742779
1 parent 8c719f8 commit b395f8f

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-0
lines changed

libraries/exoplayer/src/main/java/androidx/media3/exoplayer/video/PlaybackVideoGraphWrapper.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,8 @@ private boolean registerInput(Format sourceFormat, int inputIndex)
580580
"Color transfer %d is not supported. Falling back to OpenGl tone mapping.",
581581
inputColorInfo.colorTransfer));
582582
outputColorInfo = ColorInfo.SDR_BT709_LIMITED;
583+
} else if (inputColorInfo.colorTransfer == C.COLOR_TRANSFER_SRGB) {
584+
outputColorInfo = ColorInfo.SDR_BT709_LIMITED;
583585
} else {
584586
outputColorInfo = inputColorInfo;
585587
}
Binary file not shown.

libraries/transformer/src/androidTest/java/androidx/media3/transformer/AndroidTestUtil.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,32 @@ public String toString() {
402402
834_166L, 867_533L, 900_900L, 934_266L, 967_633L))
403403
.build();
404404

405+
public static final AssetInfo MP4_ASSET_SRGB =
406+
new AssetInfo.Builder("asset:///media/mp4/sample_srgb.mp4")
407+
.setVideoFormat(
408+
new Format.Builder()
409+
.setSampleMimeType(VIDEO_H264)
410+
.setWidth(1080)
411+
.setHeight(720)
412+
.setFrameRate(29.97f)
413+
.setCodecs("avc1.64001F")
414+
.setColorInfo(
415+
new ColorInfo.Builder()
416+
.setColorRange(C.COLOR_RANGE_LIMITED)
417+
.setColorSpace(C.COLOR_SPACE_BT709)
418+
.setColorTransfer(C.COLOR_TRANSFER_SRGB)
419+
.build())
420+
.build())
421+
.setVideoDurationUs(1_024_000L)
422+
.setVideoFrameCount(30)
423+
.setVideoTimestampsUs(
424+
ImmutableList.of(
425+
0L, 33_366L, 66_733L, 100_100L, 133_466L, 166_833L, 200_200L, 233_566L, 266_933L,
426+
300_300L, 333_666L, 367_033L, 400_400L, 433_766L, 467_133L, 500_500L, 533_866L,
427+
567_233L, 600_600L, 633_966L, 667_333L, 700_700L, 734_066L, 767_433L, 800_800L,
428+
834_166L, 867_533L, 900_900L, 934_266L, 967_633L))
429+
.build();
430+
405431
public static final AssetInfo BT601_MOV_ASSET =
406432
new AssetInfo.Builder("asset:///media/mp4/bt601.mov")
407433
.setVideoFormat(

libraries/transformer/src/androidTest/java/androidx/media3/transformer/CompositionPlayerParameterizedPlaybackTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import static androidx.media3.common.util.Util.isRunningOnEmulator;
1919
import static androidx.media3.common.util.Util.usToMs;
2020
import static androidx.media3.transformer.AndroidTestUtil.MP4_ASSET;
21+
import static androidx.media3.transformer.AndroidTestUtil.MP4_ASSET_SRGB;
2122
import static androidx.media3.transformer.AndroidTestUtil.MP4_VIDEO_ONLY_ASSET;
2223
import static androidx.media3.transformer.AndroidTestUtil.PNG_ASSET;
2324
import static androidx.media3.transformer.AndroidTestUtil.WAV_ASSET;
@@ -105,6 +106,13 @@ public long getNextSpeedChangeTimeUs(long timeUs) {
105106
.build(),
106107
MP4_ASSET.videoTimestampsUs,
107108
/* inputName= */ "Video");
109+
private static final Input VIDEO_INPUT_SRGB =
110+
new Input(
111+
new EditedMediaItem.Builder(MediaItem.fromUri(MP4_ASSET_SRGB.uri))
112+
.setDurationUs(MP4_ASSET_SRGB.videoDurationUs)
113+
.build(),
114+
MP4_ASSET_SRGB.videoTimestampsUs,
115+
/* inputName= */ "Video_srgb");
108116
private static final Input VIDEO_INPUT_WITHOUT_AUDIO =
109117
new Input(
110118
new EditedMediaItem.Builder(MediaItem.fromUri(MP4_ASSET.uri))
@@ -202,6 +210,7 @@ public static ImmutableList<TestConfig> params() {
202210
ImmutableList.Builder<TestConfig> configs = new ImmutableList.Builder<>();
203211
// Single asset.
204212
configs.add(new TestConfig(new InputSequence(VIDEO_INPUT)));
213+
configs.add(new TestConfig(new InputSequence(VIDEO_INPUT_SRGB)));
205214
configs.add(new TestConfig(new InputSequence(IMAGE_INPUT)));
206215
configs.add(new TestConfig(new InputSequence(AUDIO_INPUT)));
207216

@@ -241,6 +250,10 @@ public static ImmutableList<TestConfig> params() {
241250
configs.add(
242251
new TestConfig(
243252
new InputSequence(VIDEO_ONLY_CLIPPED_HALF_SPEED, VIDEO_ONLY_CLIPPED_HALF_SPEED)));
253+
configs.add(
254+
new TestConfig(
255+
new InputSequence(
256+
VIDEO_INPUT, VIDEO_INPUT_SRGB, VIDEO_INPUT, IMAGE_INPUT, VIDEO_INPUT_SRGB)));
244257

245258
// Multiple sequence.
246259
configs.add(

0 commit comments

Comments
 (0)