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
b51a100f
Commit
b51a100f
authored
Dec 13, 2018
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Share fft analysis code between both watermark get implementations.
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
c16d6dc0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
57 deletions
+35
-57
audiowmark.cc
src/audiowmark.cc
+35
-57
No files found.
src/audiowmark.cc
View file @
b51a100f
...
...
@@ -608,8 +608,6 @@ get_watermark (const string& infile, const string& orig_pattern)
WavData
wav_data
(
in_signal
,
in_wav_data
.
n_channels
(),
in_wav_data
.
mix_freq
(),
in_wav_data
.
bit_depth
());
if
(
Params
::
mix
)
{
vector
<
vector
<
complex
<
float
>>>
fft_out
;
for
(
int
f
=
0
;
f
<
frame_count
(
wav_data
);
f
++
)
{
...
...
@@ -637,6 +635,8 @@ get_watermark (const string& infile, const string& orig_pattern)
fft_out
.
push_back
(
fft
(
frame
));
}
}
if
(
Params
::
mix
)
{
for
(
int
block
=
0
;
block
<
frame_count
(
wav_data
)
/
(
Params
::
block
*
Params
::
frames_per_bit
);
block
++
)
{
struct
MixEntry
{
...
...
@@ -694,28 +694,7 @@ get_watermark (const string& infile, const string& orig_pattern)
{
for
(
int
ch
=
0
;
ch
<
wav_data
.
n_channels
();
ch
++
)
{
vector
<
float
>
frame
=
get_frame
(
wav_data
,
f
,
ch
);
if
(
frame
.
size
()
==
Params
::
frame_size
)
{
/* windowing */
double
window_weight
=
0
;
for
(
size_t
i
=
0
;
i
<
frame
.
size
();
i
++
)
{
const
double
fsize_2
=
frame
.
size
()
/
2.0
;
// const double win = window_cos ((i - fsize_2) / fsize_2);
const
double
win
=
window_hamming
((
i
-
fsize_2
)
/
fsize_2
);
//const double win = 1;
frame
[
i
]
*=
win
;
window_weight
+=
win
;
}
/* to get normalized fft output corrected by window weight */
for
(
size_t
i
=
0
;
i
<
frame
.
size
();
i
++
)
frame
[
i
]
*=
2.0
/
window_weight
;
/* FFT transform */
vector
<
complex
<
float
>>
fft_out
=
fft
(
frame
);
const
int
index
=
f
*
wav_data
.
n_channels
()
+
ch
;
vector
<
int
>
up
;
vector
<
int
>
down
;
get_up_down
(
f
,
up
,
down
);
...
...
@@ -723,12 +702,11 @@ get_watermark (const string& infile, const string& orig_pattern)
const
double
min_db
=
-
96
;
for
(
auto
u
:
up
)
{
umag
+=
db_from_factor
(
abs
(
fft_out
[
u
]),
min_db
);
umag
+=
db_from_factor
(
abs
(
fft_out
[
index
]
[
u
]),
min_db
);
}
for
(
auto
d
:
down
)
{
dmag
+=
db_from_factor
(
abs
(
fft_out
[
d
]),
min_db
);
}
dmag
+=
db_from_factor
(
abs
(
fft_out
[
index
][
d
]),
min_db
);
}
}
if
((
f
%
Params
::
frames_per_bit
)
==
(
Params
::
frames_per_bit
-
1
))
...
...
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