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
f8b9a98a
Commit
f8b9a98a
authored
Dec 14, 2018
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge blind and non-blind mix decode step.
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
031c1ab2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
67 deletions
+47
-67
audiowmark.cc
src/audiowmark.cc
+47
-67
No files found.
src/audiowmark.cc
View file @
f8b9a98a
...
...
@@ -620,23 +620,11 @@ truncate_to_block_size (WavData& wav_data)
wav_data
.
set_samples
(
in_signal
);
}
int
get_watermark
(
const
string
&
infile
,
const
string
&
orig_pattern
)
vector
<
int
>
mix_decode
(
const
WavData
&
wav_data
,
vector
<
vector
<
complex
<
float
>>>&
fft_out
,
vector
<
vector
<
complex
<
float
>>>&
fft_orig_out
)
{
WavData
wav_data
;
if
(
!
wav_data
.
load
(
infile
))
{
fprintf
(
stderr
,
"audiowmark: error loading %s: %s
\n
"
,
infile
.
c_str
(),
wav_data
.
error_blurb
());
return
1
;
}
vector
<
int
>
bit_vec
;
// to keep the watermark detection code simpler, we truncate samples to avoid partial filled blocks
truncate_to_block_size
(
wav_data
);
vector
<
vector
<
complex
<
float
>>>
fft_out
=
compute_frame_ffts
(
wav_data
);
if
(
Params
::
mix
)
{
for
(
int
block
=
0
;
block
<
block_count
(
wav_data
);
block
++
)
{
vector
<
MixEntry
>
mix_entries
=
gen_mix_entries
(
block
);
...
...
@@ -651,14 +639,17 @@ get_watermark (const string& infile, const string& orig_pattern)
int
b
=
f
*
Params
::
bands_per_frame
+
frame_b
;
const
double
min_db
=
-
96
;
const
in
t
index
=
(
block
*
(
Params
::
block_size
*
Params
::
frames_per_bit
)
+
mix_entries
[
b
].
frame
)
*
wav_data
.
n_channels
()
+
ch
;
const
size_
t
index
=
(
block
*
(
Params
::
block_size
*
Params
::
frames_per_bit
)
+
mix_entries
[
b
].
frame
)
*
wav_data
.
n_channels
()
+
ch
;
const
int
u
=
mix_entries
[
b
].
up
;
{
umag
+=
db_from_factor
(
abs
(
fft_out
[
index
][
u
]),
min_db
);
}
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
);
if
(
index
<
fft_orig_out
.
size
())
/* non-blind decode? */
{
umag
-=
db_from_factor
(
abs
(
fft_orig_out
[
index
][
u
]),
min_db
);
dmag
-=
db_from_factor
(
abs
(
fft_orig_out
[
index
][
d
]),
min_db
);
}
}
}
...
...
@@ -670,6 +661,29 @@ get_watermark (const string& infile, const string& orig_pattern)
}
}
}
return
bit_vec
;
}
int
get_watermark
(
const
string
&
infile
,
const
string
&
orig_pattern
)
{
WavData
wav_data
;
if
(
!
wav_data
.
load
(
infile
))
{
fprintf
(
stderr
,
"audiowmark: error loading %s: %s
\n
"
,
infile
.
c_str
(),
wav_data
.
error_blurb
());
return
1
;
}
vector
<
int
>
bit_vec
;
// to keep the watermark detection code simpler, we truncate samples to avoid partial filled blocks
truncate_to_block_size
(
wav_data
);
vector
<
vector
<
complex
<
float
>>>
fft_out
=
compute_frame_ffts
(
wav_data
);
if
(
Params
::
mix
)
{
vector
<
vector
<
complex
<
float
>>>
fft_orig_out
;
/* no original data -> blind decode */
mix_decode
(
wav_data
,
fft_out
,
fft_orig_out
);
}
else
{
...
...
@@ -745,41 +759,7 @@ get_watermark_delta (const string& origfile, const string& infile, const string&
vector
<
vector
<
complex
<
float
>>>
fft_out
=
compute_frame_ffts
(
wav_data
);
vector
<
vector
<
complex
<
float
>>>
fft_orig_out
=
compute_frame_ffts
(
orig_wav_data
);
for
(
int
block
=
0
;
block
<
block_count
(
wav_data
);
block
++
)
{
vector
<
MixEntry
>
mix_entries
=
gen_mix_entries
(
block
);
double
umag
=
0
,
dmag
=
0
;
for
(
int
f
=
0
;
f
<
Params
::
block_size
*
Params
::
frames_per_bit
;
f
++
)
{
for
(
int
ch
=
0
;
ch
<
wav_data
.
n_channels
();
ch
++
)
{
for
(
size_t
frame_b
=
0
;
frame_b
<
Params
::
bands_per_frame
;
frame_b
++
)
{
int
b
=
f
*
Params
::
bands_per_frame
+
frame_b
;
const
double
min_db
=
-
96
;
const
int
index
=
(
block
*
(
Params
::
block_size
*
Params
::
frames_per_bit
)
+
mix_entries
[
b
].
frame
)
*
wav_data
.
n_channels
()
+
ch
;
const
int
u
=
mix_entries
[
b
].
up
;
{
umag
+=
db_from_factor
(
abs
(
fft_out
[
index
][
u
]),
min_db
);
umag
-=
db_from_factor
(
abs
(
fft_orig_out
[
index
][
u
]),
min_db
);
}
const
int
d
=
mix_entries
[
b
].
down
;
{
dmag
+=
db_from_factor
(
abs
(
fft_out
[
index
][
d
]),
min_db
);
dmag
-=
db_from_factor
(
abs
(
fft_orig_out
[
index
][
d
]),
min_db
);
}
}
}
if
((
f
%
Params
::
frames_per_bit
)
==
(
Params
::
frames_per_bit
-
1
))
{
bit_vec
.
push_back
((
umag
>
dmag
)
?
1
:
0
);
umag
=
0
;
dmag
=
0
;
}
}
}
bit_vec
=
mix_decode
(
wav_data
,
fft_out
,
fft_orig_out
);
}
else
{
...
...
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