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
57b70e93
Commit
57b70e93
authored
Feb 11, 2019
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Decode AB blocks whenever an A block is followed by a B block.
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
6b0b0259
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
3 deletions
+39
-3
audiowmark.cc
src/audiowmark.cc
+39
-3
No files found.
src/audiowmark.cc
View file @
57b70e93
...
@@ -1147,10 +1147,20 @@ decode_and_report (const WavData& wav_data, const string& orig_pattern)
...
@@ -1147,10 +1147,20 @@ decode_and_report (const WavData& wav_data, const string& orig_pattern)
{
{
if
(
sync_score
.
index
)
if
(
sync_score
.
index
)
{
{
const
char
*
block_str
=
nullptr
;
switch
(
sync_score
.
block_type
)
{
case
ConvBlockType
:
:
a
:
block_str
=
"A"
;
break
;
case
ConvBlockType
:
:
b
:
block_str
=
"B"
;
break
;
case
ConvBlockType
:
:
ab
:
block_str
=
"AB"
;
break
;
}
const
int
seconds
=
sync_score
.
index
/
wav_data
.
sample_rate
();
const
int
seconds
=
sync_score
.
index
/
wav_data
.
sample_rate
();
printf
(
"pattern %2d:%02d %s %.3f %.3f %s
\n
"
,
seconds
/
60
,
seconds
%
60
,
bit_vec_to_str
(
bit_vec
).
c_str
(),
printf
(
"pattern %2d:%02d %s %.3f %.3f %s
\n
"
,
seconds
/
60
,
seconds
%
60
,
bit_vec_to_str
(
bit_vec
).
c_str
(),
sync_score
.
quality
,
decode_error
,
sync_score
.
quality
,
decode_error
,
block_str
);
sync_score
.
block_type
==
ConvBlockType
::
a
?
"A"
:
"B"
);
}
}
else
/* this is the combined pattern "all" */
else
/* this is the combined pattern "all" */
{
{
...
@@ -1175,17 +1185,23 @@ decode_and_report (const WavData& wav_data, const string& orig_pattern)
...
@@ -1175,17 +1185,23 @@ decode_and_report (const WavData& wav_data, const string& orig_pattern)
vector
<
int
>
raw_bit_vec_norm
(
2
);
vector
<
int
>
raw_bit_vec_norm
(
2
);
SyncFinder
::
Score
score_all
{
0
,
0
};
SyncFinder
::
Score
score_all
{
0
,
0
};
SyncFinder
::
Score
score_ab
{
0
,
0
,
ConvBlockType
::
ab
};
ConvBlockType
last_block_type
=
ConvBlockType
::
b
;
vector
<
vector
<
float
>>
ab_raw_bit_vec
(
2
);
vector
<
float
>
ab_quality
(
2
);
for
(
auto
sync_score
:
sync_scores
)
for
(
auto
sync_score
:
sync_scores
)
{
{
const
size_t
count
=
mark_data_frame_count
();
const
size_t
count
=
mark_data_frame_count
();
const
size_t
index
=
sync_score
.
index
+
(
mark_sync_frame_count
()
*
Params
::
frame_size
);
const
size_t
index
=
sync_score
.
index
+
(
mark_sync_frame_count
()
*
Params
::
frame_size
);
const
int
ab
=
(
sync_score
.
block_type
==
ConvBlockType
::
b
);
/* A -> 0, B -> 1 */
auto
fft_range_out
=
compute_frame_ffts
(
wav_data
,
index
,
count
);
auto
fft_range_out
=
compute_frame_ffts
(
wav_data
,
index
,
count
);
if
(
fft_range_out
.
size
())
if
(
fft_range_out
.
size
())
{
{
vector
<
vector
<
complex
<
float
>>>
junk
;
vector
<
vector
<
complex
<
float
>>>
junk
;
/* ---- retrieve bits from watermark ---- */
vector
<
float
>
raw_bit_vec
;
vector
<
float
>
raw_bit_vec
;
if
(
Params
::
mix
)
if
(
Params
::
mix
)
{
{
...
@@ -1199,19 +1215,39 @@ decode_and_report (const WavData& wav_data, const string& orig_pattern)
...
@@ -1199,19 +1215,39 @@ decode_and_report (const WavData& wav_data, const string& orig_pattern)
raw_bit_vec
=
randomize_bit_order
(
raw_bit_vec
,
/* encode */
false
);
raw_bit_vec
=
randomize_bit_order
(
raw_bit_vec
,
/* encode */
false
);
/* ---- deal with this pattern ---- */
float
decode_error
=
0
;
float
decode_error
=
0
;
vector
<
int
>
bit_vec
=
conv_decode_soft
(
sync_score
.
block_type
,
normalize_soft_bits
(
raw_bit_vec
),
&
decode_error
);
vector
<
int
>
bit_vec
=
conv_decode_soft
(
sync_score
.
block_type
,
normalize_soft_bits
(
raw_bit_vec
),
&
decode_error
);
report_pattern
(
sync_score
,
bit_vec
,
decode_error
);
report_pattern
(
sync_score
,
bit_vec
,
decode_error
);
/* ---- update "all" pattern ---- */
score_all
.
quality
+=
sync_score
.
quality
;
score_all
.
quality
+=
sync_score
.
quality
;
int
ab
=
(
sync_score
.
block_type
==
ConvBlockType
::
b
);
for
(
size_t
i
=
0
;
i
<
raw_bit_vec
.
size
();
i
++
)
for
(
size_t
i
=
0
;
i
<
raw_bit_vec
.
size
();
i
++
)
{
{
raw_bit_vec_all
[
i
*
2
+
ab
]
+=
raw_bit_vec
[
i
];
raw_bit_vec_all
[
i
*
2
+
ab
]
+=
raw_bit_vec
[
i
];
}
}
raw_bit_vec_norm
[
ab
]
++
;
raw_bit_vec_norm
[
ab
]
++
;
/* ---- if last block was A & this block is B => deal with combined AB block */
ab_raw_bit_vec
[
ab
]
=
raw_bit_vec
;
ab_quality
[
ab
]
=
sync_score
.
quality
;
if
(
last_block_type
==
ConvBlockType
::
a
&&
sync_score
.
block_type
==
ConvBlockType
::
b
)
{
/* join A and B block -> AB block */
vector
<
float
>
ab_bits
(
raw_bit_vec
.
size
()
*
2
);
for
(
size_t
i
=
0
;
i
<
raw_bit_vec
.
size
();
i
++
)
{
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
=
conv_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
;
report_pattern
(
score_ab
,
bit_vec
,
decode_error
);
}
last_block_type
=
sync_score
.
block_type
;
}
}
}
}
if
(
total_count
>
1
)
/* all pattern: average soft bits of all watermarks and decode */
if
(
total_count
>
1
)
/* all pattern: average soft bits of all watermarks and decode */
...
...
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