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
4f313a50
Commit
4f313a50
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 PLTE chunk.
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
b35fa041
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
17 deletions
+24
-17
pngdec.c
libavcodec/pngdec.c
+24
-17
No files found.
libavcodec/pngdec.c
View file @
4f313a50
...
...
@@ -671,6 +671,29 @@ static int decode_idat_chunk(AVCodecContext *avctx, PNGDecContext *s,
return
0
;
}
static
int
decode_plte_chunk
(
AVCodecContext
*
avctx
,
PNGDecContext
*
s
,
uint32_t
length
)
{
int
n
,
i
,
r
,
g
,
b
;
if
((
length
%
3
)
!=
0
||
length
>
256
*
3
)
return
AVERROR_INVALIDDATA
;
/* read the palette */
n
=
length
/
3
;
for
(
i
=
0
;
i
<
n
;
i
++
)
{
r
=
bytestream2_get_byte
(
&
s
->
gb
);
g
=
bytestream2_get_byte
(
&
s
->
gb
);
b
=
bytestream2_get_byte
(
&
s
->
gb
);
s
->
palette
[
i
]
=
(
0xFFU
<<
24
)
|
(
r
<<
16
)
|
(
g
<<
8
)
|
b
;
}
for
(;
i
<
256
;
i
++
)
s
->
palette
[
i
]
=
(
0xFFU
<<
24
);
s
->
state
|=
PNG_PLTE
;
bytestream2_skip
(
&
s
->
gb
,
4
);
/* crc */
return
0
;
}
static
int
decode_frame_png
(
AVCodecContext
*
avctx
,
void
*
data
,
int
*
got_frame
,
AVPacket
*
avpkt
)
...
...
@@ -744,24 +767,8 @@ static int decode_frame_png(AVCodecContext *avctx,
goto
fail
;
break
;
case
MKTAG
(
'P'
,
'L'
,
'T'
,
'E'
):
{
int
n
,
i
,
r
,
g
,
b
;
if
((
length
%
3
)
!=
0
||
length
>
256
*
3
)
if
(
decode_plte_chunk
(
avctx
,
s
,
length
)
<
0
)
goto
skip_tag
;
/* read the palette */
n
=
length
/
3
;
for
(
i
=
0
;
i
<
n
;
i
++
)
{
r
=
bytestream2_get_byte
(
&
s
->
gb
);
g
=
bytestream2_get_byte
(
&
s
->
gb
);
b
=
bytestream2_get_byte
(
&
s
->
gb
);
s
->
palette
[
i
]
=
(
0xFFU
<<
24
)
|
(
r
<<
16
)
|
(
g
<<
8
)
|
b
;
}
for
(;
i
<
256
;
i
++
)
s
->
palette
[
i
]
=
(
0xFFU
<<
24
);
s
->
state
|=
PNG_PLTE
;
bytestream2_skip
(
&
s
->
gb
,
4
);
/* crc */
}
break
;
case
MKTAG
(
't'
,
'R'
,
'N'
,
'S'
):
{
...
...
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