Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
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
savoirfairelinux
jami-daemon
Commits
219dec05
Commit
219dec05
authored
15 years ago
by
Emmanuel Milou
Browse files
Options
Downloads
Patches
Plain Diff
[#1796] Computing time optimization (samplerate conversion)
parent
d9971d11
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
sflphone-common/src/samplerateconverter.cpp
+111
-92
111 additions, 92 deletions
sflphone-common/src/samplerateconverter.cpp
sflphone-common/src/samplerateconverter.h
+66
-57
66 additions, 57 deletions
sflphone-common/src/samplerateconverter.h
with
177 additions
and
149 deletions
sflphone-common/src/samplerateconverter.cpp
+
111
−
92
View file @
219dec05
...
@@ -82,6 +82,21 @@ void SamplerateConverter::init (void)
...
@@ -82,6 +82,21 @@ void SamplerateConverter::init (void)
_floatBufferUpSpkr
=
new
float32
[
nbSamplesMax
];
_floatBufferUpSpkr
=
new
float32
[
nbSamplesMax
];
}
}
void
SamplerateConverter
::
Short2FloatArray
(
const
short
*
in
,
float
*
out
,
int
len
)
{
// factor is 1/(2^15), used to rescale the short int range to the
// [-1.0 - 1.0] float range.
#define S2F_FACTOR .000030517578125f;
while
(
len
)
{
len
--
;
out
[
len
]
=
(
float
)
in
[
len
]
*
S2F_FACTOR
;
}
}
//TODO Add ifdef for int16 or float32 type
//TODO Add ifdef for int16 or float32 type
int
SamplerateConverter
::
upsampleData
(
SFLDataFormat
*
dataIn
,
SFLDataFormat
*
dataOut
,
int
samplerate1
,
int
samplerate2
,
int
nbSamples
)
int
SamplerateConverter
::
upsampleData
(
SFLDataFormat
*
dataIn
,
SFLDataFormat
*
dataOut
,
int
samplerate1
,
int
samplerate2
,
int
nbSamples
)
{
{
...
@@ -99,7 +114,9 @@ int SamplerateConverter::upsampleData (SFLDataFormat* dataIn , SFLDataFormat* da
...
@@ -99,7 +114,9 @@ int SamplerateConverter::upsampleData (SFLDataFormat* dataIn , SFLDataFormat* da
src_data
.
src_ratio
=
upsampleFactor
;
src_data
.
src_ratio
=
upsampleFactor
;
src_data
.
end_of_input
=
0
;
// More data will come
src_data
.
end_of_input
=
0
;
// More data will come
//_debug("upsample %d %d %f %d\n" , src_data.input_frames , src_data.output_frames, src_data.src_ratio , nbSamples);
//_debug("upsample %d %d %f %d\n" , src_data.input_frames , src_data.output_frames, src_data.src_ratio , nbSamples);
src_short_to_float_array
(
dataIn
,
_floatBufferDownSpkr
,
nbSamples
);
// Override libsamplerate conversion function
Short2FloatArray
(
dataIn
,
_floatBufferDownSpkr
,
nbSamples
);
//src_short_to_float_array (dataIn , _floatBufferDownSpkr, nbSamples);
//_debug("upsample %d %f %d\n" , src_data.output_frames, src_data.src_ratio , nbSamples);
//_debug("upsample %d %f %d\n" , src_data.output_frames, src_data.src_ratio , nbSamples);
src_process
(
_src_state_spkr
,
&
src_data
);
src_process
(
_src_state_spkr
,
&
src_data
);
//_debug("upsample %d %d %d\n" , samplerate1, samplerate2 , nbSamples);
//_debug("upsample %d %d %d\n" , samplerate1, samplerate2 , nbSamples);
...
@@ -128,7 +145,9 @@ int SamplerateConverter::downsampleData (SFLDataFormat* dataIn , SFLDataFormat*
...
@@ -128,7 +145,9 @@ int SamplerateConverter::downsampleData (SFLDataFormat* dataIn , SFLDataFormat*
src_data
.
src_ratio
=
downsampleFactor
;
src_data
.
src_ratio
=
downsampleFactor
;
src_data
.
end_of_input
=
0
;
// More data will come
src_data
.
end_of_input
=
0
;
// More data will come
//_debug("downsample %d %f %d\n" , src_data.output_frames, src_data.src_ratio , nbSamples);
//_debug("downsample %d %f %d\n" , src_data.output_frames, src_data.src_ratio , nbSamples);
src_short_to_float_array
(
dataIn
,
_floatBufferUpMic
,
nbSamples
);
// Override libsamplerate conversion function
Short2FloatArray
(
dataIn
,
_floatBufferUpMic
,
nbSamples
);
//src_short_to_float_array (dataIn, _floatBufferUpMic, nbSamples);
//_debug("downsample %d %f %d\n" , src_data.output_frames, src_data.src_ratio , nbSamples);
//_debug("downsample %d %f %d\n" , src_data.output_frames, src_data.src_ratio , nbSamples);
src_process
(
_src_state_mic
,
&
src_data
);
src_process
(
_src_state_mic
,
&
src_data
);
//_debug("downsample %d %f %d\n" , src_data.output_frames, src_data.src_ratio , nbSamples);
//_debug("downsample %d %f %d\n" , src_data.output_frames, src_data.src_ratio , nbSamples);
...
...
This diff is collapsed.
Click to expand it.
sflphone-common/src/samplerateconverter.h
+
66
−
57
View file @
219dec05
...
@@ -57,6 +57,15 @@ class SamplerateConverter {
...
@@ -57,6 +57,15 @@ class SamplerateConverter {
int
getFramesize
(
void
)
{
return
_framesize
;
}
int
getFramesize
(
void
)
{
return
_framesize
;
}
/**
* Convert short table to floats for audio processing
* @param in the input (short) array
* @param out The resulting (float) array
* @param len The number of elements in both tables
*/
void
Short2FloatArray
(
const
short
*
in
,
float
*
out
,
int
len
);
private
:
private
:
// Copy Constructor
// Copy Constructor
SamplerateConverter
(
const
SamplerateConverter
&
rh
);
SamplerateConverter
(
const
SamplerateConverter
&
rh
);
...
...
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