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
c70c6be2
Commit
c70c6be2
authored
Jun 21, 2015
by
Rob Sykes
Committed by
Michael Niedermayer
Jun 21, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
swresample: soxr implementation for swr_get_out_samples()
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
1e700867
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
4 deletions
+31
-4
soxr_resample.c
libswresample/soxr_resample.c
+30
-4
swresample_internal.h
libswresample/swresample_internal.h
+1
-0
No files found.
libswresample/soxr_resample.c
View file @
c70c6be2
...
...
@@ -67,7 +67,17 @@ static void destroy(struct ResampleContext * *c){
}
static
int
flush
(
struct
SwrContext
*
s
){
s
->
delayed_samples_fixup
=
soxr_delay
((
soxr_t
)
s
->
resample
);
soxr_process
((
soxr_t
)
s
->
resample
,
NULL
,
0
,
NULL
,
NULL
,
0
,
NULL
);
{
float
f
;
size_t
idone
,
odone
;
soxr_process
((
soxr_t
)
s
->
resample
,
&
f
,
0
,
&
idone
,
&
f
,
0
,
&
odone
);
s
->
delayed_samples_fixup
-=
soxr_delay
((
soxr_t
)
s
->
resample
);
}
return
0
;
}
...
...
@@ -87,18 +97,34 @@ static int process(
}
static
int64_t
get_delay
(
struct
SwrContext
*
s
,
int64_t
base
){
double
delay_s
=
soxr_delay
((
soxr_t
)
s
->
resample
)
/
s
->
out_sample_rate
;
double
delayed_samples
=
soxr_delay
((
soxr_t
)
s
->
resample
);
double
delay_s
;
if
(
s
->
flushed
)
delayed_samples
+=
s
->
delayed_samples_fixup
;
delay_s
=
delayed_samples
/
s
->
out_sample_rate
;
return
(
int64_t
)(
delay_s
*
base
+
.
5
);
}
static
int
invert_initial_buffer
(
struct
ResampleContext
*
c
,
AudioData
*
dst
,
const
AudioData
*
src
,
int
in_count
,
int
*
out_idx
,
int
*
out_sz
)
{
int
in_count
,
int
*
out_idx
,
int
*
out_sz
){
return
0
;
}
static
int64_t
get_out_samples
(
struct
SwrContext
*
s
,
int
in_samples
){
double
out_samples
=
(
double
)
s
->
out_sample_rate
/
s
->
in_sample_rate
*
in_samples
;
double
delayed_samples
=
soxr_delay
((
soxr_t
)
s
->
resample
);
if
(
s
->
flushed
)
delayed_samples
+=
s
->
delayed_samples_fixup
;
return
(
int64_t
)(
out_samples
+
delayed_samples
+
1
+
.
5
);
}
struct
Resampler
const
swri_soxr_resampler
=
{
create
,
destroy
,
process
,
flush
,
NULL
/* set_compensation */
,
get_delay
,
invert_initial_buffer
,
invert_initial_buffer
,
get_out_samples
};
libswresample/swresample_internal.h
View file @
c70c6be2
...
...
@@ -157,6 +157,7 @@ struct SwrContext {
int64_t
outpts
;
///< output PTS
int64_t
firstpts
;
///< first PTS
int
drop_output
;
///< number of output samples to drop
double
delayed_samples_fixup
;
///< soxr 0.1.1: needed to fixup delayed_samples after flush has been called.
struct
AudioConvert
*
in_convert
;
///< input conversion context
struct
AudioConvert
*
out_convert
;
///< output conversion context
...
...
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