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

Add --detect-speed-hint for improving test time for speed detection.

Signed-off-by: Stefan Westerfeld's avatarStefan Westerfeld <stefan@space.twc.de>
parent 24e5194d
...@@ -565,6 +565,8 @@ parse_add_options (ArgParser& ap) ...@@ -565,6 +565,8 @@ parse_add_options (ArgParser& ap)
void void
parse_get_options (ArgParser& ap) parse_get_options (ArgParser& ap)
{ {
float f;
ap.parse_opt ("--test-cut", Params::test_cut); ap.parse_opt ("--test-cut", Params::test_cut);
ap.parse_opt ("--test-truncate", Params::test_truncate); ap.parse_opt ("--test-truncate", Params::test_truncate);
...@@ -580,6 +582,10 @@ parse_get_options (ArgParser& ap) ...@@ -580,6 +582,10 @@ parse_get_options (ArgParser& ap)
{ {
Params::detect_speed = true; Params::detect_speed = true;
} }
if (ap.parse_opt ("--detect-speed-hint", f))
{
Params::detect_speed_hint = f;
}
} }
int int
......
...@@ -26,6 +26,7 @@ bool Params::mix = true; ...@@ -26,6 +26,7 @@ bool Params::mix = true;
bool Params::hard = false; // hard decode bits? (soft decoding is better) bool Params::hard = false; // hard decode bits? (soft decoding is better)
bool Params::snr = false; // compute/show snr while adding watermark bool Params::snr = false; // compute/show snr while adding watermark
bool Params::detect_speed = false; bool Params::detect_speed = false;
double Params::detect_speed_hint = -1;
int Params::have_key = 0; int Params::have_key = 0;
size_t Params::payload_size = 128; size_t Params::payload_size = 128;
bool Params::payload_short = false; bool Params::payload_short = false;
......
...@@ -42,7 +42,9 @@ public: ...@@ -42,7 +42,9 @@ public:
static bool hard; // hard decode bits? (soft decoding is better) static bool hard; // hard decode bits? (soft decoding is better)
static bool snr; // compute/show snr while adding watermark static bool snr; // compute/show snr while adding watermark
static int have_key; static int have_key;
static bool detect_speed; static bool detect_speed;
static double detect_speed_hint; // for debugging --detect-speed
static size_t payload_size; // number of payload bits for the watermark static size_t payload_size; // number of payload bits for the watermark
static bool payload_short; static bool payload_short;
......
...@@ -1052,9 +1052,28 @@ detect_speed (const WavData& wav_data, double center, double step, int n_steps, ...@@ -1052,9 +1052,28 @@ detect_speed (const WavData& wav_data, double center, double step, int n_steps,
WavData wd_truncated = truncate (wav_data, seconds * 1.5); WavData wd_truncated = truncate (wav_data, seconds * 1.5);
double best_speed = 1.0; double best_speed = 1.0;
double best_quality = 0; double best_quality = 0;
int best_hint_step = 0;
if (Params::detect_speed_hint > 0)
{
double best_dist = 1000;
for (int p = -n_steps; p <= n_steps; p++)
{
double dist = fabs (center * pow (step, p) - Params::detect_speed_hint);
if (dist < best_dist)
{
best_hint_step = p;
best_dist = dist;
}
}
}
printf ("## range [%f..%f], n_steps=%d\n", center * pow (step, -n_steps), center * pow (step, n_steps), n_steps); printf ("## range [%f..%f], n_steps=%d\n", center * pow (step, -n_steps), center * pow (step, n_steps), n_steps);
for (int p = -n_steps; p <= n_steps; p++) for (int p = -n_steps; p <= n_steps; p++)
{ {
if (Params::detect_speed_hint > 0)
if (abs (p - best_hint_step) > 2)
continue;
double speed = center * pow (step, p); double speed = center * pow (step, p);
WavData wd_resampled = wd_truncated; WavData wd_resampled = wd_truncated;
......
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