Add ExternalCopyFrameProcessor to frameProcessors list.
PiperOrigin-RevId: 438847583
This commit is contained in:
parent
2a66c7b8f5
commit
d3931d8b96
@ -171,9 +171,11 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||||||
eglContext,
|
eglContext,
|
||||||
singleThreadExecutorService,
|
singleThreadExecutorService,
|
||||||
inputExternalTexId,
|
inputExternalTexId,
|
||||||
externalCopyFrameProcessor,
|
|
||||||
framebuffers,
|
framebuffers,
|
||||||
ImmutableList.copyOf(frameProcessors),
|
new ImmutableList.Builder<GlFrameProcessor>()
|
||||||
|
.add(externalCopyFrameProcessor)
|
||||||
|
.addAll(frameProcessors)
|
||||||
|
.build(),
|
||||||
enableExperimentalHdrEditing);
|
enableExperimentalHdrEditing);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,14 +198,15 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||||||
/** Transformation matrix associated with the {@link #inputSurfaceTexture}. */
|
/** Transformation matrix associated with the {@link #inputSurfaceTexture}. */
|
||||||
private final float[] textureTransformMatrix;
|
private final float[] textureTransformMatrix;
|
||||||
|
|
||||||
private final ExternalCopyFrameProcessor externalCopyFrameProcessor;
|
/**
|
||||||
|
* Contains an {@link ExternalCopyFrameProcessor} at the 0th index and optionally other {@link
|
||||||
|
* GlFrameProcessor GlFrameProcessors} at indices >= 1.
|
||||||
|
*/
|
||||||
private final ImmutableList<GlFrameProcessor> frameProcessors;
|
private final ImmutableList<GlFrameProcessor> frameProcessors;
|
||||||
/**
|
/**
|
||||||
* Identifiers of a framebuffer object associated with the intermediate textures that receive
|
* Identifiers of a framebuffer object associated with the intermediate textures that receive
|
||||||
* output from the previous {@link GlFrameProcessor}, and provide input for the following {@link
|
* output from the previous {@link GlFrameProcessor}, and provide input for the following {@link
|
||||||
* GlFrameProcessor}.
|
* GlFrameProcessor}.
|
||||||
*
|
|
||||||
* <p>The {@link ExternalCopyFrameProcessor} writes to the first framebuffer.
|
|
||||||
*/
|
*/
|
||||||
private final int[] framebuffers;
|
private final int[] framebuffers;
|
||||||
|
|
||||||
@ -231,15 +234,14 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||||||
EGLContext eglContext,
|
EGLContext eglContext,
|
||||||
ExecutorService singleThreadExecutorService,
|
ExecutorService singleThreadExecutorService,
|
||||||
int inputExternalTexId,
|
int inputExternalTexId,
|
||||||
ExternalCopyFrameProcessor externalCopyFrameProcessor,
|
|
||||||
int[] framebuffers,
|
int[] framebuffers,
|
||||||
ImmutableList<GlFrameProcessor> frameProcessors,
|
ImmutableList<GlFrameProcessor> frameProcessors,
|
||||||
boolean enableExperimentalHdrEditing) {
|
boolean enableExperimentalHdrEditing) {
|
||||||
|
checkState(!frameProcessors.isEmpty());
|
||||||
|
|
||||||
this.eglDisplay = eglDisplay;
|
this.eglDisplay = eglDisplay;
|
||||||
this.eglContext = eglContext;
|
this.eglContext = eglContext;
|
||||||
this.singleThreadExecutorService = singleThreadExecutorService;
|
this.singleThreadExecutorService = singleThreadExecutorService;
|
||||||
this.externalCopyFrameProcessor = externalCopyFrameProcessor;
|
|
||||||
this.framebuffers = framebuffers;
|
this.framebuffers = framebuffers;
|
||||||
this.frameProcessors = frameProcessors;
|
this.frameProcessors = frameProcessors;
|
||||||
this.enableExperimentalHdrEditing = enableExperimentalHdrEditing;
|
this.enableExperimentalHdrEditing = enableExperimentalHdrEditing;
|
||||||
@ -249,10 +251,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||||||
inputSurfaceTexture = new SurfaceTexture(inputExternalTexId);
|
inputSurfaceTexture = new SurfaceTexture(inputExternalTexId);
|
||||||
inputSurface = new Surface(inputSurfaceTexture);
|
inputSurface = new Surface(inputSurfaceTexture);
|
||||||
textureTransformMatrix = new float[16];
|
textureTransformMatrix = new float[16];
|
||||||
outputSize =
|
outputSize = getLast(frameProcessors).getOutputSize();
|
||||||
frameProcessors.isEmpty()
|
|
||||||
? externalCopyFrameProcessor.getOutputSize()
|
|
||||||
: getLast(frameProcessors).getOutputSize();
|
|
||||||
debugPreviewWidth = C.LENGTH_UNSET;
|
debugPreviewWidth = C.LENGTH_UNSET;
|
||||||
debugPreviewHeight = C.LENGTH_UNSET;
|
debugPreviewHeight = C.LENGTH_UNSET;
|
||||||
}
|
}
|
||||||
@ -379,7 +378,6 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||||||
futures.add(
|
futures.add(
|
||||||
singleThreadExecutorService.submit(
|
singleThreadExecutorService.submit(
|
||||||
() -> {
|
() -> {
|
||||||
externalCopyFrameProcessor.release();
|
|
||||||
for (int i = 0; i < frameProcessors.size(); i++) {
|
for (int i = 0; i < frameProcessors.size(); i++) {
|
||||||
frameProcessors.get(i).release();
|
frameProcessors.get(i).release();
|
||||||
}
|
}
|
||||||
@ -429,26 +427,12 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||||||
checkState(Thread.currentThread().getName().equals(THREAD_NAME));
|
checkState(Thread.currentThread().getName().equals(THREAD_NAME));
|
||||||
checkStateNotNull(eglSurface, "No output surface set.");
|
checkStateNotNull(eglSurface, "No output surface set.");
|
||||||
|
|
||||||
if (frameProcessors.isEmpty()) {
|
|
||||||
GlUtil.focusEglSurface(
|
|
||||||
eglDisplay, eglContext, eglSurface, outputSize.getWidth(), outputSize.getHeight());
|
|
||||||
} else {
|
|
||||||
Size intermediateSize = externalCopyFrameProcessor.getOutputSize();
|
|
||||||
GlUtil.focusFramebuffer(
|
|
||||||
eglDisplay,
|
|
||||||
eglContext,
|
|
||||||
eglSurface,
|
|
||||||
framebuffers[0],
|
|
||||||
intermediateSize.getWidth(),
|
|
||||||
intermediateSize.getHeight());
|
|
||||||
}
|
|
||||||
inputSurfaceTexture.updateTexImage();
|
inputSurfaceTexture.updateTexImage();
|
||||||
inputSurfaceTexture.getTransformMatrix(textureTransformMatrix);
|
|
||||||
externalCopyFrameProcessor.setTextureTransformMatrix(textureTransformMatrix);
|
|
||||||
long presentationTimeNs = inputSurfaceTexture.getTimestamp();
|
long presentationTimeNs = inputSurfaceTexture.getTimestamp();
|
||||||
long presentationTimeUs = presentationTimeNs / 1000;
|
long presentationTimeUs = presentationTimeNs / 1000;
|
||||||
clearOutputFrame();
|
inputSurfaceTexture.getTransformMatrix(textureTransformMatrix);
|
||||||
externalCopyFrameProcessor.updateProgramAndDraw(presentationTimeUs);
|
((ExternalCopyFrameProcessor) frameProcessors.get(0))
|
||||||
|
.setTextureTransformMatrix(textureTransformMatrix);
|
||||||
|
|
||||||
for (int i = 0; i < frameProcessors.size() - 1; i++) {
|
for (int i = 0; i < frameProcessors.size() - 1; i++) {
|
||||||
Size intermediateSize = frameProcessors.get(i).getOutputSize();
|
Size intermediateSize = frameProcessors.get(i).getOutputSize();
|
||||||
@ -456,18 +440,16 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||||||
eglDisplay,
|
eglDisplay,
|
||||||
eglContext,
|
eglContext,
|
||||||
eglSurface,
|
eglSurface,
|
||||||
framebuffers[i + 1],
|
framebuffers[i],
|
||||||
intermediateSize.getWidth(),
|
intermediateSize.getWidth(),
|
||||||
intermediateSize.getHeight());
|
intermediateSize.getHeight());
|
||||||
clearOutputFrame();
|
clearOutputFrame();
|
||||||
frameProcessors.get(i).updateProgramAndDraw(presentationTimeUs);
|
frameProcessors.get(i).updateProgramAndDraw(presentationTimeUs);
|
||||||
}
|
}
|
||||||
if (!frameProcessors.isEmpty()) {
|
|
||||||
GlUtil.focusEglSurface(
|
GlUtil.focusEglSurface(
|
||||||
eglDisplay, eglContext, eglSurface, outputSize.getWidth(), outputSize.getHeight());
|
eglDisplay, eglContext, eglSurface, outputSize.getWidth(), outputSize.getHeight());
|
||||||
clearOutputFrame();
|
clearOutputFrame();
|
||||||
getLast(frameProcessors).updateProgramAndDraw(presentationTimeUs);
|
getLast(frameProcessors).updateProgramAndDraw(presentationTimeUs);
|
||||||
}
|
|
||||||
|
|
||||||
EGLExt.eglPresentationTimeANDROID(eglDisplay, eglSurface, presentationTimeNs);
|
EGLExt.eglPresentationTimeANDROID(eglDisplay, eglSurface, presentationTimeNs);
|
||||||
EGL14.eglSwapBuffers(eglDisplay, eglSurface);
|
EGL14.eglSwapBuffers(eglDisplay, eglSurface);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user