Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
6268034b
Commit
6268034b
authored
Aug 26, 2019
by
Matthieu Bouron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec/mediacodec_wrapper: use MediaFormat to probe frame color characteristics
parent
cde7818d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
100 additions
and
0 deletions
+100
-0
mediacodecdec_common.c
libavcodec/mediacodecdec_common.c
+100
-0
No files found.
libavcodec/mediacodecdec_common.c
View file @
6268034b
...
...
@@ -85,6 +85,85 @@
#define OUTPUT_DEQUEUE_TIMEOUT_US 8000
#define OUTPUT_DEQUEUE_BLOCK_TIMEOUT_US 1000000
enum
{
COLOR_RANGE_FULL
=
0x1
,
COLOR_RANGE_LIMITED
=
0x2
,
};
static
enum
AVColorRange
mcdec_get_color_range
(
int
color_range
)
{
switch
(
color_range
)
{
case
COLOR_RANGE_FULL
:
return
AVCOL_RANGE_JPEG
;
case
COLOR_RANGE_LIMITED
:
return
AVCOL_RANGE_MPEG
;
default:
return
AVCOL_RANGE_UNSPECIFIED
;
}
}
enum
{
COLOR_STANDARD_BT709
=
0x1
,
COLOR_STANDARD_BT601_PAL
=
0x2
,
COLOR_STANDARD_BT601_NTSC
=
0x4
,
COLOR_STANDARD_BT2020
=
0x6
,
};
static
enum
AVColorSpace
mcdec_get_color_space
(
int
color_standard
)
{
switch
(
color_standard
)
{
case
COLOR_STANDARD_BT709
:
return
AVCOL_SPC_BT709
;
case
COLOR_STANDARD_BT601_PAL
:
return
AVCOL_SPC_BT470BG
;
case
COLOR_STANDARD_BT601_NTSC
:
return
AVCOL_SPC_SMPTE170M
;
case
COLOR_STANDARD_BT2020
:
return
AVCOL_SPC_BT2020_NCL
;
default:
return
AVCOL_SPC_UNSPECIFIED
;
}
}
static
enum
AVColorPrimaries
mcdec_get_color_pri
(
int
color_standard
)
{
switch
(
color_standard
)
{
case
COLOR_STANDARD_BT709
:
return
AVCOL_PRI_BT709
;
case
COLOR_STANDARD_BT601_PAL
:
return
AVCOL_PRI_BT470BG
;
case
COLOR_STANDARD_BT601_NTSC
:
return
AVCOL_PRI_SMPTE170M
;
case
COLOR_STANDARD_BT2020
:
return
AVCOL_PRI_BT2020
;
default:
return
AVCOL_PRI_UNSPECIFIED
;
}
}
enum
{
COLOR_TRANSFER_LINEAR
=
0x1
,
COLOR_TRANSFER_SDR_VIDEO
=
0x3
,
COLOR_TRANSFER_ST2084
=
0x6
,
COLOR_TRANSFER_HLG
=
0x7
,
};
static
enum
AVColorTransferCharacteristic
mcdec_get_color_trc
(
int
color_transfer
)
{
switch
(
color_transfer
)
{
case
COLOR_TRANSFER_LINEAR
:
return
AVCOL_TRC_LINEAR
;
case
COLOR_TRANSFER_SDR_VIDEO
:
return
AVCOL_TRC_SMPTE170M
;
case
COLOR_TRANSFER_ST2084
:
return
AVCOL_TRC_SMPTEST2084
;
case
COLOR_TRANSFER_HLG
:
return
AVCOL_TRC_ARIB_STD_B67
;
default:
return
AVCOL_TRC_UNSPECIFIED
;
}
}
enum
{
COLOR_FormatYUV420Planar
=
0x13
,
COLOR_FormatYUV420SemiPlanar
=
0x15
,
...
...
@@ -220,6 +299,10 @@ FF_DISABLE_DEPRECATION_WARNINGS
FF_ENABLE_DEPRECATION_WARNINGS
#endif
frame
->
pkt_dts
=
AV_NOPTS_VALUE
;
frame
->
color_range
=
avctx
->
color_range
;
frame
->
color_primaries
=
avctx
->
color_primaries
;
frame
->
color_trc
=
avctx
->
color_trc
;
frame
->
colorspace
=
avctx
->
colorspace
;
buffer
=
av_mallocz
(
sizeof
(
AVMediaCodecBuffer
));
if
(
!
buffer
)
{
...
...
@@ -368,6 +451,9 @@ static int mediacodec_dec_parse_format(AVCodecContext *avctx, MediaCodecDecConte
int
ret
=
0
;
int
width
=
0
;
int
height
=
0
;
int
color_range
=
0
;
int
color_standard
=
0
;
int
color_transfer
=
0
;
char
*
format
=
NULL
;
if
(
!
s
->
format
)
{
...
...
@@ -426,6 +512,20 @@ static int mediacodec_dec_parse_format(AVCodecContext *avctx, MediaCodecDecConte
ff_set_sar
(
avctx
,
sar
);
}
AMEDIAFORMAT_GET_INT32
(
color_range
,
"color-range"
,
0
);
if
(
color_range
)
avctx
->
color_range
=
mcdec_get_color_range
(
color_range
);
AMEDIAFORMAT_GET_INT32
(
color_standard
,
"color-standard"
,
0
);
if
(
color_standard
)
{
avctx
->
colorspace
=
mcdec_get_color_space
(
color_standard
);
avctx
->
color_primaries
=
mcdec_get_color_pri
(
color_standard
);
}
AMEDIAFORMAT_GET_INT32
(
color_transfer
,
"color-transfer"
,
0
);
if
(
color_transfer
)
avctx
->
color_trc
=
mcdec_get_color_trc
(
color_transfer
);
av_log
(
avctx
,
AV_LOG_INFO
,
"Output crop parameters top=%d bottom=%d left=%d right=%d, "
"resulting dimensions width=%d height=%d
\n
"
,
...
...
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