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
1523d148
Commit
1523d148
authored
Nov 14, 2014
by
Benoit Fouet
Committed by
Michael Niedermayer
Nov 14, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec/pngdec: create a function to decode IHDR chunk.
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
98abb98c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
20 deletions
+28
-20
pngdec.c
libavcodec/pngdec.c
+28
-20
No files found.
libavcodec/pngdec.c
View file @
1523d148
...
...
@@ -519,6 +519,33 @@ static int decode_text_chunk(PNGDecContext *s, uint32_t length, int compressed,
return
0
;
}
static
int
decode_ihdr_chunk
(
AVCodecContext
*
avctx
,
PNGDecContext
*
s
,
uint32_t
length
)
{
if
(
length
!=
13
)
return
AVERROR_INVALIDDATA
;
s
->
width
=
bytestream2_get_be32
(
&
s
->
gb
);
s
->
height
=
bytestream2_get_be32
(
&
s
->
gb
);
if
(
av_image_check_size
(
s
->
width
,
s
->
height
,
0
,
avctx
))
{
s
->
width
=
s
->
height
=
0
;
av_log
(
avctx
,
AV_LOG_ERROR
,
"Invalid image size
\n
"
);
return
AVERROR_INVALIDDATA
;
}
s
->
bit_depth
=
bytestream2_get_byte
(
&
s
->
gb
);
s
->
color_type
=
bytestream2_get_byte
(
&
s
->
gb
);
s
->
compression_type
=
bytestream2_get_byte
(
&
s
->
gb
);
s
->
filter_type
=
bytestream2_get_byte
(
&
s
->
gb
);
s
->
interlace_type
=
bytestream2_get_byte
(
&
s
->
gb
);
bytestream2_skip
(
&
s
->
gb
,
4
);
/* crc */
s
->
state
|=
PNG_IHDR
;
if
(
avctx
->
debug
&
FF_DEBUG_PICT_INFO
)
av_log
(
avctx
,
AV_LOG_DEBUG
,
"width=%d height=%d depth=%d color_type=%d "
"compression_type=%d filter_type=%d interlace_type=%d
\n
"
,
s
->
width
,
s
->
height
,
s
->
bit_depth
,
s
->
color_type
,
s
->
compression_type
,
s
->
filter_type
,
s
->
interlace_type
);
return
0
;
}
static
int
decode_frame_png
(
AVCodecContext
*
avctx
,
void
*
data
,
int
*
got_frame
,
AVPacket
*
avpkt
)
...
...
@@ -580,27 +607,8 @@ static int decode_frame_png(AVCodecContext *avctx,
((
tag
>>
24
)
&
0xff
),
length
);
switch
(
tag
)
{
case
MKTAG
(
'I'
,
'H'
,
'D'
,
'R'
):
if
(
length
!=
13
)
if
(
decode_ihdr_chunk
(
avctx
,
s
,
length
)
<
0
)
goto
fail
;
s
->
width
=
bytestream2_get_be32
(
&
s
->
gb
);
s
->
height
=
bytestream2_get_be32
(
&
s
->
gb
);
if
(
av_image_check_size
(
s
->
width
,
s
->
height
,
0
,
avctx
))
{
s
->
width
=
s
->
height
=
0
;
av_log
(
avctx
,
AV_LOG_ERROR
,
"Invalid image size
\n
"
);
goto
fail
;
}
s
->
bit_depth
=
bytestream2_get_byte
(
&
s
->
gb
);
s
->
color_type
=
bytestream2_get_byte
(
&
s
->
gb
);
s
->
compression_type
=
bytestream2_get_byte
(
&
s
->
gb
);
s
->
filter_type
=
bytestream2_get_byte
(
&
s
->
gb
);
s
->
interlace_type
=
bytestream2_get_byte
(
&
s
->
gb
);
bytestream2_skip
(
&
s
->
gb
,
4
);
/* crc */
s
->
state
|=
PNG_IHDR
;
if
(
avctx
->
debug
&
FF_DEBUG_PICT_INFO
)
av_log
(
avctx
,
AV_LOG_DEBUG
,
"width=%d height=%d depth=%d color_type=%d "
"compression_type=%d filter_type=%d interlace_type=%d
\n
"
,
s
->
width
,
s
->
height
,
s
->
bit_depth
,
s
->
color_type
,
s
->
compression_type
,
s
->
filter_type
,
s
->
interlace_type
);
break
;
case
MKTAG
(
'p'
,
'H'
,
'Y'
,
's'
)
:
if
(
s
->
state
&
PNG_IDAT
)
{
...
...
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