Commit af85c13c authored by Stefan Westerfeld's avatar Stefan Westerfeld

Merge branch 'sync'

parents 6fc77233 9c30e309
This diff is collapsed.
......@@ -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
......@@ -21,6 +21,8 @@ fi
cat test_list
elif [ "x$AWM_SET" == "xhuge" ]; then
ls huge/T*
elif [ "x$AWM_SET" == "xhuge2" ]; then
ls huge2/T*
else
echo "bad AWM_SET $AWM_SET" >&2
exit 1
......@@ -45,6 +47,13 @@ do
fi
audiowmark add "$i" ${AWM_FILE}.wav $PATTERN $AWM_PARAMS --test-key $SEED >/dev/null
if [ "x$AWM_RAND_CUT" != x ]; then
CUT=$RANDOM
audiowmark cut-start "${AWM_FILE}.wav" "${AWM_FILE}.wav" $CUT
TEST_CUT_ARGS="--test-cut $CUT"
else
TEST_CUT_ARGS=""
fi
if [ "x$TRANSFORM" == "xmp3" ]; then
if [ "x$2" == "x" ]; then
echo "need mp3 bitrate" >&2
......@@ -93,15 +102,17 @@ do
exit 1
fi
# blind decoding
audiowmark cmp ${AWM_FILE}.wav $PATTERN $AWM_PARAMS --test-key $SEED
audiowmark cmp ${AWM_FILE}.wav $PATTERN $AWM_PARAMS --test-key $SEED $TEST_CUT_ARGS
# 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 | {
if [ "x$AWM_REPORT" == "xfer" ]; then
awk 'BEGIN { bad = n = 0 } $1 == "match_count" { if ($2 == 0) bad++; n++; } END { print bad, n, bad * 100.0 / n; }'
elif [ "x$AWM_REPORT" == "xsync" ]; then
awk 'BEGIN { bad = n = 0 } $1 == "sync_match" { bad += (3 - $2) / 3.0; n++; } END { print bad, n, bad * 100.0 / n; }'
elif [ "x$AWM_REPORT" == "xsyncv" ]; then
awk '{ print "###", $0; } $1 == "sync_match" { correct += $2; missing += 3 - $2; incorrect += $3-$2; print "correct:", correct, "missing:", missing, "incorrect:", incorrect; }'
else
echo "unknown report $AWM_REPORT" >&2
exit 1
......
#include "utils.hh"
#include "convcode.hh"
#include <array>
#include <algorithm>
......@@ -74,7 +75,7 @@ conv_encode (const vector<int>& in_bits)
/* decode using viterbi algorithm */
vector<int>
conv_decode_soft (const vector<float>& coded_bits)
conv_decode_soft (const vector<float>& coded_bits, float *error_out)
{
vector<int> decoded_bits;
......@@ -141,6 +142,8 @@ conv_decode_soft (const vector<float>& coded_bits)
}
unsigned int state = 0;
if (error_out)
*error_out = error_count.back()[state].delta / coded_bits.size();
for (size_t idx = error_count.size() - 1; idx > 0; idx--)
{
decoded_bits.push_back (error_count[idx][state].bit);
......
......@@ -7,6 +7,6 @@
size_t conv_code_size (size_t msg_size);
std::vector<int> conv_encode (const std::vector<int>& in_bits);
std::vector<int> conv_decode_hard (const std::vector<int>& coded_bits);
std::vector<int> conv_decode_soft (const std::vector<float>& coded_bits);
std::vector<int> conv_decode_soft (const std::vector<float>& coded_bits, float *error_out = nullptr);
#endif /* AUDIOWMARK_CONV_CODE_HH */
......@@ -2,8 +2,11 @@
#include <fftw3.h>
#include <map>
using std::vector;
using std::complex;
using std::map;
float *
new_array_float (size_t N)
......@@ -22,8 +25,9 @@ free_array_float (float *f)
void
fftar_float (size_t N, float *in, float *out)
{
static fftwf_plan plan = nullptr; // FIXME: should be one plan per fft size
static map<int, fftwf_plan> plan_for_size;
fftwf_plan& plan = plan_for_size[N];
if (!plan)
{
float *plan_in = new_array_float (N);
......@@ -38,8 +42,9 @@ fftar_float (size_t N, float *in, float *out)
void
fftsr_float (size_t N, float *in, float *out)
{
static fftwf_plan plan = nullptr; // FIXME: should be one plan per fft size
static map<int, fftwf_plan> plan_for_size;
fftwf_plan& plan = plan_for_size[N];
if (!plan)
{
float *plan_in = new_array_float (N);
......
......@@ -4,7 +4,14 @@
#include <complex>
#include <vector>
/* high level api */
std::vector<std::complex<float>> fft (const std::vector<float>& in);
std::vector<float> ifft (const std::vector<std::complex<float>>& in);
/* more efficient: low level api */
void fftar_float (size_t N, float *in, float *out);
float *new_array_float (size_t N);
void free_array_float (float *f);
#endif /* AUDIOWMARK_FFT_HH */
#!/bin/bash
echo ".sync-codec-resistence"
echo '[frame="topbot",options="header",cols="<2,6*>1"]'
echo '|=========================='
echo -n "| "
for D in $(seq 10 -1 5)
do
DELTA=$(printf "0.0%02d\n" $D)
echo -n "| $DELTA"
done
echo
for TEST in mp3 double-mp3 ogg
do
if [ $TEST == mp3 ]; then
echo -n "| mp3 128kbit/s"
elif [ $TEST == double-mp3 ]; then
echo -n "| double mp3 128kbit/s"
elif [ $TEST == ogg ]; then
echo -n "| ogg 128kbit/s"
else
echo "error: bad TEST $TEST ???"
exit 1
fi
for D in $(seq 10 -1 5)
do
DELTA=$(printf "0.0%02d\n" $D)
cat $DELTA-$TEST-* | awk '{bad += $1; n += $2} END {if (n==0) n=1;fer=100.0*bad/n; bold=fer>0?"*":" ";printf ("| %s%.2f%s", bold, fer, bold)}'
done
echo
done
echo
echo '|=========================='
#!/bin/bash
DELTA_RANGE="0.005 0.006 0.007 0.008 0.009 0.010"
SEEDS="$(seq 0 19)"
echo -n "all: "
for SEED in $SEEDS
do
for DELTA in $DELTA_RANGE
do
echo -n "$DELTA-ogg-$SEED $DELTA-mp3-$SEED $DELTA-double-mp3-$SEED "
done
done
echo
echo
for SEED in $SEEDS
do
for DELTA in $DELTA_RANGE
do
FILE="$DELTA-ogg-$SEED"
echo "$FILE:"
echo -e "\t( cd ..; AWM_RAND_PATTERN=1 AWM_RAND_CUT=1 AWM_SET=huge2 AWM_PARAMS='--water-delta $DELTA' AWM_REPORT=fer AWM_SEEDS=$SEED AWM_FILE='t-$FILE' ber-test.sh ogg 128 ) >x$FILE"
echo -e "\tmv x$FILE $FILE"
echo
FILE="$DELTA-mp3-$SEED"
echo "$FILE:"
echo -e "\t( cd ..; AWM_RAND_PATTERN=1 AWM_RAND_CUT=1 AWM_SET=huge2 AWM_PARAMS='--water-delta $DELTA' AWM_REPORT=fer AWM_SEEDS=$SEED AWM_FILE='t-$FILE' ber-test.sh mp3 128 ) >x$FILE"
echo -e "\tmv x$FILE $FILE"
echo
FILE="$DELTA-double-mp3-$SEED"
echo "$FILE:"
echo -e "\t( cd ..; AWM_RAND_PATTERN=1 AWM_RAND_CUT=1 AWM_SET=huge2 AWM_PARAMS='--water-delta $DELTA' AWM_REPORT=fer AWM_SEEDS=$SEED AWM_FILE='t-$FILE' ber-test.sh double-mp3 128 ) >x$FILE"
echo -e "\tmv x$FILE $FILE"
echo
done
done
......@@ -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
......@@ -42,6 +42,7 @@ uint64_from_buffer (unsigned char *buffer)
+ buffer[7];
}
#if 0 /* debugging only */
static void
print (const string& label, const vector<unsigned char>& data)
{
......@@ -50,6 +51,7 @@ print (const string& label, const vector<unsigned char>& data)
printf ("%02x ", ch);
printf ("\n");
}
#endif
Random::Random (uint64_t seed, Stream stream)
{
......
......@@ -11,9 +11,11 @@ class Random
{
public:
enum class Stream {
up_down = 1,
mix = 2,
bit_order = 3
data_up_down = 1,
sync_up_down = 2,
pad_up_down = 3,
mix = 4,
bit_order = 5
};
private:
gcry_cipher_hd_t aes_ctr_cipher;
......
# pseudo random pattern
PATTERN=4e1243bd22c66e76c2ba9eddc1f91394e57f9f83
PATTERN=4e1243bd22c66e76c2ba9eddc1f91394
for i in test/T*
do
......
#!/bin/bash
SEEDS="$1"
MAX_SEED=$(($SEEDS - 1))
P="$2"
shift 2
echo "n seeds : $SEEDS"
echo "ber-test args : $@"
echo "params : $P"
for seed in $(seq 0 $MAX_SEED)
do
echo $(AWM_SEEDS=$seed AWM_PARAMS="$P" AWM_REPORT="sync" ber-test.sh "$@")
done | awk '{bad += $1; files += $2; print bad, files, bad * 100. / files }'
......@@ -3,7 +3,6 @@
/home/stefan/files/music/artists/gotye/making_mirrors/10 - Giving Me A Chance.flac
/home/stefan/files/music/artists/alice_cooper/the_definitive_alice_cooper/18_how_you_gonna_see_me_now.flac
/home/stefan/files/music/artists/mendelssohn/The Hebrides, Symphonies Nos.1, 4/02 - Symphony No. 1 C minor Op. 11 - Allegro di molto.flac
/home/stefan/files/music/artists/daft_punk/tron_legacy/15 - Solar Sailer.flac
/home/stefan/files/music/artists/depeche_mode/the_singles_81_to_85/09 - Love In Itself.flac
/home/stefan/files/music/artists/beethoven/Klavierkonzerte Nrr.3 & 4 (CD 2)/02 - Klavierkonzert Nr. 3 C-moll - 2. Largo.flac
/home/stefan/files/music/artists/joe_henderson/page_one/05 - Jinrikisha.flac
......@@ -12,7 +11,7 @@
/home/stefan/files/music/artists/mixed/the_world_of_trance_2/cd1/10 - Nature One - The Sense Of Live (Hurricanmix).flac
/home/stefan/files/music/artists/charles_mingus/Mingus Plays Piano/08 - Meditations for Moses.flac
/home/stefan/files/music/artists/lena/good_news/06 - Mama Told Me.flac
/home/stefan/files/music/artists/scriabin/Horowitz Plays Scriabin/06 - Scriabin - Prelude, Op.11, No.16.flac
/home/stefan/files/music/artists/mixed/tunnel_trance_force/43_cd1/24 - Niosecontrollers - Crump.flac
/home/stefan/files/music/artists/paniq/beyond_good_and_evil/paniq - Beyond Good and Evil - 02 Tartaros (The Barren Acres of Open Source).flac
/home/stefan/files/music/artists/mixed/Katia Marielle Labeque - Rhapsody in Blue/05 - Strawinsky: Petrushka_Volksfest waehrend der Fastnacht.flac
/home/stefan/files/music/artists/rosenstolz/mondkuss_cd1/09_die_zigarette_danach.flac
......@@ -23,3 +22,4 @@
/home/stefan/files/music/artists/mixed/Katia Marielle Labeque - Rhapsody in Blue/01 - Gershwin: Rhapsody in Blue.flac
/home/stefan/files/music/artists/loreena_mckennitt/collection/04 - Loreena Mckennitt - Caravanserai.flac
/home/stefan/files/music/artists/mumford_and_sons/sigh_no_more/05 - White Blank Page.flac
/home/stefan/files/music/artists/daft_punk/tron_legacy/22 - Finale.flac
......@@ -185,36 +185,18 @@ WavData::mix_freq() const
return m_mix_freq;
}
int
WavData::n_channels() const
{
return m_n_channels;
}
int
WavData::bit_depth() const
{
return m_bit_depth;
}
const vector<float>&
WavData::samples() const
{
return m_samples;
}
void
WavData::set_samples (const vector<float>& samples)
{
m_samples = samples;
}
size_t
WavData::n_values() const
{
return m_samples.size();
}
const char *
WavData::error_blurb() const
{
......
......@@ -20,12 +20,25 @@ public:
bool save (const std::string& filename);
float mix_freq() const;
int n_channels() const;
size_t n_values() const;
int bit_depth() const;
const std::vector<float>& samples() const;
const char *error_blurb() const;
int
n_channels() const
{
return m_n_channels;
}
size_t
n_values() const
{
return m_samples.size();
}
const std::vector<float>&
samples() const
{
return m_samples;
}
void set_samples (const std::vector<float>& samples);
};
......
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