Commit 172ccd3a authored by Stefan Westerfeld's avatar Stefan Westerfeld

Initial implementation for --detect-speed-patient.

Signed-off-by: Stefan Westerfeld's avatarStefan Westerfeld <stefan@space.twc.de>
parent 72273517
......@@ -600,19 +600,27 @@ parse_get_options (ArgParser& ap)
{
Params::test_no_sync = true;
}
int speed_options = 0;
if (ap.parse_opt ("--detect-speed"))
{
Params::detect_speed = true;
speed_options++;
}
if (ap.parse_opt ("--detect-speed-patient"))
{
Params::detect_speed_patient = true;
speed_options++;
}
if (ap.parse_opt ("--try-speed", f))
{
if (Params::detect_speed)
{
error ("audiowmark: can not use both options: --detect-speed and --try-speed\n");
exit (1);
}
speed_options++;
Params::try_speed = f;
}
if (speed_options > 1)
{
error ("audiowmark: can only use one option: --detect-speed or --detect-speed-patient or --try-speed\n");
exit (1);
}
if (ap.parse_opt ("--test-speed", f))
{
Params::test_speed = f;
......
......@@ -27,6 +27,7 @@ bool Params::hard = false; // hard decode bits? (soft decoding is b
bool Params::snr = false; // compute/show snr while adding watermark
bool Params::strict = false;
bool Params::detect_speed = false;
bool Params::detect_speed_patient = false;
double Params::try_speed = -1;
double Params::test_speed = -1;
int Params::have_key = 0;
......
......@@ -48,6 +48,7 @@ public:
static int have_key;
static bool detect_speed;
static bool detect_speed_patient;
static double try_speed; // manual speed correction
static double test_speed; // for debugging --detect-speed
......
......@@ -601,9 +601,9 @@ decode_and_report (const WavData& wav_data, const string& orig_pattern)
* The reason to do it this way is that the detected speed may be wrong (on short clips)
* and we don't want to loose a successful clip decoder match in this case.
*/
if (Params::detect_speed || Params::try_speed > 0)
if (Params::detect_speed || Params::detect_speed_patient || Params::try_speed > 0)
{
if (Params::detect_speed)
if (Params::detect_speed || Params::detect_speed_patient)
speed = detect_speed (wav_data, !orig_pattern.empty());
else
speed = Params::try_speed;
......
......@@ -589,6 +589,16 @@ detect_speed (const WavData& in_data, bool print_results)
.n_center_steps = 28,
.interpolate = true
};
const SpeedScanParams scan1_patient
{
.seconds = 50,
/* step / n_steps / n_center_steps settings: speed approximately 0.8..1.25 */
.step = 1.00035,
.n_steps = 11,
.n_center_steps = 28,
.interpolate = true
};
const int clip_candidates = 5;
const double clip_location = get_best_clip_location (in_data, scan1.seconds, clip_candidates);
......@@ -612,6 +622,6 @@ detect_speed (const WavData& in_data, bool print_results)
.interpolate = false
};
double speed = speed_scan (thread_pool, clip_location, in_data, scan1, scan2, scan3, /* start speed */ 1.0, print_results);
double speed = speed_scan (thread_pool, clip_location, in_data, Params::detect_speed_patient ? scan1_patient : scan1, scan2, scan3, /* start speed */ 1.0, print_results);
return speed;
}
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