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
323ecfff
Commit
323ecfff
authored
Dec 14, 2018
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge linear non-blind/blind decoding.
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
63d54b66
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
62 deletions
+45
-62
audiowmark.cc
src/audiowmark.cc
+45
-62
No files found.
src/audiowmark.cc
View file @
323ecfff
...
...
@@ -664,35 +664,17 @@ mix_decode (const WavData& wav_data, vector<vector<complex<float>>>& fft_out, ve
return
bit_vec
;
}
int
get_watermark
(
const
string
&
infile
,
const
string
&
orig_pattern
)
vector
<
int
>
linear_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
)
{
vector
<
vector
<
complex
<
float
>>>
fft_orig_out
;
/* no original data -> blind decode */
bit_vec
=
mix_decode
(
wav_data
,
fft_out
,
fft_orig_out
);
}
else
{
double
umag
=
0
,
dmag
=
0
;
for
(
int
f
=
0
;
f
<
frame_count
(
wav_data
);
f
++
)
{
for
(
int
ch
=
0
;
ch
<
wav_data
.
n_channels
();
ch
++
)
{
const
in
t
index
=
f
*
wav_data
.
n_channels
()
+
ch
;
const
size_
t
index
=
f
*
wav_data
.
n_channels
()
+
ch
;
vector
<
int
>
up
;
vector
<
int
>
down
;
get_up_down
(
f
,
up
,
down
);
...
...
@@ -701,10 +683,16 @@ get_watermark (const string& infile, const string& orig_pattern)
for
(
auto
u
:
up
)
{
umag
+=
db_from_factor
(
abs
(
fft_out
[
index
][
u
]),
min_db
);
if
(
index
<
fft_orig_out
.
size
())
umag
-=
db_from_factor
(
abs
(
fft_orig_out
[
index
][
u
]),
min_db
);
}
for
(
auto
d
:
down
)
{
dmag
+=
db_from_factor
(
abs
(
fft_out
[
index
][
d
]),
min_db
);
if
(
index
<
fft_orig_out
.
size
())
dmag
-=
db_from_factor
(
abs
(
fft_orig_out
[
index
][
d
]),
min_db
);
}
}
if
((
f
%
Params
::
frames_per_bit
)
==
(
Params
::
frames_per_bit
-
1
))
...
...
@@ -714,6 +702,33 @@ get_watermark (const string& infile, const string& orig_pattern)
dmag
=
0
;
}
}
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
);
vector
<
vector
<
complex
<
float
>>>
fft_orig_out
;
/* no original data -> blind decode */
if
(
Params
::
mix
)
{
bit_vec
=
mix_decode
(
wav_data
,
fft_out
,
fft_orig_out
);
}
else
{
bit_vec
=
linear_decode
(
wav_data
,
fft_out
,
fft_orig_out
);
}
printf
(
"pattern %s
\n
"
,
bit_vec_to_str
(
bit_vec
).
c_str
());
if
(
!
orig_pattern
.
empty
())
...
...
@@ -763,39 +778,7 @@ get_watermark_delta (const string& origfile, const string& infile, const string&
}
else
{
double
umag
=
0
,
dmag
=
0
;
for
(
int
f
=
0
;
f
<
frame_count
(
wav_data
);
f
++
)
{
for
(
int
ch
=
0
;
ch
<
wav_data
.
n_channels
();
ch
++
)
{
const
size_t
index
=
f
*
wav_data
.
n_channels
()
+
ch
;
vector
<
int
>
up
;
vector
<
int
>
down
;
get_up_down
(
f
,
up
,
down
);
const
double
min_db
=
-
96
;
for
(
auto
u
:
up
)
{
umag
+=
db_from_factor
(
abs
(
fft_out
[
index
][
u
]),
min_db
);
if
(
index
<
fft_orig_out
.
size
())
umag
-=
db_from_factor
(
abs
(
fft_orig_out
[
index
][
u
]),
min_db
);
}
for
(
auto
d
:
down
)
{
dmag
+=
db_from_factor
(
abs
(
fft_out
[
index
][
d
]),
min_db
);
if
(
index
<
fft_orig_out
.
size
())
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
=
linear_decode
(
wav_data
,
fft_out
,
fft_orig_out
);
}
printf
(
"pattern %s
\n
"
,
bit_vec_to_str
(
bit_vec
).
c_str
());
if
(
!
orig_pattern
.
empty
())
...
...
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