Skip to content

Commit

Permalink
Partial revert of 3a7d31a
Browse files Browse the repository at this point in the history
The original change did not set the color info in the codec
for standard SDR infos. This was meant to help with consistency
to avoid a situation where the information is partially set and
later the bitstream provides slightly different values (all in
standard SDR though).

We can revert this part because the bitstream may change anyway
and the decoder needs to handle this internally. And more
importantly, it also avoids removing this information when encoding
the format again in Transformer.

PiperOrigin-RevId: 617582066
(cherry picked from commit ed505df)
  • Loading branch information
tonihei authored and SheenaChhabra committed Mar 20, 2024
1 parent b0adf2f commit 5fc9dda
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public static void maybeSetByteBuffer(MediaFormat format, String key, @Nullable
*/
@SuppressWarnings("InlinedApi")
public static void maybeSetColorInfo(MediaFormat format, @Nullable ColorInfo colorInfo) {
if (!ColorInfo.isEquivalentToAssumedSdrDefault(colorInfo)) {
if (colorInfo != null) {
maybeSetInteger(format, MediaFormat.KEY_COLOR_TRANSFER, colorInfo.colorTransfer);
maybeSetInteger(format, MediaFormat.KEY_COLOR_STANDARD, colorInfo.colorSpace);
maybeSetInteger(format, MediaFormat.KEY_COLOR_RANGE, colorInfo.colorRange);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,16 +240,4 @@ public void createMediaFormatFromFormat_withCustomPcmEncoding_setsCustomPcmEncod
.isEqualTo(C.ENCODING_PCM_16BIT_BIG_ENDIAN);
assertThat(mediaFormat.containsKey(MediaFormat.KEY_PCM_ENCODING)).isFalse();
}

@Test
public void createMediaFormatFromFormat_withSdrColorInfo_omitsMediaFormatColorInfoKeys() {
Format format = new Format.Builder().setColorInfo(ColorInfo.SDR_BT709_LIMITED).build();

MediaFormat mediaFormat = MediaFormatUtil.createMediaFormatFromFormat(format);

assertThat(mediaFormat.containsKey(MediaFormat.KEY_COLOR_TRANSFER)).isFalse();
assertThat(mediaFormat.containsKey(MediaFormat.KEY_COLOR_RANGE)).isFalse();
assertThat(mediaFormat.containsKey(MediaFormat.KEY_COLOR_STANDARD)).isFalse();
assertThat(mediaFormat.containsKey(MediaFormat.KEY_HDR_STATIC_INFO)).isFalse();
}
}

0 comments on commit 5fc9dda

Please sign in to comment.