Commit 1aafa13c authored by Stefan Westerfeld's avatar Stefan Westerfeld

Fix audiowmark cmp: report matching patterns.

Signed-off-by: Stefan Westerfeld's avatarStefan Westerfeld <stefan@space.twc.de>
parent b330adeb
......@@ -981,6 +981,8 @@ public:
int
decode_and_report (const WavData& wav_data, const string& orig_pattern)
{
int match_count = 0, total_count = 0;
SyncFinder sync_finder;
for (auto pos : sync_finder.search (wav_data))
......@@ -1014,26 +1016,24 @@ decode_and_report (const WavData& wav_data, const string& orig_pattern)
vector<int> bit_vec = conv_decode_soft (randomize_bit_order (soft_bit_vec, /* encode */ false));
const int seconds = lrint (pos / wav_data.mix_freq());
printf ("pattern %2d:%02d %s\n", seconds / 60, seconds % 60, bit_vec_to_str (bit_vec).c_str());
}
#if 0 /* TODO */
if (!orig_pattern.empty())
{
int bits = 0, bit_errors = 0;
vector<int> orig_vec = bit_str_to_vec (orig_pattern);
for (size_t i = 0; i < bit_vec.size(); i++)
if (!orig_pattern.empty())
{
bits++;
if (bit_vec[i] != orig_vec[i % orig_vec.size()])
bit_errors++;
bool match = true;
vector<int> orig_vec = bit_str_to_vec (orig_pattern);
for (size_t i = 0; i < bit_vec.size(); i++)
match = match && (bit_vec[i] == orig_vec[i % orig_vec.size()]);
if (match)
match_count++;
}
printf ("bit_error_raw %d %d\n", bit_errors, bits);
printf ("bit_error_rate %.5f %%\n", double (100.0 * bit_errors) / bits);
total_count++;
}
#endif
if (!orig_pattern.empty())
printf ("match_count %d %d\n", match_count, total_count);
return 0;
}
......
......@@ -8,7 +8,7 @@ if [ "x$AWM_SEEDS" == "x" ]; then
AWM_SEEDS=0
fi
if [ "x$AWM_REPORT" == "x" ]; then
AWM_REPORT=ber
AWM_REPORT=fer
fi
if [ "x$AWM_FILE" == "x" ]; then
AWM_FILE=t
......@@ -97,11 +97,9 @@ do
# decoding with original
# audiowmark cmp-delta "$i" t.wav $PATTERN $AWM_PARAMS --test-key $SEED
done
done | grep bit_error_rate | {
if [ "x$AWM_REPORT" == "xber" ]; then
awk 'BEGIN { max_er = er = n = 0 } { er += $2; n++; if ($2 > max_er) max_er = $2;} END { print er / n, max_er; }'
elif [ "x$AWM_REPORT" == "xfer" ]; then
awk 'BEGIN { bad = n = 0 } { if ($2 > 0) bad++; n++; } END { print bad, n, bad * 100.0 / n; }'
done | grep match_count | {
if [ "x$AWM_REPORT" == "xfer" ]; then
awk 'BEGIN { bad = n = 0 } { if ($2 == 0) bad++; n++; } END { print bad, n, bad * 100.0 / n; }'
else
echo "unknown report $AWM_REPORT" >&2
exit 1
......
......@@ -5,6 +5,6 @@ mkdir -p test
seq=1
cat test_list | while read f
do
audiowmark gentest "$f" test/T$(printf "%02d__%s" $seq $(echo $f | sed 's, ,_,g;s,.*/,,g')).wav
audiowmark gentest "$f" test/T$(printf "%02d__%s" $seq $(echo $f | sed 's, ,_,g;s,.*/,,g')).wav || exit 1
((seq++))
done
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment