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

Merge branch 'warn-on-short-input'

parents c7e2aa41 58e0be12
...@@ -65,6 +65,7 @@ print_usage() ...@@ -65,6 +65,7 @@ print_usage()
printf (" --short <bits> enable short payload mode\n"); printf (" --short <bits> enable short payload mode\n");
printf (" --strength <s> set watermark strength [%.6g]\n", Params::water_delta * 1000); printf (" --strength <s> set watermark strength [%.6g]\n", Params::water_delta * 1000);
printf (" -q, --quiet disable information messages\n"); printf (" -q, --quiet disable information messages\n");
printf (" --strict treat (minor) problems as errors\n");
printf ("\n"); printf ("\n");
printf (" --input-format raw use raw stream as input\n"); printf (" --input-format raw use raw stream as input\n");
printf (" --output-format raw use raw stream as output\n"); printf (" --output-format raw use raw stream as output\n");
...@@ -487,6 +488,10 @@ parse_shared_options (ArgParser& ap) ...@@ -487,6 +488,10 @@ parse_shared_options (ArgParser& ap)
{ {
Params::mix = false; Params::mix = false;
} }
if (ap.parse_opt ("--strict"))
{
Params::strict = true;
}
if (Params::have_key > 1) if (Params::have_key > 1)
{ {
error ("audiowmark: watermark key can at most be set once (--key / --test-key option)\n"); error ("audiowmark: watermark key can at most be set once (--key / --test-key option)\n");
......
...@@ -751,13 +751,24 @@ add_stream_watermark (AudioInputStream *in_stream, AudioOutputStream *out_stream ...@@ -751,13 +751,24 @@ add_stream_watermark (AudioInputStream *in_stream, AudioOutputStream *out_stream
} }
total_output_frames += samples.size() / n_channels; total_output_frames += samples.size() / n_channels;
} }
if (Params::snr)
info ("SNR: %f dB\n", 10 * log10 (snr_signal_power / snr_delta_power));
info ("Data Blocks: %d\n", wm_resampler.data_blocks());
if (in_stream->n_frames() != AudioInputStream::N_FRAMES_UNKNOWN) if (in_stream->n_frames() != AudioInputStream::N_FRAMES_UNKNOWN)
{ {
const size_t expect_frames = in_stream->n_frames() + zero_frames; const size_t expect_frames = in_stream->n_frames() + zero_frames;
if (total_output_frames != expect_frames) if (total_output_frames != expect_frames)
{ {
error ("audiowmark: error: input frames (%zd) != output frames (%zd)\n", expect_frames, total_output_frames); auto msg = string_printf ("unexpected EOF; input frames (%zd) != output frames (%zd)", expect_frames, total_output_frames);
return 1; if (Params::strict)
{
warning ("audiowmark: error: %s\n", msg.c_str());
return 1;
}
error ("audiowmark: warning: %s\n", msg.c_str());
} }
} }
...@@ -767,11 +778,6 @@ add_stream_watermark (AudioInputStream *in_stream, AudioOutputStream *out_stream ...@@ -767,11 +778,6 @@ add_stream_watermark (AudioInputStream *in_stream, AudioOutputStream *out_stream
error ("audiowmark: closing output stream failed: %s\n", err.message()); error ("audiowmark: closing output stream failed: %s\n", err.message());
return 1; return 1;
} }
if (Params::snr)
info ("SNR: %f dB\n", 10 * log10 (snr_signal_power / snr_delta_power));
info ("Data Blocks: %d\n", wm_resampler.data_blocks());
return 0; return 0;
} }
......
...@@ -25,6 +25,7 @@ double Params::water_delta = 0.01; ...@@ -25,6 +25,7 @@ double Params::water_delta = 0.01;
bool Params::mix = true; 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::strict = false;
bool Params::detect_speed = false; bool Params::detect_speed = false;
double Params::try_speed = -1; double Params::try_speed = -1;
double Params::test_speed = -1; double Params::test_speed = -1;
......
...@@ -41,6 +41,7 @@ public: ...@@ -41,6 +41,7 @@ public:
static double water_delta; static double water_delta;
static std::string json_output; static std::string json_output;
static bool strict;
static bool mix; static bool mix;
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
......
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