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
8da680ab
Commit
8da680ab
authored
Jan 15, 2019
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge linear marking code for sync and data.
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
2fe8a43d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
46 deletions
+34
-46
audiowmark.cc
src/audiowmark.cc
+34
-46
No files found.
src/audiowmark.cc
View file @
8da680ab
...
@@ -359,6 +359,37 @@ compute_frame_ffts (const WavData& wav_data, size_t start_index, size_t frame_co
...
@@ -359,6 +359,37 @@ compute_frame_ffts (const WavData& wav_data, size_t start_index, size_t frame_co
return
fft_out
;
return
fft_out
;
}
}
void
mark_bit_linear
(
int
f
,
const
vector
<
complex
<
float
>>&
fft_out
,
vector
<
complex
<
float
>>&
fft_delta_spect
,
int
data_bit
)
{
vector
<
int
>
up
;
vector
<
int
>
down
;
get_up_down
(
f
,
up
,
down
);
const
double
data_bit_sign
=
data_bit
>
0
?
1
:
-
1
;
for
(
auto
u
:
up
)
{
/*
* for up bands, we want do use [for a 1 bit] (pow (mag, 1 - water_delta))
*
* this actually increases the amount of energy because mag is less than 1.0
*/
const
float
mag_factor
=
pow
(
abs
(
fft_out
[
u
]),
-
Params
::
water_delta
*
data_bit_sign
);
fft_delta_spect
[
u
]
=
fft_out
[
u
]
*
(
mag_factor
-
1
);
}
for
(
auto
d
:
down
)
{
/*
* for down bands, we want do use [for a 1 bit] (pow (mag, 1 + water_delta))
*
* this actually decreases the amount of energy because mag is less than 1.0
*/
const
float
mag_factor
=
pow
(
abs
(
fft_out
[
d
]),
Params
::
water_delta
*
data_bit_sign
);
fft_delta_spect
[
d
]
=
fft_out
[
d
]
*
(
mag_factor
-
1
);
}
}
size_t
size_t
mark_data_frame_count
()
mark_data_frame_count
()
{
{
...
@@ -423,34 +454,7 @@ mark_data (const WavData& wav_data, int start_frame, const vector<vector<complex
...
@@ -423,34 +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
;
size_t
index
=
(
start_frame
+
f
)
*
wav_data
.
n_channels
()
+
ch
;
vector
<
int
>
up
;
mark_bit_linear
(
f
,
fft_out
[
index
],
fft_delta_spect
[
index
],
bitvec
[
f
/
Params
::
frames_per_bit
]);
vector
<
int
>
down
;
get_up_down
(
f
,
up
,
down
);
const
int
data_bit
=
bitvec
[
f
/
Params
::
frames_per_bit
];
const
double
data_bit_sign
=
data_bit
>
0
?
1
:
-
1
;
for
(
auto
u
:
up
)
{
/*
* for up bands, we want do use [for a 1 bit] (pow (mag, 1 - water_delta))
*
* this actually increases the amount of energy because mag is less than 1.0
*/
const
float
mag_factor
=
pow
(
abs
(
fft_out
[
index
][
u
]),
-
Params
::
water_delta
*
data_bit_sign
);
fft_delta_spect
[
index
][
u
]
=
fft_out
[
index
][
u
]
*
(
mag_factor
-
1
);
}
for
(
auto
d
:
down
)
{
/*
* for down bands, we want do use [for a 1 bit] (pow (mag, 1 + water_delta))
*
* this actually decreases the amount of energy because mag is less than 1.0
*/
const
float
mag_factor
=
pow
(
abs
(
fft_out
[
index
][
d
]),
Params
::
water_delta
*
data_bit_sign
);
fft_delta_spect
[
index
][
d
]
=
fft_out
[
index
][
d
]
*
(
mag_factor
-
1
);
}
}
}
}
}
}
}
...
@@ -475,25 +479,9 @@ mark_sync (const WavData& wav_data, int start_frame, const vector<vector<complex
...
@@ -475,25 +479,9 @@ mark_sync (const WavData& wav_data, int start_frame, const vector<vector<complex
for
(
int
ch
=
0
;
ch
<
wav_data
.
n_channels
();
ch
++
)
for
(
int
ch
=
0
;
ch
<
wav_data
.
n_channels
();
ch
++
)
{
{
size_t
index
=
(
start_frame
+
f
)
*
wav_data
.
n_channels
()
+
ch
;
size_t
index
=
(
start_frame
+
f
)
*
wav_data
.
n_channels
()
+
ch
;
int
data_bit
=
(
f
/
Params
::
sync_frames_per_bit
)
&
1
;
/* write 010101 */
vector
<
int
>
up
;
mark_bit_linear
(
f
,
fft_out
[
index
],
fft_delta_spect
[
index
],
data_bit
);
vector
<
int
>
down
;
get_up_down
(
f
,
up
,
down
);
// FIXME use extra random stream for sync
const
int
data_bit
=
(
f
/
Params
::
sync_frames_per_bit
)
&
1
;
/* write 010101 */
const
double
data_bit_sign
=
data_bit
>
0
?
1
:
-
1
;
for
(
auto
u
:
up
)
{
const
float
mag_factor
=
pow
(
abs
(
fft_out
[
index
][
u
]),
-
Params
::
water_delta
*
data_bit_sign
);
fft_delta_spect
[
index
][
u
]
=
fft_out
[
index
][
u
]
*
(
mag_factor
-
1
);
}
for
(
auto
d
:
down
)
{
const
float
mag_factor
=
pow
(
abs
(
fft_out
[
index
][
d
]),
Params
::
water_delta
*
data_bit_sign
);
fft_delta_spect
[
index
][
d
]
=
fft_out
[
index
][
d
]
*
(
mag_factor
-
1
);
}
}
}
}
}
}
}
...
...
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