Support changing input colorinfo for images

since we now can support taking in the inputColor upon registering the stream, there is no need to hardcode the image input color anymore. We should now be able to support switching between texture and image input which we couldn't before, but this is untested and not necessary.

PiperOrigin-RevId: 601784149
This commit is contained in:
tofunmi 2024-01-26 09:14:38 -08:00 committed by Copybara-Service
parent b1c1c2a6dd
commit 7424cffce1
2 changed files with 7 additions and 7 deletions

View File

@ -28,7 +28,6 @@ import static androidx.media3.common.util.Util.contains;
import android.content.Context;
import android.util.SparseArray;
import android.view.Surface;
import androidx.media3.common.C;
import androidx.media3.common.ColorInfo;
import androidx.media3.common.FrameInfo;
import androidx.media3.common.GlObjectsProvider;
@ -99,16 +98,13 @@ import org.checkerframework.checker.nullness.qual.Nullable;
context, inputColorInfo, outputColorInfo, enableColorTransfers);
break;
case INPUT_TYPE_BITMAP:
// HDR bitmap input is not supported. Bitmaps are always sRGB/Full range/BT.709.
// HDR bitmap input is not supported.
checkState(!ColorInfo.isTransferHdr(inputColorInfo));
ColorInfo bitmapColorInfo = ColorInfo.SRGB_BT709_FULL;
samplingShaderProgram =
DefaultShaderProgram.createWithInternalSampler(
context, bitmapColorInfo, outputColorInfo, enableColorTransfers, inputType);
context, inputColorInfo, outputColorInfo, enableColorTransfers, inputType);
break;
case INPUT_TYPE_TEXTURE_ID:
// Image and textureId concatenation not supported.
checkState(inputColorInfo.colorTransfer != C.COLOR_TRANSFER_SRGB);
samplingShaderProgram =
DefaultShaderProgram.createWithInternalSampler(
context, inputColorInfo, outputColorInfo, enableColorTransfers, inputType);

View File

@ -68,10 +68,14 @@ import java.util.concurrent.atomic.AtomicLong;
boolean isLast) {
if (trackFormat != null) {
Size decodedSize = getDecodedSize(trackFormat);
ColorInfo colorInfo =
trackFormat.colorInfo == null || !trackFormat.colorInfo.isDataSpaceValid()
? inputColorInfo
: trackFormat.colorInfo;
videoFrameProcessor.registerInputStream(
getInputType(checkNotNull(trackFormat.sampleMimeType)),
createEffectListWithPresentation(editedMediaItem.effects.videoEffects, presentation),
new FrameInfo.Builder(inputColorInfo, decodedSize.getWidth(), decodedSize.getHeight())
new FrameInfo.Builder(colorInfo, decodedSize.getWidth(), decodedSize.getHeight())
.setPixelWidthHeightRatio(trackFormat.pixelWidthHeightRatio)
.setOffsetToAddUs(initialTimestampOffsetUs + mediaItemOffsetUs.get())
.build());