Commit 4daad3c3 authored by Stefan Westerfeld's avatar Stefan Westerfeld

Use both channels for decoding bits (average up/down values).

Signed-off-by: Stefan Westerfeld's avatarStefan Westerfeld <stefan@space.twc.de>
parent 769368ba
- use both channels for decoding
- non-blind decoder - non-blind decoder
- standard tests (-> mp3, ->ogg, ...) - standard tests (-> mp3, ->ogg, ...)
- refactor fft - refactor fft
......
...@@ -332,9 +332,12 @@ get_watermark (const string& origfile, const string& infile, const string& orig_ ...@@ -332,9 +332,12 @@ get_watermark (const string& origfile, const string& infile, const string& orig_
fprintf (stderr, "audiowmark: error loading %s: %s\n", infile.c_str(), wav_data.error_blurb()); fprintf (stderr, "audiowmark: error loading %s: %s\n", infile.c_str(), wav_data.error_blurb());
return 1; return 1;
} }
vector<int> bit_vec[wav_data.n_channels()]; vector<int> bit_vec;
for (int f = 0; f < frame_count (wav_data); f++) for (int f = 0; f < frame_count (wav_data); f++)
{ {
double umag = 0, dmag = 0;
for (int ch = 0; ch < wav_data.n_channels(); ch++) for (int ch = 0; ch < wav_data.n_channels(); ch++)
{ {
vector<float> frame = get_frame (wav_data, f, ch); vector<float> frame = get_frame (wav_data, f, ch);
...@@ -365,7 +368,6 @@ get_watermark (const string& origfile, const string& infile, const string& orig_ ...@@ -365,7 +368,6 @@ get_watermark (const string& origfile, const string& infile, const string& orig_
vector<int> up; vector<int> up;
vector<int> down; vector<int> down;
get_up_down (f, up, down); get_up_down (f, up, down);
double umag = 0, dmag = 0;
for (auto u : up) for (auto u : up)
{ {
const double re = fft_out[u * 2]; const double re = fft_out[u * 2];
...@@ -383,30 +385,26 @@ get_watermark (const string& origfile, const string& infile, const string& orig_ ...@@ -383,30 +385,26 @@ get_watermark (const string& origfile, const string& infile, const string& orig_
dmag += mag; dmag += mag;
} }
bit_vec[ch].push_back ((umag > dmag) ? 1 : 0);
free_array_float (fft_out); free_array_float (fft_out);
free_array_float (fft_in); free_array_float (fft_in);
} }
} }
bit_vec.push_back ((umag > dmag) ? 1 : 0);
} }
int bits = 0, bit_errors = 0; if (!orig_pattern.empty())
for (int ch = 0; ch < wav_data.n_channels(); ch++)
{ {
printf ("ch[%d]=%s\n", ch, bit_vec_to_str (bit_vec[ch]).c_str()); int bits = 0, bit_errors = 0;
if (!orig_pattern.empty()) vector<int> orig_vec = bit_str_to_vec (orig_pattern);
for (size_t i = 0; i < bit_vec.size(); i++)
{ {
vector<int> orig_vec = bit_str_to_vec (orig_pattern); bits++;
for (size_t i = 0; i < bit_vec[ch].size(); i++) if (bit_vec[i] != orig_vec[i % orig_vec.size()])
{ bit_errors++;
bits++;
if (bit_vec[ch][i] != orig_vec[i % orig_vec.size()])
bit_errors++;
}
} }
printf ("bit_error_rate %.3f %%\n", double (100.0 * bit_errors) / bits);
} }
printf ("bit_error_rate %.3f %%\n", double (100.0 * bit_errors) / bits);
return 0; return 0;
} }
......
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