Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
2fa2c341
authored
Apr 04, 2023
by
tofunmi
Committed by
Marc Baechinger
Apr 05, 2023
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Effect: Add support for disabling color transfers for SDR
PiperOrigin-RevId: 521805477
parent
dfc69dee
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
145 additions
and
20 deletions
library/effect/src/main/assets/shaders/fragment_shader_transformation_sdr_external_es2.glsl
library/effect/src/main/assets/shaders/fragment_shader_transformation_sdr_internal_es2.glsl
library/effect/src/main/java/com/google/android/exoplayer2/effect/DefaultShaderProgram.java
library/effect/src/main/java/com/google/android/exoplayer2/effect/DefaultVideoFrameProcessor.java
library/effect/src/main/java/com/google/android/exoplayer2/effect/FinalShaderProgramWrapper.java
library/effect/src/main/assets/shaders/fragment_shader_transformation_sdr_external_es2.glsl
View file @
2fa2c341
...
@@ -32,9 +32,12 @@ varying vec2 vTexSamplingCoord;
...
@@ -32,9 +32,12 @@ varying vec2 vTexSamplingCoord;
// C.java#ColorTransfer value.
// C.java#ColorTransfer value.
// Only COLOR_TRANSFER_LINEAR and COLOR_TRANSFER_SDR_VIDEO are allowed.
// Only COLOR_TRANSFER_LINEAR and COLOR_TRANSFER_SDR_VIDEO are allowed.
uniform
int
uOutputColorTransfer
;
uniform
int
uOutputColorTransfer
;
uniform
int
uEnableColorTransfer
;
const
float
inverseGamma
=
0
.
4500
;
const
float
inverseGamma
=
0
.
4500
;
const
float
gamma
=
1
.
0
/
inverseGamma
;
const
float
gamma
=
1
.
0
/
inverseGamma
;
const
int
GL_FALSE
=
0
;
const
int
GL_TRUE
=
1
;
// Transforms a single channel from electrical to optical SDR using the SMPTE
// Transforms a single channel from electrical to optical SDR using the SMPTE
// 170M OETF.
// 170M OETF.
...
@@ -77,7 +80,8 @@ highp vec3 applyOetf(highp vec3 linearColor) {
...
@@ -77,7 +80,8 @@ highp vec3 applyOetf(highp vec3 linearColor) {
// LINT.IfChange(color_transfer)
// LINT.IfChange(color_transfer)
const
int
COLOR_TRANSFER_LINEAR
=
1
;
const
int
COLOR_TRANSFER_LINEAR
=
1
;
const
int
COLOR_TRANSFER_SDR_VIDEO
=
3
;
const
int
COLOR_TRANSFER_SDR_VIDEO
=
3
;
if
(
uOutputColorTransfer
==
COLOR_TRANSFER_LINEAR
)
{
if
(
uOutputColorTransfer
==
COLOR_TRANSFER_LINEAR
||
uEnableColorTransfer
==
GL_FALSE
)
{
return
linearColor
;
return
linearColor
;
}
else
if
(
uOutputColorTransfer
==
COLOR_TRANSFER_SDR_VIDEO
)
{
}
else
if
(
uOutputColorTransfer
==
COLOR_TRANSFER_SDR_VIDEO
)
{
return
smpte170mOetf
(
linearColor
);
return
smpte170mOetf
(
linearColor
);
...
@@ -87,9 +91,20 @@ highp vec3 applyOetf(highp vec3 linearColor) {
...
@@ -87,9 +91,20 @@ highp vec3 applyOetf(highp vec3 linearColor) {
}
}
}
}
vec3
applyEotf
(
vec3
electricalColor
){
if
(
uEnableColorTransfer
==
GL_TRUE
){
return
smpte170mEotf
(
electricalColor
);
}
else
if
(
uEnableColorTransfer
==
GL_FALSE
)
{
return
electricalColor
;
}
else
{
// Output blue as an obviously visible error.
return
vec3
(
0
.
0
,
0
.
0
,
1
.
0
);
}
}
void
main
()
{
void
main
()
{
vec4
inputColor
=
texture2D
(
uTexSampler
,
vTexSamplingCoord
);
vec4
inputColor
=
texture2D
(
uTexSampler
,
vTexSamplingCoord
);
vec3
linearInputColor
=
smpte170m
Eotf
(
inputColor
.
rgb
);
vec3
linearInputColor
=
apply
Eotf
(
inputColor
.
rgb
);
vec4
transformedColors
=
uRgbMatrix
*
vec4
(
linearInputColor
,
1
);
vec4
transformedColors
=
uRgbMatrix
*
vec4
(
linearInputColor
,
1
);
...
...
library/effect/src/main/assets/shaders/fragment_shader_transformation_sdr_internal_es2.glsl
View file @
2fa2c341
...
@@ -32,9 +32,12 @@ varying vec2 vTexSamplingCoord;
...
@@ -32,9 +32,12 @@ varying vec2 vTexSamplingCoord;
// C.java#ColorTransfer value.
// C.java#ColorTransfer value.
// Only COLOR_TRANSFER_LINEAR and COLOR_TRANSFER_SDR_VIDEO are allowed.
// Only COLOR_TRANSFER_LINEAR and COLOR_TRANSFER_SDR_VIDEO are allowed.
uniform
int
uOutputColorTransfer
;
uniform
int
uOutputColorTransfer
;
uniform
int
uEnableColorTransfer
;
const
float
inverseGamma
=
0
.
4500
;
const
float
inverseGamma
=
0
.
4500
;
const
float
gamma
=
1
.
0
/
inverseGamma
;
const
float
gamma
=
1
.
0
/
inverseGamma
;
const
int
GL_FALSE
=
0
;
const
int
GL_TRUE
=
1
;
// Transforms a single channel from electrical to optical SDR using the sRGB
// Transforms a single channel from electrical to optical SDR using the sRGB
// EOTF.
// EOTF.
...
@@ -78,7 +81,8 @@ highp vec3 applyOetf(highp vec3 linearColor) {
...
@@ -78,7 +81,8 @@ highp vec3 applyOetf(highp vec3 linearColor) {
// LINT.IfChange(color_transfer)
// LINT.IfChange(color_transfer)
const
int
COLOR_TRANSFER_LINEAR
=
1
;
const
int
COLOR_TRANSFER_LINEAR
=
1
;
const
int
COLOR_TRANSFER_SDR_VIDEO
=
3
;
const
int
COLOR_TRANSFER_SDR_VIDEO
=
3
;
if
(
uOutputColorTransfer
==
COLOR_TRANSFER_LINEAR
)
{
if
(
uOutputColorTransfer
==
COLOR_TRANSFER_LINEAR
||
uEnableColorTransfer
==
GL_FALSE
)
{
return
linearColor
;
return
linearColor
;
}
else
if
(
uOutputColorTransfer
==
COLOR_TRANSFER_SDR_VIDEO
)
{
}
else
if
(
uOutputColorTransfer
==
COLOR_TRANSFER_SDR_VIDEO
)
{
return
smpte170mOetf
(
linearColor
);
return
smpte170mOetf
(
linearColor
);
...
@@ -88,6 +92,17 @@ highp vec3 applyOetf(highp vec3 linearColor) {
...
@@ -88,6 +92,17 @@ highp vec3 applyOetf(highp vec3 linearColor) {
}
}
}
}
vec3
applyEotf
(
vec3
electricalColor
){
if
(
uEnableColorTransfer
==
GL_TRUE
){
return
srgbEotf
(
electricalColor
)
;
}
else
if
(
uEnableColorTransfer
==
GL_FALSE
)
{
return
electricalColor
;
}
else
{
// Output blue as an obviously visible error.
return
vec3
(
0
.
0
,
0
.
0
,
1
.
0
);
}
}
void
main
()
{
void
main
()
{
vec2
vTexSamplingCoordFlipped
=
vec2
vTexSamplingCoordFlipped
=
vec2
(
vTexSamplingCoord
.
x
,
1
.
0
-
vTexSamplingCoord
.
y
);
vec2
(
vTexSamplingCoord
.
x
,
1
.
0
-
vTexSamplingCoord
.
y
);
...
@@ -96,7 +111,7 @@ void main() {
...
@@ -96,7 +111,7 @@ void main() {
// texture gets flipped. We flip the texture vertically to ensure the
// texture gets flipped. We flip the texture vertically to ensure the
// orientation of the output is correct.
// orientation of the output is correct.
vec4
inputColor
=
texture2D
(
uTexSampler
,
vTexSamplingCoordFlipped
);
vec4
inputColor
=
texture2D
(
uTexSampler
,
vTexSamplingCoordFlipped
);
vec3
linearInputColor
=
srgb
Eotf
(
inputColor
.
rgb
);
vec3
linearInputColor
=
apply
Eotf
(
inputColor
.
rgb
);
vec4
transformedColors
=
uRgbMatrix
*
vec4
(
linearInputColor
,
1
);
vec4
transformedColors
=
uRgbMatrix
*
vec4
(
linearInputColor
,
1
);
...
...
library/effect/src/main/java/com/google/android/exoplayer2/effect/DefaultShaderProgram.java
View file @
2fa2c341
...
@@ -90,6 +90,9 @@ import java.util.List;
...
@@ -90,6 +90,9 @@ import java.util.List;
1.6853f
,
-
0.6530f
,
0.0000f
,
1.6853f
,
-
0.6530f
,
0.0000f
,
};
};
private
static
final
int
GL_FALSE
=
0
;
private
static
final
int
GL_TRUE
=
1
;
/** The {@link MatrixTransformation MatrixTransformations} to apply. */
/** The {@link MatrixTransformation MatrixTransformations} to apply. */
private
final
ImmutableList
<
GlMatrixTransformation
>
matrixTransformations
;
private
final
ImmutableList
<
GlMatrixTransformation
>
matrixTransformations
;
/** The {@link RgbMatrix RgbMatrices} to apply. */
/** The {@link RgbMatrix RgbMatrices} to apply. */
...
@@ -183,6 +186,8 @@ import java.util.List;
...
@@ -183,6 +186,8 @@ import java.util.List;
* @param outputColorInfo The output electrical (nonlinear) or optical (linear) {@link ColorInfo}.
* @param outputColorInfo The output electrical (nonlinear) or optical (linear) {@link ColorInfo}.
* If this is an optical color, it must be BT.2020 if {@code inputColorInfo} is {@linkplain
* If this is an optical color, it must be BT.2020 if {@code inputColorInfo} is {@linkplain
* ColorInfo#isTransferHdr(ColorInfo) HDR}, and RGB BT.709 if not.
* ColorInfo#isTransferHdr(ColorInfo) HDR}, and RGB BT.709 if not.
* @param enableColorTransfers Whether to transfer colors to an intermediate color space when
* applying effects. If the input or output is HDR, this must be {@code true}.
* @throws VideoFrameProcessingException If a problem occurs while reading shader files or an
* @throws VideoFrameProcessingException If a problem occurs while reading shader files or an
* OpenGL operation fails or is unsupported.
* OpenGL operation fails or is unsupported.
*/
*/
...
@@ -191,7 +196,8 @@ import java.util.List;
...
@@ -191,7 +196,8 @@ import java.util.List;
List
<
GlMatrixTransformation
>
matrixTransformations
,
List
<
GlMatrixTransformation
>
matrixTransformations
,
List
<
RgbMatrix
>
rgbMatrices
,
List
<
RgbMatrix
>
rgbMatrices
,
ColorInfo
inputColorInfo
,
ColorInfo
inputColorInfo
,
ColorInfo
outputColorInfo
)
ColorInfo
outputColorInfo
,
boolean
enableColorTransfers
)
throws
VideoFrameProcessingException
{
throws
VideoFrameProcessingException
{
checkState
(
checkState
(
!
ColorInfo
.
isTransferHdr
(
inputColorInfo
),
!
ColorInfo
.
isTransferHdr
(
inputColorInfo
),
...
@@ -202,7 +208,12 @@ import java.util.List;
...
@@ -202,7 +208,12 @@ import java.util.List;
VERTEX_SHADER_TRANSFORMATION_PATH
,
VERTEX_SHADER_TRANSFORMATION_PATH
,
FRAGMENT_SHADER_TRANSFORMATION_SDR_INTERNAL_PATH
);
FRAGMENT_SHADER_TRANSFORMATION_SDR_INTERNAL_PATH
);
return
createWithSampler
(
return
createWithSampler
(
glProgram
,
matrixTransformations
,
rgbMatrices
,
inputColorInfo
,
outputColorInfo
);
glProgram
,
matrixTransformations
,
rgbMatrices
,
inputColorInfo
,
outputColorInfo
,
enableColorTransfers
);
}
}
/**
/**
...
@@ -227,6 +238,8 @@ import java.util.List;
...
@@ -227,6 +238,8 @@ import java.util.List;
* @param outputColorInfo The output electrical (nonlinear) or optical (linear) {@link ColorInfo}.
* @param outputColorInfo The output electrical (nonlinear) or optical (linear) {@link ColorInfo}.
* If this is an optical color, it must be BT.2020 if {@code inputColorInfo} is {@linkplain
* If this is an optical color, it must be BT.2020 if {@code inputColorInfo} is {@linkplain
* ColorInfo#isTransferHdr(ColorInfo) HDR}, and RGB BT.709 if not.
* ColorInfo#isTransferHdr(ColorInfo) HDR}, and RGB BT.709 if not.
* @param enableColorTransfers Whether to transfer colors to an intermediate color space when
* applying effects. If the input or output is HDR, this must be {@code true}.
* @throws VideoFrameProcessingException If a problem occurs while reading shader files or an
* @throws VideoFrameProcessingException If a problem occurs while reading shader files or an
* OpenGL operation fails or is unsupported.
* OpenGL operation fails or is unsupported.
*/
*/
...
@@ -235,7 +248,8 @@ import java.util.List;
...
@@ -235,7 +248,8 @@ import java.util.List;
List
<
GlMatrixTransformation
>
matrixTransformations
,
List
<
GlMatrixTransformation
>
matrixTransformations
,
List
<
RgbMatrix
>
rgbMatrices
,
List
<
RgbMatrix
>
rgbMatrices
,
ColorInfo
inputColorInfo
,
ColorInfo
inputColorInfo
,
ColorInfo
outputColorInfo
)
ColorInfo
outputColorInfo
,
boolean
enableColorTransfers
)
throws
VideoFrameProcessingException
{
throws
VideoFrameProcessingException
{
boolean
isInputTransferHdr
=
ColorInfo
.
isTransferHdr
(
inputColorInfo
);
boolean
isInputTransferHdr
=
ColorInfo
.
isTransferHdr
(
inputColorInfo
);
String
vertexShaderFilePath
=
String
vertexShaderFilePath
=
...
@@ -251,7 +265,8 @@ import java.util.List;
...
@@ -251,7 +265,8 @@ import java.util.List;
matrixTransformations
,
matrixTransformations
,
rgbMatrices
,
rgbMatrices
,
inputColorInfo
,
inputColorInfo
,
outputColorInfo
);
outputColorInfo
,
enableColorTransfers
);
}
}
/**
/**
...
@@ -314,12 +329,15 @@ import java.util.List;
...
@@ -314,12 +329,15 @@ import java.util.List;
List
<
GlMatrixTransformation
>
matrixTransformations
,
List
<
GlMatrixTransformation
>
matrixTransformations
,
List
<
RgbMatrix
>
rgbMatrices
,
List
<
RgbMatrix
>
rgbMatrices
,
ColorInfo
inputColorInfo
,
ColorInfo
inputColorInfo
,
ColorInfo
outputColorInfo
)
ColorInfo
outputColorInfo
,
boolean
enableColorTransfers
)
throws
VideoFrameProcessingException
{
throws
VideoFrameProcessingException
{
glProgram
.
setIntUniform
(
"uEnableColorTransfer"
,
enableColorTransfers
?
GL_TRUE
:
GL_FALSE
);
boolean
isInputTransferHdr
=
ColorInfo
.
isTransferHdr
(
inputColorInfo
);
boolean
isInputTransferHdr
=
ColorInfo
.
isTransferHdr
(
inputColorInfo
);
@C
.
ColorTransfer
int
outputColorTransfer
=
outputColorInfo
.
colorTransfer
;
@C
.
ColorTransfer
int
outputColorTransfer
=
outputColorInfo
.
colorTransfer
;
if
(
isInputTransferHdr
)
{
if
(
isInputTransferHdr
)
{
checkArgument
(
inputColorInfo
.
colorSpace
==
C
.
COLOR_SPACE_BT2020
);
checkArgument
(
inputColorInfo
.
colorSpace
==
C
.
COLOR_SPACE_BT2020
);
checkArgument
(
enableColorTransfers
);
// In HDR editing mode the decoder output is sampled in YUV.
// In HDR editing mode the decoder output is sampled in YUV.
if
(!
GlUtil
.
isYuvTargetExtensionSupported
())
{
if
(!
GlUtil
.
isYuvTargetExtensionSupported
())
{
...
...
library/effect/src/main/java/com/google/android/exoplayer2/effect/DefaultVideoFrameProcessor.java
View file @
2fa2c341
...
@@ -46,6 +46,7 @@ import com.google.android.exoplayer2.util.VideoFrameProcessor;
...
@@ -46,6 +46,7 @@ import com.google.android.exoplayer2.util.VideoFrameProcessor;
import
com.google.android.exoplayer2.video.ColorInfo
;
import
com.google.android.exoplayer2.video.ColorInfo
;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.util.concurrent.MoreExecutors
;
import
com.google.common.util.concurrent.MoreExecutors
;
import
com.google.errorprone.annotations.CanIgnoreReturnValue
;
import
java.util.List
;
import
java.util.List
;
import
java.util.concurrent.CountDownLatch
;
import
java.util.concurrent.CountDownLatch
;
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.ExecutionException
;
...
@@ -62,9 +63,54 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
...
@@ -62,9 +63,54 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
/** A factory for {@link DefaultVideoFrameProcessor} instances. */
/** A factory for {@link DefaultVideoFrameProcessor} instances. */
public
static
final
class
Factory
implements
VideoFrameProcessor
.
Factory
{
public
static
final
class
Factory
implements
VideoFrameProcessor
.
Factory
{
/** A builder for {@link DefaultVideoFrameProcessor.Factory} instances. */
public
static
final
class
Builder
{
private
boolean
enableColorTransfers
;
/** Creates an instance. */
public
Builder
()
{
enableColorTransfers
=
true
;
}
/**
* Sets whether to transfer colors to an intermediate color space when applying effects.
*
* <p>If the input or output is HDR, this must be {@code true}.
*/
@CanIgnoreReturnValue
public
DefaultVideoFrameProcessor
.
Factory
.
Builder
setEnableColorTransfers
(
boolean
enableColorTransfers
)
{
this
.
enableColorTransfers
=
enableColorTransfers
;
return
this
;
}
/** Builds an {@link DefaultVideoFrameProcessor.Factory} instance. */
public
DefaultVideoFrameProcessor
.
Factory
build
()
{
return
new
DefaultVideoFrameProcessor
.
Factory
(
enableColorTransfers
);
}
}
/** Whether to transfer colors to an intermediate color space when applying effects. */
public
final
boolean
enableColorTransfers
;
private
GlObjectsProvider
glObjectsProvider
=
GlObjectsProvider
.
DEFAULT
;
private
GlObjectsProvider
glObjectsProvider
=
GlObjectsProvider
.
DEFAULT
;
private
boolean
outputToTexture
;
private
boolean
outputToTexture
;
private
Factory
(
boolean
enableColorTransfers
)
{
this
.
enableColorTransfers
=
enableColorTransfers
;
}
// TODO(276913828): Remove and change all calls to a builder.
/**
* @deprecated Use {@link DefaultVideoFrameProcessor.Factory.Builder} instead.
*/
@Deprecated
public
Factory
()
{
this
(
/* enableColorTransfers= */
true
);
}
// TODO(276913828): Move this setter to the DefaultVideoFrameProcessor.Factory.Builder.
/**
/**
* {@inheritDoc}
* {@inheritDoc}
*
*
...
@@ -77,10 +123,11 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
...
@@ -77,10 +123,11 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
return
this
;
return
this
;
}
}
// TODO(276913828): Move this setter to the DefaultVideoFrameProcessor.Factory.Builder.
/**
/**
* Sets whether to output to a texture for testing.
* Sets whether to output to a texture for testing.
*
*
* <p>Must be called before {@link #create}.
* <p>Must be called before {@link
VideoFrameProcessor.Factory
#create}.
*
*
* <p>The default value is {@code false}.
* <p>The default value is {@code false}.
*/
*/
...
@@ -112,6 +159,9 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
...
@@ -112,6 +159,9 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
* are HDR}, textures will use {@link GLES30#GL_RGBA16F} and {@link GLES30#GL_HALF_FLOAT}.
* are HDR}, textures will use {@link GLES30#GL_RGBA16F} and {@link GLES30#GL_HALF_FLOAT}.
* Otherwise, textures will use {@link GLES20#GL_RGBA} and {@link GLES20#GL_UNSIGNED_BYTE}.
* Otherwise, textures will use {@link GLES20#GL_RGBA} and {@link GLES20#GL_UNSIGNED_BYTE}.
*
*
* <p>If {@code inputColorInfo} or {@code outputColorInfo} {@linkplain ColorInfo#isTransferHdr}
* are HDR}, color transfers must be enabled.
*
* <p>If {@code outputColorInfo} {@linkplain ColorInfo#isTransferHdr is HDR}, the context will
* <p>If {@code outputColorInfo} {@linkplain ColorInfo#isTransferHdr is HDR}, the context will
* be configured with {@link GlUtil#EGL_CONFIG_ATTRIBUTES_RGBA_1010102}. Otherwise, the context
* be configured with {@link GlUtil#EGL_CONFIG_ATTRIBUTES_RGBA_1010102}. Otherwise, the context
* will be configured with {@link GlUtil#EGL_CONFIG_ATTRIBUTES_RGBA_8888}.
* will be configured with {@link GlUtil#EGL_CONFIG_ATTRIBUTES_RGBA_8888}.
...
@@ -137,6 +187,9 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
...
@@ -137,6 +187,9 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
checkArgument
(
inputColorInfo
.
colorTransfer
!=
C
.
COLOR_TRANSFER_LINEAR
);
checkArgument
(
inputColorInfo
.
colorTransfer
!=
C
.
COLOR_TRANSFER_LINEAR
);
checkArgument
(
outputColorInfo
.
isValid
());
checkArgument
(
outputColorInfo
.
isValid
());
checkArgument
(
outputColorInfo
.
colorTransfer
!=
C
.
COLOR_TRANSFER_LINEAR
);
checkArgument
(
outputColorInfo
.
colorTransfer
!=
C
.
COLOR_TRANSFER_LINEAR
);
if
(
ColorInfo
.
isTransferHdr
(
inputColorInfo
)
||
ColorInfo
.
isTransferHdr
(
outputColorInfo
))
{
checkArgument
(
enableColorTransfers
);
}
if
(
inputColorInfo
.
colorSpace
!=
outputColorInfo
.
colorSpace
if
(
inputColorInfo
.
colorSpace
!=
outputColorInfo
.
colorSpace
||
ColorInfo
.
isTransferHdr
(
inputColorInfo
)
!=
ColorInfo
.
isTransferHdr
(
outputColorInfo
))
{
||
ColorInfo
.
isTransferHdr
(
inputColorInfo
)
!=
ColorInfo
.
isTransferHdr
(
outputColorInfo
))
{
...
@@ -161,6 +214,7 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
...
@@ -161,6 +214,7 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
debugViewProvider
,
debugViewProvider
,
inputColorInfo
,
inputColorInfo
,
outputColorInfo
,
outputColorInfo
,
enableColorTransfers
,
isInputTextureExternal
,
isInputTextureExternal
,
releaseFramesAutomatically
,
releaseFramesAutomatically
,
singleThreadExecutorService
,
singleThreadExecutorService
,
...
@@ -405,6 +459,7 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
...
@@ -405,6 +459,7 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
DebugViewProvider
debugViewProvider
,
DebugViewProvider
debugViewProvider
,
ColorInfo
inputColorInfo
,
ColorInfo
inputColorInfo
,
ColorInfo
outputColorInfo
,
ColorInfo
outputColorInfo
,
boolean
enableColorTransfers
,
boolean
isInputTextureExternal
,
boolean
isInputTextureExternal
,
boolean
releaseFramesAutomatically
,
boolean
releaseFramesAutomatically
,
ExecutorService
singleThreadExecutorService
,
ExecutorService
singleThreadExecutorService
,
...
@@ -450,6 +505,7 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
...
@@ -450,6 +505,7 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
debugViewProvider
,
debugViewProvider
,
inputColorInfo
,
inputColorInfo
,
outputColorInfo
,
outputColorInfo
,
enableColorTransfers
,
isInputTextureExternal
,
isInputTextureExternal
,
releaseFramesAutomatically
,
releaseFramesAutomatically
,
executor
,
executor
,
...
@@ -490,6 +546,7 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
...
@@ -490,6 +546,7 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
DebugViewProvider
debugViewProvider
,
DebugViewProvider
debugViewProvider
,
ColorInfo
inputColorInfo
,
ColorInfo
inputColorInfo
,
ColorInfo
outputColorInfo
,
ColorInfo
outputColorInfo
,
boolean
enableColorTransfers
,
boolean
isInputTextureExternal
,
boolean
isInputTextureExternal
,
boolean
releaseFramesAutomatically
,
boolean
releaseFramesAutomatically
,
Executor
executor
,
Executor
executor
,
...
@@ -535,11 +592,21 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
...
@@ -535,11 +592,21 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
if
(
isInputTextureExternal
)
{
if
(
isInputTextureExternal
)
{
defaultShaderProgram
=
defaultShaderProgram
=
DefaultShaderProgram
.
createWithExternalSampler
(
DefaultShaderProgram
.
createWithExternalSampler
(
context
,
matrixTransformations
,
rgbMatrices
,
inputColorInfo
,
linearColorInfo
);
context
,
matrixTransformations
,
rgbMatrices
,
inputColorInfo
,
linearColorInfo
,
enableColorTransfers
);
}
else
{
}
else
{
defaultShaderProgram
=
defaultShaderProgram
=
DefaultShaderProgram
.
createWithInternalSampler
(
DefaultShaderProgram
.
createWithInternalSampler
(
context
,
matrixTransformations
,
rgbMatrices
,
inputColorInfo
,
linearColorInfo
);
context
,
matrixTransformations
,
rgbMatrices
,
inputColorInfo
,
linearColorInfo
,
enableColorTransfers
);
}
}
}
else
{
}
else
{
defaultShaderProgram
=
defaultShaderProgram
=
...
@@ -564,6 +631,7 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
...
@@ -564,6 +631,7 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
debugViewProvider
,
debugViewProvider
,
/* inputColorInfo= */
sampleFromInputTexture
?
inputColorInfo
:
linearColorInfo
,
/* inputColorInfo= */
sampleFromInputTexture
?
inputColorInfo
:
linearColorInfo
,
outputColorInfo
,
outputColorInfo
,
enableColorTransfers
,
sampleFromInputTexture
,
sampleFromInputTexture
,
isInputTextureExternal
,
isInputTextureExternal
,
releaseFramesAutomatically
,
releaseFramesAutomatically
,
...
...
library/effect/src/main/java/com/google/android/exoplayer2/effect/FinalShaderProgramWrapper.java
View file @
2fa2c341
...
@@ -77,6 +77,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
...
@@ -77,6 +77,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
private
final
boolean
isInputTextureExternal
;
private
final
boolean
isInputTextureExternal
;
private
final
ColorInfo
inputColorInfo
;
private
final
ColorInfo
inputColorInfo
;
private
final
ColorInfo
outputColorInfo
;
private
final
ColorInfo
outputColorInfo
;
private
final
boolean
enableColorTransfers
;
private
final
boolean
releaseFramesAutomatically
;
private
final
boolean
releaseFramesAutomatically
;
private
final
Executor
videoFrameProcessorListenerExecutor
;
private
final
Executor
videoFrameProcessorListenerExecutor
;
private
final
VideoFrameProcessor
.
Listener
videoFrameProcessorListener
;
private
final
VideoFrameProcessor
.
Listener
videoFrameProcessorListener
;
...
@@ -115,6 +116,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
...
@@ -115,6 +116,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
DebugViewProvider
debugViewProvider
,
DebugViewProvider
debugViewProvider
,
ColorInfo
inputColorInfo
,
ColorInfo
inputColorInfo
,
ColorInfo
outputColorInfo
,
ColorInfo
outputColorInfo
,
boolean
enableColorTransfers
,
boolean
sampleFromInputTexture
,
boolean
sampleFromInputTexture
,
boolean
isInputTextureExternal
,
boolean
isInputTextureExternal
,
boolean
releaseFramesAutomatically
,
boolean
releaseFramesAutomatically
,
...
@@ -132,6 +134,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
...
@@ -132,6 +134,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
this
.
isInputTextureExternal
=
isInputTextureExternal
;
this
.
isInputTextureExternal
=
isInputTextureExternal
;
this
.
inputColorInfo
=
inputColorInfo
;
this
.
inputColorInfo
=
inputColorInfo
;
this
.
outputColorInfo
=
outputColorInfo
;
this
.
outputColorInfo
=
outputColorInfo
;
this
.
enableColorTransfers
=
enableColorTransfers
;
this
.
releaseFramesAutomatically
=
releaseFramesAutomatically
;
this
.
releaseFramesAutomatically
=
releaseFramesAutomatically
;
this
.
videoFrameProcessorListenerExecutor
=
videoFrameProcessorListenerExecutor
;
this
.
videoFrameProcessorListenerExecutor
=
videoFrameProcessorListenerExecutor
;
this
.
videoFrameProcessorListener
=
videoFrameProcessorListener
;
this
.
videoFrameProcessorListener
=
videoFrameProcessorListener
;
...
@@ -491,7 +494,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
...
@@ -491,7 +494,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
expandedMatrixTransformations
,
expandedMatrixTransformations
,
rgbMatrices
,
rgbMatrices
,
inputColorInfo
,
inputColorInfo
,
outputColorInfo
);
outputColorInfo
,
enableColorTransfers
);
}
else
{
}
else
{
defaultShaderProgram
=
defaultShaderProgram
=
DefaultShaderProgram
.
createWithInternalSampler
(
DefaultShaderProgram
.
createWithInternalSampler
(
...
@@ -499,7 +503,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
...
@@ -499,7 +503,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
expandedMatrixTransformations
,
expandedMatrixTransformations
,
rgbMatrices
,
rgbMatrices
,
inputColorInfo
,
inputColorInfo
,
outputColorInfo
);
outputColorInfo
,
enableColorTransfers
);
}
}
}
else
{
}
else
{
defaultShaderProgram
=
defaultShaderProgram
=
...
@@ -522,12 +527,16 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
...
@@ -522,12 +527,16 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
.
maybeRenderToSurfaceView
(
.
maybeRenderToSurfaceView
(
()
->
{
()
->
{
GlUtil
.
clearOutputFrame
();
GlUtil
.
clearOutputFrame
();
@C
.
ColorTransfer
if
(
enableColorTransfers
)
{
int
configuredColorTransfer
=
defaultShaderProgram
.
getOutputColorTransfer
();
defaultShaderProgram
.
drawFrame
(
inputTexture
.
texId
,
presentationTimeUs
);
defaultShaderProgram
.
setOutputColorTransfer
(
}
else
{
debugSurfaceViewWrapper
.
outputColorTransfer
);
@C
.
ColorTransfer
defaultShaderProgram
.
drawFrame
(
inputTexture
.
texId
,
presentationTimeUs
);
int
configuredColorTransfer
=
defaultShaderProgram
.
getOutputColorTransfer
();
defaultShaderProgram
.
setOutputColorTransfer
(
configuredColorTransfer
);
defaultShaderProgram
.
setOutputColorTransfer
(
debugSurfaceViewWrapper
.
outputColorTransfer
);
defaultShaderProgram
.
drawFrame
(
inputTexture
.
texId
,
presentationTimeUs
);
defaultShaderProgram
.
setOutputColorTransfer
(
configuredColorTransfer
);
}
},
},
glObjectsProvider
);
glObjectsProvider
);
}
catch
(
VideoFrameProcessingException
|
GlUtil
.
GlException
e
)
{
}
catch
(
VideoFrameProcessingException
|
GlUtil
.
GlException
e
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment