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
aacf8e3b
Commit
aacf8e3b
authored
Feb 08, 2019
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix inf/nan problems for fft bands with mag = 0.0.
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
b050d32e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
9 deletions
+27
-9
audiowmark.cc
src/audiowmark.cc
+27
-9
No files found.
src/audiowmark.cc
View file @
aacf8e3b
...
...
@@ -346,6 +346,7 @@ mark_bit_linear (int f, const vector<complex<float>>& fft_out, vector<complex<fl
vector
<
int
>
down
;
get_up_down
(
f
,
up
,
down
,
random_stream
);
const
double
data_bit_sign
=
data_bit
>
0
?
1
:
-
1
;
const
float
min_mag
=
1e-7
;
// avoid computing pow (0.0, -water_delta) which would be inf
for
(
auto
u
:
up
)
{
/*
...
...
@@ -353,10 +354,14 @@ mark_bit_linear (int f, const vector<complex<float>>& fft_out, vector<complex<fl
*
* this actually increases the amount of energy because mag is less than 1.0
*/
const
float
mag_factor
=
pow
(
abs
(
fft_out
[
u
]),
-
Params
::
water_delta
*
data_bit_sign
);
const
float
mag
=
abs
(
fft_out
[
u
]);
if
(
mag
>
min_mag
)
{
const
float
mag_factor
=
pow
(
mag
,
-
Params
::
water_delta
*
data_bit_sign
);
fft_delta_spect
[
u
]
=
fft_out
[
u
]
*
(
mag_factor
-
1
);
}
}
for
(
auto
d
:
down
)
{
/*
...
...
@@ -364,10 +369,14 @@ mark_bit_linear (int f, const vector<complex<float>>& fft_out, vector<complex<fl
*
* this actually decreases the amount of energy because mag is less than 1.0
*/
const
float
mag_factor
=
pow
(
abs
(
fft_out
[
d
]),
Params
::
water_delta
*
data_bit_sign
);
const
float
mag
=
abs
(
fft_out
[
d
]);
if
(
mag
>
min_mag
)
{
const
float
mag_factor
=
pow
(
mag
,
Params
::
water_delta
*
data_bit_sign
);
fft_delta_spect
[
d
]
=
fft_out
[
d
]
*
(
mag_factor
-
1
);
}
}
}
size_t
...
...
@@ -412,6 +421,7 @@ mark_data (const WavData& wav_data, int start_frame, const vector<vector<complex
assert
(
bitvec
.
size
()
==
mark_data_frame_count
()
/
Params
::
frames_per_bit
);
const
int
frame_count
=
mark_data_frame_count
();
const
float
min_mag
=
1e-7
;
// avoid computing pow (0.0, -water_delta) which would be inf
if
(
Params
::
mix
)
{
...
...
@@ -431,13 +441,20 @@ mark_data (const WavData& wav_data, int start_frame, const vector<vector<complex
const
int
u
=
mix_entries
[
b
].
up
;
const
int
index
=
(
start_frame
+
mix_entries
[
b
].
frame
)
*
wav_data
.
n_channels
()
+
ch
;
{
const
float
mag_factor
=
pow
(
abs
(
fft_out
[
index
][
u
]),
-
Params
::
water_delta
*
data_bit_sign
);
const
float
mag
=
abs
(
fft_out
[
index
][
u
]);
if
(
mag
>
min_mag
)
{
const
float
mag_factor
=
pow
(
mag
,
-
Params
::
water_delta
*
data_bit_sign
);
fft_delta_spect
[
index
][
u
]
=
fft_out
[
index
][
u
]
*
(
mag_factor
-
1
);
}
}
const
int
d
=
mix_entries
[
b
].
down
;
{
const
float
mag_factor
=
pow
(
abs
(
fft_out
[
index
][
d
]),
Params
::
water_delta
*
data_bit_sign
);
const
float
mag
=
abs
(
fft_out
[
index
][
d
]);
if
(
mag
>
min_mag
)
{
const
float
mag_factor
=
pow
(
mag
,
Params
::
water_delta
*
data_bit_sign
);
fft_delta_spect
[
index
][
d
]
=
fft_out
[
index
][
d
]
*
(
mag_factor
-
1
);
}
...
...
@@ -445,6 +462,7 @@ mark_data (const WavData& wav_data, int start_frame, const vector<vector<complex
}
}
}
}
else
{
for
(
int
f
=
0
;
f
<
frame_count
;
f
++
)
...
...
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