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
d66f0c51
authored
Jul 05, 2019
by
tonihei
Committed by
Toni
Jul 05, 2019
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
CEA608: no-op readability clean-up
PiperOrigin-RevId: 256676196
parent
fbb76243
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
36 deletions
library/core/src/main/java/com/google/android/exoplayer2/text/cea/Cea608Decoder.java
library/core/src/main/java/com/google/android/exoplayer2/text/cea/Cea608Decoder.java
View file @
d66f0c51
...
...
@@ -387,45 +387,27 @@ public final class Cea608Decoder extends CeaDecoder {
continue
;
}
// Special North American character set.
// ccData1 - 0|0|0|1|C|0|0|1
// ccData2 - 0|0|1|1|X|X|X|X
if
(((
ccData1
&
0xF7
)
==
0x11
)
&&
((
ccData2
&
0xF0
)
==
0x30
))
{
if
(
getChannel
(
ccData1
)
==
selectedChannel
)
{
currentCueBuilder
.
append
(
getSpecialChar
(
ccData2
));
}
if
(!
updateAndVerifyCurrentChannel
(
ccData1
))
{
// Wrong channel.
continue
;
}
// Extended Western European character set.
// ccData1 - 0|0|0|1|C|0|1|S
// ccData2 - 0|0|1|X|X|X|X|X
if
(((
ccData1
&
0xF6
)
==
0x12
)
&&
(
ccData2
&
0xE0
)
==
0x20
)
{
if
(
getChannel
(
ccData1
)
==
selectedChannel
)
{
// Remove standard equivalent of the special extended char before appending new one
if
(
isCtrlCode
(
ccData1
))
{
if
(
isSpecialChar
(
ccData1
,
ccData2
))
{
// Special North American character.
currentCueBuilder
.
append
(
getSpecialChar
(
ccData2
));
}
else
if
(
isExtendedWestEuropeanChar
(
ccData1
,
ccData2
))
{
// Extended West European character.
// Remove standard equivalent of the special extended char before appending new one.
currentCueBuilder
.
backspace
();
if
((
ccData1
&
0x01
)
==
0x00
)
{
// Extended Spanish/Miscellaneous and French character set (S = 0).
currentCueBuilder
.
append
(
getExtendedEsFrChar
(
ccData2
));
}
else
{
// Extended Portuguese and German/Danish character set (S = 1).
currentCueBuilder
.
append
(
getExtendedPtDeChar
(
ccData2
));
}
currentCueBuilder
.
append
(
getExtendedWestEuropeanChar
(
ccData1
,
ccData2
));
}
else
{
// Non-character control code.
handleCtrl
(
ccData1
,
ccData2
,
repeatedControlPossible
);
}
continue
;
}
// Control character.
// ccData1 - 0|0|0|X|X|X|X|X
if
((
ccData1
&
0xE0
)
==
0x00
)
{
handleCtrl
(
ccData1
,
ccData2
,
repeatedControlPossible
);
continue
;
}
if
(
currentChannel
!=
selectedChannel
)
{
continue
;
}
// Basic North American character set.
currentCueBuilder
.
append
(
getChar
(
ccData1
));
if
((
ccData2
&
0xE0
)
!=
0x00
)
{
...
...
@@ -440,8 +422,14 @@ public final class Cea608Decoder extends CeaDecoder {
}
}
private
boolean
updateAndVerifyCurrentChannel
(
byte
cc1
)
{
if
(
isCtrlCode
(
cc1
))
{
currentChannel
=
getChannel
(
cc1
);
}
return
currentChannel
==
selectedChannel
;
}
private
void
handleCtrl
(
byte
cc1
,
byte
cc2
,
boolean
repeatedControlPossible
)
{
currentChannel
=
getChannel
(
cc1
);
// Most control commands are sent twice in succession to ensure they are received properly. We
// don't want to process duplicate commands, so if we see the same repeatable command twice in a
// row then we ignore the second one.
...
...
@@ -459,10 +447,6 @@ public final class Cea608Decoder extends CeaDecoder {
}
}
if
(
currentChannel
!=
selectedChannel
)
{
return
;
}
if
(
isMidrowCtrlCode
(
cc1
,
cc2
))
{
handleMidrowCtrl
(
cc2
);
}
else
if
(
isPreambleAddressCode
(
cc1
,
cc2
))
{
...
...
@@ -681,11 +665,33 @@ public final class Cea608Decoder extends CeaDecoder {
return
(
char
)
BASIC_CHARACTER_SET
[
index
];
}
private
static
boolean
isSpecialChar
(
byte
cc1
,
byte
cc2
)
{
// cc1 - 0|0|0|1|C|0|0|1
// cc2 - 0|0|1|1|X|X|X|X
return
((
cc1
&
0xF7
)
==
0x11
)
&&
((
cc2
&
0xF0
)
==
0x30
);
}
private
static
char
getSpecialChar
(
byte
ccData
)
{
int
index
=
ccData
&
0x0F
;
return
(
char
)
SPECIAL_CHARACTER_SET
[
index
];
}
private
static
boolean
isExtendedWestEuropeanChar
(
byte
cc1
,
byte
cc2
)
{
// cc1 - 0|0|0|1|C|0|1|S
// cc2 - 0|0|1|X|X|X|X|X
return
((
cc1
&
0xF6
)
==
0x12
)
&&
((
cc2
&
0xE0
)
==
0x20
);
}
private
static
char
getExtendedWestEuropeanChar
(
byte
cc1
,
byte
cc2
)
{
if
((
cc1
&
0x01
)
==
0x00
)
{
// Extended Spanish/Miscellaneous and French character set (S = 0).
return
getExtendedEsFrChar
(
cc2
);
}
else
{
// Extended Portuguese and German/Danish character set (S = 1).
return
getExtendedPtDeChar
(
cc2
);
}
}
private
static
char
getExtendedEsFrChar
(
byte
ccData
)
{
int
index
=
ccData
&
0x1F
;
return
(
char
)
SPECIAL_ES_FR_CHARACTER_SET
[
index
];
...
...
@@ -696,6 +702,11 @@ public final class Cea608Decoder extends CeaDecoder {
return
(
char
)
SPECIAL_PT_DE_CHARACTER_SET
[
index
];
}
private
static
boolean
isCtrlCode
(
byte
cc1
)
{
// cc1 - 0|0|0|X|X|X|X|X
return
(
cc1
&
0xE0
)
==
0x00
;
}
private
static
int
getChannel
(
byte
cc1
)
{
// cc1 - X|X|X|X|C|X|X|X
return
(
cc1
>>
3
)
&
0x1
;
...
...
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