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
ccd8856d
authored
Feb 14, 2023
by
samrobinson
Committed by
Andrew Lewis
Feb 15, 2023
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Preserve aspect ratio when scaling resolution is insufficient.
PiperOrigin-RevId: 509546771
parent
ccdb3b70
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
3 deletions
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/EncoderUtil.java
library/transformer/src/test/java/com/google/android/exoplayer2/transformer/EncoderUtilTest.java
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/EncoderUtil.java
View file @
ccd8856d
...
...
@@ -250,9 +250,8 @@ public final class EncoderUtil {
}
}
// Fix frame being too wide or too tall.
width
=
videoCapabilities
.
getSupportedWidths
().
clamp
(
width
);
int
adjustedHeight
=
videoCapabilities
.
getSupportedHeightsFor
(
width
).
clamp
(
height
);
int
supportedWidth
=
videoCapabilities
.
getSupportedWidths
().
clamp
(
width
);
int
adjustedHeight
=
videoCapabilities
.
getSupportedHeightsFor
(
supportedWidth
).
clamp
(
height
);
if
(
adjustedHeight
!=
height
)
{
width
=
alignResolution
((
int
)
round
((
double
)
width
*
adjustedHeight
/
height
),
widthAlignment
);
...
...
library/transformer/src/test/java/com/google/android/exoplayer2/transformer/EncoderUtilTest.java
View file @
ccd8856d
...
...
@@ -164,6 +164,23 @@ public class EncoderUtilTest {
assertThat
(
closestSupportedResolution
.
getHeight
()).
isEqualTo
(
1080
);
}
@Test
public
void
getSupportedResolution_requestedReallyLarge_matchesAspectRatio
()
{
ImmutableList
<
MediaCodecInfo
>
supportedEncoders
=
EncoderUtil
.
getSupportedEncoders
(
MIME_TYPE
);
MediaCodecInfo
encoderInfo
=
supportedEncoders
.
get
(
0
);
double
aspectRatio
=
1.5
;
@Nullable
Size
closestSupportedResolution
=
EncoderUtil
.
getSupportedResolution
(
encoderInfo
,
MIME_TYPE
,
(
int
)
(
aspectRatio
*
5000
),
5000
);
assertThat
(
closestSupportedResolution
).
isNotNull
();
assertThat
(
(
double
)
closestSupportedResolution
.
getWidth
()
/
closestSupportedResolution
.
getHeight
())
.
isEqualTo
(
aspectRatio
);
}
/**
* @see EncoderUtil#getSupportedEncodersForHdrEditing(String, ColorInfo)
*/
...
...
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