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
475b1fe3
authored
Mar 25, 2021
by
Denise LaFayette
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Address code review comments
parent
4be774aa
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
14 deletions
library/core/src/main/java/com/google/android/exoplayer2/text/ttml/TtmlDecoder.java
library/ui/src/main/java/com/google/android/exoplayer2/ui/WebViewSubtitleOutput.java
library/core/src/main/java/com/google/android/exoplayer2/text/ttml/TtmlDecoder.java
View file @
475b1fe3
...
...
@@ -615,13 +615,9 @@ public final class TtmlDecoder extends SimpleSubtitleDecoder {
style
=
createIfNull
(
style
)
.
setTextEmphasis
(
TextEmphasis
.
parse
(
Util
.
toLowerInvariant
(
attributeValue
)));
break
;
case
TtmlNode
.
ATTR_TTS_SHEAR
:
style
=
createIfNull
(
style
);
try
{
parseShear
(
attributeValue
,
style
);
}
catch
(
SubtitleDecoderException
e
)
{
Log
.
w
(
TAG
,
"Failed parsing shear value: "
+
attributeValue
);
}
style
=
createIfNull
(
style
).
setShearPercentage
(
parseShear
(
attributeValue
));
break
;
default
:
// ignore
...
...
@@ -764,25 +760,25 @@ public final class TtmlDecoder extends SimpleSubtitleDecoder {
}
}
private
static
void
parseShear
(
String
expression
,
TtmlStyle
out
)
throws
SubtitleDecoderException
{
private
static
float
parseShear
(
String
expression
)
{
Matcher
matcher
=
SIGNED_PERCENTAGE
.
matcher
(
expression
);
if
(
matcher
.
matches
())
{
try
{
float
value
=
Float
.
parseFloat
(
matcher
.
group
(
1
));
String
percentage
=
Assertions
.
checkNotNull
(
matcher
.
group
(
1
));
float
value
=
Float
.
parseFloat
(
percentage
);
// https://www.w3.org/TR/2018/REC-ttml2-20181108/#semantics-style-procedures-shear
// If the absolute value of the specified percentage is greater than 100%, then it must be
// interpreted as if 100% were specified with the appropriate sign.
value
=
Math
.
max
(-
100
f
,
value
);
value
=
Math
.
min
(
100
f
,
value
);
out
.
setShearPercentage
(
value
)
;
return
value
;
}
catch
(
NumberFormatException
e
)
{
throw
new
SubtitleDecoderException
(
"Invalid expression for shear: '"
+
expression
+
"'."
,
e
);
Log
.
w
(
TAG
,
"NumberFormatException while parsing shear: "
+
expression
);
}
}
else
{
throw
new
SubtitleDecoderException
(
"Invalid expression for shear: '"
+
expression
+
"'."
);
Log
.
w
(
TAG
,
"Invalid value for shear: "
+
expression
);
}
return
0
f
;
}
/**
...
...
library/ui/src/main/java/com/google/android/exoplayer2/ui/WebViewSubtitleOutput.java
View file @
475b1fe3
...
...
@@ -326,7 +326,7 @@ import java.util.Map;
String
direction
=
(
cue
.
verticalType
==
Cue
.
VERTICAL_TYPE_LR
||
cue
.
verticalType
==
Cue
.
VERTICAL_TYPE_RL
)
?
"skewY"
:
"skewX"
;
return
Util
.
formatInvariant
(
"
%s(%.2fdeg)"
,
direction
,
cue
.
shearDegrees
);
return
Util
.
formatInvariant
(
"%s(%.2fdeg)"
,
direction
,
cue
.
shearDegrees
);
}
return
""
;
}
...
...
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