Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
0a771e6b
Commit
0a771e6b
authored
Sep 25, 2017
by
Rostislav Pehlivanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pngdec: expose gAMA and cHRM chunks as side/meta data
Signed-off-by:
Rostislav Pehlivanov
<
atomnuker@gmail.com
>
parent
723b6baa
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
1 deletion
+38
-1
pngdec.c
libavcodec/pngdec.c
+38
-1
No files found.
libavcodec/pngdec.c
View file @
0a771e6b
...
...
@@ -25,6 +25,7 @@
#include "libavutil/bprint.h"
#include "libavutil/imgutils.h"
#include "libavutil/stereo3d.h"
#include "libavutil/mastering_display_metadata.h"
#include "avcodec.h"
#include "bytestream.h"
...
...
@@ -1167,7 +1168,7 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s,
AVDictionary
**
metadatap
=
NULL
;
uint32_t
tag
,
length
;
int
decode_next_dat
=
0
;
int
ret
;
int
i
,
ret
;
for
(;;)
{
length
=
bytestream2_get_bytes_left
(
&
s
->
gb
);
...
...
@@ -1289,6 +1290,42 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s,
goto
fail
;
break
;
}
case
MKTAG
(
'c'
,
'H'
,
'R'
,
'M'
):
{
AVMasteringDisplayMetadata
*
mdm
=
av_mastering_display_metadata_create_side_data
(
p
);
if
(
!
mdm
)
{
ret
=
AVERROR
(
ENOMEM
);
goto
fail
;
}
mdm
->
white_point
[
0
]
=
av_make_q
(
bytestream2_get_be32
(
&
s
->
gb
),
100000
);
mdm
->
white_point
[
1
]
=
av_make_q
(
bytestream2_get_be32
(
&
s
->
gb
),
100000
);
/* RGB Primaries */
for
(
i
=
0
;
i
<
3
;
i
++
)
{
mdm
->
display_primaries
[
i
][
0
]
=
av_make_q
(
bytestream2_get_be32
(
&
s
->
gb
),
100000
);
mdm
->
display_primaries
[
i
][
1
]
=
av_make_q
(
bytestream2_get_be32
(
&
s
->
gb
),
100000
);
}
mdm
->
has_primaries
=
1
;
bytestream2_skip
(
&
s
->
gb
,
4
);
/* crc */
break
;
}
case
MKTAG
(
'g'
,
'A'
,
'M'
,
'A'
):
{
AVBPrint
bp
;
char
*
gamma_str
;
int
num
=
bytestream2_get_be32
(
&
s
->
gb
);
av_bprint_init
(
&
bp
,
0
,
-
1
);
av_bprintf
(
&
bp
,
"%i/%i"
,
num
,
100000
);
av_bprint_finalize
(
&
bp
,
&
gamma_str
);
if
(
!
gamma_str
)
return
AVERROR
(
ENOMEM
);
av_dict_set
(
&
p
->
metadata
,
"gamma"
,
gamma_str
,
AV_DICT_DONT_STRDUP_VAL
);
bytestream2_skip
(
&
s
->
gb
,
4
);
/* crc */
break
;
}
case
MKTAG
(
'I'
,
'E'
,
'N'
,
'D'
):
if
(
!
(
s
->
pic_state
&
PNG_ALLIMAGE
))
av_log
(
avctx
,
AV_LOG_ERROR
,
"IEND without all image
\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