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
acaeb485
Commit
acaeb485
authored
Jan 14, 2020
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add hacky snr peak masking
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
4a2f0b2d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
5 deletions
+25
-5
audiowmark.cc
src/audiowmark.cc
+25
-5
No files found.
src/audiowmark.cc
View file @
acaeb485
...
@@ -419,19 +419,39 @@ test_snr (const string& orig_file, const string& wm_file)
...
@@ -419,19 +419,39 @@ test_snr (const string& orig_file, const string& wm_file)
assert
(
orig_data
.
n_values
()
==
wm_data
.
n_values
());
assert
(
orig_data
.
n_values
()
==
wm_data
.
n_values
());
assert
(
orig_data
.
n_channels
()
==
orig_data
.
n_channels
());
assert
(
orig_data
.
n_channels
()
==
orig_data
.
n_channels
());
const
auto
&
orig_signal
=
orig_data
.
samples
();
auto
orig_signal
=
orig_data
.
samples
();
const
auto
&
wm_signal
=
wm_data
.
samples
();
const
auto
&
wm_signal
=
wm_data
.
samples
();
for
(
int
m
=
0
;
m
<
orig_signal
.
size
();
m
++
)
{
if
(
fabs
(
orig_signal
[
m
])
>
0.9
)
{
for
(
int
k
=
-
1000
;
k
<
1000
;
k
++
)
{
if
(
m
+
k
>=
0
&&
m
+
k
<
int
(
orig_signal
.
size
()))
orig_signal
[
m
+
k
]
=
0
;
}
}
}
#if 0
WavData out_wav_data (orig_signal, orig_data.n_channels(), orig_data.sample_rate(), orig_data.bit_depth());
out_wav_data.save ("/tmp/foo.wav");
#endif
double
snr_delta_power
=
0
;
double
snr_delta_power
=
0
;
double
snr_signal_power
=
0
;
double
snr_signal_power
=
0
;
for
(
size_t
i
=
0
;
i
<
orig_signal
.
size
();
i
++
)
for
(
size_t
i
=
0
;
i
<
orig_signal
.
size
();
i
++
)
{
{
const
double
orig
=
orig_signal
[
i
];
// original sample
if
(
orig_signal
[
i
]
!=
0
)
const
double
delta
=
orig_signal
[
i
]
-
wm_signal
[
i
];
// watermark
{
const
double
orig
=
orig_signal
[
i
];
// original sample
const
double
delta
=
orig_signal
[
i
]
-
wm_signal
[
i
];
// watermark
snr_delta_power
+=
delta
*
delta
;
snr_delta_power
+=
delta
*
delta
;
snr_signal_power
+=
orig
*
orig
;
snr_signal_power
+=
orig
*
orig
;
}
}
}
printf
(
"%f
\n
"
,
10
*
log10
(
snr_signal_power
/
snr_delta_power
));
printf
(
"%f
\n
"
,
10
*
log10
(
snr_signal_power
/
snr_delta_power
));
return
0
;
return
0
;
...
...
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