Log Format.colorInfo

Log Format.colorInfo in EventLogger and the demo app's debug text.

#minor-release

PiperOrigin-RevId: 516172936
This commit is contained in:
christosts 2023-03-13 11:26:54 +00:00 committed by tonihei
parent 0588068f19
commit ed4c3471f2
3 changed files with 29 additions and 0 deletions

View File

@ -1259,6 +1259,8 @@ public final class Format implements Bundleable {
+ height + height
+ ", " + ", "
+ frameRate + frameRate
+ ", "
+ colorInfo
+ "]" + "]"
+ ", [" + ", ["
+ channelCount + channelCount
@ -1423,6 +1425,9 @@ public final class Format implements Bundleable {
if (format.width != NO_VALUE && format.height != NO_VALUE) { if (format.width != NO_VALUE && format.height != NO_VALUE) {
builder.append(", res=").append(format.width).append("x").append(format.height); 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) { if (format.frameRate != NO_VALUE) {
builder.append(", fps=").append(format.frameRate); builder.append(", fps=").append(format.frameRate);
} }

View File

@ -239,6 +239,23 @@ public final class ColorInfo implements Bundleable {
&& colorTransfer != Format.NO_VALUE; && 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 @Override
public boolean equals(@Nullable Object obj) { public boolean equals(@Nullable Object obj) {
if (this == obj) { if (this == obj) {

View File

@ -18,10 +18,12 @@ package com.google.android.exoplayer2.util;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.os.Looper; import android.os.Looper;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.decoder.DecoderCounters; import com.google.android.exoplayer2.decoder.DecoderCounters;
import com.google.android.exoplayer2.video.ColorInfo;
import java.util.Locale; import java.util.Locale;
/** /**
@ -131,6 +133,7 @@ public class DebugTextViewHelper {
+ format.width + format.width
+ "x" + "x"
+ format.height + format.height
+ getColorInfoString(format.colorInfo)
+ getPixelAspectRatioString(format.pixelWidthHeightRatio) + getPixelAspectRatioString(format.pixelWidthHeightRatio)
+ getDecoderCountersBufferCountString(decoderCounters) + getDecoderCountersBufferCountString(decoderCounters)
+ " vfpo: " + " vfpo: "
@ -178,6 +181,10 @@ public class DebugTextViewHelper {
+ counters.droppedToKeyframeCount; + counters.droppedToKeyframeCount;
} }
private static String getColorInfoString(@Nullable ColorInfo colorInfo) {
return colorInfo != null && colorInfo.isValid() ? " colr:" + colorInfo.toLogString() : "";
}
private static String getPixelAspectRatioString(float pixelAspectRatio) { private static String getPixelAspectRatioString(float pixelAspectRatio) {
return pixelAspectRatio == Format.NO_VALUE || pixelAspectRatio == 1f return pixelAspectRatio == Format.NO_VALUE || pixelAspectRatio == 1f
? "" ? ""