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
c19eb587
Commit
c19eb587
authored
Dec 10, 2018
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add command line parameter to set the random seed.
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
a896c01d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
7 deletions
+18
-7
audiowmark.cc
src/audiowmark.cc
+18
-7
No files found.
src/audiowmark.cc
View file @
c19eb587
...
...
@@ -28,6 +28,7 @@ namespace Params
static
double
water_delta
=
0.015
;
// strength of the watermark
static
double
pre_scale
=
0.95
;
// rescale the signal to avoid clipping after watermark is added
static
bool
shuffle
=
false
;
static
unsigned
int
seed
=
0
;
}
void
...
...
@@ -145,6 +146,10 @@ parse_options (int *argc_p,
{
Params
::
shuffle
=
true
;
}
else
if
(
check_arg
(
argc
,
argv
,
&
i
,
"--seed"
,
&
opt_arg
))
{
Params
::
seed
=
atoi
(
opt_arg
);
}
else
if
(
check_arg
(
argc
,
argv
,
&
i
,
"--water-delta"
,
&
opt_arg
))
{
Params
::
water_delta
=
atof
(
opt_arg
);
...
...
@@ -227,14 +232,22 @@ get_frame (WavData& wav_data, int f, int ch)
return
result
;
}
std
::
mt19937_64
init_rng
(
uint64_t
seed
)
{
const
uint64_t
prime
=
3126986573
;
std
::
mt19937_64
rng
;
rng
.
seed
(
seed
+
prime
*
Params
::
seed
);
return
rng
;
}
void
get_up_down
(
int
f
,
vector
<
int
>&
up
,
vector
<
int
>&
down
)
{
vector
<
int
>
used
(
Params
::
frame_size
/
2
);
std
::
mt19937_64
rng
;
// use per frame random seed, may want to have cryptographically secure algorithm
rng
.
seed
(
f
);
std
::
mt19937_64
rng
=
init_rng
(
f
);
// use per frame random seed, may want to have cryptographically secure algorithm
auto
choose_bands
=
[
&
used
,
&
rng
]
(
vector
<
int
>&
bands
)
{
while
(
bands
.
size
()
<
Params
::
bands_per_frame
)
...
...
@@ -256,9 +269,7 @@ gen_shuffle (size_t size, int seed)
{
vector
<
int
>
result
(
size
);
std
::
mt19937_64
rng
;
// should use cryptographically secure generator, properly seeded
rng
.
seed
(
seed
);
std
::
mt19937_64
rng
=
init_rng
(
seed
);
// should use cryptographically secure generator, properly seeded
for
(
size_t
i
=
0
;
i
<
result
.
size
();
i
++
)
result
[
i
]
=
i
;
...
...
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