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
f937e40e
authored
Nov 03, 2020
by
ibaker
Committed by
Andrew Lewis
Nov 06, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Make Tx3gDecoder fields final, and remove unnecessary null-check
PiperOrigin-RevId: 340412910
parent
57c53c5a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
16 deletions
library/core/src/main/java/com/google/android/exoplayer2/text/tx3g/Tx3gDecoder.java
library/core/src/main/java/com/google/android/exoplayer2/text/tx3g/Tx3gDecoder.java
View file @
f937e40e
...
@@ -72,12 +72,12 @@ public final class Tx3gDecoder extends SimpleSubtitleDecoder {
...
@@ -72,12 +72,12 @@ public final class Tx3gDecoder extends SimpleSubtitleDecoder {
private
final
ParsableByteArray
parsableByteArray
;
private
final
ParsableByteArray
parsableByteArray
;
private
boolean
customVerticalPlacement
;
private
final
boolean
customVerticalPlacement
;
private
int
defaultFontFace
;
private
final
int
defaultFontFace
;
private
int
defaultColorRgba
;
private
final
int
defaultColorRgba
;
private
String
defaultFontFamily
;
private
final
String
defaultFontFamily
;
private
float
defaultVerticalPlacement
;
private
f
inal
f
loat
defaultVerticalPlacement
;
private
int
calculatedVideoTrackHeight
;
private
final
int
calculatedVideoTrackHeight
;
/**
/**
* Sets up a new {@link Tx3gDecoder} with default values.
* Sets up a new {@link Tx3gDecoder} with default values.
...
@@ -88,7 +88,7 @@ public final class Tx3gDecoder extends SimpleSubtitleDecoder {
...
@@ -88,7 +88,7 @@ public final class Tx3gDecoder extends SimpleSubtitleDecoder {
super
(
"Tx3gDecoder"
);
super
(
"Tx3gDecoder"
);
parsableByteArray
=
new
ParsableByteArray
();
parsableByteArray
=
new
ParsableByteArray
();
if
(
initializationData
!=
null
&&
initializationData
.
size
()
==
1
if
(
initializationData
.
size
()
==
1
&&
(
initializationData
.
get
(
0
).
length
==
48
||
initializationData
.
get
(
0
).
length
==
53
))
{
&&
(
initializationData
.
get
(
0
).
length
==
48
||
initializationData
.
get
(
0
).
length
==
53
))
{
byte
[]
initializationBytes
=
initializationData
.
get
(
0
);
byte
[]
initializationBytes
=
initializationData
.
get
(
0
);
defaultFontFace
=
initializationBytes
[
24
];
defaultFontFace
=
initializationBytes
[
24
];
...
@@ -105,8 +105,9 @@ public final class Tx3gDecoder extends SimpleSubtitleDecoder {
...
@@ -105,8 +105,9 @@ public final class Tx3gDecoder extends SimpleSubtitleDecoder {
if
(
customVerticalPlacement
)
{
if
(
customVerticalPlacement
)
{
int
requestedVerticalPlacement
=
((
initializationBytes
[
10
]
&
0xFF
)
<<
8
)
int
requestedVerticalPlacement
=
((
initializationBytes
[
10
]
&
0xFF
)
<<
8
)
|
(
initializationBytes
[
11
]
&
0xFF
);
|
(
initializationBytes
[
11
]
&
0xFF
);
defaultVerticalPlacement
=
(
float
)
requestedVerticalPlacement
/
calculatedVideoTrackHeight
;
defaultVerticalPlacement
=
defaultVerticalPlacement
=
Util
.
constrainValue
(
defaultVerticalPlacement
,
0.0f
,
0.95f
);
Util
.
constrainValue
(
(
float
)
requestedVerticalPlacement
/
calculatedVideoTrackHeight
,
0.0f
,
0.95f
);
}
else
{
}
else
{
defaultVerticalPlacement
=
DEFAULT_VERTICAL_PLACEMENT
;
defaultVerticalPlacement
=
DEFAULT_VERTICAL_PLACEMENT
;
}
}
...
@@ -116,6 +117,7 @@ public final class Tx3gDecoder extends SimpleSubtitleDecoder {
...
@@ -116,6 +117,7 @@ public final class Tx3gDecoder extends SimpleSubtitleDecoder {
defaultFontFamily
=
DEFAULT_FONT_FAMILY
;
defaultFontFamily
=
DEFAULT_FONT_FAMILY
;
customVerticalPlacement
=
false
;
customVerticalPlacement
=
false
;
defaultVerticalPlacement
=
DEFAULT_VERTICAL_PLACEMENT
;
defaultVerticalPlacement
=
DEFAULT_VERTICAL_PLACEMENT
;
calculatedVideoTrackHeight
=
C
.
LENGTH_UNSET
;
}
}
}
}
...
@@ -133,8 +135,7 @@ public final class Tx3gDecoder extends SimpleSubtitleDecoder {
...
@@ -133,8 +135,7 @@ public final class Tx3gDecoder extends SimpleSubtitleDecoder {
SPAN_PRIORITY_LOW
);
SPAN_PRIORITY_LOW
);
attachColor
(
cueText
,
defaultColorRgba
,
DEFAULT_COLOR
,
0
,
cueText
.
length
(),
attachColor
(
cueText
,
defaultColorRgba
,
DEFAULT_COLOR
,
0
,
cueText
.
length
(),
SPAN_PRIORITY_LOW
);
SPAN_PRIORITY_LOW
);
attachFontFamily
(
cueText
,
defaultFontFamily
,
DEFAULT_FONT_FAMILY
,
0
,
cueText
.
length
(),
attachFontFamily
(
cueText
,
defaultFontFamily
,
0
,
cueText
.
length
());
SPAN_PRIORITY_LOW
);
float
verticalPlacement
=
defaultVerticalPlacement
;
float
verticalPlacement
=
defaultVerticalPlacement
;
// Find and attach additional styles.
// Find and attach additional styles.
while
(
parsableByteArray
.
bytesLeft
()
>=
SIZE_ATOM_HEADER
)
{
while
(
parsableByteArray
.
bytesLeft
()
>=
SIZE_ATOM_HEADER
)
{
...
@@ -237,11 +238,14 @@ public final class Tx3gDecoder extends SimpleSubtitleDecoder {
...
@@ -237,11 +238,14 @@ public final class Tx3gDecoder extends SimpleSubtitleDecoder {
}
}
@SuppressWarnings
(
"ReferenceEquality"
)
@SuppressWarnings
(
"ReferenceEquality"
)
private
static
void
attachFontFamily
(
SpannableStringBuilder
cueText
,
String
fontFamily
,
private
static
void
attachFontFamily
(
String
defaultFontFamily
,
int
start
,
int
end
,
int
spanPriority
)
{
SpannableStringBuilder
cueText
,
String
fontFamily
,
int
start
,
int
end
)
{
if
(
fontFamily
!=
defaultFontFamily
)
{
if
(
fontFamily
!=
Tx3gDecoder
.
DEFAULT_FONT_FAMILY
)
{
cueText
.
setSpan
(
new
TypefaceSpan
(
fontFamily
),
start
,
end
,
cueText
.
setSpan
(
Spanned
.
SPAN_EXCLUSIVE_EXCLUSIVE
|
spanPriority
);
new
TypefaceSpan
(
fontFamily
),
start
,
end
,
Spanned
.
SPAN_EXCLUSIVE_EXCLUSIVE
|
Tx3gDecoder
.
SPAN_PRIORITY_LOW
);
}
}
}
}
...
...
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