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
682a5ca7
authored
Mar 14, 2022
by
hschlueter
Committed by
Ian Baker
Mar 14, 2022
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Clarify GlProgram parameter name.
PiperOrigin-RevId: 434441008
parent
fb88a4fb
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
13 deletions
demos/gl/src/main/java/androidx/media3/demo/gl/BitmapOverlayVideoProcessor.java
libraries/common/src/main/java/androidx/media3/common/util/GlProgram.java
libraries/transformer/src/main/java/androidx/media3/transformer/ExternalCopyFrameProcessor.java
libraries/transformer/src/main/java/androidx/media3/transformer/TransformationFrameProcessor.java
demos/gl/src/main/java/androidx/media3/demo/gl/BitmapOverlayVideoProcessor.java
View file @
682a5ca7
...
@@ -119,8 +119,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
...
@@ -119,8 +119,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
// Run the shader program.
// Run the shader program.
GlProgram
program
=
checkNotNull
(
this
.
program
);
GlProgram
program
=
checkNotNull
(
this
.
program
);
program
.
setSamplerTexIdUniform
(
"uTexSampler0"
,
frameTexture
,
/*
unit
= */
0
);
program
.
setSamplerTexIdUniform
(
"uTexSampler0"
,
frameTexture
,
/*
texUnitIndex
= */
0
);
program
.
setSamplerTexIdUniform
(
"uTexSampler1"
,
textures
[
0
],
/*
unit
= */
1
);
program
.
setSamplerTexIdUniform
(
"uTexSampler1"
,
textures
[
0
],
/*
texUnitIndex
= */
1
);
program
.
setFloatUniform
(
"uScaleX"
,
bitmapScaleX
);
program
.
setFloatUniform
(
"uScaleX"
,
bitmapScaleX
);
program
.
setFloatUniform
(
"uScaleY"
,
bitmapScaleY
);
program
.
setFloatUniform
(
"uScaleY"
,
bitmapScaleY
);
program
.
setFloatsUniform
(
"uTexTransform"
,
transformMatrix
);
program
.
setFloatsUniform
(
"uTexTransform"
,
transformMatrix
);
...
...
libraries/common/src/main/java/androidx/media3/common/util/GlProgram.java
View file @
682a5ca7
...
@@ -175,9 +175,16 @@ public final class GlProgram {
...
@@ -175,9 +175,16 @@ public final class GlProgram {
checkNotNull
(
attributeByName
.
get
(
name
)).
setBuffer
(
values
,
size
);
checkNotNull
(
attributeByName
.
get
(
name
)).
setBuffer
(
values
,
size
);
}
}
/** Sets a texture sampler type uniform. */
/**
public
void
setSamplerTexIdUniform
(
String
name
,
int
texId
,
int
unit
)
{
* Sets a texture sampler type uniform.
checkNotNull
(
uniformByName
.
get
(
name
)).
setSamplerTexId
(
texId
,
unit
);
*
* @param name The uniform's name.
* @param texId The texture identifier.
* @param texUnitIndex The texture unit index. Use a different index (0, 1, 2, ...) for each
* texture sampler in the program.
*/
public
void
setSamplerTexIdUniform
(
String
name
,
int
texId
,
int
texUnitIndex
)
{
checkNotNull
(
uniformByName
.
get
(
name
)).
setSamplerTexId
(
texId
,
texUnitIndex
);
}
}
/** Sets a float type uniform. */
/** Sets a float type uniform. */
...
@@ -322,7 +329,7 @@ public final class GlProgram {
...
@@ -322,7 +329,7 @@ public final class GlProgram {
private
final
float
[]
value
;
private
final
float
[]
value
;
private
int
texId
;
private
int
texId
;
private
int
unit
;
private
int
texUnitIndex
;
private
Uniform
(
String
name
,
int
location
,
int
type
)
{
private
Uniform
(
String
name
,
int
location
,
int
type
)
{
this
.
name
=
name
;
this
.
name
=
name
;
...
@@ -335,11 +342,11 @@ public final class GlProgram {
...
@@ -335,11 +342,11 @@ public final class GlProgram {
* Configures {@link #bind()} to use the specified {@code texId} for this sampler uniform.
* Configures {@link #bind()} to use the specified {@code texId} for this sampler uniform.
*
*
* @param texId The GL texture identifier from which to sample.
* @param texId The GL texture identifier from which to sample.
* @param
unit
The GL texture unit index.
* @param
texUnitIndex
The GL texture unit index.
*/
*/
public
void
setSamplerTexId
(
int
texId
,
int
unit
)
{
public
void
setSamplerTexId
(
int
texId
,
int
texUnitIndex
)
{
this
.
texId
=
texId
;
this
.
texId
=
texId
;
this
.
unit
=
unit
;
this
.
texUnitIndex
=
texUnitIndex
;
}
}
/** Configures {@link #bind()} to use the specified float {@code value} for this uniform. */
/** Configures {@link #bind()} to use the specified float {@code value} for this uniform. */
...
@@ -382,7 +389,7 @@ public final class GlProgram {
...
@@ -382,7 +389,7 @@ public final class GlProgram {
if
(
texId
==
0
)
{
if
(
texId
==
0
)
{
throw
new
IllegalStateException
(
"No call to setSamplerTexId() before bind."
);
throw
new
IllegalStateException
(
"No call to setSamplerTexId() before bind."
);
}
}
GLES20
.
glActiveTexture
(
GLES20
.
GL_TEXTURE0
+
unit
);
GLES20
.
glActiveTexture
(
GLES20
.
GL_TEXTURE0
+
texUnitIndex
);
if
(
type
==
GLES11Ext
.
GL_SAMPLER_EXTERNAL_OES
||
type
==
GL_SAMPLER_EXTERNAL_2D_Y2Y_EXT
)
{
if
(
type
==
GLES11Ext
.
GL_SAMPLER_EXTERNAL_OES
||
type
==
GL_SAMPLER_EXTERNAL_2D_Y2Y_EXT
)
{
GLES20
.
glBindTexture
(
GLES11Ext
.
GL_TEXTURE_EXTERNAL_OES
,
texId
);
GLES20
.
glBindTexture
(
GLES11Ext
.
GL_TEXTURE_EXTERNAL_OES
,
texId
);
}
else
if
(
type
==
GLES20
.
GL_SAMPLER_2D
)
{
}
else
if
(
type
==
GLES20
.
GL_SAMPLER_2D
)
{
...
@@ -390,7 +397,7 @@ public final class GlProgram {
...
@@ -390,7 +397,7 @@ public final class GlProgram {
}
else
{
}
else
{
throw
new
IllegalStateException
(
"Unexpected uniform type: "
+
type
);
throw
new
IllegalStateException
(
"Unexpected uniform type: "
+
type
);
}
}
GLES20
.
glUniform1i
(
location
,
unit
);
GLES20
.
glUniform1i
(
location
,
texUnitIndex
);
GLES20
.
glTexParameteri
(
GLES20
.
GL_TEXTURE_2D
,
GLES20
.
GL_TEXTURE_MAG_FILTER
,
GLES20
.
GL_LINEAR
);
GLES20
.
glTexParameteri
(
GLES20
.
GL_TEXTURE_2D
,
GLES20
.
GL_TEXTURE_MAG_FILTER
,
GLES20
.
GL_LINEAR
);
GLES20
.
glTexParameteri
(
GLES20
.
GL_TEXTURE_2D
,
GLES20
.
GL_TEXTURE_MIN_FILTER
,
GLES20
.
GL_LINEAR
);
GLES20
.
glTexParameteri
(
GLES20
.
GL_TEXTURE_2D
,
GLES20
.
GL_TEXTURE_MIN_FILTER
,
GLES20
.
GL_LINEAR
);
GLES20
.
glTexParameteri
(
GLES20
.
glTexParameteri
(
...
...
libraries/transformer/src/main/java/androidx/media3/transformer/ExternalCopyFrameProcessor.java
View file @
682a5ca7
...
@@ -70,7 +70,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
...
@@ -70,7 +70,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
?
FRAGMENT_SHADER_COPY_EXTERNAL_YUV_ES3_PATH
?
FRAGMENT_SHADER_COPY_EXTERNAL_YUV_ES3_PATH
:
FRAGMENT_SHADER_COPY_EXTERNAL_PATH
;
:
FRAGMENT_SHADER_COPY_EXTERNAL_PATH
;
glProgram
=
new
GlProgram
(
context
,
vertexShaderFilePath
,
fragmentShaderFilePath
);
glProgram
=
new
GlProgram
(
context
,
vertexShaderFilePath
,
fragmentShaderFilePath
);
glProgram
.
setSamplerTexIdUniform
(
"uTexSampler"
,
inputTexId
,
/*
unit
= */
0
);
glProgram
.
setSamplerTexIdUniform
(
"uTexSampler"
,
inputTexId
,
/*
texUnitIndex
= */
0
);
// Draw the frame on the entire normalized device coordinate space, from -1 to 1, for x and y.
// Draw the frame on the entire normalized device coordinate space, from -1 to 1, for x and y.
glProgram
.
setBufferAttribute
(
glProgram
.
setBufferAttribute
(
"aFramePosition"
,
GlUtil
.
getNormalizedCoordinateBounds
(),
GlUtil
.
RECTANGLE_VERTICES_COUNT
);
"aFramePosition"
,
GlUtil
.
getNormalizedCoordinateBounds
(),
GlUtil
.
RECTANGLE_VERTICES_COUNT
);
...
...
libraries/transformer/src/main/java/androidx/media3/transformer/TransformationFrameProcessor.java
View file @
682a5ca7
...
@@ -97,7 +97,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
...
@@ -97,7 +97,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
// TODO(b/205002913): check the loaded program is consistent with the attributes and uniforms
// TODO(b/205002913): check the loaded program is consistent with the attributes and uniforms
// expected in the code.
// expected in the code.
glProgram
=
new
GlProgram
(
context
,
VERTEX_SHADER_TRANSFORMATION_PATH
,
FRAGMENT_SHADER_PATH
);
glProgram
=
new
GlProgram
(
context
,
VERTEX_SHADER_TRANSFORMATION_PATH
,
FRAGMENT_SHADER_PATH
);
glProgram
.
setSamplerTexIdUniform
(
"uTexSampler"
,
inputTexId
,
/*
unit
= */
0
);
glProgram
.
setSamplerTexIdUniform
(
"uTexSampler"
,
inputTexId
,
/*
texUnitIndex
= */
0
);
// Draw the frame on the entire normalized device coordinate space, from -1 to 1, for x and y.
// Draw the frame on the entire normalized device coordinate space, from -1 to 1, for x and y.
glProgram
.
setBufferAttribute
(
glProgram
.
setBufferAttribute
(
"aFramePosition"
,
GlUtil
.
getNormalizedCoordinateBounds
(),
GlUtil
.
RECTANGLE_VERTICES_COUNT
);
"aFramePosition"
,
GlUtil
.
getNormalizedCoordinateBounds
(),
GlUtil
.
RECTANGLE_VERTICES_COUNT
);
...
...
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