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
ee82f4cc
Commit
ee82f4cc
authored
Jun 02, 2020
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support --short for 16 bit payload.
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
b7be33aa
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
9 deletions
+26
-9
audiowmark.cc
src/audiowmark.cc
+6
-0
wmadd.cc
src/wmadd.cc
+7
-1
wmcommon.cc
src/wmcommon.cc
+4
-1
wmcommon.hh
src/wmcommon.hh
+2
-1
wmget.cc
src/wmget.cc
+7
-6
No files found.
src/audiowmark.cc
View file @
ee82f4cc
...
...
@@ -57,6 +57,7 @@ print_usage()
printf
(
"Global options:
\n
"
);
printf
(
" --strength <s> set watermark strength [%.6g]
\n
"
,
Params
::
water_delta
*
1000
);
printf
(
" --linear disable non-linear bit storage
\n
"
);
printf
(
" --short enable short payload mode (16 bits)
\n
"
);
printf
(
" --key <file> load watermarking key from file
\n
"
);
printf
(
" -q, --quiet disable information messages
\n
"
);
printf
(
"
\n
"
);
...
...
@@ -183,6 +184,11 @@ parse_options (int *argc_p,
{
Params
::
mix
=
false
;
}
else
if
(
check_arg
(
argc
,
argv
,
&
i
,
"--short"
))
{
Params
::
payload_size
=
16
;
Params
::
payload_short
=
true
;
}
else
if
(
check_arg
(
argc
,
argv
,
&
i
,
"--hard"
))
{
Params
::
hard
=
true
;
...
...
src/wmadd.cc
View file @
ee82f4cc
...
...
@@ -30,6 +30,7 @@
#include "rawinputstream.hh"
#include "rawoutputstream.hh"
#include "stdoutwavoutputstream.hh"
#include "shortcode.hh"
using
std
::
string
;
using
std
::
vector
;
...
...
@@ -149,7 +150,7 @@ init_frame_mod_vec (vector<vector<FrameMod>>& frame_mod_vec, int ab, const vecto
/* forward error correction */
ConvBlockType
block_type
=
ab
?
ConvBlockType
::
b
:
ConvBlockType
::
a
;
vector
<
int
>
bitvec_fec
=
randomize_bit_order
(
co
nv
_encode
(
block_type
,
bitvec
),
/* encode */
true
);
vector
<
int
>
bitvec_fec
=
randomize_bit_order
(
co
de
_encode
(
block_type
,
bitvec
),
/* encode */
true
);
mark_sync
(
frame_mod_vec
,
ab
);
mark_data
(
frame_mod_vec
,
bitvec_fec
);
...
...
@@ -553,6 +554,11 @@ add_watermark (const string& infile, const string& outfile, const string& bits)
error
(
"audiowmark: cannot parse bits %s
\n
"
,
bits
.
c_str
());
return
1
;
}
if
(
Params
::
payload_short
&&
bitvec
.
size
()
!=
Params
::
payload_size
)
{
error
(
"audiowmark: number of message bits must match payload size (%zd bits)
\n
"
,
Params
::
payload_size
);
return
1
;
}
if
(
bitvec
.
size
()
>
Params
::
payload_size
)
{
error
(
"audiowmark: number of bits in message '%s' larger than payload size
\n
"
,
bits
.
c_str
());
...
...
src/wmcommon.cc
View file @
ee82f4cc
...
...
@@ -18,6 +18,7 @@
#include "wmcommon.hh"
#include "fft.hh"
#include "convcode.hh"
#include "shortcode.hh"
int
Params
::
frames_per_bit
=
2
;
double
Params
::
water_delta
=
0.01
;
...
...
@@ -25,6 +26,8 @@ bool Params::mix = true;
bool
Params
::
hard
=
false
;
// hard decode bits? (soft decoding is better)
bool
Params
::
snr
=
false
;
// compute/show snr while adding watermark
int
Params
::
have_key
=
0
;
size_t
Params
::
payload_size
=
128
;
bool
Params
::
payload_short
=
false
;
int
Params
::
test_cut
=
0
;
// for sync test
bool
Params
::
test_no_sync
=
false
;
// disable sync
bool
Params
::
test_no_limiter
=
false
;
// disable limiter
...
...
@@ -209,7 +212,7 @@ data_frame_pos (int f)
size_t
mark_data_frame_count
()
{
return
co
nv_co
de_size
(
ConvBlockType
::
a
,
Params
::
payload_size
)
*
Params
::
frames_per_bit
;
return
code_size
(
ConvBlockType
::
a
,
Params
::
payload_size
)
*
Params
::
frames_per_bit
;
}
size_t
...
...
src/wmcommon.hh
View file @
ee82f4cc
...
...
@@ -43,7 +43,8 @@ public:
static
bool
snr
;
// compute/show snr while adding watermark
static
int
have_key
;
static
constexpr
size_t
payload_size
=
128
;
// number of payload bits for the watermark
static
size_t
payload_size
;
// number of payload bits for the watermark
static
bool
payload_short
;
static
constexpr
int
sync_bits
=
6
;
static
constexpr
int
sync_frames_per_bit
=
85
;
...
...
src/wmget.cc
View file @
ee82f4cc
...
...
@@ -24,6 +24,7 @@
#include "wavdata.hh"
#include "wmcommon.hh"
#include "convcode.hh"
#include "shortcode.hh"
using
std
::
string
;
using
std
::
vector
;
...
...
@@ -758,7 +759,7 @@ public:
SyncFinder
sync_finder
;
sync_scores
=
sync_finder
.
search
(
wav_data
,
SyncFinder
::
Mode
::
BLOCK
);
vector
<
float
>
raw_bit_vec_all
(
co
nv_co
de_size
(
ConvBlockType
::
ab
,
Params
::
payload_size
));
vector
<
float
>
raw_bit_vec_all
(
code_size
(
ConvBlockType
::
ab
,
Params
::
payload_size
));
vector
<
int
>
raw_bit_vec_norm
(
2
);
SyncFinder
::
Score
score_all
{
0
,
0
};
...
...
@@ -787,13 +788,13 @@ public:
{
raw_bit_vec
=
linear_decode
(
fft_range_out
,
wav_data
.
n_channels
());
}
assert
(
raw_bit_vec
.
size
()
==
co
nv_co
de_size
(
ConvBlockType
::
a
,
Params
::
payload_size
));
assert
(
raw_bit_vec
.
size
()
==
code_size
(
ConvBlockType
::
a
,
Params
::
payload_size
));
raw_bit_vec
=
randomize_bit_order
(
raw_bit_vec
,
/* encode */
false
);
/* ---- deal with this pattern ---- */
float
decode_error
=
0
;
vector
<
int
>
bit_vec
=
co
nv
_decode_soft
(
sync_score
.
block_type
,
normalize_soft_bits
(
raw_bit_vec
),
&
decode_error
);
vector
<
int
>
bit_vec
=
co
de
_decode_soft
(
sync_score
.
block_type
,
normalize_soft_bits
(
raw_bit_vec
),
&
decode_error
);
result_set
.
add_pattern
(
sync_score
,
bit_vec
,
decode_error
,
ResultSet
::
Type
::
BLOCK
);
total_count
+=
1
;
...
...
@@ -819,7 +820,7 @@ public:
ab_bits
[
i
*
2
]
=
ab_raw_bit_vec
[
0
][
i
];
ab_bits
[
i
*
2
+
1
]
=
ab_raw_bit_vec
[
1
][
i
];
}
vector
<
int
>
bit_vec
=
co
nv
_decode_soft
(
ConvBlockType
::
ab
,
normalize_soft_bits
(
ab_bits
),
&
decode_error
);
vector
<
int
>
bit_vec
=
co
de
_decode_soft
(
ConvBlockType
::
ab
,
normalize_soft_bits
(
ab_bits
),
&
decode_error
);
score_ab
.
index
=
sync_score
.
index
;
score_ab
.
quality
=
(
ab_quality
[
0
]
+
ab_quality
[
1
])
/
2
;
result_set
.
add_pattern
(
score_ab
,
bit_vec
,
decode_error
,
ResultSet
::
Type
::
BLOCK
);
...
...
@@ -839,7 +840,7 @@ public:
vector
<
float
>
soft_bit_vec
=
normalize_soft_bits
(
raw_bit_vec_all
);
float
decode_error
=
0
;
vector
<
int
>
bit_vec
=
co
nv
_decode_soft
(
ConvBlockType
::
ab
,
soft_bit_vec
,
&
decode_error
);
vector
<
int
>
bit_vec
=
co
de
_decode_soft
(
ConvBlockType
::
ab
,
soft_bit_vec
,
&
decode_error
);
result_set
.
add_pattern
(
score_all
,
bit_vec
,
decode_error
,
ResultSet
::
Type
::
ALL
);
}
...
...
@@ -943,7 +944,7 @@ class ClipDecoder
}
float
decode_error
=
0
;
vector
<
int
>
bit_vec
=
co
nv
_decode_soft
(
ConvBlockType
::
ab
,
normalize_soft_bits
(
raw_bit_vec
),
&
decode_error
);
vector
<
int
>
bit_vec
=
co
de
_decode_soft
(
ConvBlockType
::
ab
,
normalize_soft_bits
(
raw_bit_vec
),
&
decode_error
);
SyncFinder
::
Score
sync_score_nopad
=
sync_score
;
sync_score_nopad
.
index
=
time_offset_sec
*
wav_data
.
sample_rate
();
...
...
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