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
0760520b
authored
Apr 25, 2022
by
huangdarwin
Committed by
Ian Baker
Apr 26, 2022
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
FrameProcessor: Avoid early rounding in Presentation output dimensions.
PiperOrigin-RevId: 444253425
parent
40c27c43
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
15 deletions
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/PresentationFrameProcessor.java
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/PresentationFrameProcessor.java
View file @
0760520b
...
@@ -231,8 +231,9 @@ public final class PresentationFrameProcessor implements GlFrameProcessor {
...
@@ -231,8 +231,9 @@ public final class PresentationFrameProcessor implements GlFrameProcessor {
private
final
float
requestedAspectRatio
;
private
final
float
requestedAspectRatio
;
private
final
@Layout
int
layout
;
private
final
@Layout
int
layout
;
private
int
outputWidth
;
private
float
outputWidth
;
private
int
outputHeight
;
private
float
outputHeight
;
private
@MonotonicNonNull
Size
outputSize
;
private
@MonotonicNonNull
Matrix
transformationMatrix
;
private
@MonotonicNonNull
Matrix
transformationMatrix
;
private
@MonotonicNonNull
AdvancedFrameProcessor
advancedFrameProcessor
;
private
@MonotonicNonNull
AdvancedFrameProcessor
advancedFrameProcessor
;
...
@@ -268,10 +269,10 @@ public final class PresentationFrameProcessor implements GlFrameProcessor {
...
@@ -268,10 +269,10 @@ public final class PresentationFrameProcessor implements GlFrameProcessor {
@Override
@Override
public
Size
getOutputSize
()
{
public
Size
getOutputSize
()
{
checkState
(
checkState
NotNull
(
output
Width
!=
C
.
LENGTH_UNSET
&&
outputHeight
!=
C
.
LENGTH_UNSET
,
output
Size
,
"configureOutputSizeAndTransformationMatrix must be called before getOutputSize"
);
"configureOutputSizeAndTransformationMatrix must be called before getOutputSize"
);
return
new
Size
(
outputWidth
,
outputHeight
)
;
return
outputSize
;
}
}
@Override
@Override
...
@@ -307,9 +308,10 @@ public final class PresentationFrameProcessor implements GlFrameProcessor {
...
@@ -307,9 +308,10 @@ public final class PresentationFrameProcessor implements GlFrameProcessor {
// Scale width and height to desired requestedHeightPixels, preserving aspect ratio.
// Scale width and height to desired requestedHeightPixels, preserving aspect ratio.
if
(
requestedHeightPixels
!=
C
.
LENGTH_UNSET
&&
requestedHeightPixels
!=
outputHeight
)
{
if
(
requestedHeightPixels
!=
C
.
LENGTH_UNSET
&&
requestedHeightPixels
!=
outputHeight
)
{
outputWidth
=
Math
.
round
((
float
)
requestedHeightPixels
*
outputWidth
/
outputHeight
)
;
outputWidth
=
requestedHeightPixels
*
outputWidth
/
outputHeight
;
outputHeight
=
requestedHeightPixels
;
outputHeight
=
requestedHeightPixels
;
}
}
outputSize
=
new
Size
(
Math
.
round
(
outputWidth
),
Math
.
round
(
outputHeight
));
}
}
@RequiresNonNull
(
"transformationMatrix"
)
@RequiresNonNull
(
"transformationMatrix"
)
...
@@ -322,34 +324,34 @@ public final class PresentationFrameProcessor implements GlFrameProcessor {
...
@@ -322,34 +324,34 @@ public final class PresentationFrameProcessor implements GlFrameProcessor {
transformationMatrix
.
postTranslate
(-
centerX
,
-
centerY
);
transformationMatrix
.
postTranslate
(-
centerX
,
-
centerY
);
transformationMatrix
.
postScale
(
1
f
/
scaleX
,
1
f
/
scaleY
);
transformationMatrix
.
postScale
(
1
f
/
scaleX
,
1
f
/
scaleY
);
outputWidth
=
Math
.
round
(
outputWidth
*
scaleX
)
;
outputWidth
=
outputWidth
*
scaleX
;
outputHeight
=
Math
.
round
(
outputHeight
*
scaleY
)
;
outputHeight
=
outputHeight
*
scaleY
;
}
}
@RequiresNonNull
(
"transformationMatrix"
)
@RequiresNonNull
(
"transformationMatrix"
)
private
void
applyAspectRatio
()
{
private
void
applyAspectRatio
()
{
float
inputAspectRatio
=
(
float
)
outputWidth
/
outputHeight
;
float
inputAspectRatio
=
outputWidth
/
outputHeight
;
if
(
layout
==
LAYOUT_SCALE_TO_FIT
)
{
if
(
layout
==
LAYOUT_SCALE_TO_FIT
)
{
if
(
requestedAspectRatio
>
inputAspectRatio
)
{
if
(
requestedAspectRatio
>
inputAspectRatio
)
{
transformationMatrix
.
setScale
(
inputAspectRatio
/
requestedAspectRatio
,
1
f
);
transformationMatrix
.
setScale
(
inputAspectRatio
/
requestedAspectRatio
,
1
f
);
outputWidth
=
Math
.
round
(
outputHeight
*
requestedAspectRatio
)
;
outputWidth
=
outputHeight
*
requestedAspectRatio
;
}
else
{
}
else
{
transformationMatrix
.
setScale
(
1
f
,
requestedAspectRatio
/
inputAspectRatio
);
transformationMatrix
.
setScale
(
1
f
,
requestedAspectRatio
/
inputAspectRatio
);
outputHeight
=
Math
.
round
(
outputWidth
/
requestedAspectRatio
)
;
outputHeight
=
outputWidth
/
requestedAspectRatio
;
}
}
}
else
if
(
layout
==
LAYOUT_SCALE_TO_FIT_WITH_CROP
)
{
}
else
if
(
layout
==
LAYOUT_SCALE_TO_FIT_WITH_CROP
)
{
if
(
requestedAspectRatio
>
inputAspectRatio
)
{
if
(
requestedAspectRatio
>
inputAspectRatio
)
{
transformationMatrix
.
setScale
(
1
f
,
requestedAspectRatio
/
inputAspectRatio
);
transformationMatrix
.
setScale
(
1
f
,
requestedAspectRatio
/
inputAspectRatio
);
outputHeight
=
Math
.
round
(
outputWidth
/
requestedAspectRatio
)
;
outputHeight
=
outputWidth
/
requestedAspectRatio
;
}
else
{
}
else
{
transformationMatrix
.
setScale
(
inputAspectRatio
/
requestedAspectRatio
,
1
f
);
transformationMatrix
.
setScale
(
inputAspectRatio
/
requestedAspectRatio
,
1
f
);
outputWidth
=
Math
.
round
(
outputHeight
*
requestedAspectRatio
)
;
outputWidth
=
outputHeight
*
requestedAspectRatio
;
}
}
}
else
if
(
layout
==
LAYOUT_STRETCH_TO_FIT
)
{
}
else
if
(
layout
==
LAYOUT_STRETCH_TO_FIT
)
{
if
(
requestedAspectRatio
>
inputAspectRatio
)
{
if
(
requestedAspectRatio
>
inputAspectRatio
)
{
outputWidth
=
Math
.
round
(
outputHeight
*
requestedAspectRatio
)
;
outputWidth
=
outputHeight
*
requestedAspectRatio
;
}
else
{
}
else
{
outputHeight
=
Math
.
round
(
outputWidth
/
requestedAspectRatio
)
;
outputHeight
=
outputWidth
/
requestedAspectRatio
;
}
}
}
}
}
}
...
...
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