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
4d8516fd
Commit
4d8516fd
authored
Jul 02, 2012
by
Martin Storsjö
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
snow: Check mallocs at init
Signed-off-by:
Martin Storsjö
<
martin@martin.st
>
parent
4719ea7e
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
10 deletions
+23
-10
snow.c
libavcodec/snow.c
+12
-7
snowdec.c
libavcodec/snowdec.c
+6
-1
snowenc.c
libavcodec/snowenc.c
+5
-2
No files found.
libavcodec/snow.c
View file @
4d8516fd
...
...
@@ -394,7 +394,7 @@ mca( 8, 8,8)
av_cold
int
ff_snow_common_init
(
AVCodecContext
*
avctx
){
SnowContext
*
s
=
avctx
->
priv_data
;
int
width
,
height
;
int
i
,
j
;
int
i
,
j
,
ret
;
s
->
avctx
=
avctx
;
s
->
max_ref_frames
=
1
;
//just make sure its not an invalid value in case of no initial keyframe
...
...
@@ -447,19 +447,24 @@ av_cold int ff_snow_common_init(AVCodecContext *avctx){
width
=
s
->
avctx
->
width
;
height
=
s
->
avctx
->
height
;
s
->
spatial_idwt_buffer
=
av_mallocz
(
width
*
height
*
sizeof
(
IDWTELEM
)
);
s
->
spatial_dwt_buffer
=
av_mallocz
(
width
*
height
*
sizeof
(
DWTELEM
)
);
//FIXME this does not belong here
s
->
temp_dwt_buffer
=
av_mallocz
(
width
*
sizeof
(
DWTELEM
)
);
s
->
temp_idwt_buffer
=
av_mallocz
(
width
*
sizeof
(
IDWTELEM
)
);
FF_ALLOCZ_OR_GOTO
(
avctx
,
s
->
spatial_idwt_buffer
,
width
*
height
*
sizeof
(
IDWTELEM
),
fail
);
FF_ALLOCZ_OR_GOTO
(
avctx
,
s
->
spatial_dwt_buffer
,
width
*
height
*
sizeof
(
DWTELEM
),
fail
);
//FIXME this does not belong here
FF_ALLOCZ_OR_GOTO
(
avctx
,
s
->
temp_dwt_buffer
,
width
*
sizeof
(
DWTELEM
),
fail
);
FF_ALLOCZ_OR_GOTO
(
avctx
,
s
->
temp_idwt_buffer
,
width
*
sizeof
(
IDWTELEM
),
fail
);
for
(
i
=
0
;
i
<
MAX_REF_FRAMES
;
i
++
)
for
(
j
=
0
;
j
<
MAX_REF_FRAMES
;
j
++
)
ff_scale_mv_ref
[
i
][
j
]
=
256
*
(
i
+
1
)
/
(
j
+
1
);
s
->
avctx
->
get_buffer
(
s
->
avctx
,
&
s
->
mconly_picture
);
s
->
scratchbuf
=
av_malloc
(
s
->
mconly_picture
.
linesize
[
0
]
*
7
*
MB_SIZE
);
if
((
ret
=
s
->
avctx
->
get_buffer
(
s
->
avctx
,
&
s
->
mconly_picture
))
<
0
)
{
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"get_buffer() failed
\n
"
);
return
ret
;
}
FF_ALLOC_OR_GOTO
(
avctx
,
s
->
scratchbuf
,
s
->
mconly_picture
.
linesize
[
0
]
*
7
*
MB_SIZE
,
fail
);
return
0
;
fail
:
return
AVERROR
(
ENOMEM
);
}
int
ff_snow_common_init_after_header
(
AVCodecContext
*
avctx
)
{
...
...
libavcodec/snowdec.c
View file @
4d8516fd
...
...
@@ -354,9 +354,14 @@ static int decode_header(SnowContext *s){
static
av_cold
int
decode_init
(
AVCodecContext
*
avctx
)
{
int
ret
;
avctx
->
pix_fmt
=
PIX_FMT_YUV420P
;
ff_snow_common_init
(
avctx
);
if
((
ret
=
ff_snow_common_init
(
avctx
))
<
0
)
{
ff_snow_common_end
(
avctx
->
priv_data
);
return
ret
;
}
return
0
;
}
...
...
libavcodec/snowenc.c
View file @
4d8516fd
...
...
@@ -155,7 +155,7 @@ static void dwt_quantize(SnowContext *s, Plane *p, DWTELEM *buffer, int width, i
static
av_cold
int
encode_init
(
AVCodecContext
*
avctx
)
{
SnowContext
*
s
=
avctx
->
priv_data
;
int
plane_index
;
int
plane_index
,
ret
;
if
(
avctx
->
strict_std_compliance
>
FF_COMPLIANCE_EXPERIMENTAL
){
av_log
(
avctx
,
AV_LOG_ERROR
,
"This codec is under development, files encoded with it may not be decodable with future versions!!!
\n
"
...
...
@@ -184,7 +184,10 @@ static av_cold int encode_init(AVCodecContext *avctx)
s
->
plane
[
plane_index
].
fast_mc
=
1
;
}
ff_snow_common_init
(
avctx
);
if
((
ret
=
ff_snow_common_init
(
avctx
))
<
0
)
{
ff_snow_common_end
(
avctx
->
priv_data
);
return
ret
;
}
ff_snow_alloc_blocks
(
s
);
s
->
version
=
0
;
...
...
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