From ed4c3471f22f66e51eb8e732aaf8ffcec2eee57d Mon Sep 17 00:00:00 2001 From: christosts Date: Mon, 13 Mar 2023 11:26:54 +0000 Subject: [PATCH] Log Format.colorInfo Log Format.colorInfo in EventLogger and the demo app's debug text. #minor-release PiperOrigin-RevId: 516172936 --- .../com/google/android/exoplayer2/Format.java | 5 +++++ .../android/exoplayer2/video/ColorInfo.java | 17 +++++++++++++++++ .../exoplayer2/util/DebugTextViewHelper.java | 7 +++++++ 3 files changed, 29 insertions(+) diff --git a/library/common/src/main/java/com/google/android/exoplayer2/Format.java b/library/common/src/main/java/com/google/android/exoplayer2/Format.java index 4e15771f9a..45e726b4fd 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/Format.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/Format.java @@ -1259,6 +1259,8 @@ public final class Format implements Bundleable { + height + ", " + frameRate + + ", " + + colorInfo + "]" + ", [" + channelCount @@ -1423,6 +1425,9 @@ public final class Format implements Bundleable { if (format.width != NO_VALUE && format.height != NO_VALUE) { builder.append(", res=").append(format.width).append("x").append(format.height); } + if (format.colorInfo != null && format.colorInfo.isValid()) { + builder.append(", color=").append(format.colorInfo.toLogString()); + } if (format.frameRate != NO_VALUE) { builder.append(", fps=").append(format.frameRate); } diff --git a/library/common/src/main/java/com/google/android/exoplayer2/video/ColorInfo.java b/library/common/src/main/java/com/google/android/exoplayer2/video/ColorInfo.java index 9e15f5e814..6c5bdd91c3 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/video/ColorInfo.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/video/ColorInfo.java @@ -239,6 +239,23 @@ public final class ColorInfo implements Bundleable { && colorTransfer != Format.NO_VALUE; } + /** + * Returns a prettier {@link String} than {@link #toString()}, intended for logging. + * + * @see Format#toLogString(Format) + */ + public String toLogString() { + if (!isValid()) { + return "NA"; + } + + return Util.formatInvariant( + "%s/%s/%s", + colorSpaceToString(colorSpace), + colorRangeToString(colorRange), + colorTransferToString(colorTransfer)); + } + @Override public boolean equals(@Nullable Object obj) { if (this == obj) { diff --git a/library/core/src/main/java/com/google/android/exoplayer2/util/DebugTextViewHelper.java b/library/core/src/main/java/com/google/android/exoplayer2/util/DebugTextViewHelper.java index 3461ee9e48..617bc798ce 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/util/DebugTextViewHelper.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/util/DebugTextViewHelper.java @@ -18,10 +18,12 @@ package com.google.android.exoplayer2.util; import android.annotation.SuppressLint; import android.os.Looper; import android.widget.TextView; +import androidx.annotation.Nullable; import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.decoder.DecoderCounters; +import com.google.android.exoplayer2.video.ColorInfo; import java.util.Locale; /** @@ -131,6 +133,7 @@ public class DebugTextViewHelper { + format.width + "x" + format.height + + getColorInfoString(format.colorInfo) + getPixelAspectRatioString(format.pixelWidthHeightRatio) + getDecoderCountersBufferCountString(decoderCounters) + " vfpo: " @@ -178,6 +181,10 @@ public class DebugTextViewHelper { + counters.droppedToKeyframeCount; } + private static String getColorInfoString(@Nullable ColorInfo colorInfo) { + return colorInfo != null && colorInfo.isValid() ? " colr:" + colorInfo.toLogString() : ""; + } + private static String getPixelAspectRatioString(float pixelAspectRatio) { return pixelAspectRatio == Format.NO_VALUE || pixelAspectRatio == 1f ? ""