mirror of
https://github.com/samsonjs/media.git
synced 2026-04-08 11:45:51 +00:00
Move luma and chroma bitdepths to ColorInfo class
This commit is contained in:
parent
59ff0dbb85
commit
f8d98861ea
9 changed files with 144 additions and 116 deletions
|
|
@ -43,12 +43,16 @@ public final class ColorInfo implements Bundleable {
|
|||
private @C.ColorRange int colorRange;
|
||||
private @C.ColorTransfer int colorTransfer;
|
||||
@Nullable private byte[] hdrStaticInfo;
|
||||
private int lumaBitdepth;
|
||||
private int chromaBitdepth;
|
||||
|
||||
/** Creates a new instance with default values. */
|
||||
public Builder() {
|
||||
colorSpace = Format.NO_VALUE;
|
||||
colorRange = Format.NO_VALUE;
|
||||
colorTransfer = Format.NO_VALUE;
|
||||
lumaBitdepth = Format.NO_VALUE;
|
||||
chromaBitdepth = Format.NO_VALUE;
|
||||
}
|
||||
|
||||
/** Creates a new instance to build upon the provided {@link ColorInfo}. */
|
||||
|
|
@ -57,6 +61,8 @@ public final class ColorInfo implements Bundleable {
|
|||
this.colorRange = colorInfo.colorRange;
|
||||
this.colorTransfer = colorInfo.colorTransfer;
|
||||
this.hdrStaticInfo = colorInfo.hdrStaticInfo;
|
||||
this.lumaBitdepth = colorInfo.lumaBitdepth;
|
||||
this.chromaBitdepth = colorInfo.chromaBitdepth;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -116,19 +122,43 @@ public final class ColorInfo implements Bundleable {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the luma bit depth.
|
||||
*
|
||||
* @param lumaBitdepth The lumaBitdepth. The default value is {@link Format#NO_VALUE}.
|
||||
* @return The builder.
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
public Builder setLumaBitdepth(int lumaBitdepth) {
|
||||
this.lumaBitdepth = lumaBitdepth;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets chroma bit depth.
|
||||
*
|
||||
* @param chromaBitdepth The chromaBitdepth. The default value is {@link Format#NO_VALUE}.
|
||||
* @return The builder.
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
public Builder setChromaBitdepth(int chromaBitdepth) {
|
||||
this.chromaBitdepth = chromaBitdepth;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Builds a new {@link ColorInfo} instance. */
|
||||
public ColorInfo build() {
|
||||
return new ColorInfo(colorSpace, colorRange, colorTransfer, hdrStaticInfo);
|
||||
return new ColorInfo(colorSpace, colorRange, colorTransfer, hdrStaticInfo, lumaBitdepth, chromaBitdepth);
|
||||
}
|
||||
}
|
||||
|
||||
/** Color info representing SDR BT.709 limited range, which is a common SDR video color format. */
|
||||
public static final ColorInfo SDR_BT709_LIMITED =
|
||||
new ColorInfo(
|
||||
C.COLOR_SPACE_BT709,
|
||||
C.COLOR_RANGE_LIMITED,
|
||||
C.COLOR_TRANSFER_SDR,
|
||||
/* hdrStaticInfo= */ null);
|
||||
new ColorInfo.Builder()
|
||||
.setColorSpace(C.COLOR_SPACE_BT709)
|
||||
.setColorRange(C.COLOR_RANGE_LIMITED)
|
||||
.setColorTransfer(C.COLOR_TRANSFER_SDR)
|
||||
.build();
|
||||
|
||||
/**
|
||||
* Color info representing SDR sRGB in accordance with {@link
|
||||
|
|
@ -213,6 +243,11 @@ public final class ColorInfo implements Bundleable {
|
|||
/** HdrStaticInfo as defined in CTA-861.3, or null if none specified. */
|
||||
@Nullable public final byte[] hdrStaticInfo;
|
||||
|
||||
/** The bit depth of the luma samples of the video. */
|
||||
public final int lumaBitdepth;
|
||||
/** The bit depth of the chroma samples of the video. It may differ from the luma bit depth. */
|
||||
public final int chromaBitdepth;
|
||||
|
||||
// Lazily initialized hashcode.
|
||||
private int hashCode;
|
||||
|
||||
|
|
@ -223,6 +258,8 @@ public final class ColorInfo implements Bundleable {
|
|||
* @param colorRange The color range of the video.
|
||||
* @param colorTransfer The color transfer characteristics of the video.
|
||||
* @param hdrStaticInfo HdrStaticInfo as defined in CTA-861.3, or null if none specified.
|
||||
* @param lumaBitdepth The bit depth of the luma samples of the video.
|
||||
* @param chromaBitdepth The bit depth of the chroma samples of the video.
|
||||
* @deprecated Use {@link Builder}.
|
||||
*/
|
||||
@Deprecated
|
||||
|
|
@ -230,11 +267,15 @@ public final class ColorInfo implements Bundleable {
|
|||
@C.ColorSpace int colorSpace,
|
||||
@C.ColorRange int colorRange,
|
||||
@C.ColorTransfer int colorTransfer,
|
||||
@Nullable byte[] hdrStaticInfo) {
|
||||
@Nullable byte[] hdrStaticInfo,
|
||||
int lumaBitdepth,
|
||||
int chromaBitdepth) {
|
||||
this.colorSpace = colorSpace;
|
||||
this.colorRange = colorRange;
|
||||
this.colorTransfer = colorTransfer;
|
||||
this.hdrStaticInfo = hdrStaticInfo;
|
||||
this.lumaBitdepth = lumaBitdepth;
|
||||
this.chromaBitdepth = chromaBitdepth;
|
||||
}
|
||||
|
||||
/** Returns a {@link Builder} initialized with the values of this instance. */
|
||||
|
|
@ -245,7 +286,8 @@ public final class ColorInfo implements Bundleable {
|
|||
/**
|
||||
* Returns whether this instance is valid.
|
||||
*
|
||||
* <p>This instance is valid if no members are {@link Format#NO_VALUE}.
|
||||
* <p>This instance is valid if no color members are {@link Format#NO_VALUE},
|
||||
* while bit depths may be unset.
|
||||
*/
|
||||
public boolean isValid() {
|
||||
return colorSpace != Format.NO_VALUE
|
||||
|
|
@ -258,7 +300,7 @@ public final class ColorInfo implements Bundleable {
|
|||
*
|
||||
* @see Format#toLogString(Format)
|
||||
*/
|
||||
public String toLogString() {
|
||||
public String toColorString() {
|
||||
if (!isValid()) {
|
||||
return "NA";
|
||||
}
|
||||
|
|
@ -270,6 +312,20 @@ public final class ColorInfo implements Bundleable {
|
|||
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";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (this == obj) {
|
||||
|
|
@ -282,12 +338,18 @@ public final class ColorInfo implements Bundleable {
|
|||
return colorSpace == other.colorSpace
|
||||
&& colorRange == other.colorRange
|
||||
&& colorTransfer == other.colorTransfer
|
||||
&& Arrays.equals(hdrStaticInfo, other.hdrStaticInfo);
|
||||
&& Arrays.equals(hdrStaticInfo, other.hdrStaticInfo)
|
||||
&& lumaBitdepth == other.lumaBitdepth
|
||||
&& chromaBitdepth == other.chromaBitdepth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ColorInfo("
|
||||
+ lumaBitdepth
|
||||
+ ", "
|
||||
+ chromaBitdepth
|
||||
+ ", "
|
||||
+ colorSpaceToString(colorSpace)
|
||||
+ ", "
|
||||
+ colorRangeToString(colorRange)
|
||||
|
|
@ -358,6 +420,8 @@ public final class ColorInfo implements Bundleable {
|
|||
result = 31 * result + colorRange;
|
||||
result = 31 * result + colorTransfer;
|
||||
result = 31 * result + Arrays.hashCode(hdrStaticInfo);
|
||||
result = 31 * result + lumaBitdepth;
|
||||
result = 31 * result + chromaBitdepth;
|
||||
hashCode = result;
|
||||
}
|
||||
return hashCode;
|
||||
|
|
@ -369,6 +433,8 @@ public final class ColorInfo implements Bundleable {
|
|||
private static final String FIELD_COLOR_RANGE = Util.intToStringMaxRadix(1);
|
||||
private static final String FIELD_COLOR_TRANSFER = Util.intToStringMaxRadix(2);
|
||||
private static final String FIELD_HDR_STATIC_INFO = Util.intToStringMaxRadix(3);
|
||||
private static final String FIELD_LUMA_BITDEPTH = Util.intToStringMaxRadix(4);
|
||||
private static final String FIELD_CHROMA_BITDEPTH = Util.intToStringMaxRadix(5);
|
||||
|
||||
@Override
|
||||
public Bundle toBundle() {
|
||||
|
|
@ -377,6 +443,8 @@ public final class ColorInfo implements Bundleable {
|
|||
bundle.putInt(FIELD_COLOR_RANGE, colorRange);
|
||||
bundle.putInt(FIELD_COLOR_TRANSFER, colorTransfer);
|
||||
bundle.putByteArray(FIELD_HDR_STATIC_INFO, hdrStaticInfo);
|
||||
bundle.putInt(FIELD_LUMA_BITDEPTH, lumaBitdepth);
|
||||
bundle.putInt(FIELD_CHROMA_BITDEPTH, chromaBitdepth);
|
||||
return bundle;
|
||||
}
|
||||
|
||||
|
|
@ -386,5 +454,7 @@ public final class ColorInfo implements Bundleable {
|
|||
bundle.getInt(FIELD_COLOR_SPACE, Format.NO_VALUE),
|
||||
bundle.getInt(FIELD_COLOR_RANGE, Format.NO_VALUE),
|
||||
bundle.getInt(FIELD_COLOR_TRANSFER, Format.NO_VALUE),
|
||||
bundle.getByteArray(FIELD_HDR_STATIC_INFO));
|
||||
bundle.getByteArray(FIELD_HDR_STATIC_INFO),
|
||||
bundle.getInt(FIELD_LUMA_BITDEPTH, Format.NO_VALUE),
|
||||
bundle.getInt(FIELD_CHROMA_BITDEPTH, Format.NO_VALUE));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,8 +96,6 @@ import java.util.UUID;
|
|||
* <li>{@link #projectionData}
|
||||
* <li>{@link #stereoMode}
|
||||
* <li>{@link #colorInfo}
|
||||
* <li>{@link #lumaBitdepth}
|
||||
* <li>{@link #chromaBitdepth}
|
||||
* </ul>
|
||||
*
|
||||
* <h2 id="audio-formats">Fields relevant to audio formats</h2>
|
||||
|
|
@ -169,8 +167,6 @@ public final class Format implements Bundleable {
|
|||
@Nullable private byte[] projectionData;
|
||||
private @C.StereoMode int stereoMode;
|
||||
@Nullable private ColorInfo colorInfo;
|
||||
private int lumaBitdepth;
|
||||
private int chromaBitdepth;
|
||||
|
||||
// Audio specific.
|
||||
|
||||
|
|
@ -207,8 +203,6 @@ public final class Format implements Bundleable {
|
|||
frameRate = NO_VALUE;
|
||||
pixelWidthHeightRatio = 1.0f;
|
||||
stereoMode = NO_VALUE;
|
||||
lumaBitdepth = 8;
|
||||
chromaBitdepth = 8;
|
||||
// Audio specific.
|
||||
channelCount = NO_VALUE;
|
||||
sampleRate = NO_VALUE;
|
||||
|
|
@ -255,8 +249,6 @@ public final class Format implements Bundleable {
|
|||
this.projectionData = format.projectionData;
|
||||
this.stereoMode = format.stereoMode;
|
||||
this.colorInfo = format.colorInfo;
|
||||
this.lumaBitdepth = format.lumaBitdepth;
|
||||
this.chromaBitdepth = format.chromaBitdepth;
|
||||
// Audio specific.
|
||||
this.channelCount = format.channelCount;
|
||||
this.sampleRate = format.sampleRate;
|
||||
|
|
@ -568,30 +560,6 @@ public final class Format implements Bundleable {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets {@link Format#lumaBitdepth}. The default value is 8.
|
||||
*
|
||||
* @param lumaBitdepth The {@link Format#lumaBitdepth}.
|
||||
* @return The builder.
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
public Builder setLumaBitdepth(int lumaBitdepth) {
|
||||
this.lumaBitdepth = lumaBitdepth;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets {@link Format#chromaBitdepth}. The default value is 8.
|
||||
*
|
||||
* @param chromaBitdepth The {@link Format#chromaBitdepth}.
|
||||
* @return The builder.
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
public Builder setChromaBitdepth(int chromaBitdepth) {
|
||||
this.chromaBitdepth = chromaBitdepth;
|
||||
return this;
|
||||
}
|
||||
|
||||
// Audio specific.
|
||||
|
||||
/**
|
||||
|
|
@ -904,10 +872,6 @@ public final class Format implements Bundleable {
|
|||
|
||||
/** The color metadata associated with the video, or null if not applicable. */
|
||||
@UnstableApi @Nullable public final ColorInfo colorInfo;
|
||||
/** The bit depth of the luma samples of the video. */
|
||||
public final int lumaBitdepth;
|
||||
/** The bit depth of the chroma samples of the video. It might differ from the luma bit depth. */
|
||||
public final int chromaBitdepth;
|
||||
|
||||
// Audio specific.
|
||||
|
||||
|
|
@ -995,8 +959,6 @@ public final class Format implements Bundleable {
|
|||
projectionData = builder.projectionData;
|
||||
stereoMode = builder.stereoMode;
|
||||
colorInfo = builder.colorInfo;
|
||||
lumaBitdepth = builder.lumaBitdepth;
|
||||
chromaBitdepth = builder.chromaBitdepth;
|
||||
// Audio specific.
|
||||
channelCount = builder.channelCount;
|
||||
sampleRate = builder.sampleRate;
|
||||
|
|
@ -1130,10 +1092,6 @@ public final class Format implements Bundleable {
|
|||
+ ", "
|
||||
+ frameRate
|
||||
+ ", "
|
||||
+ lumaBitdepth
|
||||
+ ", "
|
||||
+ chromaBitdepth
|
||||
+ ", "
|
||||
+ colorInfo
|
||||
+ "]"
|
||||
+ ", ["
|
||||
|
|
@ -1174,8 +1132,6 @@ public final class Format implements Bundleable {
|
|||
// [Omitted] projectionData.
|
||||
result = 31 * result + stereoMode;
|
||||
// [Omitted] colorInfo.
|
||||
result = 31 * result + lumaBitdepth;
|
||||
result = 31 * result + chromaBitdepth;
|
||||
// Audio specific.
|
||||
result = 31 * result + channelCount;
|
||||
result = 31 * result + sampleRate;
|
||||
|
|
@ -1217,8 +1173,6 @@ public final class Format implements Bundleable {
|
|||
&& height == other.height
|
||||
&& rotationDegrees == other.rotationDegrees
|
||||
&& stereoMode == other.stereoMode
|
||||
&& lumaBitdepth == other.lumaBitdepth
|
||||
&& chromaBitdepth == other.chromaBitdepth
|
||||
&& channelCount == other.channelCount
|
||||
&& sampleRate == other.sampleRate
|
||||
&& pcmEncoding == other.pcmEncoding
|
||||
|
|
@ -1305,11 +1259,8 @@ 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.lumaBitdepth != NO_VALUE && format.chromaBitdepth != NO_VALUE) {
|
||||
builder.append(", bitdepth=[").append(format.lumaBitdepth).append(",").append(format.chromaBitdepth).append(']');
|
||||
}
|
||||
if (format.colorInfo != null && format.colorInfo.isValid()) {
|
||||
builder.append(", color=").append(format.colorInfo.toLogString());
|
||||
builder.append(", color=").append(format.colorInfo.toColorString());
|
||||
}
|
||||
if (format.frameRate != NO_VALUE) {
|
||||
builder.append(", fps=").append(format.frameRate);
|
||||
|
|
@ -1422,17 +1373,15 @@ public final class Format implements Bundleable {
|
|||
private static final String FIELD_PROJECTION_DATA = Util.intToStringMaxRadix(20);
|
||||
private static final String FIELD_STEREO_MODE = Util.intToStringMaxRadix(21);
|
||||
private static final String FIELD_COLOR_INFO = Util.intToStringMaxRadix(22);
|
||||
private static final String FIELD_LUMA_BITDEPTH = Util.intToStringMaxRadix(23);
|
||||
private static final String FIELD_CHROMA_BITDEPTH = Util.intToStringMaxRadix(24);
|
||||
private static final String FIELD_CHANNEL_COUNT = Util.intToStringMaxRadix(25);
|
||||
private static final String FIELD_SAMPLE_RATE = Util.intToStringMaxRadix(26);
|
||||
private static final String FIELD_PCM_ENCODING = Util.intToStringMaxRadix(27);
|
||||
private static final String FIELD_ENCODER_DELAY = Util.intToStringMaxRadix(28);
|
||||
private static final String FIELD_ENCODER_PADDING = Util.intToStringMaxRadix(29);
|
||||
private static final String FIELD_ACCESSIBILITY_CHANNEL = Util.intToStringMaxRadix(30);
|
||||
private static final String FIELD_CRYPTO_TYPE = Util.intToStringMaxRadix(31);
|
||||
private static final String FIELD_TILE_COUNT_HORIZONTAL = Util.intToStringMaxRadix(32);
|
||||
private static final String FIELD_TILE_COUNT_VERTICAL = Util.intToStringMaxRadix(33);
|
||||
private static final String FIELD_CHANNEL_COUNT = Util.intToStringMaxRadix(23);
|
||||
private static final String FIELD_SAMPLE_RATE = Util.intToStringMaxRadix(24);
|
||||
private static final String FIELD_PCM_ENCODING = Util.intToStringMaxRadix(25);
|
||||
private static final String FIELD_ENCODER_DELAY = Util.intToStringMaxRadix(26);
|
||||
private static final String FIELD_ENCODER_PADDING = Util.intToStringMaxRadix(27);
|
||||
private static final String FIELD_ACCESSIBILITY_CHANNEL = Util.intToStringMaxRadix(28);
|
||||
private static final String FIELD_CRYPTO_TYPE = Util.intToStringMaxRadix(29);
|
||||
private static final String FIELD_TILE_COUNT_HORIZONTAL = Util.intToStringMaxRadix(30);
|
||||
private static final String FIELD_TILE_COUNT_VERTICAL = Util.intToStringMaxRadix(31);
|
||||
|
||||
@UnstableApi
|
||||
@Override
|
||||
|
|
@ -1482,8 +1431,6 @@ public final class Format implements Bundleable {
|
|||
if (colorInfo != null) {
|
||||
bundle.putBundle(FIELD_COLOR_INFO, colorInfo.toBundle());
|
||||
}
|
||||
bundle.putInt(FIELD_LUMA_BITDEPTH, lumaBitdepth);
|
||||
bundle.putInt(FIELD_CHROMA_BITDEPTH, chromaBitdepth);
|
||||
// Audio specific.
|
||||
bundle.putInt(FIELD_CHANNEL_COUNT, channelCount);
|
||||
bundle.putInt(FIELD_SAMPLE_RATE, sampleRate);
|
||||
|
|
@ -1549,8 +1496,6 @@ public final class Format implements Bundleable {
|
|||
if (colorInfoBundle != null) {
|
||||
builder.setColorInfo(ColorInfo.CREATOR.fromBundle(colorInfoBundle));
|
||||
}
|
||||
builder.setLumaBitdepth(bundle.getInt(FIELD_LUMA_BITDEPTH, DEFAULT.lumaBitdepth));
|
||||
builder.setChromaBitdepth(bundle.getInt(FIELD_CHROMA_BITDEPTH, DEFAULT.chromaBitdepth));
|
||||
// Audio specific.
|
||||
builder
|
||||
.setChannelCount(bundle.getInt(FIELD_CHANNEL_COUNT, DEFAULT.channelCount))
|
||||
|
|
|
|||
|
|
@ -78,7 +78,9 @@ public final class FormatTest {
|
|||
C.COLOR_SPACE_BT709,
|
||||
C.COLOR_RANGE_LIMITED,
|
||||
C.COLOR_TRANSFER_SDR,
|
||||
new byte[] {1, 2, 3, 4, 5, 6, 7});
|
||||
new byte[] {1, 2, 3, 4, 5, 6, 7},
|
||||
/* lumaBitdepth */ 9,
|
||||
/* chromaBitdepth */ 11);
|
||||
|
||||
return new Format.Builder()
|
||||
.setId("id")
|
||||
|
|
@ -104,8 +106,6 @@ public final class FormatTest {
|
|||
.setProjectionData(projectionData)
|
||||
.setStereoMode(C.STEREO_MODE_TOP_BOTTOM)
|
||||
.setColorInfo(colorInfo)
|
||||
.setLumaBitdepth(9)
|
||||
.setChromaBitdepth(11)
|
||||
.setChannelCount(6)
|
||||
.setSampleRate(44100)
|
||||
.setPcmEncoding(C.ENCODING_PCM_24BIT)
|
||||
|
|
|
|||
|
|
@ -139,7 +139,6 @@ public class DebugTextViewHelper {
|
|||
+ format.width
|
||||
+ "x"
|
||||
+ format.height
|
||||
+ getBitdepthInfoString(format.lumaBitdepth)
|
||||
+ getColorInfoString(format.colorInfo)
|
||||
+ getPixelAspectRatioString(format.pixelWidthHeightRatio)
|
||||
+ getDecoderCountersBufferCountString(decoderCounters)
|
||||
|
|
@ -189,12 +188,9 @@ public class DebugTextViewHelper {
|
|||
+ counters.droppedToKeyframeCount;
|
||||
}
|
||||
|
||||
private static String getBitdepthInfoString(int lumaBitdepth) {
|
||||
return lumaBitdepth != Format.NO_VALUE ? " b:" + lumaBitdepth : "";
|
||||
}
|
||||
|
||||
private static String getColorInfoString(@Nullable ColorInfo colorInfo) {
|
||||
return colorInfo != null && colorInfo.isValid() ? " colr:" + colorInfo.toLogString() : "";
|
||||
return colorInfo != null ? (colorInfo.isBppValid() ? " b:" + colorInfo.toBppString() : "")
|
||||
+ (colorInfo.isValid() ? " colr:" + colorInfo.toColorString() : "") : "";
|
||||
}
|
||||
|
||||
private static String getPixelAspectRatioString(float pixelAspectRatio) {
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import android.util.Pair;
|
|||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.media3.common.C;
|
||||
import androidx.media3.common.ColorInfo;
|
||||
import androidx.media3.common.Format;
|
||||
import androidx.media3.common.MimeTypes;
|
||||
import androidx.media3.common.ParserException;
|
||||
|
|
@ -421,10 +422,14 @@ import com.google.common.collect.ImmutableMap;
|
|||
formatBuilder.setPixelWidthHeightRatio(spsData.pixelWidthHeightRatio);
|
||||
formatBuilder.setHeight(spsData.height);
|
||||
formatBuilder.setWidth(spsData.width);
|
||||
int bitdepthLuma = spsData.bitDepthLumaMinus8 + 8;
|
||||
formatBuilder.setLumaBitdepth(bitdepthLuma);
|
||||
int bitdepthChroma = spsData.bitDepthChromaMinus8 + 8;
|
||||
formatBuilder.setChromaBitdepth(bitdepthChroma);
|
||||
formatBuilder.setColorInfo(
|
||||
new ColorInfo(
|
||||
spsData.colorSpace,
|
||||
spsData.colorRange,
|
||||
spsData.colorTransfer,
|
||||
null,
|
||||
spsData.bitDepthLumaMinus8 + 8,
|
||||
spsData.bitDepthChromaMinus8 + 8));
|
||||
|
||||
@Nullable String profileLevel = fmtpAttributes.get(PARAMETER_PROFILE_LEVEL_ID);
|
||||
if (profileLevel != null) {
|
||||
|
|
@ -468,10 +473,14 @@ import com.google.common.collect.ImmutableMap;
|
|||
spsNalDataWithStartCode, NAL_START_CODE.length, spsNalDataWithStartCode.length);
|
||||
formatBuilder.setPixelWidthHeightRatio(spsData.pixelWidthHeightRatio);
|
||||
formatBuilder.setHeight(spsData.height).setWidth(spsData.width);
|
||||
int bitdepthLuma = spsData.bitDepthLumaMinus8 + 8;
|
||||
formatBuilder.setLumaBitdepth(bitdepthLuma);
|
||||
int bitdepthChroma = spsData.bitDepthChromaMinus8 + 8;
|
||||
formatBuilder.setChromaBitdepth(bitdepthChroma);
|
||||
formatBuilder.setColorInfo(
|
||||
new ColorInfo(
|
||||
spsData.colorSpace,
|
||||
spsData.colorRange,
|
||||
spsData.colorTransfer,
|
||||
null,
|
||||
spsData.bitDepthLumaMinus8 + 8,
|
||||
spsData.bitDepthChromaMinus8 + 8));
|
||||
|
||||
formatBuilder.setCodecs(
|
||||
CodecSpecificDataUtil.buildHevcCodecString(
|
||||
|
|
|
|||
|
|
@ -1021,6 +1021,7 @@ public class MatroskaExtractor implements Extractor {
|
|||
break;
|
||||
case ID_COLOUR_BITS_PER_CHANNEL:
|
||||
assertInTrackEntry(id);
|
||||
currentTrack.hasColorInfo = true;
|
||||
currentTrack.bitsPerChannel = (int)value;
|
||||
break;
|
||||
case ID_COLOUR_RANGE:
|
||||
|
|
@ -2307,7 +2308,7 @@ public class MatroskaExtractor implements Extractor {
|
|||
@Nullable ColorInfo colorInfo = null;
|
||||
if (hasColorInfo) {
|
||||
@Nullable byte[] hdrStaticInfo = getHdrStaticInfo();
|
||||
colorInfo = new ColorInfo(colorSpace, colorRange, colorTransfer, hdrStaticInfo);
|
||||
colorInfo = new ColorInfo(colorSpace, colorRange, colorTransfer, hdrStaticInfo, bitsPerChannel, bitsPerChannel);
|
||||
}
|
||||
int rotationDegrees = Format.NO_VALUE;
|
||||
|
||||
|
|
@ -2332,8 +2333,6 @@ public class MatroskaExtractor implements Extractor {
|
|||
formatBuilder
|
||||
.setWidth(width)
|
||||
.setHeight(height)
|
||||
.setLumaBitdepth(bitsPerChannel)
|
||||
.setChromaBitdepth(bitsPerChannel)
|
||||
.setPixelWidthHeightRatio(pixelWidthHeightRatio)
|
||||
.setRotationDegrees(rotationDegrees)
|
||||
.setProjectionData(projectionData)
|
||||
|
|
|
|||
|
|
@ -1358,27 +1358,22 @@ import java.util.List;
|
|||
.setCodecs(codecs)
|
||||
.setWidth(width)
|
||||
.setHeight(height)
|
||||
.setLumaBitdepth(bitdepthLuma)
|
||||
.setChromaBitdepth(bitdepthChroma)
|
||||
.setPixelWidthHeightRatio(pixelWidthHeightRatio)
|
||||
.setRotationDegrees(rotationDegrees)
|
||||
.setProjectionData(projectionData)
|
||||
.setStereoMode(stereoMode)
|
||||
.setInitializationData(initializationData)
|
||||
.setDrmInitData(drmInitData);
|
||||
if (colorSpace != Format.NO_VALUE
|
||||
|| colorRange != Format.NO_VALUE
|
||||
|| colorTransfer != Format.NO_VALUE
|
||||
|| hdrStaticInfo != null) {
|
||||
// Note that if either mdcv or clli are missing, we leave the corresponding HDR static
|
||||
// metadata bytes with value zero. See [Internal ref: b/194535665].
|
||||
formatBuilder.setColorInfo(
|
||||
new ColorInfo(
|
||||
colorSpace,
|
||||
colorRange,
|
||||
colorTransfer,
|
||||
hdrStaticInfo != null ? hdrStaticInfo.array() : null));
|
||||
}
|
||||
.setDrmInitData(drmInitData)
|
||||
// Note that if either mdcv or clli are missing, we leave the corresponding HDR static
|
||||
// metadata bytes with value zero. See [Internal ref: b/194535665].
|
||||
.setColorInfo(
|
||||
new ColorInfo(
|
||||
colorSpace,
|
||||
colorRange,
|
||||
colorTransfer,
|
||||
hdrStaticInfo != null ? hdrStaticInfo.array() : null,
|
||||
bitdepthLuma,
|
||||
bitdepthChroma));
|
||||
|
||||
if (esdsData != null) {
|
||||
formatBuilder
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import static androidx.media3.extractor.ts.TsPayloadReader.FLAG_RANDOM_ACCESS_IN
|
|||
import android.util.SparseArray;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.media3.common.C;
|
||||
import androidx.media3.common.ColorInfo;
|
||||
import androidx.media3.common.Format;
|
||||
import androidx.media3.common.MimeTypes;
|
||||
import androidx.media3.common.util.Assertions;
|
||||
|
|
@ -219,8 +220,14 @@ public final class H264Reader implements ElementaryStreamReader {
|
|||
.setCodecs(codecs)
|
||||
.setWidth(spsData.width)
|
||||
.setHeight(spsData.height)
|
||||
.setLumaBitdepth(spsData.bitDepthLumaMinus8 + 8)
|
||||
.setChromaBitdepth(spsData.bitDepthChromaMinus8 + 8)
|
||||
.setColorInfo(
|
||||
new ColorInfo(
|
||||
spsData.colorSpace,
|
||||
spsData.colorRange,
|
||||
spsData.colorTransfer,
|
||||
null,
|
||||
spsData.bitDepthLumaMinus8 + 8,
|
||||
spsData.bitDepthChromaMinus8 + 8))
|
||||
.setPixelWidthHeightRatio(spsData.pixelWidthHeightRatio)
|
||||
.setInitializationData(initializationData)
|
||||
.build());
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ package androidx.media3.extractor.ts;
|
|||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.media3.common.C;
|
||||
import androidx.media3.common.ColorInfo;
|
||||
import androidx.media3.common.Format;
|
||||
import androidx.media3.common.MimeTypes;
|
||||
import androidx.media3.common.util.Assertions;
|
||||
|
|
@ -264,8 +265,14 @@ public final class H265Reader implements ElementaryStreamReader {
|
|||
.setCodecs(codecs)
|
||||
.setWidth(spsData.width)
|
||||
.setHeight(spsData.height)
|
||||
.setLumaBitdepth(spsData.bitDepthLumaMinus8 + 8)
|
||||
.setChromaBitdepth(spsData.bitDepthChromaMinus8 + 8)
|
||||
.setColorInfo(
|
||||
new ColorInfo(
|
||||
spsData.colorSpace,
|
||||
spsData.colorRange,
|
||||
spsData.colorTransfer,
|
||||
null,
|
||||
spsData.bitDepthLumaMinus8 + 8,
|
||||
spsData.bitDepthChromaMinus8 + 8))
|
||||
.setPixelWidthHeightRatio(spsData.pixelWidthHeightRatio)
|
||||
.setInitializationData(Collections.singletonList(csdData))
|
||||
.build();
|
||||
|
|
|
|||
Loading…
Reference in a new issue