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
2e8d4c91
authored
May 25, 2021
by
aquilescanta
Committed by
Oliver Woodman
May 26, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Extract function for mapping ColorInfo-related constants
PiperOrigin-RevId: 375705247
parent
4e5e654e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
29 deletions
library/common/src/main/java/com/google/android/exoplayer2/video/ColorInfo.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/MatroskaExtractor.java
library/common/src/main/java/com/google/android/exoplayer2/video/ColorInfo.java
View file @
2e8d4c91
...
...
@@ -22,11 +22,57 @@ import com.google.android.exoplayer2.C;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.util.Util
;
import
java.util.Arrays
;
import
org.checkerframework.dataflow.qual.Pure
;
/** Stores color info. */
public
final
class
ColorInfo
implements
Parcelable
{
/**
* Returns the {@link C.ColorSpace} corresponding to the given ISO color primary code, as per
* table A.7.21.1 in Rec. ITU-T T.832 (03/2009), or {@link Format#NO_VALUE} if no mapping can be
* made.
*/
@Pure
@C
.
ColorSpace
public
static
int
isoColorPrimariesToColorSpace
(
int
isoColorPrimaries
)
{
switch
(
isoColorPrimaries
)
{
case
1
:
return
C
.
COLOR_SPACE_BT709
;
case
4
:
// BT.470M.
case
5
:
// BT.470BG.
case
6
:
// SMPTE 170M.
case
7
:
// SMPTE 240M.
return
C
.
COLOR_SPACE_BT601
;
case
9
:
return
C
.
COLOR_SPACE_BT2020
;
default
:
return
Format
.
NO_VALUE
;
}
}
/**
* Returns the {@link C.ColorTransfer} corresponding to the given ISO transfer characteristics
* code, as per table A.7.21.2 in Rec. ITU-T T.832 (03/2009), or {@link Format#NO_VALUE} if no
* mapping can be made.
*/
@Pure
@C
.
ColorTransfer
public
static
int
isoTransferCharacteristicsToColorTransfer
(
int
isoTransferCharacteristics
)
{
switch
(
isoTransferCharacteristics
)
{
case
1
:
// BT.709.
case
6
:
// SMPTE 170M.
case
7
:
// SMPTE 240M.
return
C
.
COLOR_TRANSFER_SDR
;
case
16
:
return
C
.
COLOR_TRANSFER_ST2084
;
case
18
:
return
C
.
COLOR_TRANSFER_HLG
;
default
:
return
Format
.
NO_VALUE
;
}
}
/**
* The color space of the video. Valid values are {@link C#COLOR_SPACE_BT601}, {@link
* C#COLOR_SPACE_BT709}, {@link C#COLOR_SPACE_BT2020} or {@link Format#NO_VALUE} if unknown.
*/
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/MatroskaExtractor.java
View file @
2e8d4c91
...
...
@@ -931,39 +931,16 @@ public class MatroskaExtractor implements Extractor {
case
ID_COLOUR_PRIMARIES:
assertInTrackEntry
(
id
);
currentTrack
.
hasColorInfo
=
true
;
switch
((
int
)
value
)
{
case
1
:
currentTrack
.
colorSpace
=
C
.
COLOR_SPACE_BT709
;
break
;
case
4
:
// BT.470M.
case
5
:
// BT.470BG.
case
6
:
// SMPTE 170M.
case
7
:
// SMPTE 240M.
currentTrack
.
colorSpace
=
C
.
COLOR_SPACE_BT601
;
break
;
case
9
:
currentTrack
.
colorSpace
=
C
.
COLOR_SPACE_BT2020
;
break
;
default
:
break
;
int
colorSpace
=
ColorInfo
.
isoColorPrimariesToColorSpace
((
int
)
value
);
if
(
colorSpace
!=
Format
.
NO_VALUE
)
{
currentTrack
.
colorSpace
=
colorSpace
;
}
break
;
case
ID_COLOUR_TRANSFER:
assertInTrackEntry
(
id
);
switch
((
int
)
value
)
{
case
1
:
// BT.709.
case
6
:
// SMPTE 170M.
case
7
:
// SMPTE 240M.
currentTrack
.
colorTransfer
=
C
.
COLOR_TRANSFER_SDR
;
break
;
case
16
:
currentTrack
.
colorTransfer
=
C
.
COLOR_TRANSFER_ST2084
;
break
;
case
18
:
currentTrack
.
colorTransfer
=
C
.
COLOR_TRANSFER_HLG
;
break
;
default
:
break
;
int
colorTransfer
=
ColorInfo
.
isoTransferCharacteristicsToColorTransfer
((
int
)
value
);
if
(
colorTransfer
!=
Format
.
NO_VALUE
)
{
currentTrack
.
colorTransfer
=
colorTransfer
;
}
break
;
case
ID_COLOUR_RANGE:
...
...
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