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
c131a9fe
Commit
c131a9fe
authored
May 15, 2015
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec/sonic: check memory allocations
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
cdd25f9a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
3 deletions
+18
-3
sonic.c
libavcodec/sonic.c
+18
-3
No files found.
libavcodec/sonic.c
View file @
c131a9fe
...
...
@@ -497,12 +497,15 @@ static int predictor_calc_error(int *k, int *state, int order, int error)
// copes better with quantization, and calculates the
// actual whitened result as it goes.
static
void
modified_levinson_durbin
(
int
*
window
,
int
window_entries
,
static
int
modified_levinson_durbin
(
int
*
window
,
int
window_entries
,
int
*
out
,
int
out_entries
,
int
channels
,
int
*
tap_quant
)
{
int
i
;
int
*
state
=
av_calloc
(
window_entries
,
sizeof
(
*
state
));
if
(
!
state
)
return
AVERROR
(
ENOMEM
);
memcpy
(
state
,
window
,
4
*
window_entries
);
for
(
i
=
0
;
i
<
out_entries
;
i
++
)
...
...
@@ -567,6 +570,7 @@ static void modified_levinson_durbin(int *window, int window_entries,
}
av_free
(
state
);
return
0
;
}
static
inline
int
code_samplerate
(
int
samplerate
)
...
...
@@ -627,6 +631,9 @@ static av_cold int sonic_encode_init(AVCodecContext *avctx)
// generate taps
s
->
tap_quant
=
av_calloc
(
s
->
num_taps
,
sizeof
(
*
s
->
tap_quant
));
if
(
!
s
->
tap_quant
)
return
AVERROR
(
ENOMEM
);
for
(
i
=
0
;
i
<
s
->
num_taps
;
i
++
)
s
->
tap_quant
[
i
]
=
ff_sqrt
(
i
+
1
);
...
...
@@ -656,7 +663,7 @@ static av_cold int sonic_encode_init(AVCodecContext *avctx)
s
->
window_size
=
((
2
*
s
->
tail_size
)
+
s
->
frame_size
);
s
->
window
=
av_calloc
(
s
->
window_size
,
sizeof
(
*
s
->
window
));
if
(
!
s
->
window
)
if
(
!
s
->
window
||
!
s
->
int_samples
)
return
AVERROR
(
ENOMEM
);
avctx
->
extradata
=
av_mallocz
(
16
);
...
...
@@ -769,8 +776,11 @@ static int sonic_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
s
->
tail
[
i
]
=
s
->
int_samples
[
s
->
frame_size
-
s
->
tail_size
+
i
];
// generate taps
modified_levinson_durbin
(
s
->
window
,
s
->
window_size
,
ret
=
modified_levinson_durbin
(
s
->
window
,
s
->
window_size
,
s
->
predictor_k
,
s
->
num_taps
,
s
->
channels
,
s
->
tap_quant
);
if
(
ret
<
0
)
return
ret
;
if
((
ret
=
intlist_write
(
&
c
,
state
,
s
->
predictor_k
,
s
->
num_taps
,
0
))
<
0
)
return
ret
;
...
...
@@ -913,6 +923,9 @@ static av_cold int sonic_decode_init(AVCodecContext *avctx)
// generate taps
s
->
tap_quant
=
av_calloc
(
s
->
num_taps
,
sizeof
(
*
s
->
tap_quant
));
if
(
!
s
->
tap_quant
)
return
AVERROR
(
ENOMEM
);
for
(
i
=
0
;
i
<
s
->
num_taps
;
i
++
)
s
->
tap_quant
[
i
]
=
ff_sqrt
(
i
+
1
);
...
...
@@ -932,6 +945,8 @@ static av_cold int sonic_decode_init(AVCodecContext *avctx)
return
AVERROR
(
ENOMEM
);
}
s
->
int_samples
=
av_calloc
(
s
->
frame_size
,
sizeof
(
*
s
->
int_samples
));
if
(
!
s
->
int_samples
)
return
AVERROR
(
ENOMEM
);
avctx
->
sample_fmt
=
AV_SAMPLE_FMT_S16
;
return
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