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
5725ebbe
authored
Sep 23, 2022
by
leonwind
Committed by
Marc Baechinger
Oct 19, 2022
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add HSL Adjustments to the demo.
PiperOrigin-RevId: 476373520
parent
09691180
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
126 additions
and
3 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/hsl_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 @
5725ebbe
...
...
@@ -72,6 +72,9 @@ public final class ConfigurationActivity extends AppCompatActivity {
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
String
HSL_ADJUSTMENTS_HUE
=
"hsl_adjustments_hue"
;
public
static
final
String
HSL_ADJUSTMENTS_SATURATION
=
"hsl_adjustments_saturation"
;
public
static
final
String
HSL_ADJUSTMENTS_LIGHTNESS
=
"hsl_adjustments_lightness"
;
public
static
final
int
COLOR_FILTER_GRAYSCALE
=
0
;
public
static
final
int
COLOR_FILTER_INVERTED
=
1
;
public
static
final
int
COLOR_FILTER_SEPIA
=
2
;
...
...
@@ -110,6 +113,7 @@ public final class ConfigurationActivity extends AppCompatActivity {
"Edge detector (Media Pipe)"
,
"Color filters"
,
"RGB Adjustments"
,
"HSL Adjustments"
,
"Contrast"
,
"Periodic vignette"
,
"3D spin"
,
...
...
@@ -118,8 +122,9 @@ public final class ConfigurationActivity extends AppCompatActivity {
};
private
static
final
int
COLOR_FILTERS_INDEX
=
2
;
private
static
final
int
RGB_ADJUSTMENTS_INDEX
=
3
;
private
static
final
int
CONTRAST_INDEX
=
4
;
private
static
final
int
PERIODIC_VIGNETTE_INDEX
=
5
;
private
static
final
int
HSL_ADJUSTMENT_INDEX
=
4
;
private
static
final
int
CONTRAST_INDEX
=
5
;
private
static
final
int
PERIODIC_VIGNETTE_INDEX
=
6
;
private
static
final
String
SAME_AS_INPUT_OPTION
=
"same as input"
;
private
static
final
float
HALF_DIAGONAL
=
1
f
/
(
float
)
Math
.
sqrt
(
2
);
...
...
@@ -148,6 +153,9 @@ public final class ConfigurationActivity extends AppCompatActivity {
private
float
rgbAdjustmentGreenScale
;
private
float
rgbAdjustmentBlueScale
;
private
float
contrastValue
;
private
float
hueAdjustment
;
private
float
saturationAdjustment
;
private
float
lightnessAdjustment
;
private
float
periodicVignetteCenterX
;
private
float
periodicVignetteCenterY
;
private
float
periodicVignetteInnerRadius
;
...
...
@@ -308,6 +316,9 @@ public final class ConfigurationActivity extends AppCompatActivity {
bundle
.
putFloat
(
RGB_ADJUSTMENT_RED_SCALE
,
rgbAdjustmentRedScale
);
bundle
.
putFloat
(
RGB_ADJUSTMENT_GREEN_SCALE
,
rgbAdjustmentGreenScale
);
bundle
.
putFloat
(
RGB_ADJUSTMENT_BLUE_SCALE
,
rgbAdjustmentBlueScale
);
bundle
.
putFloat
(
HSL_ADJUSTMENTS_HUE
,
hueAdjustment
);
bundle
.
putFloat
(
HSL_ADJUSTMENTS_SATURATION
,
saturationAdjustment
);
bundle
.
putFloat
(
HSL_ADJUSTMENTS_LIGHTNESS
,
lightnessAdjustment
);
bundle
.
putFloat
(
PERIODIC_VIGNETTE_CENTER_X
,
periodicVignetteCenterX
);
bundle
.
putFloat
(
PERIODIC_VIGNETTE_CENTER_Y
,
periodicVignetteCenterY
);
bundle
.
putFloat
(
PERIODIC_VIGNETTE_INNER_RADIUS
,
periodicVignetteInnerRadius
);
...
...
@@ -384,6 +395,9 @@ public final class ConfigurationActivity extends AppCompatActivity {
case
CONTRAST_INDEX:
controlContrastSettings
();
break
;
case
HSL_ADJUSTMENT_INDEX:
controlHslAdjustmentSettings
();
break
;
case
PERIODIC_VIGNETTE_INDEX:
controlPeriodicVignetteSettings
();
break
;
...
...
@@ -441,6 +455,28 @@ public final class ConfigurationActivity extends AppCompatActivity {
.
show
();
}
private
void
controlHslAdjustmentSettings
()
{
View
dialogView
=
getLayoutInflater
().
inflate
(
R
.
layout
.
hsl_adjustment_options
,
/* root= */
null
);
Slider
hueAdjustmentSlider
=
checkNotNull
(
dialogView
.
findViewById
(
R
.
id
.
hsl_adjustments_hue
));
Slider
saturationAdjustmentSlider
=
checkNotNull
(
dialogView
.
findViewById
(
R
.
id
.
hsl_adjustments_saturation
));
Slider
lightnessAdjustmentSlider
=
checkNotNull
(
dialogView
.
findViewById
(
R
.
id
.
hsl_adjustment_lightness
));
new
AlertDialog
.
Builder
(
/* context= */
this
)
.
setTitle
(
R
.
string
.
hsl_adjustment_options
)
.
setView
(
dialogView
)
.
setPositiveButton
(
android
.
R
.
string
.
ok
,
(
DialogInterface
dialogInterface
,
int
i
)
->
{
hueAdjustment
=
hueAdjustmentSlider
.
getValue
();
saturationAdjustment
=
saturationAdjustmentSlider
.
getValue
();
lightnessAdjustment
=
lightnessAdjustmentSlider
.
getValue
();
})
.
create
()
.
show
();
}
private
void
controlPeriodicVignetteSettings
()
{
View
dialogView
=
getLayoutInflater
().
inflate
(
R
.
layout
.
periodic_vignette_options
,
/* root= */
null
);
...
...
demos/transformer/src/main/java/com/google/android/exoplayer2/transformerdemo/TransformerActivity.java
View file @
5725ebbe
...
...
@@ -40,6 +40,7 @@ import androidx.media3.common.Effect;
import
androidx.media3.effect.Contrast
;
import
androidx.media3.effect.GlEffect
;
import
androidx.media3.effect.GlTextureProcessor
;
import
androidx.media3.effect.HslAdjustment
;
import
androidx.media3.effect.RgbAdjustment
;
import
androidx.media3.effect.RgbFilter
;
import
androidx.media3.effect.RgbMatrix
;
...
...
@@ -345,9 +346,18 @@ public final class TransformerActivity extends AppCompatActivity {
.
build
());
}
if
(
selectedEffects
[
4
])
{
effects
.
add
(
new
Contrast
(
bundle
.
getFloat
(
ConfigurationActivity
.
CONTRAST_VALUE
)));
effects
.
add
(
new
HslAdjustment
.
Builder
()
.
adjustHue
(
bundle
.
getFloat
(
ConfigurationActivity
.
HSL_ADJUSTMENTS_HUE
))
.
adjustSaturation
(
bundle
.
getFloat
(
ConfigurationActivity
.
HSL_ADJUSTMENTS_SATURATION
))
.
adjustLightness
(
bundle
.
getFloat
(
ConfigurationActivity
.
HSL_ADJUSTMENTS_LIGHTNESS
))
.
build
());
}
if
(
selectedEffects
[
5
])
{
effects
.
add
(
new
Contrast
(
bundle
.
getFloat
(
ConfigurationActivity
.
CONTRAST_VALUE
)));
}
if
(
selectedEffects
[
6
])
{
effects
.
add
(
(
GlEffect
)
(
Context
context
,
boolean
useHdr
)
->
...
...
demos/transformer/src/main/res/layout/hsl_adjustment_options.xml
0 → 100644
View file @
5725ebbe
<?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/hue_adjustment"
/>
<com.google.android.material.slider.Slider
android:id=
"@+id/hsl_adjustments_hue"
android:valueFrom=
"-360"
android:value=
"0"
android:valueTo=
"360"
android:layout_gravity=
"right"
/>
</TableRow>
<TableRow
android:layout_weight=
"1"
android:gravity=
"center_vertical"
>
<TextView
android:text=
"@string/saturation_adjustment"
/>
<com.google.android.material.slider.Slider
android:id=
"@+id/hsl_adjustments_saturation"
android:valueFrom=
"-100"
android:value=
"0"
android:valueTo=
"100"
android:layout_gravity=
"right"
/>
</TableRow>
<TableRow
android:layout_weight=
"1"
android:gravity=
"center_vertical"
>
<TextView
android:text=
"@string/lightness_adjustment"
/>
<com.google.android.material.slider.Slider
android:id=
"@+id/hsl_adjustment_lightness"
android:valueFrom=
"-100"
android:value=
"0"
android:valueTo=
"100"
android:layout_gravity=
"right"
/>
</TableRow>
</TableLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
demos/transformer/src/main/res/values/strings.xml
View file @
5725ebbe
...
...
@@ -55,4 +55,8 @@
<string
name=
"center_x"
>
Center X
</string>
<string
name=
"center_y"
>
Center Y
</string>
<string
name=
"radius_range"
>
Radius range
</string>
<string
name=
"hsl_adjustment_options"
translatable=
"false"
>
HSL Adjustment Options
</string>
<string
name=
"hue_adjustment"
>
Hue Adjustment
</string>
<string
name=
"saturation_adjustment"
>
Saturation Adjustment
</string>
<string
name=
"lightness_adjustment"
>
Lightness Adjustment
</string>
</resources>
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