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
bcb42fb6
Commit
bcb42fb6
authored
Jun 22, 2013
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sonic: use av_calloc()
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
81c5ceed
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
15 deletions
+15
-15
sonic.c
libavcodec/sonic.c
+15
-15
No files found.
libavcodec/sonic.c
View file @
bcb42fb6
...
...
@@ -172,7 +172,7 @@ static int intlist_write(PutBitContext *pb, int *buf, int entries, int base_2_pa
int
step
=
256
,
pos
=
0
,
dominant
=
0
,
any
=
0
;
int
*
copy
,
*
bits
;
copy
=
av_
mallocz
(
sizeof
(
*
copy
)
*
entries
);
copy
=
av_
calloc
(
entries
,
sizeof
(
*
copy
)
);
if
(
!
copy
)
return
AVERROR
(
ENOMEM
);
...
...
@@ -198,7 +198,7 @@ static int intlist_write(PutBitContext *pb, int *buf, int entries, int base_2_pa
max
=
abs
(
copy
[
i
]);
}
bits
=
av_
mallocz
(
sizeof
(
*
bits
)
*
entries
*
max
);
bits
=
av_
calloc
(
entries
*
max
,
sizeof
(
*
bits
)
);
if
(
!
bits
)
{
// av_free(copy);
...
...
@@ -268,7 +268,7 @@ static int intlist_read(GetBitContext *gb, int *buf, int entries, int base_2_par
int
i
,
low_bits
=
0
,
x
=
0
;
int
n_zeros
=
0
,
step
=
256
,
dominant
=
0
;
int
pos
=
0
,
level
=
0
;
int
*
bits
=
av_
mallocz
(
sizeof
(
*
bits
)
*
entries
);
int
*
bits
=
av_
calloc
(
entries
,
sizeof
(
*
bits
)
);
if
(
!
bits
)
return
AVERROR
(
ENOMEM
);
...
...
@@ -418,7 +418,7 @@ static void modified_levinson_durbin(int *window, int window_entries,
int
*
out
,
int
out_entries
,
int
channels
,
int
*
tap_quant
)
{
int
i
;
int
*
state
=
av_
mallocz
(
sizeof
(
*
state
)
*
window_entries
);
int
*
state
=
av_
calloc
(
window_entries
,
sizeof
(
*
state
)
);
memcpy
(
state
,
window
,
4
*
window_entries
);
...
...
@@ -543,7 +543,7 @@ static av_cold int sonic_encode_init(AVCodecContext *avctx)
}
// generate taps
s
->
tap_quant
=
av_
mallocz
(
sizeof
(
*
s
->
tap_quant
)
*
s
->
num_taps
);
s
->
tap_quant
=
av_
calloc
(
s
->
num_taps
,
sizeof
(
*
s
->
tap_quant
)
);
for
(
i
=
0
;
i
<
s
->
num_taps
;
i
++
)
s
->
tap_quant
[
i
]
=
(
int
)(
sqrt
(
i
+
1
));
...
...
@@ -554,25 +554,25 @@ static av_cold int sonic_encode_init(AVCodecContext *avctx)
s
->
frame_size
=
s
->
channels
*
s
->
block_align
*
s
->
downsampling
;
s
->
tail_size
=
s
->
num_taps
*
s
->
channels
;
s
->
tail
=
av_
mallocz
(
sizeof
(
*
s
->
tail
)
*
s
->
tail_size
);
s
->
tail
=
av_
calloc
(
s
->
tail_size
,
sizeof
(
*
s
->
tail
)
);
if
(
!
s
->
tail
)
return
AVERROR
(
ENOMEM
);
s
->
predictor_k
=
av_
mallocz
(
sizeof
(
*
s
->
predictor_k
)
*
s
->
num_taps
);
s
->
predictor_k
=
av_
calloc
(
s
->
num_taps
,
sizeof
(
*
s
->
predictor_k
)
);
if
(
!
s
->
predictor_k
)
return
AVERROR
(
ENOMEM
);
for
(
i
=
0
;
i
<
s
->
channels
;
i
++
)
{
s
->
coded_samples
[
i
]
=
av_
mallocz
(
sizeof
(
**
s
->
coded_samples
)
*
s
->
block_align
);
s
->
coded_samples
[
i
]
=
av_
calloc
(
s
->
block_align
,
sizeof
(
**
s
->
coded_samples
)
);
if
(
!
s
->
coded_samples
[
i
])
return
AVERROR
(
ENOMEM
);
}
s
->
int_samples
=
av_
mallocz
(
sizeof
(
*
s
->
int_samples
)
*
s
->
frame_size
);
s
->
int_samples
=
av_
calloc
(
s
->
frame_size
,
sizeof
(
*
s
->
int_samples
)
);
s
->
window_size
=
((
2
*
s
->
tail_size
)
+
s
->
frame_size
);
s
->
window
=
av_
mallocz
(
sizeof
(
*
s
->
window
)
*
s
->
window_size
);
s
->
window
=
av_
calloc
(
s
->
window_size
,
sizeof
(
*
s
->
window
)
);
if
(
!
s
->
window
)
return
AVERROR
(
ENOMEM
);
...
...
@@ -821,26 +821,26 @@ static av_cold int sonic_decode_init(AVCodecContext *avctx)
version
,
s
->
lossless
,
s
->
decorrelation
,
s
->
num_taps
,
s
->
block_align
,
s
->
frame_size
,
s
->
downsampling
);
// generate taps
s
->
tap_quant
=
av_
mallocz
(
sizeof
(
*
s
->
tap_quant
)
*
s
->
num_taps
);
s
->
tap_quant
=
av_
calloc
(
s
->
num_taps
,
sizeof
(
*
s
->
tap_quant
)
);
for
(
i
=
0
;
i
<
s
->
num_taps
;
i
++
)
s
->
tap_quant
[
i
]
=
(
int
)(
sqrt
(
i
+
1
));
s
->
predictor_k
=
av_
mallocz
(
sizeof
(
*
s
->
predictor_k
)
*
s
->
num_taps
);
s
->
predictor_k
=
av_
calloc
(
s
->
num_taps
,
sizeof
(
*
s
->
predictor_k
)
);
for
(
i
=
0
;
i
<
s
->
channels
;
i
++
)
{
s
->
predictor_state
[
i
]
=
av_
mallocz
(
sizeof
(
**
s
->
predictor_state
)
*
s
->
num_taps
);
s
->
predictor_state
[
i
]
=
av_
calloc
(
s
->
num_taps
,
sizeof
(
**
s
->
predictor_state
)
);
if
(
!
s
->
predictor_state
[
i
])
return
AVERROR
(
ENOMEM
);
}
for
(
i
=
0
;
i
<
s
->
channels
;
i
++
)
{
s
->
coded_samples
[
i
]
=
av_
mallocz
(
sizeof
(
**
s
->
coded_samples
)
*
s
->
block_align
);
s
->
coded_samples
[
i
]
=
av_
calloc
(
s
->
block_align
,
sizeof
(
**
s
->
coded_samples
)
);
if
(
!
s
->
coded_samples
[
i
])
return
AVERROR
(
ENOMEM
);
}
s
->
int_samples
=
av_
mallocz
(
sizeof
(
*
s
->
int_samples
)
*
s
->
frame_size
);
s
->
int_samples
=
av_
calloc
(
s
->
frame_size
,
sizeof
(
*
s
->
int_samples
)
);
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