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
ae5a55e7
Commit
ae5a55e7
authored
Dec 11, 2012
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
swr: move flush into Resampler
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
431dcc49
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
18 deletions
+25
-18
resample.c
libswresample/resample.c
+17
-0
swresample.c
libswresample/swresample.c
+6
-18
swresample_internal.h
libswresample/swresample_internal.h
+2
-0
No files found.
libswresample/resample.c
View file @
ae5a55e7
...
...
@@ -344,10 +344,27 @@ static int64_t get_delay(struct SwrContext *s, int64_t base){
return
av_rescale
(
num
,
base
,
s
->
in_sample_rate
*
(
int64_t
)
c
->
src_incr
<<
c
->
phase_shift
);
}
static
int
resample_flush
(
struct
SwrContext
*
s
)
{
AudioData
*
a
=
&
s
->
in_buffer
;
int
i
,
j
,
ret
;
if
((
ret
=
swri_realloc_audio
(
a
,
s
->
in_buffer_index
+
2
*
s
->
in_buffer_count
))
<
0
)
return
ret
;
av_assert0
(
a
->
planar
);
for
(
i
=
0
;
i
<
a
->
ch_count
;
i
++
){
for
(
j
=
0
;
j
<
s
->
in_buffer_count
;
j
++
){
memcpy
(
a
->
ch
[
i
]
+
(
s
->
in_buffer_index
+
s
->
in_buffer_count
+
j
)
*
a
->
bps
,
a
->
ch
[
i
]
+
(
s
->
in_buffer_index
+
s
->
in_buffer_count
-
j
-
1
)
*
a
->
bps
,
a
->
bps
);
}
}
s
->
in_buffer_count
+=
(
s
->
in_buffer_count
+
1
)
/
2
;
return
0
;
}
struct
Resampler
const
swri_resampler
=
{
resample_init
,
resample_free
,
multiple_resample
,
resample_flush
,
set_compensation
,
get_delay
,
};
libswresample/swresample.c
View file @
ae5a55e7
...
...
@@ -662,24 +662,12 @@ int swr_convert(struct SwrContext *s, uint8_t *out_arg[SWR_CH_MAX], int out_coun
}
if
(
!
in_arg
){
if
(
s
->
in_buffer_count
){
if
(
s
->
resample
&&
!
s
->
flushed
)
{
AudioData
*
a
=
&
s
->
in_buffer
;
int
i
,
j
,
ret
;
if
((
ret
=
swri_realloc_audio
(
a
,
s
->
in_buffer_index
+
2
*
s
->
in_buffer_count
))
<
0
)
return
ret
;
av_assert0
(
a
->
planar
);
for
(
i
=
0
;
i
<
a
->
ch_count
;
i
++
){
for
(
j
=
0
;
j
<
s
->
in_buffer_count
;
j
++
){
memcpy
(
a
->
ch
[
i
]
+
(
s
->
in_buffer_index
+
s
->
in_buffer_count
+
j
)
*
a
->
bps
,
a
->
ch
[
i
]
+
(
s
->
in_buffer_index
+
s
->
in_buffer_count
-
j
-
1
)
*
a
->
bps
,
a
->
bps
);
}
}
s
->
in_buffer_count
+=
(
s
->
in_buffer_count
+
1
)
/
2
;
s
->
resample_in_constraint
=
0
;
s
->
flushed
=
1
;
}
}
else
{
if
(
s
->
resample
){
if
(
!
s
->
flushed
)
s
->
resampler
->
flush
(
s
);
s
->
resample_in_constraint
=
0
;
s
->
flushed
=
1
;
}
else
if
(
!
s
->
in_buffer_count
){
return
0
;
}
}
else
...
...
libswresample/swresample_internal.h
View file @
ae5a55e7
...
...
@@ -128,6 +128,7 @@ typedef struct ResampleContext * (* resample_init_func)(struct ResampleContext *
double
cutoff
,
enum
AVSampleFormat
format
,
enum
SwrFilterType
filter_type
,
int
kaiser_beta
);
typedef
void
(
*
resample_free_func
)(
struct
ResampleContext
**
c
);
typedef
int
(
*
multiple_resample_func
)(
struct
ResampleContext
*
c
,
AudioData
*
dst
,
int
dst_size
,
AudioData
*
src
,
int
src_size
,
int
*
consumed
);
typedef
int
(
*
resample_flush_func
)(
struct
SwrContext
*
c
);
typedef
int
(
*
set_compensation_func
)(
struct
ResampleContext
*
c
,
int
sample_delta
,
int
compensation_distance
);
typedef
int64_t
(
*
get_delay_func
)(
struct
SwrContext
*
s
,
int64_t
base
);
...
...
@@ -135,6 +136,7 @@ struct Resampler {
resample_init_func
init
;
resample_free_func
free
;
multiple_resample_func
multiple_resample
;
resample_flush_func
flush
;
set_compensation_func
set_compensation
;
get_delay_func
get_delay
;
};
...
...
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