Resume toLogString() in ColorInfo; revert DebugTextViewHelper

This commit is contained in:
Daniele Sparano 2023-08-17 16:17:05 +01:00 committed by microkatz
parent c72ec74e11
commit 1fe9c3303e
5 changed files with 39 additions and 29 deletions

View File

@ -288,10 +288,27 @@ public final class ColorInfo implements Bundleable {
/**
* Returns whether this instance is valid.
*
* <p>This instance is valid if no color members are {@link Format#NO_VALUE}, while bit depths may
* be unset.
* <p>This instance is valid if at least one between bitdepths and color info are valid.
*/
public boolean isValid() {
return isBitdepthValid() || isColorValid();
}
/**
* Returns whether this instance has valid bitdepths.
*
* <p>This instance has valid bitdepths if none of them is {@link Format#NO_VALUE}.
*/
public boolean isBitdepthValid() {
return lumaBitdepth != Format.NO_VALUE && chromaBitdepth != Format.NO_VALUE;
}
/**
* Returns whether this instance is color valid.
*
* <p>This instance is valid if no color members are {@link Format#NO_VALUE}.
*/
public boolean isColorValid() {
return colorSpace != Format.NO_VALUE
&& colorRange != Format.NO_VALUE
&& colorTransfer != Format.NO_VALUE;
@ -302,29 +319,17 @@ public final class ColorInfo implements Bundleable {
*
* @see Format#toLogString(Format)
*/
public String toColorString() {
public String toLogString() {
if (!isValid()) {
return "NA";
}
return Util.formatInvariant(
"%s/%s/%s",
String bitdepthsString = isBitdepthValid() ? lumaBitdepth + "/" + chromaBitdepth : "NA";
String colorString = isColorValid() ? Util.formatInvariant("%s/%s/%s",
colorSpaceToString(colorSpace),
colorRangeToString(colorRange),
colorTransferToString(colorTransfer));
}
/**
* Returns whether this instance has valid bitdepths.
*
* <p>This instance has valid bitdepths if none of them is {@link Format#NO_VALUE}.
*/
public boolean isBppValid() {
return lumaBitdepth != Format.NO_VALUE && chromaBitdepth != Format.NO_VALUE;
}
public String toBppString() {
return isBppValid() ? lumaBitdepth + "," + chromaBitdepth : "NA";
colorTransferToString(colorTransfer)) : "NA";
return bitdepthsString + "/" + colorString;
}
@Override
@ -347,9 +352,9 @@ public final class ColorInfo implements Bundleable {
@Override
public String toString() {
return "ColorInfo("
+ lumaBitdepth
+ lumaBitdepthToString(lumaBitdepth)
+ ", "
+ chromaBitdepth
+ chromaBitdepthToString(chromaBitdepth)
+ ", "
+ colorSpaceToString(colorSpace)
+ ", "
@ -361,6 +366,14 @@ public final class ColorInfo implements Bundleable {
+ ")";
}
private static String lumaBitdepthToString(int val) {
return val != Format.NO_VALUE ? val + "bit Luma" : "NA";
}
private static String chromaBitdepthToString(int val) {
return val != Format.NO_VALUE ? val + "bit Chroma" : "NA";
}
private static String colorSpaceToString(@C.ColorSpace int colorSpace) {
// LINT.IfChange(color_space)
switch (colorSpace) {

View File

@ -1260,7 +1260,7 @@ public final class Format implements Bundleable {
builder.append(", res=").append(format.width).append("x").append(format.height);
}
if (format.colorInfo != null && format.colorInfo.isValid()) {
builder.append(", color=").append(format.colorInfo.toColorString());
builder.append(", color=").append(format.colorInfo.toLogString());
}
if (format.frameRate != NO_VALUE) {
builder.append(", fps=").append(format.frameRate);

View File

@ -253,9 +253,9 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
throws VideoFrameProcessingException {
// TODO(b/261188041) Add tests to verify the Listener is invoked on the given Executor.
checkArgument(inputColorInfo.isValid());
checkArgument(inputColorInfo.isColorValid());
checkArgument(inputColorInfo.colorTransfer != C.COLOR_TRANSFER_LINEAR);
checkArgument(outputColorInfo.isValid());
checkArgument(outputColorInfo.isColorValid());
checkArgument(outputColorInfo.colorTransfer != C.COLOR_TRANSFER_LINEAR);
if (ColorInfo.isTransferHdr(inputColorInfo) || ColorInfo.isTransferHdr(outputColorInfo)) {
checkArgument(enableColorTransfers);

View File

@ -189,10 +189,7 @@ public class DebugTextViewHelper {
}
private static String getColorInfoString(@Nullable ColorInfo colorInfo) {
return colorInfo != null
? (colorInfo.isBppValid() ? " b:" + colorInfo.toBppString() : "")
+ (colorInfo.isValid() ? " colr:" + colorInfo.toColorString() : "")
: "";
return colorInfo != null && colorInfo.isValid() ? " colr:" + colorInfo.toLogString() : "";
}
private static String getPixelAspectRatioString(float pixelAspectRatio) {

View File

@ -97,7 +97,7 @@ import org.checkerframework.dataflow.qual.Pure;
finalFramePresentationTimeUs = C.TIME_UNSET;
ColorInfo decoderInputColor;
if (firstInputFormat.colorInfo == null || !firstInputFormat.colorInfo.isValid()) {
if (firstInputFormat.colorInfo == null || !firstInputFormat.colorInfo.isColorValid()) {
Log.d(TAG, "colorInfo is null or invalid. Defaulting to SDR_BT709_LIMITED.");
decoderInputColor = ColorInfo.SDR_BT709_LIMITED;
} else {