Commit 456df468 authored by Tim Janik's avatar Tim Janik

SRC: wmget.cc: change JSON output to provide "btype" field to describe blocks

Signed-off-by: 's avatarTim Janik <timj@gnu.org>
parent 9fb0c96b
...@@ -192,28 +192,28 @@ public: ...@@ -192,28 +192,28 @@ public:
{ {
if (nth++ != 0) if (nth++ != 0)
fprintf (outfile, ",\n"); fprintf (outfile, ",\n");
if (pattern.type == Type::ALL) /* this is the combined pattern "all" */
{ std::string btype;
fprintf (outfile, " { \"pos\": \"0:00\", \"bits\": \"%s\", \"quality\": %.6f, \"error\": %.6f, \"clip\": false, \"type\": \"ALL\" }", switch (pattern.sync_score.block_type)
bit_vec_to_str (pattern.bit_vec).c_str(),
pattern.sync_score.quality, pattern.decode_error);
}
else
{ {
const char *blockc; // quoted block type + comma case ConvBlockType::a: btype = "A"; break;
switch (pattern.sync_score.block_type) case ConvBlockType::b: btype = "B"; break;
{ case ConvBlockType::ab: btype = "AB"; break;
case ConvBlockType::a: blockc = "\"A\""; break;
case ConvBlockType::b: blockc = "\"B\""; break;
case ConvBlockType::ab: blockc = "\"AB\""; break;
}
const int seconds = pattern.sync_score.index / Params::mark_sample_rate;
fprintf (outfile, " { \"pos\": \"%d:%02d\", \"bits\": \"%s\", \"quality\": %.5f, \"error\": %.6f, \"clip\": %-6s \"type\": %s }",
seconds / 60, seconds % 60,
bit_vec_to_str (pattern.bit_vec).c_str(),
pattern.sync_score.quality, pattern.decode_error,
pattern.type == Type::CLIP ? "true," : "false,", blockc);
} }
if (pattern.type == Type::ALL)
btype = "ALL";
if (pattern.type == Type::CLIP)
btype = "CLIP-" + btype;
if (pattern.speed_pattern)
btype += "-SPEED";
const int seconds = pattern.type == Type::ALL ? 0 : pattern.sync_score.index / Params::mark_sample_rate;
fprintf (outfile, " { \"pos\": \"%d:%02d\", \"bits\": \"%s\", \"quality\": %.5f, \"error\": %.6f, \"type\": \"%s\" }",
seconds / 60, seconds % 60,
bit_vec_to_str (pattern.bit_vec).c_str(),
pattern.sync_score.quality, pattern.decode_error,
btype.c_str());
} }
fprintf (outfile, " ]\n}\n"); fprintf (outfile, " ]\n}\n");
fclose (outfile); fclose (outfile);
......
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