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
00df32f6
Commit
00df32f6
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: split frame decoding in its own function.
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
8cab24df
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
39 deletions
+49
-39
pngdec.c
libavcodec/pngdec.c
+49
-39
No files found.
libavcodec/pngdec.c
View file @
00df32f6
...
...
@@ -786,44 +786,12 @@ static void handle_small_bpp(PNGDecContext *s, AVFrame *p)
}
}
static
int
decode_frame_png
(
AVCodecContext
*
avctx
,
void
*
data
,
int
*
got_frame
,
AVPacket
*
avpkt
)
static
int
decode_frame_common
(
AVCodecContext
*
avctx
,
PNGDecContext
*
s
,
AVFrame
*
p
,
AVPacket
*
avpkt
)
{
PNGDecContext
*
const
s
=
avctx
->
priv_data
;
const
uint8_t
*
buf
=
avpkt
->
data
;
int
buf_size
=
avpkt
->
size
;
AVFrame
*
p
;
AVDictionary
*
metadata
=
NULL
;
uint32_t
tag
,
length
;
int64_t
sig
;
int
ret
;
ff_thread_release_buffer
(
avctx
,
&
s
->
last_picture
);
FFSWAP
(
ThreadFrame
,
s
->
picture
,
s
->
last_picture
);
p
=
s
->
picture
.
f
;
bytestream2_init
(
&
s
->
gb
,
buf
,
buf_size
);
/* check signature */
sig
=
bytestream2_get_be64
(
&
s
->
gb
);
if
(
sig
!=
PNGSIG
&&
sig
!=
MNGSIG
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"Missing png signature
\n
"
);
return
AVERROR_INVALIDDATA
;
}
s
->
y
=
s
->
state
=
0
;
/* init the zlib */
s
->
zstream
.
zalloc
=
ff_png_zalloc
;
s
->
zstream
.
zfree
=
ff_png_zfree
;
s
->
zstream
.
opaque
=
NULL
;
ret
=
inflateInit
(
&
s
->
zstream
);
if
(
ret
!=
Z_OK
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"inflateInit returned error %d
\n
"
,
ret
);
return
AVERROR_EXTERNAL
;
}
for
(;;)
{
if
(
bytestream2_get_bytes_left
(
&
s
->
gb
)
<=
0
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"%d bytes left
\n
"
,
bytestream2_get_bytes_left
(
&
s
->
gb
));
...
...
@@ -921,6 +889,53 @@ exit_loop:
av_frame_set_metadata
(
p
,
metadata
);
metadata
=
NULL
;
return
0
;
fail
:
av_dict_free
(
&
metadata
);
ff_thread_report_progress
(
&
s
->
picture
,
INT_MAX
,
0
);
return
AVERROR_INVALIDDATA
;
}
static
int
decode_frame_png
(
AVCodecContext
*
avctx
,
void
*
data
,
int
*
got_frame
,
AVPacket
*
avpkt
)
{
PNGDecContext
*
const
s
=
avctx
->
priv_data
;
const
uint8_t
*
buf
=
avpkt
->
data
;
int
buf_size
=
avpkt
->
size
;
AVFrame
*
p
;
int64_t
sig
;
int
ret
;
ff_thread_release_buffer
(
avctx
,
&
s
->
last_picture
);
FFSWAP
(
ThreadFrame
,
s
->
picture
,
s
->
last_picture
);
p
=
s
->
picture
.
f
;
bytestream2_init
(
&
s
->
gb
,
buf
,
buf_size
);
/* check signature */
sig
=
bytestream2_get_be64
(
&
s
->
gb
);
if
(
sig
!=
PNGSIG
&&
sig
!=
MNGSIG
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"Missing png signature
\n
"
);
return
AVERROR_INVALIDDATA
;
}
s
->
y
=
s
->
state
=
0
;
/* init the zlib */
s
->
zstream
.
zalloc
=
ff_png_zalloc
;
s
->
zstream
.
zfree
=
ff_png_zfree
;
s
->
zstream
.
opaque
=
NULL
;
ret
=
inflateInit
(
&
s
->
zstream
);
if
(
ret
!=
Z_OK
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"inflateInit returned error %d
\n
"
,
ret
);
return
AVERROR_EXTERNAL
;
}
if
((
ret
=
decode_frame_common
(
avctx
,
s
,
p
,
avpkt
))
<
0
)
goto
the_end
;
if
((
ret
=
av_frame_ref
(
data
,
s
->
picture
.
f
))
<
0
)
return
ret
;
...
...
@@ -932,11 +947,6 @@ the_end:
inflateEnd
(
&
s
->
zstream
);
s
->
crow_buf
=
NULL
;
return
ret
;
fail
:
av_dict_free
(
&
metadata
);
ff_thread_report_progress
(
&
s
->
picture
,
INT_MAX
,
0
);
ret
=
AVERROR_INVALIDDATA
;
goto
the_end
;
}
static
int
update_thread_context
(
AVCodecContext
*
dst
,
const
AVCodecContext
*
src
)
...
...
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