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
0d8a3656
Commit
0d8a3656
authored
Oct 02, 2014
by
Vittorio Giovara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mov: support the Color Parameter Atoms 'colr'
parent
586ea037
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
0 deletions
+69
-0
mov.c
libavformat/mov.c
+69
-0
No files found.
libavformat/mov.c
View file @
0d8a3656
...
...
@@ -887,6 +887,74 @@ static int mov_read_enda(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return
0
;
}
static
int
mov_read_colr
(
MOVContext
*
c
,
AVIOContext
*
pb
,
MOVAtom
atom
)
{
AVStream
*
st
;
char
color_parameter_type
[
5
]
=
{
0
};
int
color_primaries
,
color_trc
,
color_matrix
;
if
(
c
->
fc
->
nb_streams
<
1
)
return
0
;
st
=
c
->
fc
->
streams
[
c
->
fc
->
nb_streams
-
1
];
avio_read
(
pb
,
color_parameter_type
,
4
);
if
(
strncmp
(
color_parameter_type
,
"nclx"
,
4
)
&&
strncmp
(
color_parameter_type
,
"nclc"
,
4
))
{
av_log
(
c
->
fc
,
AV_LOG_WARNING
,
"unsupported color_parameter_type %s
\n
"
,
color_parameter_type
);
return
0
;
}
color_primaries
=
avio_rb16
(
pb
);
color_trc
=
avio_rb16
(
pb
);
color_matrix
=
avio_rb16
(
pb
);
av_dlog
(
c
->
fc
,
"%s: pri %"
PRIu16
" trc %"
PRIu16
" matrix %"
PRIu16
""
,
color_parameter_type
,
color_primaries
,
color_trc
,
color_matrix
);
if
(
c
->
isom
)
{
uint8_t
color_range
=
avio_r8
(
pb
)
>>
7
;
av_dlog
(
c
->
fc
,
" full %"
PRIu8
""
,
color_range
)
if
(
color_range
)
st
->
codec
->
color_range
=
AVCOL_RANGE_JPEG
;
else
st
->
codec
->
color_range
=
AVCOL_RANGE_MPEG
;
/* 14496-12 references JPEG XR specs (rather than the more complete
* 23001-8) so some adjusting is required */
if
(
color_primaries
>=
AVCOL_PRI_FILM
)
color_primaries
=
AVCOL_PRI_UNSPECIFIED
;
if
(
color_trc
>=
AVCOL_TRC_LINEAR
||
color_trc
<=
AVCOL_TRC_LOG_SQRT
||
color_trc
>=
AVCOL_TRC_BT2020_10
)
color_trc
=
AVCOL_TRC_UNSPECIFIED
;
if
(
color_matrix
>=
AVCOL_SPC_BT2020_NCL
)
color_matrix
=
AVCOL_SPC_UNSPECIFIED
;
st
->
codec
->
color_primaries
=
color_primaries
;
st
->
codec
->
color_trc
=
color_trc
;
st
->
codec
->
colorspace
=
color_matrix
;
}
else
{
/* color primaries, Table 4-4 */
switch
(
color_primaries
)
{
case
1
:
st
->
codec
->
color_primaries
=
AVCOL_PRI_BT709
;
break
;
case
5
:
st
->
codec
->
color_primaries
=
AVCOL_PRI_SMPTE170M
;
break
;
case
6
:
st
->
codec
->
color_primaries
=
AVCOL_PRI_SMPTE240M
;
break
;
}
/* color transfer, Table 4-5 */
switch
(
color_trc
)
{
case
1
:
st
->
codec
->
color_trc
=
AVCOL_TRC_BT709
;
break
;
case
7
:
st
->
codec
->
color_trc
=
AVCOL_TRC_SMPTE240M
;
break
;
}
/* color matrix, Table 4-6 */
switch
(
color_matrix
)
{
case
1
:
st
->
codec
->
colorspace
=
AVCOL_SPC_BT709
;
break
;
case
6
:
st
->
codec
->
colorspace
=
AVCOL_SPC_BT470BG
;
break
;
case
7
:
st
->
codec
->
colorspace
=
AVCOL_SPC_SMPTE240M
;
break
;
}
}
av_dlog
(
c
->
fc
,
"
\n
"
)
return
0
;
}
static
int
mov_read_fiel
(
MOVContext
*
c
,
AVIOContext
*
pb
,
MOVAtom
atom
)
{
AVStream
*
st
;
...
...
@@ -2765,6 +2833,7 @@ static const MOVParseTableEntry mov_default_parse_table[] = {
{
MKTAG
(
'a'
,
'v'
,
's'
,
's'
),
mov_read_extradata
},
{
MKTAG
(
'c'
,
'h'
,
'p'
,
'l'
),
mov_read_chpl
},
{
MKTAG
(
'c'
,
'o'
,
'6'
,
'4'
),
mov_read_stco
},
{
MKTAG
(
'c'
,
'o'
,
'l'
,
'r'
),
mov_read_colr
},
{
MKTAG
(
'c'
,
't'
,
't'
,
's'
),
mov_read_ctts
},
/* composition time to sample */
{
MKTAG
(
'd'
,
'i'
,
'n'
,
'f'
),
mov_read_default
},
{
MKTAG
(
'd'
,
'r'
,
'e'
,
'f'
),
mov_read_dref
},
...
...
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