Commit 8e0cec5b 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 4516957b
...@@ -981,6 +981,8 @@ public: ...@@ -981,6 +981,8 @@ public:
int int
decode_and_report (const WavData& wav_data, const string& orig_pattern) decode_and_report (const WavData& wav_data, const string& orig_pattern)
{ {
int match_count = 0, total_count = 0;
SyncFinder sync_finder; SyncFinder sync_finder;
for (auto pos : sync_finder.search (wav_data)) for (auto pos : sync_finder.search (wav_data))
...@@ -1014,26 +1016,24 @@ decode_and_report (const WavData& wav_data, const string& orig_pattern) ...@@ -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)); vector<int> bit_vec = conv_decode_soft (randomize_bit_order (soft_bit_vec, /* encode */ false));
const int seconds = lrint (pos / wav_data.mix_freq()); 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()); 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); if (!orig_pattern.empty())
for (size_t i = 0; i < bit_vec.size(); i++)
{ {
bits++; bool match = true;
if (bit_vec[i] != orig_vec[i % orig_vec.size()]) vector<int> orig_vec = bit_str_to_vec (orig_pattern);
bit_errors++;
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); total_count++;
printf ("bit_error_rate %.5f %%\n", double (100.0 * bit_errors) / bits);
} }
#endif
if (!orig_pattern.empty())
printf ("match_count %d %d\n", match_count, total_count);
return 0; return 0;
} }
......
...@@ -8,7 +8,7 @@ if [ "x$AWM_SEEDS" == "x" ]; then ...@@ -8,7 +8,7 @@ if [ "x$AWM_SEEDS" == "x" ]; then
AWM_SEEDS=0 AWM_SEEDS=0
fi fi
if [ "x$AWM_REPORT" == "x" ]; then if [ "x$AWM_REPORT" == "x" ]; then
AWM_REPORT=ber AWM_REPORT=fer
fi fi
if [ "x$AWM_FILE" == "x" ]; then if [ "x$AWM_FILE" == "x" ]; then
AWM_FILE=t AWM_FILE=t
...@@ -97,11 +97,9 @@ do ...@@ -97,11 +97,9 @@ do
# decoding with original # decoding with original
# audiowmark cmp-delta "$i" t.wav $PATTERN $AWM_PARAMS --test-key $SEED # audiowmark cmp-delta "$i" t.wav $PATTERN $AWM_PARAMS --test-key $SEED
done done
done | grep bit_error_rate | { done | grep match_count | {
if [ "x$AWM_REPORT" == "xber" ]; then if [ "x$AWM_REPORT" == "xfer" ]; then
awk 'BEGIN { max_er = er = n = 0 } { er += $2; n++; if ($2 > max_er) max_er = $2;} END { print er / n, max_er; }' awk 'BEGIN { bad = n = 0 } { if ($2 == 0) bad++; n++; } END { print bad, n, bad * 100.0 / n; }'
elif [ "x$AWM_REPORT" == "xfer" ]; then
awk 'BEGIN { bad = n = 0 } { if ($2 > 0) bad++; n++; } END { print bad, n, bad * 100.0 / n; }'
else else
echo "unknown report $AWM_REPORT" >&2 echo "unknown report $AWM_REPORT" >&2
exit 1 exit 1
......
...@@ -5,6 +5,6 @@ mkdir -p test ...@@ -5,6 +5,6 @@ mkdir -p test
seq=1 seq=1
cat test_list | while read f cat test_list | while read f
do 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++)) ((seq++))
done 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