Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFmpeg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libremedia
Tethys
FFmpeg
Commits
c70c6be2
Commit
c70c6be2
authored
9 years ago
by
Rob Sykes
Committed by
Michael Niedermayer
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
swresample: soxr implementation for swr_get_out_samples()
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
1e700867
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
libswresample/soxr_resample.c
+30
-4
30 additions, 4 deletions
libswresample/soxr_resample.c
libswresample/swresample_internal.h
+1
-0
1 addition, 0 deletions
libswresample/swresample_internal.h
with
31 additions
and
4 deletions
libswresample/soxr_resample.c
+
30
−
4
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
};
This diff is collapsed.
Click to expand it.
libswresample/swresample_internal.h
+
1
−
0
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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment