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
3acd2d29
Commit
3acd2d29
authored
Jan 15, 2019
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use separate random streams for sync / data / padding.
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
e6e0e5a3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
13 deletions
+15
-13
audiowmark.cc
src/audiowmark.cc
+10
-10
random.hh
src/random.hh
+5
-3
No files found.
src/audiowmark.cc
View file @
3acd2d29
...
...
@@ -231,13 +231,13 @@ frame_count (const WavData& wav_data)
}
void
get_up_down
(
int
f
,
vector
<
int
>&
up
,
vector
<
int
>&
down
)
get_up_down
(
int
f
,
vector
<
int
>&
up
,
vector
<
int
>&
down
,
Random
::
Stream
random_stream
)
{
vector
<
int
>
bands_reorder
;
for
(
int
i
=
Params
::
min_band
;
i
<=
Params
::
max_band
;
i
++
)
bands_reorder
.
push_back
(
i
);
Random
random
(
f
,
Random
::
Stream
::
up_down
);
// use per frame random seed
Random
random
(
f
,
random_stream
);
// use per frame random seed
random
.
shuffle
(
bands_reorder
);
assert
(
2
*
Params
::
bands_per_frame
<
bands_reorder
.
size
());
...
...
@@ -286,7 +286,7 @@ gen_mix_entries (int block)
{
vector
<
int
>
up
;
vector
<
int
>
down
;
get_up_down
(
f
,
up
,
down
);
get_up_down
(
f
,
up
,
down
,
Random
::
Stream
::
data_up_down
);
assert
(
up
.
size
()
==
down
.
size
());
for
(
size_t
i
=
0
;
i
<
up
.
size
();
i
++
)
...
...
@@ -360,11 +360,11 @@ compute_frame_ffts (const WavData& wav_data, size_t start_index, size_t frame_co
}
void
mark_bit_linear
(
int
f
,
const
vector
<
complex
<
float
>>&
fft_out
,
vector
<
complex
<
float
>>&
fft_delta_spect
,
int
data_bit
)
mark_bit_linear
(
int
f
,
const
vector
<
complex
<
float
>>&
fft_out
,
vector
<
complex
<
float
>>&
fft_delta_spect
,
int
data_bit
,
Random
::
Stream
random_stream
)
{
vector
<
int
>
up
;
vector
<
int
>
down
;
get_up_down
(
f
,
up
,
down
);
get_up_down
(
f
,
up
,
down
,
random_stream
);
const
double
data_bit_sign
=
data_bit
>
0
?
1
:
-
1
;
for
(
auto
u
:
up
)
{
...
...
@@ -454,7 +454,7 @@ mark_data (const WavData& wav_data, int start_frame, const vector<vector<complex
{
size_t
index
=
(
start_frame
+
f
)
*
wav_data
.
n_channels
()
+
ch
;
mark_bit_linear
(
f
,
fft_out
[
index
],
fft_delta_spect
[
index
],
bitvec
[
f
/
Params
::
frames_per_bit
]);
mark_bit_linear
(
f
,
fft_out
[
index
],
fft_delta_spect
[
index
],
bitvec
[
f
/
Params
::
frames_per_bit
]
,
Random
::
Stream
::
data_up_down
);
}
}
}
...
...
@@ -481,7 +481,7 @@ mark_sync (const WavData& wav_data, int start_frame, const vector<vector<complex
size_t
index
=
(
start_frame
+
f
)
*
wav_data
.
n_channels
()
+
ch
;
int
data_bit
=
(
f
/
Params
::
sync_frames_per_bit
)
&
1
;
/* write 010101 */
mark_bit_linear
(
f
,
fft_out
[
index
],
fft_delta_spect
[
index
],
data_bit
);
mark_bit_linear
(
f
,
fft_out
[
index
],
fft_delta_spect
[
index
],
data_bit
,
Random
::
Stream
::
sync_up_down
);
}
}
}
...
...
@@ -495,7 +495,7 @@ mark_pad (const WavData& wav_data, size_t frame, const vector<vector<complex<flo
{
size_t
index
=
frame
*
wav_data
.
n_channels
()
+
ch
;
mark_bit_linear
(
frame
,
fft_out
[
index
],
fft_delta_spect
[
index
],
0
);
mark_bit_linear
(
frame
,
fft_out
[
index
],
fft_delta_spect
[
index
],
0
,
Random
::
Stream
::
pad_up_down
);
}
}
...
...
@@ -748,7 +748,7 @@ linear_decode (vector<vector<complex<float>>>& fft_out, vector<vector<complex<fl
const
size_t
index
=
f
*
n_channels
+
ch
;
vector
<
int
>
up
;
vector
<
int
>
down
;
get_up_down
(
f
,
up
,
down
);
get_up_down
(
f
,
up
,
down
,
Random
::
Stream
::
data_up_down
);
const
double
min_db
=
-
96
;
for
(
auto
u
:
up
)
...
...
@@ -800,7 +800,7 @@ public:
down
.
resize
(
mark_sync_frame_count
());
for
(
size_t
i
=
0
;
i
<
mark_sync_frame_count
();
i
++
)
get_up_down
(
i
,
up
[
i
],
down
[
i
]);
get_up_down
(
i
,
up
[
i
],
down
[
i
]
,
Random
::
Stream
::
sync_up_down
);
}
double
sync_decode
(
const
WavData
&
wav_data
,
const
size_t
start_frame
,
const
vector
<
vector
<
float
>>&
fft_out_db
)
...
...
src/random.hh
View file @
3acd2d29
...
...
@@ -11,9 +11,11 @@ class Random
{
public
:
enum
class
Stream
{
up_down
=
1
,
mix
=
2
,
bit_order
=
3
data_up_down
=
1
,
sync_up_down
=
2
,
pad_up_down
=
3
,
mix
=
4
,
bit_order
=
5
};
private
:
gcry_cipher_hd_t
aes_ctr_cipher
;
...
...
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