mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Change isInputTextureExternal boolean parameter to inputType intDef
PiperOrigin-RevId: 525690361
This commit is contained in:
parent
3bc0172188
commit
0f8fa232e7
@ -15,12 +15,19 @@
|
|||||||
*/
|
*/
|
||||||
package androidx.media3.common;
|
package androidx.media3.common;
|
||||||
|
|
||||||
|
import static java.lang.annotation.ElementType.TYPE_USE;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.opengl.EGLExt;
|
import android.opengl.EGLExt;
|
||||||
import android.view.Surface;
|
import android.view.Surface;
|
||||||
|
import androidx.annotation.IntDef;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.media3.common.util.UnstableApi;
|
import androidx.media3.common.util.UnstableApi;
|
||||||
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
@ -39,6 +46,24 @@ import java.util.concurrent.Executor;
|
|||||||
@UnstableApi
|
@UnstableApi
|
||||||
public interface VideoFrameProcessor {
|
public interface VideoFrameProcessor {
|
||||||
// TODO(b/243036513): Allow effects to be replaced.
|
// TODO(b/243036513): Allow effects to be replaced.
|
||||||
|
/**
|
||||||
|
* Specifies how the input frames are made available to the {@link VideoFrameProcessor}. One of
|
||||||
|
* {@link #INPUT_TYPE_SURFACE}, {@link #INPUT_TYPE_BITMAP} or {@link #INPUT_TYPE_TEXID}.
|
||||||
|
*/
|
||||||
|
@Documented
|
||||||
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
|
@Target(TYPE_USE)
|
||||||
|
@IntDef({INPUT_TYPE_SURFACE, INPUT_TYPE_BITMAP, INPUT_TYPE_TEXID})
|
||||||
|
public @interface InputType {}
|
||||||
|
/** Input frames come from a {@link #getInputSurface surface}. */
|
||||||
|
public static final int INPUT_TYPE_SURFACE = 1;
|
||||||
|
/** Input frames come from a {@link Bitmap}. */
|
||||||
|
public static final int INPUT_TYPE_BITMAP = 2;
|
||||||
|
/**
|
||||||
|
* Input frames come from a {@linkplain android.opengl.GLES10#GL_TEXTURE_2D traditional GLES
|
||||||
|
* texture}.
|
||||||
|
*/
|
||||||
|
public static final int INPUT_TYPE_TEXID = 3;
|
||||||
|
|
||||||
/** A factory for {@link VideoFrameProcessor} instances. */
|
/** A factory for {@link VideoFrameProcessor} instances. */
|
||||||
interface Factory {
|
interface Factory {
|
||||||
@ -53,10 +78,7 @@ public interface VideoFrameProcessor {
|
|||||||
* @param debugViewProvider A {@link DebugViewProvider}.
|
* @param debugViewProvider A {@link DebugViewProvider}.
|
||||||
* @param inputColorInfo The {@link ColorInfo} for input frames.
|
* @param inputColorInfo The {@link ColorInfo} for input frames.
|
||||||
* @param outputColorInfo The {@link ColorInfo} for output frames.
|
* @param outputColorInfo The {@link ColorInfo} for output frames.
|
||||||
* @param isInputTextureExternal Whether the input frames are produced externally (e.g. from a
|
* @param inputType The {@link InputType}.
|
||||||
* video) or not (e.g. from a {@link Bitmap}). See <a
|
|
||||||
* href="https://source.android.com/docs/core/graphics/arch-st#ext_texture">the
|
|
||||||
* SurfaceTexture docs</a> for more information on external textures.
|
|
||||||
* @param releaseFramesAutomatically If {@code true}, the instance will render output frames to
|
* @param releaseFramesAutomatically If {@code true}, the instance will render output frames to
|
||||||
* the {@linkplain #setOutputSurfaceInfo(SurfaceInfo) output surface} automatically as
|
* the {@linkplain #setOutputSurfaceInfo(SurfaceInfo) output surface} automatically as
|
||||||
* {@link VideoFrameProcessor} is done processing them. If {@code false}, the {@link
|
* {@link VideoFrameProcessor} is done processing them. If {@code false}, the {@link
|
||||||
@ -74,7 +96,7 @@ public interface VideoFrameProcessor {
|
|||||||
DebugViewProvider debugViewProvider,
|
DebugViewProvider debugViewProvider,
|
||||||
ColorInfo inputColorInfo,
|
ColorInfo inputColorInfo,
|
||||||
ColorInfo outputColorInfo,
|
ColorInfo outputColorInfo,
|
||||||
boolean isInputTextureExternal,
|
@InputType int inputType,
|
||||||
boolean releaseFramesAutomatically,
|
boolean releaseFramesAutomatically,
|
||||||
Executor executor,
|
Executor executor,
|
||||||
Listener listener)
|
Listener listener)
|
||||||
@ -129,10 +151,10 @@ public interface VideoFrameProcessor {
|
|||||||
long DROP_OUTPUT_FRAME = -2;
|
long DROP_OUTPUT_FRAME = -2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides an input {@link Bitmap} to the {@code VideoFrameProcessor}.
|
* Provides an input {@link Bitmap} to the {@link VideoFrameProcessor}.
|
||||||
*
|
*
|
||||||
* <p>This method should only be used for when the {@code VideoFrameProcessor}'s {@code
|
* <p>This method must only be called when the {@link VideoFrameProcessor} is {@linkplain
|
||||||
* isInputTextureExternal} parameter is set to {@code false}.
|
* Factory#create created} with {@link #INPUT_TYPE_BITMAP}.
|
||||||
*
|
*
|
||||||
* <p>Can be called on any thread.
|
* <p>Can be called on any thread.
|
||||||
*
|
*
|
||||||
@ -146,11 +168,11 @@ public interface VideoFrameProcessor {
|
|||||||
void queueInputBitmap(Bitmap inputBitmap, long durationUs, float frameRate);
|
void queueInputBitmap(Bitmap inputBitmap, long durationUs, float frameRate);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the input {@link Surface}, where {@code VideoFrameProcessor} consumes input frames
|
* Returns the input {@link Surface}, where {@link VideoFrameProcessor} consumes input frames
|
||||||
* from.
|
* from.
|
||||||
*
|
*
|
||||||
* <p>This method should only be used for when the {@code VideoFrameProcessor}'s {@code
|
* <p>This method must only be called when the {@link VideoFrameProcessor} is {@linkplain
|
||||||
* isInputTextureExternal} parameter is set to {@code true}.
|
* Factory#create created} with {@link #INPUT_TYPE_SURFACE}.
|
||||||
*
|
*
|
||||||
* <p>Can be called on any thread.
|
* <p>Can be called on any thread.
|
||||||
*/
|
*/
|
||||||
@ -175,8 +197,8 @@ public interface VideoFrameProcessor {
|
|||||||
*
|
*
|
||||||
* <p>Must be called before rendering a frame to the input surface.
|
* <p>Must be called before rendering a frame to the input surface.
|
||||||
*
|
*
|
||||||
* <p>This method should only be used for when the {@code VideoFrameProcessor}'s {@code
|
* <p>This method must only be called when the {@link VideoFrameProcessor} is {@linkplain
|
||||||
* isInputTextureExternal} parameter is set to {@code true}.
|
* Factory#create created} with {@link #INPUT_TYPE_SURFACE}.
|
||||||
*
|
*
|
||||||
* <p>Can be called on any thread.
|
* <p>Can be called on any thread.
|
||||||
*
|
*
|
||||||
@ -189,8 +211,8 @@ public interface VideoFrameProcessor {
|
|||||||
* Returns the number of input frames that have been {@linkplain #registerInputFrame() registered}
|
* Returns the number of input frames that have been {@linkplain #registerInputFrame() registered}
|
||||||
* but not processed off the {@linkplain #getInputSurface() input surface} yet.
|
* but not processed off the {@linkplain #getInputSurface() input surface} yet.
|
||||||
*
|
*
|
||||||
* <p>This method should only be used for when the {@code VideoFrameProcessor}'s {@code
|
* <p>This method must only be called when the {@link VideoFrameProcessor} is {@linkplain
|
||||||
* isInputTextureExternal} parameter is set to {@code true}.
|
* Factory#create created} with {@link #INPUT_TYPE_SURFACE}.
|
||||||
*
|
*
|
||||||
* <p>Can be called on any thread.
|
* <p>Can be called on any thread.
|
||||||
*/
|
*/
|
||||||
@ -249,8 +271,8 @@ public interface VideoFrameProcessor {
|
|||||||
* <p>All the frames that are {@linkplain #registerInputFrame() registered} prior to calling this
|
* <p>All the frames that are {@linkplain #registerInputFrame() registered} prior to calling this
|
||||||
* method are no longer considered to be registered when this method returns.
|
* method are no longer considered to be registered when this method returns.
|
||||||
*
|
*
|
||||||
* <p>This method should only be used for when the {@code VideoFrameProcessor}'s {@code
|
* <p>This method must only be called when the {@link VideoFrameProcessor} is {@linkplain
|
||||||
* isInputTextureExternal} parameter is set to {@code true}.
|
* Factory#create created} with {@link #INPUT_TYPE_SURFACE}.
|
||||||
*
|
*
|
||||||
* <p>{@link Listener} methods invoked prior to calling this method should be ignored.
|
* <p>{@link Listener} methods invoked prior to calling this method should be ignored.
|
||||||
*/
|
*/
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package androidx.media3.effect;
|
package androidx.media3.effect;
|
||||||
|
|
||||||
|
import static androidx.media3.common.VideoFrameProcessor.INPUT_TYPE_BITMAP;
|
||||||
import static androidx.media3.common.util.Assertions.checkNotNull;
|
import static androidx.media3.common.util.Assertions.checkNotNull;
|
||||||
import static androidx.media3.test.utils.BitmapPixelTestUtil.readBitmap;
|
import static androidx.media3.test.utils.BitmapPixelTestUtil.readBitmap;
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
@ -124,7 +125,7 @@ public class DefaultVideoFrameProcessorImageFrameOutputTest {
|
|||||||
return new VideoFrameProcessorTestRunner.Builder()
|
return new VideoFrameProcessorTestRunner.Builder()
|
||||||
.setTestId(testId)
|
.setTestId(testId)
|
||||||
.setVideoFrameProcessorFactory(new DefaultVideoFrameProcessor.Factory.Builder().build())
|
.setVideoFrameProcessorFactory(new DefaultVideoFrameProcessor.Factory.Builder().build())
|
||||||
.setIsInputTextureExternal(false)
|
.setInputType(INPUT_TYPE_BITMAP)
|
||||||
.setOnOutputFrameAvailableListener(
|
.setOnOutputFrameAvailableListener(
|
||||||
unused -> checkNotNull(framesProduced).incrementAndGet());
|
unused -> checkNotNull(framesProduced).incrementAndGet());
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package androidx.media3.effect;
|
package androidx.media3.effect;
|
||||||
|
|
||||||
|
import static androidx.media3.common.VideoFrameProcessor.INPUT_TYPE_BITMAP;
|
||||||
import static androidx.media3.common.util.Assertions.checkNotNull;
|
import static androidx.media3.common.util.Assertions.checkNotNull;
|
||||||
import static androidx.media3.common.util.Assertions.checkStateNotNull;
|
import static androidx.media3.common.util.Assertions.checkStateNotNull;
|
||||||
import static androidx.media3.test.utils.BitmapPixelTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE;
|
import static androidx.media3.test.utils.BitmapPixelTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE;
|
||||||
@ -110,7 +111,7 @@ public final class DefaultVideoFrameProcessorPixelTest {
|
|||||||
public void noEffects_withImageInput_matchesGoldenFile() throws Exception {
|
public void noEffects_withImageInput_matchesGoldenFile() throws Exception {
|
||||||
String testId = "noEffects_withImageInput_matchesGoldenFile";
|
String testId = "noEffects_withImageInput_matchesGoldenFile";
|
||||||
videoFrameProcessorTestRunner =
|
videoFrameProcessorTestRunner =
|
||||||
getDefaultFrameProcessorTestRunnerBuilder(testId).setIsInputTextureExternal(false).build();
|
getDefaultFrameProcessorTestRunnerBuilder(testId).setInputType(INPUT_TYPE_BITMAP).build();
|
||||||
Bitmap originalBitmap = readBitmap(IMAGE_PNG_ASSET_PATH);
|
Bitmap originalBitmap = readBitmap(IMAGE_PNG_ASSET_PATH);
|
||||||
Bitmap expectedBitmap = readBitmap(IMAGE_TO_VIDEO_PNG_ASSET_PATH);
|
Bitmap expectedBitmap = readBitmap(IMAGE_TO_VIDEO_PNG_ASSET_PATH);
|
||||||
|
|
||||||
@ -129,7 +130,7 @@ public final class DefaultVideoFrameProcessorPixelTest {
|
|||||||
String testId = "wrappedCrop_withImageInput_matchesGoldenFile";
|
String testId = "wrappedCrop_withImageInput_matchesGoldenFile";
|
||||||
videoFrameProcessorTestRunner =
|
videoFrameProcessorTestRunner =
|
||||||
getDefaultFrameProcessorTestRunnerBuilder(testId)
|
getDefaultFrameProcessorTestRunnerBuilder(testId)
|
||||||
.setIsInputTextureExternal(false)
|
.setInputType(INPUT_TYPE_BITMAP)
|
||||||
.setEffects(
|
.setEffects(
|
||||||
new GlEffectWrapper(
|
new GlEffectWrapper(
|
||||||
new Crop(
|
new Crop(
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package androidx.media3.effect;
|
package androidx.media3.effect;
|
||||||
|
|
||||||
|
import static androidx.media3.common.VideoFrameProcessor.INPUT_TYPE_SURFACE;
|
||||||
import static androidx.media3.common.util.Assertions.checkNotNull;
|
import static androidx.media3.common.util.Assertions.checkNotNull;
|
||||||
import static androidx.test.core.app.ApplicationProvider.getApplicationContext;
|
import static androidx.test.core.app.ApplicationProvider.getApplicationContext;
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
@ -300,7 +301,7 @@ public final class DefaultVideoFrameProcessorVideoFrameReleaseTest {
|
|||||||
DebugViewProvider.NONE,
|
DebugViewProvider.NONE,
|
||||||
/* inputColorInfo= */ ColorInfo.SDR_BT709_LIMITED,
|
/* inputColorInfo= */ ColorInfo.SDR_BT709_LIMITED,
|
||||||
/* outputColorInfo= */ ColorInfo.SDR_BT709_LIMITED,
|
/* outputColorInfo= */ ColorInfo.SDR_BT709_LIMITED,
|
||||||
/* isInputTextureExternal= */ true,
|
INPUT_TYPE_SURFACE,
|
||||||
releaseFramesAutomatically,
|
releaseFramesAutomatically,
|
||||||
MoreExecutors.directExecutor(),
|
MoreExecutors.directExecutor(),
|
||||||
new VideoFrameProcessor.Listener() {
|
new VideoFrameProcessor.Listener() {
|
||||||
|
@ -182,7 +182,7 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
|
|||||||
DebugViewProvider debugViewProvider,
|
DebugViewProvider debugViewProvider,
|
||||||
ColorInfo inputColorInfo,
|
ColorInfo inputColorInfo,
|
||||||
ColorInfo outputColorInfo,
|
ColorInfo outputColorInfo,
|
||||||
boolean isInputTextureExternal,
|
@InputType int inputType,
|
||||||
boolean releaseFramesAutomatically,
|
boolean releaseFramesAutomatically,
|
||||||
Executor listenerExecutor,
|
Executor listenerExecutor,
|
||||||
Listener listener)
|
Listener listener)
|
||||||
@ -221,7 +221,7 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
|
|||||||
inputColorInfo,
|
inputColorInfo,
|
||||||
outputColorInfo,
|
outputColorInfo,
|
||||||
enableColorTransfers,
|
enableColorTransfers,
|
||||||
isInputTextureExternal,
|
inputType,
|
||||||
releaseFramesAutomatically,
|
releaseFramesAutomatically,
|
||||||
singleThreadExecutorService,
|
singleThreadExecutorService,
|
||||||
listenerExecutor,
|
listenerExecutor,
|
||||||
@ -259,7 +259,7 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
|
|||||||
private DefaultVideoFrameProcessor(
|
private DefaultVideoFrameProcessor(
|
||||||
EGLDisplay eglDisplay,
|
EGLDisplay eglDisplay,
|
||||||
EGLContext eglContext,
|
EGLContext eglContext,
|
||||||
boolean isInputTextureExternal,
|
@InputType int inputType,
|
||||||
VideoFrameProcessingTaskExecutor videoFrameProcessingTaskExecutor,
|
VideoFrameProcessingTaskExecutor videoFrameProcessingTaskExecutor,
|
||||||
ImmutableList<GlShaderProgram> shaderPrograms,
|
ImmutableList<GlShaderProgram> shaderPrograms,
|
||||||
boolean releaseFramesAutomatically)
|
boolean releaseFramesAutomatically)
|
||||||
@ -275,16 +275,22 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
|
|||||||
|
|
||||||
GlShaderProgram inputShaderProgram = shaderPrograms.get(0);
|
GlShaderProgram inputShaderProgram = shaderPrograms.get(0);
|
||||||
|
|
||||||
if (isInputTextureExternal) {
|
switch (inputType) {
|
||||||
checkState(inputShaderProgram instanceof ExternalShaderProgram);
|
case VideoFrameProcessor.INPUT_TYPE_SURFACE:
|
||||||
inputExternalTextureManager =
|
checkState(inputShaderProgram instanceof ExternalShaderProgram);
|
||||||
new ExternalTextureManager(
|
inputExternalTextureManager =
|
||||||
(ExternalShaderProgram) inputShaderProgram, videoFrameProcessingTaskExecutor);
|
new ExternalTextureManager(
|
||||||
inputShaderProgram.setInputListener(inputExternalTextureManager);
|
(ExternalShaderProgram) inputShaderProgram, videoFrameProcessingTaskExecutor);
|
||||||
} else {
|
inputShaderProgram.setInputListener(inputExternalTextureManager);
|
||||||
inputBitmapTextureManager =
|
break;
|
||||||
new BitmapTextureManager(inputShaderProgram, videoFrameProcessingTaskExecutor);
|
case VideoFrameProcessor.INPUT_TYPE_BITMAP:
|
||||||
inputShaderProgram.setInputListener(inputBitmapTextureManager);
|
inputBitmapTextureManager =
|
||||||
|
new BitmapTextureManager(inputShaderProgram, videoFrameProcessingTaskExecutor);
|
||||||
|
inputShaderProgram.setInputListener(inputBitmapTextureManager);
|
||||||
|
break;
|
||||||
|
case VideoFrameProcessor.INPUT_TYPE_TEXID: // fall through
|
||||||
|
default:
|
||||||
|
throw new VideoFrameProcessingException("Input type not supported yet");
|
||||||
}
|
}
|
||||||
|
|
||||||
finalShaderProgramWrapper = (FinalShaderProgramWrapper) getLast(shaderPrograms);
|
finalShaderProgramWrapper = (FinalShaderProgramWrapper) getLast(shaderPrograms);
|
||||||
@ -306,8 +312,8 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
|
|||||||
* call this method after instantiation to ensure that buffers are handled at full resolution. See
|
* call this method after instantiation to ensure that buffers are handled at full resolution. See
|
||||||
* {@link SurfaceTexture#setDefaultBufferSize(int, int)} for more information.
|
* {@link SurfaceTexture#setDefaultBufferSize(int, int)} for more information.
|
||||||
*
|
*
|
||||||
* <p>This method should only be used for when the {@link VideoFrameProcessor}'s {@code
|
* <p>This method must only be called when the {@link VideoFrameProcessor} is {@linkplain
|
||||||
* isInputTextureExternal} parameter is set to {@code true}.
|
* Factory#create created} with {@link #INPUT_TYPE_SURFACE}.
|
||||||
*
|
*
|
||||||
* @param width The default width for input buffers, in pixels.
|
* @param width The default width for input buffers, in pixels.
|
||||||
* @param height The default height for input buffers, in pixels.
|
* @param height The default height for input buffers, in pixels.
|
||||||
@ -443,7 +449,7 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
|
|||||||
ColorInfo inputColorInfo,
|
ColorInfo inputColorInfo,
|
||||||
ColorInfo outputColorInfo,
|
ColorInfo outputColorInfo,
|
||||||
boolean enableColorTransfers,
|
boolean enableColorTransfers,
|
||||||
boolean isInputTextureExternal,
|
@InputType int inputType,
|
||||||
boolean releaseFramesAutomatically,
|
boolean releaseFramesAutomatically,
|
||||||
ExecutorService singleThreadExecutorService,
|
ExecutorService singleThreadExecutorService,
|
||||||
Executor executor,
|
Executor executor,
|
||||||
@ -487,7 +493,7 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
|
|||||||
inputColorInfo,
|
inputColorInfo,
|
||||||
outputColorInfo,
|
outputColorInfo,
|
||||||
enableColorTransfers,
|
enableColorTransfers,
|
||||||
isInputTextureExternal,
|
inputType,
|
||||||
releaseFramesAutomatically,
|
releaseFramesAutomatically,
|
||||||
executor,
|
executor,
|
||||||
listener,
|
listener,
|
||||||
@ -502,7 +508,7 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
|
|||||||
return new DefaultVideoFrameProcessor(
|
return new DefaultVideoFrameProcessor(
|
||||||
eglDisplay,
|
eglDisplay,
|
||||||
eglContext,
|
eglContext,
|
||||||
isInputTextureExternal,
|
inputType,
|
||||||
videoFrameProcessingTaskExecutor,
|
videoFrameProcessingTaskExecutor,
|
||||||
shaderPrograms,
|
shaderPrograms,
|
||||||
releaseFramesAutomatically);
|
releaseFramesAutomatically);
|
||||||
@ -528,7 +534,7 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
|
|||||||
ColorInfo inputColorInfo,
|
ColorInfo inputColorInfo,
|
||||||
ColorInfo outputColorInfo,
|
ColorInfo outputColorInfo,
|
||||||
boolean enableColorTransfers,
|
boolean enableColorTransfers,
|
||||||
boolean isInputTextureExternal,
|
@InputType int inputType,
|
||||||
boolean releaseFramesAutomatically,
|
boolean releaseFramesAutomatically,
|
||||||
Executor executor,
|
Executor executor,
|
||||||
Listener listener,
|
Listener listener,
|
||||||
@ -570,7 +576,7 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
|
|||||||
if (!matrixTransformations.isEmpty() || !rgbMatrices.isEmpty() || sampleFromInputTexture) {
|
if (!matrixTransformations.isEmpty() || !rgbMatrices.isEmpty() || sampleFromInputTexture) {
|
||||||
DefaultShaderProgram defaultShaderProgram;
|
DefaultShaderProgram defaultShaderProgram;
|
||||||
if (sampleFromInputTexture) {
|
if (sampleFromInputTexture) {
|
||||||
if (isInputTextureExternal) {
|
if (inputType == INPUT_TYPE_SURFACE) {
|
||||||
defaultShaderProgram =
|
defaultShaderProgram =
|
||||||
DefaultShaderProgram.createWithExternalSampler(
|
DefaultShaderProgram.createWithExternalSampler(
|
||||||
context,
|
context,
|
||||||
@ -614,7 +620,7 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
|
|||||||
outputColorInfo,
|
outputColorInfo,
|
||||||
enableColorTransfers,
|
enableColorTransfers,
|
||||||
sampleFromInputTexture,
|
sampleFromInputTexture,
|
||||||
isInputTextureExternal,
|
inputType,
|
||||||
releaseFramesAutomatically,
|
releaseFramesAutomatically,
|
||||||
executor,
|
executor,
|
||||||
listener,
|
listener,
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package androidx.media3.effect;
|
package androidx.media3.effect;
|
||||||
|
|
||||||
|
import static androidx.media3.common.VideoFrameProcessor.INPUT_TYPE_SURFACE;
|
||||||
import static androidx.media3.common.util.Assertions.checkNotNull;
|
import static androidx.media3.common.util.Assertions.checkNotNull;
|
||||||
import static androidx.media3.common.util.Assertions.checkState;
|
import static androidx.media3.common.util.Assertions.checkState;
|
||||||
|
|
||||||
@ -72,7 +73,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
private final EGLContext eglContext;
|
private final EGLContext eglContext;
|
||||||
private final DebugViewProvider debugViewProvider;
|
private final DebugViewProvider debugViewProvider;
|
||||||
private final boolean sampleFromInputTexture;
|
private final boolean sampleFromInputTexture;
|
||||||
private final boolean isInputTextureExternal;
|
private final @VideoFrameProcessor.InputType int inputType;
|
||||||
private final ColorInfo inputColorInfo;
|
private final ColorInfo inputColorInfo;
|
||||||
private final ColorInfo outputColorInfo;
|
private final ColorInfo outputColorInfo;
|
||||||
private final boolean enableColorTransfers;
|
private final boolean enableColorTransfers;
|
||||||
@ -115,7 +116,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
ColorInfo outputColorInfo,
|
ColorInfo outputColorInfo,
|
||||||
boolean enableColorTransfers,
|
boolean enableColorTransfers,
|
||||||
boolean sampleFromInputTexture,
|
boolean sampleFromInputTexture,
|
||||||
boolean isInputTextureExternal,
|
@VideoFrameProcessor.InputType int inputType,
|
||||||
boolean releaseFramesAutomatically,
|
boolean releaseFramesAutomatically,
|
||||||
Executor videoFrameProcessorListenerExecutor,
|
Executor videoFrameProcessorListenerExecutor,
|
||||||
VideoFrameProcessor.Listener videoFrameProcessorListener,
|
VideoFrameProcessor.Listener videoFrameProcessorListener,
|
||||||
@ -128,7 +129,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
this.eglContext = eglContext;
|
this.eglContext = eglContext;
|
||||||
this.debugViewProvider = debugViewProvider;
|
this.debugViewProvider = debugViewProvider;
|
||||||
this.sampleFromInputTexture = sampleFromInputTexture;
|
this.sampleFromInputTexture = sampleFromInputTexture;
|
||||||
this.isInputTextureExternal = isInputTextureExternal;
|
this.inputType = inputType;
|
||||||
this.inputColorInfo = inputColorInfo;
|
this.inputColorInfo = inputColorInfo;
|
||||||
this.outputColorInfo = outputColorInfo;
|
this.outputColorInfo = outputColorInfo;
|
||||||
this.enableColorTransfers = enableColorTransfers;
|
this.enableColorTransfers = enableColorTransfers;
|
||||||
@ -456,7 +457,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
ImmutableList<GlMatrixTransformation> expandedMatrixTransformations =
|
ImmutableList<GlMatrixTransformation> expandedMatrixTransformations =
|
||||||
matrixTransformationListBuilder.build();
|
matrixTransformationListBuilder.build();
|
||||||
if (sampleFromInputTexture) {
|
if (sampleFromInputTexture) {
|
||||||
if (isInputTextureExternal) {
|
if (inputType == INPUT_TYPE_SURFACE) {
|
||||||
defaultShaderProgram =
|
defaultShaderProgram =
|
||||||
DefaultShaderProgram.createWithExternalSampler(
|
DefaultShaderProgram.createWithExternalSampler(
|
||||||
context,
|
context,
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
package androidx.media3.exoplayer.video;
|
package androidx.media3.exoplayer.video;
|
||||||
|
|
||||||
import static android.view.Display.DEFAULT_DISPLAY;
|
import static android.view.Display.DEFAULT_DISPLAY;
|
||||||
|
import static androidx.media3.common.VideoFrameProcessor.INPUT_TYPE_SURFACE;
|
||||||
import static androidx.media3.common.util.Assertions.checkNotNull;
|
import static androidx.media3.common.util.Assertions.checkNotNull;
|
||||||
import static androidx.media3.common.util.Assertions.checkState;
|
import static androidx.media3.common.util.Assertions.checkState;
|
||||||
import static androidx.media3.common.util.Assertions.checkStateNotNull;
|
import static androidx.media3.common.util.Assertions.checkStateNotNull;
|
||||||
@ -2014,7 +2015,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
|
|||||||
DebugViewProvider.NONE,
|
DebugViewProvider.NONE,
|
||||||
inputColorInfo,
|
inputColorInfo,
|
||||||
outputColorInfo,
|
outputColorInfo,
|
||||||
/* isInputTextureExternal= */ true,
|
INPUT_TYPE_SURFACE,
|
||||||
/* releaseFramesAutomatically= */ false,
|
/* releaseFramesAutomatically= */ false,
|
||||||
/* executor= */ handler::post,
|
/* executor= */ handler::post,
|
||||||
new VideoFrameProcessor.Listener() {
|
new VideoFrameProcessor.Listener() {
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package androidx.media3.test.utils;
|
package androidx.media3.test.utils;
|
||||||
|
|
||||||
|
import static androidx.media3.common.VideoFrameProcessor.INPUT_TYPE_SURFACE;
|
||||||
import static androidx.media3.common.util.Assertions.checkNotNull;
|
import static androidx.media3.common.util.Assertions.checkNotNull;
|
||||||
import static androidx.media3.common.util.Assertions.checkStateNotNull;
|
import static androidx.media3.common.util.Assertions.checkStateNotNull;
|
||||||
import static androidx.media3.test.utils.BitmapPixelTestUtil.createArgb8888BitmapFromRgba8888Image;
|
import static androidx.media3.test.utils.BitmapPixelTestUtil.createArgb8888BitmapFromRgba8888Image;
|
||||||
@ -65,13 +66,13 @@ public final class VideoFrameProcessorTestRunner {
|
|||||||
private float pixelWidthHeightRatio;
|
private float pixelWidthHeightRatio;
|
||||||
private @MonotonicNonNull ColorInfo inputColorInfo;
|
private @MonotonicNonNull ColorInfo inputColorInfo;
|
||||||
private @MonotonicNonNull ColorInfo outputColorInfo;
|
private @MonotonicNonNull ColorInfo outputColorInfo;
|
||||||
private boolean isInputTextureExternal;
|
private @VideoFrameProcessor.InputType int inputType;
|
||||||
private OnOutputFrameAvailableListener onOutputFrameAvailableListener;
|
private OnOutputFrameAvailableListener onOutputFrameAvailableListener;
|
||||||
|
|
||||||
/** Creates a new instance with default values. */
|
/** Creates a new instance with default values. */
|
||||||
public Builder() {
|
public Builder() {
|
||||||
pixelWidthHeightRatio = DEFAULT_PIXEL_WIDTH_HEIGHT_RATIO;
|
pixelWidthHeightRatio = DEFAULT_PIXEL_WIDTH_HEIGHT_RATIO;
|
||||||
isInputTextureExternal = true;
|
inputType = INPUT_TYPE_SURFACE;
|
||||||
onOutputFrameAvailableListener = unused -> {};
|
onOutputFrameAvailableListener = unused -> {};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,11 +192,11 @@ public final class VideoFrameProcessorTestRunner {
|
|||||||
* Sets whether input comes from an external texture. See {@link
|
* Sets whether input comes from an external texture. See {@link
|
||||||
* VideoFrameProcessor.Factory#create}.
|
* VideoFrameProcessor.Factory#create}.
|
||||||
*
|
*
|
||||||
* <p>The default value is {@code true}.
|
* <p>The default value is {@link VideoFrameProcessor#INPUT_TYPE_SURFACE}.
|
||||||
*/
|
*/
|
||||||
@CanIgnoreReturnValue
|
@CanIgnoreReturnValue
|
||||||
public Builder setIsInputTextureExternal(boolean isInputTextureExternal) {
|
public Builder setInputType(@VideoFrameProcessor.InputType int inputType) {
|
||||||
this.isInputTextureExternal = isInputTextureExternal;
|
this.inputType = inputType;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,7 +226,7 @@ public final class VideoFrameProcessorTestRunner {
|
|||||||
pixelWidthHeightRatio,
|
pixelWidthHeightRatio,
|
||||||
inputColorInfo == null ? ColorInfo.SDR_BT709_LIMITED : inputColorInfo,
|
inputColorInfo == null ? ColorInfo.SDR_BT709_LIMITED : inputColorInfo,
|
||||||
outputColorInfo == null ? ColorInfo.SDR_BT709_LIMITED : outputColorInfo,
|
outputColorInfo == null ? ColorInfo.SDR_BT709_LIMITED : outputColorInfo,
|
||||||
isInputTextureExternal,
|
inputType,
|
||||||
onOutputFrameAvailableListener);
|
onOutputFrameAvailableListener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -257,7 +258,7 @@ public final class VideoFrameProcessorTestRunner {
|
|||||||
float pixelWidthHeightRatio,
|
float pixelWidthHeightRatio,
|
||||||
ColorInfo inputColorInfo,
|
ColorInfo inputColorInfo,
|
||||||
ColorInfo outputColorInfo,
|
ColorInfo outputColorInfo,
|
||||||
boolean isInputTextureExternal,
|
@VideoFrameProcessor.InputType int inputType,
|
||||||
OnOutputFrameAvailableListener onOutputFrameAvailableListener)
|
OnOutputFrameAvailableListener onOutputFrameAvailableListener)
|
||||||
throws VideoFrameProcessingException {
|
throws VideoFrameProcessingException {
|
||||||
this.testId = testId;
|
this.testId = testId;
|
||||||
@ -274,7 +275,7 @@ public final class VideoFrameProcessorTestRunner {
|
|||||||
DebugViewProvider.NONE,
|
DebugViewProvider.NONE,
|
||||||
inputColorInfo,
|
inputColorInfo,
|
||||||
outputColorInfo,
|
outputColorInfo,
|
||||||
isInputTextureExternal,
|
inputType,
|
||||||
/* releaseFramesAutomatically= */ true,
|
/* releaseFramesAutomatically= */ true,
|
||||||
MoreExecutors.directExecutor(),
|
MoreExecutors.directExecutor(),
|
||||||
new VideoFrameProcessor.Listener() {
|
new VideoFrameProcessor.Listener() {
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
package androidx.media3.transformer;
|
package androidx.media3.transformer;
|
||||||
|
|
||||||
import static androidx.media3.common.ColorInfo.isTransferHdr;
|
import static androidx.media3.common.ColorInfo.isTransferHdr;
|
||||||
|
import static androidx.media3.common.VideoFrameProcessor.INPUT_TYPE_BITMAP;
|
||||||
|
import static androidx.media3.common.VideoFrameProcessor.INPUT_TYPE_SURFACE;
|
||||||
import static androidx.media3.common.util.Assertions.checkNotNull;
|
import static androidx.media3.common.util.Assertions.checkNotNull;
|
||||||
import static androidx.media3.transformer.EncoderUtil.getSupportedEncodersForHdrEditing;
|
import static androidx.media3.transformer.EncoderUtil.getSupportedEncodersForHdrEditing;
|
||||||
import static androidx.media3.transformer.TransformationRequest.HDR_MODE_KEEP_HDR;
|
import static androidx.media3.transformer.TransformationRequest.HDR_MODE_KEEP_HDR;
|
||||||
@ -128,6 +130,9 @@ import org.checkerframework.dataflow.qual.Pure;
|
|||||||
if (presentation != null) {
|
if (presentation != null) {
|
||||||
effectsWithPresentation.add(presentation);
|
effectsWithPresentation.add(presentation);
|
||||||
}
|
}
|
||||||
|
@VideoFrameProcessor.InputType
|
||||||
|
int inputType =
|
||||||
|
MimeTypes.isVideo(firstInputFormat.sampleMimeType) ? INPUT_TYPE_SURFACE : INPUT_TYPE_BITMAP;
|
||||||
try {
|
try {
|
||||||
videoFrameProcessor =
|
videoFrameProcessor =
|
||||||
videoFrameProcessorFactory.create(
|
videoFrameProcessorFactory.create(
|
||||||
@ -136,7 +141,7 @@ import org.checkerframework.dataflow.qual.Pure;
|
|||||||
debugViewProvider,
|
debugViewProvider,
|
||||||
videoFrameProcessorInputColor,
|
videoFrameProcessorInputColor,
|
||||||
videoFrameProcessorOutputColor,
|
videoFrameProcessorOutputColor,
|
||||||
MimeTypes.isVideo(firstInputFormat.sampleMimeType),
|
inputType,
|
||||||
/* releaseFramesAutomatically= */ true,
|
/* releaseFramesAutomatically= */ true,
|
||||||
MoreExecutors.directExecutor(),
|
MoreExecutors.directExecutor(),
|
||||||
new VideoFrameProcessor.Listener() {
|
new VideoFrameProcessor.Listener() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user