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
9b8ac526
Commit
9b8ac526
authored
Sep 27, 2016
by
James Almer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avformat/matroskaenc: don't write an empty Colour master element
Signed-off-by:
James Almer
<
jamrial@gmail.com
>
parent
d2af93ac
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
19 deletions
+34
-19
matroskaenc.c
libavformat/matroskaenc.c
+34
-19
No files found.
libavformat/matroskaenc.c
View file @
9b8ac526
...
...
@@ -734,60 +734,73 @@ static int mkv_write_codecprivate(AVFormatContext *s, AVIOContext *pb,
}
static
int
mkv_write_video_color
(
AVIOContext
*
pb
,
AVCodecParameters
*
par
,
AVStream
*
st
)
{
AVIOContext
*
dyn_cp
;
uint8_t
*
colorinfo_ptr
;
int
side_data_size
=
0
;
int
ret
,
colorinfo_size
;
const
uint8_t
*
side_data
=
av_stream_get_side_data
(
st
,
AV_PKT_DATA_MASTERING_DISPLAY_METADATA
,
&
side_data_size
);
ebml_master
colorinfo
=
start_ebml_master
(
pb
,
MATROSKA_ID_VIDEOCOLOR
,
0
);
ret
=
avio_open_dyn_buf
(
&
dyn_cp
);
if
(
ret
<
0
)
return
ret
;
if
(
par
->
color_trc
!=
AVCOL_TRC_UNSPECIFIED
&&
par
->
color_trc
<
AVCOL_TRC_NB
)
{
put_ebml_uint
(
pb
,
MATROSKA_ID_VIDEOCOLORTRANSFERCHARACTERISTICS
,
put_ebml_uint
(
dyn_cp
,
MATROSKA_ID_VIDEOCOLORTRANSFERCHARACTERISTICS
,
par
->
color_trc
);
}
if
(
par
->
color_space
!=
AVCOL_SPC_UNSPECIFIED
&&
par
->
color_space
<
AVCOL_SPC_NB
)
{
put_ebml_uint
(
pb
,
MATROSKA_ID_VIDEOCOLORMATRIXCOEFF
,
par
->
color_space
);
put_ebml_uint
(
dyn_cp
,
MATROSKA_ID_VIDEOCOLORMATRIXCOEFF
,
par
->
color_space
);
}
if
(
par
->
color_primaries
!=
AVCOL_PRI_UNSPECIFIED
&&
par
->
color_primaries
<
AVCOL_PRI_NB
)
{
put_ebml_uint
(
pb
,
MATROSKA_ID_VIDEOCOLORPRIMARIES
,
par
->
color_primaries
);
put_ebml_uint
(
dyn_cp
,
MATROSKA_ID_VIDEOCOLORPRIMARIES
,
par
->
color_primaries
);
}
if
(
par
->
color_range
!=
AVCOL_RANGE_UNSPECIFIED
&&
par
->
color_range
<
AVCOL_RANGE_NB
)
{
put_ebml_uint
(
pb
,
MATROSKA_ID_VIDEOCOLORRANGE
,
par
->
color_range
);
put_ebml_uint
(
dyn_cp
,
MATROSKA_ID_VIDEOCOLORRANGE
,
par
->
color_range
);
}
if
(
side_data_size
==
sizeof
(
AVMasteringDisplayMetadata
))
{
ebml_master
meta_element
=
start_ebml_master
(
pb
,
MATROSKA_ID_VIDEOCOLORMASTERINGMETA
,
0
);
dyn_cp
,
MATROSKA_ID_VIDEOCOLORMASTERINGMETA
,
0
);
const
AVMasteringDisplayMetadata
*
metadata
=
(
const
AVMasteringDisplayMetadata
*
)
side_data
;
if
(
metadata
->
has_primaries
)
{
put_ebml_float
(
pb
,
MATROSKA_ID_VIDEOCOLOR_RX
,
put_ebml_float
(
dyn_cp
,
MATROSKA_ID_VIDEOCOLOR_RX
,
av_q2d
(
metadata
->
display_primaries
[
0
][
0
]));
put_ebml_float
(
pb
,
MATROSKA_ID_VIDEOCOLOR_RY
,
put_ebml_float
(
dyn_cp
,
MATROSKA_ID_VIDEOCOLOR_RY
,
av_q2d
(
metadata
->
display_primaries
[
0
][
1
]));
put_ebml_float
(
pb
,
MATROSKA_ID_VIDEOCOLOR_GX
,
put_ebml_float
(
dyn_cp
,
MATROSKA_ID_VIDEOCOLOR_GX
,
av_q2d
(
metadata
->
display_primaries
[
1
][
0
]));
put_ebml_float
(
pb
,
MATROSKA_ID_VIDEOCOLOR_GY
,
put_ebml_float
(
dyn_cp
,
MATROSKA_ID_VIDEOCOLOR_GY
,
av_q2d
(
metadata
->
display_primaries
[
1
][
1
]));
put_ebml_float
(
pb
,
MATROSKA_ID_VIDEOCOLOR_BX
,
put_ebml_float
(
dyn_cp
,
MATROSKA_ID_VIDEOCOLOR_BX
,
av_q2d
(
metadata
->
display_primaries
[
2
][
0
]));
put_ebml_float
(
pb
,
MATROSKA_ID_VIDEOCOLOR_BY
,
put_ebml_float
(
dyn_cp
,
MATROSKA_ID_VIDEOCOLOR_BY
,
av_q2d
(
metadata
->
display_primaries
[
2
][
1
]));
put_ebml_float
(
pb
,
MATROSKA_ID_VIDEOCOLOR_WHITEX
,
put_ebml_float
(
dyn_cp
,
MATROSKA_ID_VIDEOCOLOR_WHITEX
,
av_q2d
(
metadata
->
white_point
[
0
]));
put_ebml_float
(
pb
,
MATROSKA_ID_VIDEOCOLOR_WHITEY
,
put_ebml_float
(
dyn_cp
,
MATROSKA_ID_VIDEOCOLOR_WHITEY
,
av_q2d
(
metadata
->
white_point
[
1
]));
}
if
(
metadata
->
has_luminance
)
{
put_ebml_float
(
pb
,
MATROSKA_ID_VIDEOCOLOR_LUMINANCEMAX
,
put_ebml_float
(
dyn_cp
,
MATROSKA_ID_VIDEOCOLOR_LUMINANCEMAX
,
av_q2d
(
metadata
->
max_luminance
));
put_ebml_float
(
pb
,
MATROSKA_ID_VIDEOCOLOR_LUMINANCEMIN
,
put_ebml_float
(
dyn_cp
,
MATROSKA_ID_VIDEOCOLOR_LUMINANCEMIN
,
av_q2d
(
metadata
->
min_luminance
));
}
end_ebml_master
(
pb
,
meta_element
);
end_ebml_master
(
dyn_cp
,
meta_element
);
}
end_ebml_master
(
pb
,
colorinfo
);
colorinfo_size
=
avio_close_dyn_buf
(
dyn_cp
,
&
colorinfo_ptr
);
if
(
colorinfo_size
)
{
ebml_master
colorinfo
=
start_ebml_master
(
pb
,
MATROSKA_ID_VIDEOCOLOR
,
0
);
avio_write
(
pb
,
colorinfo_ptr
,
colorinfo_size
);
end_ebml_master
(
pb
,
colorinfo
);
}
av_free
(
colorinfo_ptr
);
return
0
;
}
...
...
@@ -1126,7 +1139,9 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv,
put_ebml_binary
(
pb
,
MATROSKA_ID_VIDEOCOLORSPACE
,
&
color_space
,
sizeof
(
color_space
));
}
if
(
s
->
strict_std_compliance
<=
FF_COMPLIANCE_UNOFFICIAL
)
{
mkv_write_video_color
(
pb
,
par
,
st
);
ret
=
mkv_write_video_color
(
pb
,
par
,
st
);
if
(
ret
<
0
)
return
ret
;
}
end_ebml_master
(
pb
,
subinfo
);
break
;
...
...
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