Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Resume toLogString() in ColorInfo; revert DebugTextViewHelper
  • Loading branch information
dsparano authored and microkatz committed Oct 17, 2023
commit 1fe9c3303e2811aed0273f3359d97bb00faed0e6
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,27 @@ public Builder buildUpon() {
/**
* 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;
Expand All @@ -302,29 +319,17 @@ public boolean isValid() {
*
* @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
Expand All @@ -347,9 +352,9 @@ public boolean equals(@Nullable Object obj) {
@Override
public String toString() {
return "ColorInfo("
+ lumaBitdepth
+ lumaBitdepthToString(lumaBitdepth)
+ ", "
+ chromaBitdepth
+ chromaBitdepthToString(chromaBitdepth)
+ ", "
+ colorSpaceToString(colorSpace)
+ ", "
Expand All @@ -361,6 +366,14 @@ public String toString() {
+ ")";
}

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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,7 @@ public static String toLogString(@Nullable Format format) {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,9 @@ public DefaultVideoFrameProcessor create(
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,7 @@ private static String getDecoderCountersBufferCountString(DecoderCounters counte
}

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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public VideoSampleExporter(
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 {
Expand Down