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
9df0d405
authored
Jul 29, 2022
by
leonwind
Committed by
Marc Baechinger
Oct 19, 2022
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add slider option for contrast in demo app
PiperOrigin-RevId: 464050072
parent
810f451e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
89 additions
and
11 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/contrast_options.xml
demos/transformer/src/main/res/values/strings.xml
demos/transformer/src/main/java/com/google/android/exoplayer2/transformerdemo/ConfigurationActivity.java
View file @
9df0d405
...
...
@@ -67,6 +67,7 @@ public final class ConfigurationActivity extends AppCompatActivity {
public
static
final
String
PERIODIC_VIGNETTE_CENTER_Y
=
"periodic_vignette_center_y"
;
public
static
final
String
PERIODIC_VIGNETTE_INNER_RADIUS
=
"periodic_vignette_inner_radius"
;
public
static
final
String
PERIODIC_VIGNETTE_OUTER_RADIUS
=
"periodic_vignette_outer_radius"
;
public
static
final
String
CONTRAST_VALUE
=
"contrast_value"
;
private
static
final
String
[]
INPUT_URIS
=
{
"https://storage.googleapis.com/exoplayer-test-media-1/mp4/android-screens-10s.mp4"
,
"https://storage.googleapis.com/exoplayer-test-media-0/android-block-1080-hevc.mp4"
,
...
...
@@ -100,13 +101,14 @@ public final class ConfigurationActivity extends AppCompatActivity {
private
static
final
String
[]
DEMO_EFFECTS
=
{
"Dizzy crop"
,
"Edge detector (Media Pipe)"
,
"Contrast"
,
"Periodic vignette"
,
"3D spin"
,
"Overlay logo & timer"
,
"Zoom in start"
,
"Increase contrast"
};
private
static
final
int
PERIODIC_VIGNETTE_INDEX
=
2
;
private
static
final
int
CONTRAST_INDEX
=
2
;
private
static
final
int
PERIODIC_VIGNETTE_INDEX
=
3
;
private
static
final
String
SAME_AS_INPUT_OPTION
=
"same as input"
;
private
static
final
float
HALF_DIAGONAL
=
1
f
/
(
float
)
Math
.
sqrt
(
2
);
...
...
@@ -130,6 +132,7 @@ public final class ConfigurationActivity extends AppCompatActivity {
private
int
inputUriPosition
;
private
long
trimStartMs
;
private
long
trimEndMs
;
private
float
contrastValue
;
private
float
periodicVignetteCenterX
;
private
float
periodicVignetteCenterY
;
private
float
periodicVignetteInnerRadius
;
...
...
@@ -285,6 +288,7 @@ public final class ConfigurationActivity extends AppCompatActivity {
ENABLE_REQUEST_SDR_TONE_MAPPING
,
enableRequestSdrToneMappingCheckBox
.
isChecked
());
bundle
.
putBoolean
(
ENABLE_HDR_EDITING
,
enableHdrEditingCheckBox
.
isChecked
());
bundle
.
putBooleanArray
(
DEMO_EFFECTS_SELECTIONS
,
demoEffectsSelections
);
bundle
.
putFloat
(
CONTRAST_VALUE
,
contrastValue
);
bundle
.
putFloat
(
PERIODIC_VIGNETTE_CENTER_X
,
periodicVignetteCenterX
);
bundle
.
putFloat
(
PERIODIC_VIGNETTE_CENTER_Y
,
periodicVignetteCenterY
);
bundle
.
putFloat
(
PERIODIC_VIGNETTE_INNER_RADIUS
,
periodicVignetteInnerRadius
);
...
...
@@ -347,10 +351,35 @@ public final class ConfigurationActivity extends AppCompatActivity {
@RequiresNonNull
(
"demoEffectsSelections"
)
private
void
selectDemoEffect
(
DialogInterface
dialog
,
int
which
,
boolean
isChecked
)
{
demoEffectsSelections
[
which
]
=
isChecked
;
if
(!
isChecked
||
which
!=
PERIODIC_VIGNETTE_INDEX
)
{
if
(!
isChecked
)
{
return
;
}
switch
(
which
)
{
case
CONTRAST_INDEX:
controlContrastSettings
();
break
;
case
PERIODIC_VIGNETTE_INDEX:
controlPeriodicVignetteSettings
();
break
;
}
}
private
void
controlContrastSettings
()
{
View
dialogView
=
getLayoutInflater
().
inflate
(
R
.
layout
.
contrast_options
,
/* root= */
null
);
Slider
contrastSlider
=
checkNotNull
(
dialogView
.
findViewById
(
R
.
id
.
contrast_slider
));
new
AlertDialog
.
Builder
(
/* context= */
this
)
.
setView
(
dialogView
)
.
setPositiveButton
(
android
.
R
.
string
.
ok
,
(
DialogInterface
dialogInterface
,
int
i
)
->
{
contrastValue
=
contrastSlider
.
getValue
();
})
.
create
()
.
show
();
}
private
void
controlPeriodicVignetteSettings
()
{
View
dialogView
=
getLayoutInflater
().
inflate
(
R
.
layout
.
periodic_vignette_options
,
/* root= */
null
);
Slider
centerXSlider
=
...
...
demos/transformer/src/main/java/com/google/android/exoplayer2/transformerdemo/TransformerActivity.java
View file @
9df0d405
...
...
@@ -302,6 +302,9 @@ public final class TransformerActivity extends AppCompatActivity {
}
}
if
(
selectedEffects
[
2
])
{
effects
.
add
(
new
Contrast
(
bundle
.
getFloat
(
ConfigurationActivity
.
CONTRAST_VALUE
)));
}
if
(
selectedEffects
[
3
])
{
effects
.
add
(
(
GlEffect
)
(
Context
context
,
boolean
useHdr
)
->
...
...
@@ -316,18 +319,14 @@ public final class TransformerActivity extends AppCompatActivity {
ConfigurationActivity
.
PERIODIC_VIGNETTE_OUTER_RADIUS
),
bundle
.
getFloat
(
ConfigurationActivity
.
PERIODIC_VIGNETTE_OUTER_RADIUS
)));
}
if
(
selectedEffects
[
3
])
{
effects
.
add
(
MatrixTransformationFactory
.
createSpin3dEffect
());
}
if
(
selectedEffects
[
4
])
{
effects
.
add
(
(
GlEffect
)
BitmapOverlayProcessor:
:
new
);
effects
.
add
(
MatrixTransformationFactory
.
createSpin3dEffect
()
);
}
if
(
selectedEffects
[
5
])
{
effects
.
add
(
MatrixTransformationFactory
.
createZoomInTransition
()
);
effects
.
add
(
(
GlEffect
)
BitmapOverlayProcessor:
:
new
);
}
if
(
selectedEffects
[
6
])
{
// TODO(b/238630175): Add slider for contrast adjustments.
effects
.
add
(
new
Contrast
(
0.75f
));
effects
.
add
(
MatrixTransformationFactory
.
createZoomInTransition
());
}
transformerBuilder
.
setVideoEffects
(
effects
.
build
());
}
...
...
demos/transformer/src/main/res/layout/contrast_options.xml
0 → 100644
View file @
9df0d405
<?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/contrast_value"
/>
<com.google.android.material.slider.Slider
android:id=
"@+id/contrast_slider"
android:valueFrom=
"-1.0"
android:value=
"0.0"
android:valueTo=
"1.0"
android:layout_gravity=
"right"
/>
</TableRow>
</TableLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
demos/transformer/src/main/res/values/strings.xml
View file @
9df0d405
...
...
@@ -41,8 +41,9 @@
<string
name=
"transformation_timer"
translatable=
"false"
>
Transformation started %d seconds ago.
</string>
<string
name=
"transformation_completed"
translatable=
"false"
>
Transformation completed in %d seconds.
</string>
<string
name=
"transformation_error"
translatable=
"false"
>
Transformation error
</string>
<string
name=
"trim_range"
>
Bounds in seconds
</string>
<string
name=
"contrast_value"
translatable=
"false"
>
Contrast value
</string>
<string
name=
"center_x"
>
Center X
</string>
<string
name=
"center_y"
>
Center Y
</string>
<string
name=
"radius_range"
>
Radius range
</string>
<string
name=
"trim_range"
>
Bounds in seconds
</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