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
cfc0eef2
authored
Sep 22, 2022
by
leonwind
Committed by
Marc Baechinger
Oct 19, 2022
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add RGB Adjustments to transformer demo.
PiperOrigin-RevId: 476049125
parent
08bb01b2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
130 additions
and
6 deletions
demos/transformer/src/main/java/com/google/android/exoplayer2/transformerdemo/ConfigurationActivity.java
demos/transformer/src/main/java/com/google/android/exoplayer2/transformerdemo/TransformerActivity.java
demos/transformer/src/main/res/layout/rgb_adjustment_options.xml
demos/transformer/src/main/res/values/strings.xml
demos/transformer/src/main/java/com/google/android/exoplayer2/transformerdemo/ConfigurationActivity.java
View file @
cfc0eef2
...
@@ -69,6 +69,9 @@ public final class ConfigurationActivity extends AppCompatActivity {
...
@@ -69,6 +69,9 @@ public final class ConfigurationActivity extends AppCompatActivity {
public
static
final
String
PERIODIC_VIGNETTE_OUTER_RADIUS
=
"periodic_vignette_outer_radius"
;
public
static
final
String
PERIODIC_VIGNETTE_OUTER_RADIUS
=
"periodic_vignette_outer_radius"
;
public
static
final
String
COLOR_FILTER_SELECTION
=
"color_filter_selection"
;
public
static
final
String
COLOR_FILTER_SELECTION
=
"color_filter_selection"
;
public
static
final
String
CONTRAST_VALUE
=
"contrast_value"
;
public
static
final
String
CONTRAST_VALUE
=
"contrast_value"
;
public
static
final
String
RGB_ADJUSTMENT_RED_SCALE
=
"rgb_adjustment_red_scale"
;
public
static
final
String
RGB_ADJUSTMENT_GREEN_SCALE
=
"rgb_adjustment_green_scale"
;
public
static
final
String
RGB_ADJUSTMENT_BLUE_SCALE
=
"rgb_adjustment_blue_scale"
;
public
static
final
int
COLOR_FILTER_GRAYSCALE
=
0
;
public
static
final
int
COLOR_FILTER_GRAYSCALE
=
0
;
public
static
final
int
COLOR_FILTER_INVERTED
=
1
;
public
static
final
int
COLOR_FILTER_INVERTED
=
1
;
public
static
final
int
COLOR_FILTER_SEPIA
=
2
;
public
static
final
int
COLOR_FILTER_SEPIA
=
2
;
...
@@ -106,6 +109,7 @@ public final class ConfigurationActivity extends AppCompatActivity {
...
@@ -106,6 +109,7 @@ public final class ConfigurationActivity extends AppCompatActivity {
"Dizzy crop"
,
"Dizzy crop"
,
"Edge detector (Media Pipe)"
,
"Edge detector (Media Pipe)"
,
"Color filters"
,
"Color filters"
,
"RGB Adjustments"
,
"Contrast"
,
"Contrast"
,
"Periodic vignette"
,
"Periodic vignette"
,
"3D spin"
,
"3D spin"
,
...
@@ -113,8 +117,9 @@ public final class ConfigurationActivity extends AppCompatActivity {
...
@@ -113,8 +117,9 @@ public final class ConfigurationActivity extends AppCompatActivity {
"Zoom in start"
,
"Zoom in start"
,
};
};
private
static
final
int
COLOR_FILTERS_INDEX
=
2
;
private
static
final
int
COLOR_FILTERS_INDEX
=
2
;
private
static
final
int
CONTRAST_INDEX
=
3
;
private
static
final
int
RGB_ADJUSTMENTS_INDEX
=
3
;
private
static
final
int
PERIODIC_VIGNETTE_INDEX
=
4
;
private
static
final
int
CONTRAST_INDEX
=
4
;
private
static
final
int
PERIODIC_VIGNETTE_INDEX
=
5
;
private
static
final
String
SAME_AS_INPUT_OPTION
=
"same as input"
;
private
static
final
String
SAME_AS_INPUT_OPTION
=
"same as input"
;
private
static
final
float
HALF_DIAGONAL
=
1
f
/
(
float
)
Math
.
sqrt
(
2
);
private
static
final
float
HALF_DIAGONAL
=
1
f
/
(
float
)
Math
.
sqrt
(
2
);
...
@@ -139,6 +144,9 @@ public final class ConfigurationActivity extends AppCompatActivity {
...
@@ -139,6 +144,9 @@ public final class ConfigurationActivity extends AppCompatActivity {
private
long
trimStartMs
;
private
long
trimStartMs
;
private
long
trimEndMs
;
private
long
trimEndMs
;
private
int
colorFilterSelection
;
private
int
colorFilterSelection
;
private
float
rgbAdjustmentRedScale
;
private
float
rgbAdjustmentGreenScale
;
private
float
rgbAdjustmentBlueScale
;
private
float
contrastValue
;
private
float
contrastValue
;
private
float
periodicVignetteCenterX
;
private
float
periodicVignetteCenterX
;
private
float
periodicVignetteCenterY
;
private
float
periodicVignetteCenterY
;
...
@@ -297,6 +305,9 @@ public final class ConfigurationActivity extends AppCompatActivity {
...
@@ -297,6 +305,9 @@ public final class ConfigurationActivity extends AppCompatActivity {
bundle
.
putBooleanArray
(
DEMO_EFFECTS_SELECTIONS
,
demoEffectsSelections
);
bundle
.
putBooleanArray
(
DEMO_EFFECTS_SELECTIONS
,
demoEffectsSelections
);
bundle
.
putInt
(
COLOR_FILTER_SELECTION
,
colorFilterSelection
);
bundle
.
putInt
(
COLOR_FILTER_SELECTION
,
colorFilterSelection
);
bundle
.
putFloat
(
CONTRAST_VALUE
,
contrastValue
);
bundle
.
putFloat
(
CONTRAST_VALUE
,
contrastValue
);
bundle
.
putFloat
(
RGB_ADJUSTMENT_RED_SCALE
,
rgbAdjustmentRedScale
);
bundle
.
putFloat
(
RGB_ADJUSTMENT_GREEN_SCALE
,
rgbAdjustmentGreenScale
);
bundle
.
putFloat
(
RGB_ADJUSTMENT_BLUE_SCALE
,
rgbAdjustmentBlueScale
);
bundle
.
putFloat
(
PERIODIC_VIGNETTE_CENTER_X
,
periodicVignetteCenterX
);
bundle
.
putFloat
(
PERIODIC_VIGNETTE_CENTER_X
,
periodicVignetteCenterX
);
bundle
.
putFloat
(
PERIODIC_VIGNETTE_CENTER_Y
,
periodicVignetteCenterY
);
bundle
.
putFloat
(
PERIODIC_VIGNETTE_CENTER_Y
,
periodicVignetteCenterY
);
bundle
.
putFloat
(
PERIODIC_VIGNETTE_INNER_RADIUS
,
periodicVignetteInnerRadius
);
bundle
.
putFloat
(
PERIODIC_VIGNETTE_INNER_RADIUS
,
periodicVignetteInnerRadius
);
...
@@ -367,6 +378,9 @@ public final class ConfigurationActivity extends AppCompatActivity {
...
@@ -367,6 +378,9 @@ public final class ConfigurationActivity extends AppCompatActivity {
case
COLOR_FILTERS_INDEX:
case
COLOR_FILTERS_INDEX:
controlColorFiltersSettings
();
controlColorFiltersSettings
();
break
;
break
;
case
RGB_ADJUSTMENTS_INDEX:
controlRgbAdjustmentsScale
();
break
;
case
CONTRAST_INDEX:
case
CONTRAST_INDEX:
controlContrastSettings
();
controlContrastSettings
();
break
;
break
;
...
@@ -394,6 +408,27 @@ public final class ConfigurationActivity extends AppCompatActivity {
...
@@ -394,6 +408,27 @@ public final class ConfigurationActivity extends AppCompatActivity {
.
show
();
.
show
();
}
}
private
void
controlRgbAdjustmentsScale
()
{
View
dialogView
=
getLayoutInflater
().
inflate
(
R
.
layout
.
rgb_adjustment_options
,
/* root= */
null
);
Slider
redScaleSlider
=
checkNotNull
(
dialogView
.
findViewById
(
R
.
id
.
rgb_adjustment_red_scale
));
Slider
greenScaleSlider
=
checkNotNull
(
dialogView
.
findViewById
(
R
.
id
.
rgb_adjustment_green_scale
));
Slider
blueScaleSlider
=
checkNotNull
(
dialogView
.
findViewById
(
R
.
id
.
rgb_adjustment_blue_scale
));
new
AlertDialog
.
Builder
(
/* context= */
this
)
.
setTitle
(
R
.
string
.
rgb_adjustment_options
)
.
setView
(
dialogView
)
.
setPositiveButton
(
android
.
R
.
string
.
ok
,
(
DialogInterface
dialogInterface
,
int
i
)
->
{
rgbAdjustmentRedScale
=
redScaleSlider
.
getValue
();
rgbAdjustmentGreenScale
=
greenScaleSlider
.
getValue
();
rgbAdjustmentBlueScale
=
blueScaleSlider
.
getValue
();
})
.
create
()
.
show
();
}
private
void
controlContrastSettings
()
{
private
void
controlContrastSettings
()
{
View
dialogView
=
getLayoutInflater
().
inflate
(
R
.
layout
.
contrast_options
,
/* root= */
null
);
View
dialogView
=
getLayoutInflater
().
inflate
(
R
.
layout
.
contrast_options
,
/* root= */
null
);
Slider
contrastSlider
=
checkNotNull
(
dialogView
.
findViewById
(
R
.
id
.
contrast_slider
));
Slider
contrastSlider
=
checkNotNull
(
dialogView
.
findViewById
(
R
.
id
.
contrast_slider
));
...
...
demos/transformer/src/main/java/com/google/android/exoplayer2/transformerdemo/TransformerActivity.java
View file @
cfc0eef2
...
@@ -40,6 +40,7 @@ import androidx.media3.common.Effect;
...
@@ -40,6 +40,7 @@ import androidx.media3.common.Effect;
import
androidx.media3.effect.Contrast
;
import
androidx.media3.effect.Contrast
;
import
androidx.media3.effect.GlEffect
;
import
androidx.media3.effect.GlEffect
;
import
androidx.media3.effect.GlTextureProcessor
;
import
androidx.media3.effect.GlTextureProcessor
;
import
androidx.media3.effect.RgbAdjustment
;
import
androidx.media3.effect.RgbFilter
;
import
androidx.media3.effect.RgbFilter
;
import
androidx.media3.effect.RgbMatrix
;
import
androidx.media3.effect.RgbMatrix
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.C
;
...
@@ -336,9 +337,17 @@ public final class TransformerActivity extends AppCompatActivity {
...
@@ -336,9 +337,17 @@ public final class TransformerActivity extends AppCompatActivity {
}
}
}
}
if
(
selectedEffects
[
3
])
{
if
(
selectedEffects
[
3
])
{
effects
.
add
(
new
Contrast
(
bundle
.
getFloat
(
ConfigurationActivity
.
CONTRAST_VALUE
)));
effects
.
add
(
new
RgbAdjustment
.
Builder
()
.
setRedScale
(
bundle
.
getFloat
(
ConfigurationActivity
.
RGB_ADJUSTMENT_RED_SCALE
))
.
setGreenScale
(
bundle
.
getFloat
(
ConfigurationActivity
.
RGB_ADJUSTMENT_GREEN_SCALE
))
.
setBlueScale
(
bundle
.
getFloat
(
ConfigurationActivity
.
RGB_ADJUSTMENT_BLUE_SCALE
))
.
build
());
}
}
if
(
selectedEffects
[
4
])
{
if
(
selectedEffects
[
4
])
{
effects
.
add
(
new
Contrast
(
bundle
.
getFloat
(
ConfigurationActivity
.
CONTRAST_VALUE
)));
}
if
(
selectedEffects
[
5
])
{
effects
.
add
(
effects
.
add
(
(
GlEffect
)
(
GlEffect
)
(
Context
context
,
boolean
useHdr
)
->
(
Context
context
,
boolean
useHdr
)
->
...
@@ -353,13 +362,13 @@ public final class TransformerActivity extends AppCompatActivity {
...
@@ -353,13 +362,13 @@ public final class TransformerActivity extends AppCompatActivity {
ConfigurationActivity
.
PERIODIC_VIGNETTE_OUTER_RADIUS
),
ConfigurationActivity
.
PERIODIC_VIGNETTE_OUTER_RADIUS
),
bundle
.
getFloat
(
ConfigurationActivity
.
PERIODIC_VIGNETTE_OUTER_RADIUS
)));
bundle
.
getFloat
(
ConfigurationActivity
.
PERIODIC_VIGNETTE_OUTER_RADIUS
)));
}
}
if
(
selectedEffects
[
5
])
{
if
(
selectedEffects
[
6
])
{
effects
.
add
(
MatrixTransformationFactory
.
createSpin3dEffect
());
effects
.
add
(
MatrixTransformationFactory
.
createSpin3dEffect
());
}
}
if
(
selectedEffects
[
6
])
{
if
(
selectedEffects
[
7
])
{
effects
.
add
((
GlEffect
)
BitmapOverlayProcessor:
:
new
);
effects
.
add
((
GlEffect
)
BitmapOverlayProcessor:
:
new
);
}
}
if
(
selectedEffects
[
7
])
{
if
(
selectedEffects
[
8
])
{
effects
.
add
(
MatrixTransformationFactory
.
createZoomInTransition
());
effects
.
add
(
MatrixTransformationFactory
.
createZoomInTransition
());
}
}
transformerBuilder
.
setVideoEffects
(
effects
.
build
());
transformerBuilder
.
setVideoEffects
(
effects
.
build
());
...
...
demos/transformer/src/main/res/layout/rgb_adjustment_options.xml
0 → 100644
View file @
cfc0eef2
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright 2022 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"fill_parent"
android:layout_height=
"fill_parent"
tools:context=
".ConfigurationActivity"
>
<TableLayout
android:layout_width=
"fill_parent"
android:layout_height=
"wrap_content"
android:stretchColumns=
"1"
android:layout_marginTop=
"32dp"
android:measureWithLargestChild=
"true"
android:paddingLeft=
"24dp"
android:paddingRight=
"12dp"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintBottom_toBottomOf=
"parent"
>
<TableRow
android:layout_weight=
"1"
android:gravity=
"center_vertical"
>
<TextView
android:text=
"@string/rgb_adjustment_scale_red"
/>
<com.google.android.material.slider.Slider
android:id=
"@+id/rgb_adjustment_red_scale"
android:valueFrom=
"0"
android:value=
"1"
android:valueTo=
"2"
android:layout_gravity=
"right"
app:labelBehavior=
"gone"
/>
</TableRow>
<TableRow
android:layout_weight=
"1"
android:gravity=
"center_vertical"
>
<TextView
android:text=
"@string/rgb_adjustment_scale_green"
/>
<com.google.android.material.slider.Slider
android:id=
"@+id/rgb_adjustment_green_scale"
android:valueFrom=
"0"
android:value=
"1"
android:valueTo=
"2"
android:layout_gravity=
"right"
app:labelBehavior=
"gone"
/>
</TableRow>
<TableRow
android:layout_weight=
"1"
android:gravity=
"center_vertical"
>
<TextView
android:text=
"@string/rgb_adjustment_scale_blue"
/>
<com.google.android.material.slider.Slider
android:id=
"@+id/rgb_adjustment_blue_scale"
android:valueFrom=
"0"
android:value=
"1"
android:valueTo=
"2"
android:layout_gravity=
"right"
app:labelBehavior=
"gone"
/>
</TableRow>
</TableLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
demos/transformer/src/main/res/values/strings.xml
View file @
cfc0eef2
...
@@ -48,6 +48,10 @@
...
@@ -48,6 +48,10 @@
<item>
Sepia
</item>
<item>
Sepia
</item>
</string-array>
</string-array>
<string
name=
"contrast_value"
translatable=
"false"
>
Contrast value
</string>
<string
name=
"contrast_value"
translatable=
"false"
>
Contrast value
</string>
<string
name=
"rgb_adjustment_options"
translatable=
"false"
>
Scale RGB Channels individually
</string>
<string
name=
"rgb_adjustment_scale_red"
translatable=
"false"
>
Scale Red
</string>
<string
name=
"rgb_adjustment_scale_green"
translatable=
"false"
>
Scale Green
</string>
<string
name=
"rgb_adjustment_scale_blue"
translatable=
"false"
>
Scale Blue
</string>
<string
name=
"center_x"
>
Center X
</string>
<string
name=
"center_x"
>
Center X
</string>
<string
name=
"center_y"
>
Center Y
</string>
<string
name=
"center_y"
>
Center Y
</string>
<string
name=
"radius_range"
>
Radius range
</string>
<string
name=
"radius_range"
>
Radius range
</string>
...
...
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