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
db4e0eca
Commit
db4e0eca
authored
Jan 13, 2013
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
swr: move silence buffer to context to avoid per use malloc/free
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
dc658842
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
9 deletions
+9
-9
swresample.c
libswresample/swresample.c
+8
-9
swresample_internal.h
libswresample/swresample_internal.h
+1
-0
No files found.
libswresample/swresample.c
View file @
db4e0eca
...
...
@@ -217,6 +217,7 @@ av_cold void swr_free(SwrContext **ss){
free_temp
(
&
s
->
midbuf
);
free_temp
(
&
s
->
preout
);
free_temp
(
&
s
->
in_buffer
);
free_temp
(
&
s
->
silence
);
free_temp
(
&
s
->
drop_temp
);
free_temp
(
&
s
->
dither
.
noise
);
free_temp
(
&
s
->
dither
.
temp
);
...
...
@@ -240,6 +241,7 @@ av_cold int swr_init(struct SwrContext *s){
free_temp
(
&
s
->
midbuf
);
free_temp
(
&
s
->
preout
);
free_temp
(
&
s
->
in_buffer
);
free_temp
(
&
s
->
silence
);
free_temp
(
&
s
->
drop_temp
);
free_temp
(
&
s
->
dither
.
noise
);
free_temp
(
&
s
->
dither
.
temp
);
...
...
@@ -359,6 +361,7 @@ av_assert0(s->out.ch_count);
s
->
resample_first
=
RSC
*
s
->
out
.
ch_count
/
s
->
in
.
ch_count
-
RSC
<
s
->
out_sample_rate
/
(
float
)
s
->
in_sample_rate
-
1
.
0
;
s
->
in_buffer
=
s
->
in
;
s
->
silence
=
s
->
in
;
s
->
drop_temp
=
s
->
out
;
if
(
!
s
->
resample
&&
!
s
->
rematrix
&&
!
s
->
channel_map
&&
!
s
->
dither
.
method
){
...
...
@@ -807,26 +810,22 @@ int swr_drop_output(struct SwrContext *s, int count){
int
swr_inject_silence
(
struct
SwrContext
*
s
,
int
count
){
int
ret
,
i
;
AudioData
silence
=
s
->
in
;
uint8_t
*
tmp_arg
[
SWR_CH_MAX
];
if
(
count
<=
0
)
return
0
;
silence
.
count
=
0
;
silence
.
data
=
NULL
;
if
((
ret
=
swri_realloc_audio
(
&
silence
,
count
))
<
0
)
if
((
ret
=
swri_realloc_audio
(
&
s
->
silence
,
count
))
<
0
)
return
ret
;
if
(
s
ilence
.
planar
)
for
(
i
=
0
;
i
<
silence
.
ch_count
;
i
++
)
{
memset
(
s
ilence
.
ch
[
i
],
silence
.
bps
==
1
?
0x80
:
0
,
count
*
silence
.
bps
);
if
(
s
->
silence
.
planar
)
for
(
i
=
0
;
i
<
s
->
silence
.
ch_count
;
i
++
)
{
memset
(
s
->
silence
.
ch
[
i
],
s
->
silence
.
bps
==
1
?
0x80
:
0
,
count
*
s
->
silence
.
bps
);
}
else
memset
(
s
ilence
.
ch
[
0
],
silence
.
bps
==
1
?
0x80
:
0
,
count
*
silence
.
bps
*
silence
.
ch_count
);
memset
(
s
->
silence
.
ch
[
0
],
s
->
silence
.
bps
==
1
?
0x80
:
0
,
count
*
s
->
silence
.
bps
*
s
->
silence
.
ch_count
);
reversefill_audiodata
(
&
silence
,
tmp_arg
);
reversefill_audiodata
(
&
s
->
s
ilence
,
tmp_arg
);
av_log
(
s
,
AV_LOG_VERBOSE
,
"adding %d audio samples of silence
\n
"
,
count
);
ret
=
swr_convert
(
s
,
NULL
,
0
,
(
const
uint8_t
**
)
tmp_arg
,
count
);
av_freep
(
&
silence
.
data
);
return
ret
;
}
...
...
libswresample/swresample_internal.h
View file @
db4e0eca
...
...
@@ -113,6 +113,7 @@ struct SwrContext {
AudioData
preout
;
///< pre-output audio data: used for rematrix/resample
AudioData
out
;
///< converted output audio data
AudioData
in_buffer
;
///< cached audio data (convert and resample purpose)
AudioData
silence
;
///< temporary with silence
AudioData
drop_temp
;
///< temporary used to discard output
int
in_buffer_index
;
///< cached buffer position
int
in_buffer_count
;
///< cached buffer length
...
...
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