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
daeb4e30
Commit
daeb4e30
authored
Jul 01, 2013
by
Luca Barbato
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jpeg2000: Proper cleanup on failure in decode_frame()
Signed-off-by:
Luca Barbato
<
lu_zero@gentoo.org
>
parent
589e5b52
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
7 deletions
+13
-7
jpeg2000.c
libavcodec/jpeg2000.c
+3
-1
jpeg2000dec.c
libavcodec/jpeg2000dec.c
+10
-6
No files found.
libavcodec/jpeg2000.c
View file @
daeb4e30
...
@@ -484,7 +484,9 @@ int ff_jpeg2000_init_component(Jpeg2000Component *comp,
...
@@ -484,7 +484,9 @@ int ff_jpeg2000_init_component(Jpeg2000Component *comp,
void
ff_jpeg2000_cleanup
(
Jpeg2000Component
*
comp
,
Jpeg2000CodingStyle
*
codsty
)
void
ff_jpeg2000_cleanup
(
Jpeg2000Component
*
comp
,
Jpeg2000CodingStyle
*
codsty
)
{
{
int
reslevelno
,
bandno
,
precno
;
int
reslevelno
,
bandno
,
precno
;
for
(
reslevelno
=
0
;
reslevelno
<
codsty
->
nreslevels
;
reslevelno
++
)
{
for
(
reslevelno
=
0
;
comp
->
reslevel
&&
reslevelno
<
codsty
->
nreslevels
;
reslevelno
++
)
{
Jpeg2000ResLevel
*
reslevel
=
comp
->
reslevel
+
reslevelno
;
Jpeg2000ResLevel
*
reslevel
=
comp
->
reslevel
+
reslevelno
;
for
(
bandno
=
0
;
bandno
<
reslevel
->
nbands
;
bandno
++
)
{
for
(
bandno
=
0
;
bandno
<
reslevel
->
nbands
;
bandno
++
)
{
...
...
libavcodec/jpeg2000dec.c
View file @
daeb4e30
...
@@ -1346,8 +1346,10 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -1346,8 +1346,10 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx, void *data,
bytestream2_init
(
&
s
->
g
,
avpkt
->
data
,
avpkt
->
size
);
bytestream2_init
(
&
s
->
g
,
avpkt
->
data
,
avpkt
->
size
);
s
->
curtileno
=
0
;
// TODO: only one tile in DCI JP2K. to implement for more tiles
s
->
curtileno
=
0
;
// TODO: only one tile in DCI JP2K. to implement for more tiles
if
(
bytestream2_get_bytes_left
(
&
s
->
g
)
<
2
)
if
(
bytestream2_get_bytes_left
(
&
s
->
g
)
<
2
)
{
return
AVERROR_INVALIDDATA
;
ret
=
AVERROR_INVALIDDATA
;
goto
end
;
}
// check if the image is in jp2 format
// check if the image is in jp2 format
if
(
bytestream2_get_bytes_left
(
&
s
->
g
)
>=
12
&&
if
(
bytestream2_get_bytes_left
(
&
s
->
g
)
>=
12
&&
...
@@ -1357,17 +1359,17 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -1357,17 +1359,17 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx, void *data,
if
(
!
jp2_find_codestream
(
s
))
{
if
(
!
jp2_find_codestream
(
s
))
{
av_log
(
avctx
,
AV_LOG_ERROR
,
av_log
(
avctx
,
AV_LOG_ERROR
,
"Could not find Jpeg2000 codestream atom.
\n
"
);
"Could not find Jpeg2000 codestream atom.
\n
"
);
return
AVERROR_INVALIDDATA
;
ret
=
AVERROR_INVALIDDATA
;
goto
end
;
}
}
}
else
{
}
else
{
bytestream2_seek
(
&
s
->
g
,
0
,
SEEK_SET
);
bytestream2_seek
(
&
s
->
g
,
0
,
SEEK_SET
);
if
(
bytestream2_peek_be16
(
&
s
->
g
)
!=
JPEG2000_SOC
)
bytestream2_skip
(
&
s
->
g
,
8
);
}
}
if
(
bytestream2_get_be16u
(
&
s
->
g
)
!=
JPEG2000_SOC
)
{
if
(
bytestream2_get_be16u
(
&
s
->
g
)
!=
JPEG2000_SOC
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"SOC marker not present
\n
"
);
av_log
(
avctx
,
AV_LOG_ERROR
,
"SOC marker not present
\n
"
);
return
AVERROR_INVALIDDATA
;
ret
=
AVERROR_INVALIDDATA
;
goto
end
;
}
}
if
(
ret
=
jpeg2000_read_main_headers
(
s
))
if
(
ret
=
jpeg2000_read_main_headers
(
s
))
goto
end
;
goto
end
;
...
@@ -1386,6 +1388,8 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -1386,6 +1388,8 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx, void *data,
if
(
ret
=
jpeg2000_decode_tile
(
s
,
s
->
tile
+
tileno
,
picture
))
if
(
ret
=
jpeg2000_decode_tile
(
s
,
s
->
tile
+
tileno
,
picture
))
goto
end
;
goto
end
;
jpeg2000_dec_cleanup
(
s
);
*
got_frame
=
1
;
*
got_frame
=
1
;
return
bytestream2_tell
(
&
s
->
g
);
return
bytestream2_tell
(
&
s
->
g
);
...
...
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