Skip to content

Commit

Permalink
Use ColorInfo.Builder in transformer and common.
Browse files Browse the repository at this point in the history
Because the ColorInfo constructor is deprecated.

PiperOrigin-RevId: 509468663
  • Loading branch information
claincly authored and christosts committed Feb 14, 2023
1 parent 749c10a commit 3aca3ad
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,12 @@ public static ColorInfo getColorInfo(MediaFormat mediaFormat) {
|| colorRange != Format.NO_VALUE
|| colorTransfer != Format.NO_VALUE
|| hdrStaticInfo != null) {
return new ColorInfo(colorSpace, colorRange, colorTransfer, hdrStaticInfo);
return new ColorInfo.Builder()
.setColorSpace(colorSpace)
.setColorRange(colorRange)
.setColorTransfer(colorTransfer)
.setHdrStaticInfo(hdrStaticInfo)
.build();
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,11 @@ private static ImmutableList<GlShaderProgram> getGlShaderProgramsForGlEffects(
ImmutableList.Builder<RgbMatrix> rgbMatrixListBuilder = new ImmutableList.Builder<>();
boolean sampleFromInputTexture = true;
ColorInfo linearColorInfo =
new ColorInfo(
outputColorInfo.colorSpace, outputColorInfo.colorRange, C.COLOR_TRANSFER_LINEAR, null);
outputColorInfo
.buildUpon()
.setColorTransfer(C.COLOR_TRANSFER_LINEAR)
.setHdrStaticInfo(null)
.build();
for (int i = 0; i < effects.size(); i++) {
Effect effect = effects.get(i);
checkArgument(effect instanceof GlEffect, "GlEffectsFrameProcessor only supports GlEffects");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ public final class AndroidTestUtil {
.setHeight(1080)
.setFrameRate(30.000f)
.setColorInfo(
new ColorInfo(
C.COLOR_SPACE_BT2020,
C.COLOR_RANGE_LIMITED,
C.COLOR_TRANSFER_HLG,
/* hdrStaticInfo= */ null))
new ColorInfo.Builder()
.setColorSpace(C.COLOR_SPACE_BT2020)
.setColorRange(C.COLOR_RANGE_LIMITED)
.setColorTransfer(C.COLOR_TRANSFER_HLG)
.build())
.build();
public static final String MP4_ASSET_1080P_4_SECOND_HDR10 = "asset:///media/mp4/hdr10-1080p.mp4";
public static final Format MP4_ASSET_1080P_4_SECOND_HDR10_FORMAT =
Expand All @@ -117,11 +117,11 @@ public final class AndroidTestUtil {
.setHeight(1080)
.setFrameRate(23.517f)
.setColorInfo(
new ColorInfo(
C.COLOR_SPACE_BT2020,
C.COLOR_RANGE_LIMITED,
C.COLOR_TRANSFER_ST2084,
/* hdrStaticInfo= */ null))
new ColorInfo.Builder()
.setColorSpace(C.COLOR_SPACE_BT2020)
.setColorRange(C.COLOR_RANGE_LIMITED)
.setColorTransfer(C.COLOR_TRANSFER_ST2084)
.build())
.build();
public static final String MP4_ASSET_1080P_1_SECOND_HDR10_VIDEO_SDR_CONTAINER =
"asset:///media/mp4/hdr10-video-with-sdr-container.mp4";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,17 @@
public class HdrEditingTest {
public static final String TAG = "HdrEditingTest";
private static final ColorInfo HDR10_DEFAULT_COLOR_INFO =
new ColorInfo(
C.COLOR_SPACE_BT2020,
C.COLOR_RANGE_LIMITED,
C.COLOR_TRANSFER_ST2084,
/* hdrStaticInfo= */ null);
new ColorInfo.Builder()
.setColorSpace(C.COLOR_SPACE_BT2020)
.setColorRange(C.COLOR_RANGE_LIMITED)
.setColorTransfer(C.COLOR_TRANSFER_ST2084)
.build();
private static final ColorInfo HLG10_DEFAULT_COLOR_INFO =
new ColorInfo(
C.COLOR_SPACE_BT2020,
C.COLOR_RANGE_LIMITED,
C.COLOR_TRANSFER_HLG,
/* hdrStaticInfo= */ null);
new ColorInfo.Builder()
.setColorSpace(C.COLOR_SPACE_BT2020)
.setColorRange(C.COLOR_RANGE_LIMITED)
.setColorTransfer(C.COLOR_TRANSFER_HLG)
.build();

@Test
public void transform_noRequestedTranscode_hdr10File_transformsOrThrows() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ public VideoSamplePipeline(
// C.COLOR_TRANSFER_SDR to the encoder.
ColorInfo frameProcessorOutputColor =
isGlToneMapping
? new ColorInfo(
C.COLOR_SPACE_BT709,
C.COLOR_RANGE_LIMITED,
C.COLOR_TRANSFER_GAMMA_2_2,
/* hdrStaticInfo= */ null)
? new ColorInfo.Builder()
.setColorSpace(C.COLOR_SPACE_BT709)
.setColorRange(C.COLOR_RANGE_LIMITED)
.setColorTransfer(C.COLOR_TRANSFER_GAMMA_2_2)
.build()
: encoderInputColor;
try {
frameProcessor =
Expand Down

0 comments on commit 3aca3ad

Please sign in to comment.