Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
audiowmark
Project
Project
Details
Activity
Releases
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefan Westerfeld
audiowmark
Commits
077e1019
Commit
077e1019
authored
Dec 29, 2021
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Performance optimization: use db_from_complex everywhere.
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
dd9497f7
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
47 deletions
+28
-47
syncfinder.cc
src/syncfinder.cc
+1
-1
wmcommon.cc
src/wmcommon.cc
+0
-24
wmcommon.hh
src/wmcommon.hh
+22
-2
wmget.cc
src/wmget.cc
+5
-4
wmspeed.cc
src/wmspeed.cc
+0
-16
No files found.
src/syncfinder.cc
View file @
077e1019
...
...
@@ -391,7 +391,7 @@ SyncFinder::sync_fft (const WavData& wav_data, size_t index, size_t frame_count,
/* computing db-magnitude is expensive, so we better do it here */
for
(
int
ch
=
0
;
ch
<
wav_data
.
n_channels
();
ch
++
)
for
(
int
i
=
Params
::
min_band
;
i
<=
Params
::
max_band
;
i
++
)
fft_out_db
[
out_pos
++
]
=
db_from_
factor
(
abs
(
frame_result
[
ch
][
i
])
,
min_db
);
fft_out_db
[
out_pos
++
]
=
db_from_
complex
(
frame_result
[
ch
][
i
]
,
min_db
);
have_frames
[
f
]
=
1
;
}
...
...
src/wmcommon.cc
View file @
077e1019
...
...
@@ -49,30 +49,6 @@ std::string Params::output_label;
using
std
::
vector
;
using
std
::
complex
;
/*
* glibc log2f is a lot faster than glibc log10
*/
inline
double
fast_log10
(
double
l
)
{
constexpr
double
log2_log10_factor
=
0.3010299956639811952
;
// 1 / log2 (10)
return
log2f
(
l
)
*
log2_log10_factor
;
}
double
db_from_factor
(
double
factor
,
double
min_dB
)
{
if
(
factor
>
0
)
{
double
dB
=
fast_log10
(
factor
);
/* Bell */
dB
*=
20
;
return
dB
;
}
else
return
min_dB
;
}
FFTAnalyzer
::
FFTAnalyzer
(
int
n_channels
)
:
m_n_channels
(
n_channels
),
m_fft_processor
(
Params
::
frame_size
)
...
...
src/wmcommon.hh
View file @
077e1019
...
...
@@ -136,8 +136,6 @@ struct MixEntry
std
::
vector
<
MixEntry
>
gen_mix_entries
();
double
db_from_factor
(
double
factor
,
double
min_dB
);
size_t
mark_data_frame_count
();
size_t
mark_sync_frame_count
();
...
...
@@ -185,6 +183,28 @@ window_hamming (double x) /* sharp (rectangle) cutoffs at boundaries */
return
0.54
+
0.46
*
cos
(
M_PI
*
x
);
}
static
inline
float
db_from_complex
(
float
re
,
float
im
,
float
min_dB
)
{
float
abs2
=
re
*
re
+
im
*
im
;
if
(
abs2
>
0
)
{
constexpr
float
log2_log10_factor
=
3.01029995663981
;
// 10 / log2 (10)
// glibc log2f is a lot faster than glibc log10
return
log2f
(
abs2
)
*
log2_log10_factor
;
}
else
return
min_dB
;
}
static
inline
float
db_from_complex
(
std
::
complex
<
float
>
f
,
float
min_dB
)
{
return
db_from_complex
(
f
.
real
(),
f
.
imag
(),
min_dB
);
}
int
add_stream_watermark
(
AudioInputStream
*
in_stream
,
AudioOutputStream
*
out_stream
,
const
std
::
string
&
bits
,
size_t
zero_frames
);
int
add_watermark
(
const
std
::
string
&
infile
,
const
std
::
string
&
outfile
,
const
std
::
string
&
bits
);
int
get_watermark
(
const
std
::
string
&
infile
,
const
std
::
string
&
orig_pattern
);
...
...
src/wmget.cc
View file @
077e1019
...
...
@@ -83,8 +83,8 @@ mix_decode (vector<vector<complex<float>>>& fft_out, int n_channels)
const
int
u
=
mix_entries
[
b
].
up
;
const
int
d
=
mix_entries
[
b
].
down
;
umag
+=
db_from_
factor
(
abs
(
fft_out
[
index
][
u
])
,
min_db
);
dmag
+=
db_from_
factor
(
abs
(
fft_out
[
index
][
d
])
,
min_db
);
umag
+=
db_from_
complex
(
fft_out
[
index
][
u
]
,
min_db
);
dmag
+=
db_from_
complex
(
fft_out
[
index
][
d
]
,
min_db
);
}
}
if
((
f
%
Params
::
frames_per_bit
)
==
(
Params
::
frames_per_bit
-
1
))
...
...
@@ -116,10 +116,11 @@ linear_decode (vector<vector<complex<float>>>& fft_out, int n_channels)
const
double
min_db
=
-
96
;
for
(
auto
u
:
up
)
umag
+=
db_from_
factor
(
abs
(
fft_out
[
index
][
u
])
,
min_db
);
umag
+=
db_from_
complex
(
fft_out
[
index
][
u
]
,
min_db
);
for
(
auto
d
:
down
)
dmag
+=
db_from_factor
(
abs
(
fft_out
[
index
][
d
]),
min_db
);
dmag
+=
db_from_complex
(
fft_out
[
index
][
d
],
min_db
);
}
if
((
f
%
Params
::
frames_per_bit
)
==
(
Params
::
frames_per_bit
-
1
))
{
...
...
src/wmspeed.cc
View file @
077e1019
...
...
@@ -166,22 +166,6 @@ public:
}
};
static
inline
float
db_from_complex
(
float
re
,
float
im
,
float
min_dB
)
{
float
abs2
=
re
*
re
+
im
*
im
;
if
(
abs2
>
0
)
{
constexpr
float
log2_log10_factor
=
3.01029995663981
;
// 10 / log2 (10)
// glibc log2f is a lot faster than glibc log10
return
log2f
(
abs2
)
*
log2_log10_factor
;
}
else
return
min_dB
;
}
void
SpeedSync
::
prepare_mags
()
{
...
...
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