Commit b7cf973c authored by Stefan Westerfeld's avatar Stefan Westerfeld

Support --block argument to set the reorder block size.

Signed-off-by: Stefan Westerfeld's avatarStefan Westerfeld <stefan@space.twc.de>
parent 52496a92
......@@ -15,11 +15,13 @@ using std::string;
using std::vector;
using std::complex;
using std::min;
using std::max;
namespace Params
{
static size_t frame_size = 1024;
static int frames_per_bit = 4;
static int block = 1;
static int bands_per_frame = 30;
static int max_band = 100;
static int min_band = 20;
......@@ -51,6 +53,7 @@ print_usage()
printf ("Global options:\n");
printf (" --frame-size frame size (must be power of 2) [%zd]\n", Params::frame_size);
printf (" --frames-per-bit number of frames per bit [%d]\n", Params::frames_per_bit);
printf (" --block set bit reordering block size [%d]\n", Params::block);
printf (" --water-delta set watermarking delta [%.4f]\n", Params::water_delta);
printf (" --pre-scale set scaling used for normalization [%.3f]\n", Params::pre_scale);
}
......@@ -133,6 +136,10 @@ parse_options (int *argc_p,
{
Params::frames_per_bit = atoi (opt_arg);
}
else if (check_arg (argc, argv, &i, "--block", &opt_arg))
{
Params::block = atoi (opt_arg);
}
else if (check_arg (argc, argv, &i, "--water-delta", &opt_arg))
{
Params::water_delta = atof (opt_arg);
......@@ -378,12 +385,22 @@ add_watermark (const string& infile, const string& outfile, const string& bits)
printf ("loading %s\n", infile.c_str());
WavData wav_data;
if (!wav_data.load (infile))
WavData xwav_data;
if (!xwav_data.load (infile))
{
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(), xwav_data.error_blurb());
return 1;
}
size_t block_size = Params::block * Params::frames_per_bit * Params::frame_size * xwav_data.n_channels();
/* we truncate the audio down to a multiple of the reorder block size - for a production quality
* implemenation this is not good enough, but it is ok for comparing error rates
*/
vector<float> in_signal (xwav_data.samples().begin(), xwav_data.samples().end() - xwav_data.n_values() % block_size);
WavData wav_data (in_signal, xwav_data.n_channels(), xwav_data.mix_freq(), xwav_data.bit_depth());
printf ("input signal frames: before = %f\n", double (xwav_data.n_values()) / block_size);
printf ("input signal frames: after = %f\n", double (wav_data.n_values()) / block_size);
vector<float> out_signal (wav_data.n_values());
printf ("channels: %d, samples: %zd, mix_freq: %f\n", wav_data.n_channels(), wav_data.n_values(), wav_data.mix_freq());
......
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