diff options
| -rw-r--r-- | src/etianalyse.cpp | 34 | ||||
| -rw-r--r-- | src/repetitionrate.cpp | 26 | ||||
| -rw-r--r-- | src/repetitionrate.hpp | 3 |
3 files changed, 43 insertions, 20 deletions
diff --git a/src/etianalyse.cpp b/src/etianalyse.cpp index 513246e..f803124 100644 --- a/src/etianalyse.cpp +++ b/src/etianalyse.cpp @@ -441,13 +441,13 @@ void ETI_Analyser::eti_analyse() disp_mst.printvalue("FIC"); fib = p + 12 + 4*nst; - for (int i = 0; i < ficl*4/32; i++) { + for (int fib_ix = 0; fib_ix < ficl*4/32; fib_ix++) { auto d = disp_mst.indent(); d.printsequencestart(); - d.printvalue("FIB", "", to_string(i)); + d.printvalue("FIB", "", to_string(fib_ix)); fig=fib; - figs.set_fib(i); - rate_new_fib(i); + figs.set_fib(fib_ix); + rate_new_fib(fib_ix); const uint16_t figcrc = read_u16_from_buf(fib + 30); crc = 0xffff; @@ -466,24 +466,22 @@ void ETI_Analyser::eti_analyse() if (crccorrect or config.ignore_error) { d.printvalue("FIGs"); - bool endmarker = false; int figcount = 0; - while (!endmarker) { + while (true) { uint8_t figtype, figlen; figtype = (fig[0] & 0xE0) >> 5; - if (figtype != 7) { - figlen = fig[0] & 0x1F; - - decodeFIG(config, figs, fig+1, figlen, figtype, d, crccorrect); - fig += figlen + 1; - figcount += figlen + 1; - if (figcount >= 29) - endmarker = true; - } - else { - endmarker = true; - } + + if (figtype == 7) break; + + figlen = fig[0] & 0x1F; + + decodeFIG(config, figs, fig+1, figlen, figtype, d, crccorrect); + fig += figlen + 1; + figcount += figlen + 1; + if (figcount >= 29) break; } + + rate_announce_fig_byte_count(fib_ix, figcount); } fib += 32; diff --git a/src/repetitionrate.cpp b/src/repetitionrate.cpp index 81a50e1..842a519 100644 --- a/src/repetitionrate.cpp +++ b/src/repetitionrate.cpp @@ -119,8 +119,8 @@ static string length_histogram(const std::vector<uint8_t>& lengths) { const array<const char*, 7> hist_chars({"▁", "▂", "▃", "▄", "▅", "▆", "▇"}); - // FIB length is 30 - vector<size_t> histogram(30); + // FIB length is 30, 0 to 30 means we have 31 possible lengths + vector<size_t> histogram(31); for (const uint8_t l : lengths) { histogram.at(l)++; } @@ -138,6 +138,17 @@ static string length_histogram(const std::vector<uint8_t>& lengths) return ss.str(); } +static map<uint8_t /* fib */, vector<uint8_t> > fib_bytes_used; + +void rate_announce_fig_byte_count(int fib, uint8_t byte_count) +{ + if (fib < 0 or fib > 2) + throw invalid_argument("rate_announce_fig_byte_count FIB must be 0,1 or 2"); + if (byte_count > 30) + throw invalid_argument("rate_announce_fig_byte_count byte count must be <= 30"); + + fib_bytes_used[fib].push_back(byte_count); +} void rate_display_analysis(bool per_second) { @@ -187,8 +198,19 @@ void rate_display_analysis(bool per_second) printf(" %d", fib); } printf("\n"); + } + + printf("\nBytes by FIG\n"); + for (const auto& fib_lengths : fib_bytes_used) { + const uint8_t fib = fib_lengths.first; + const auto& lengths = fib_lengths.second; + printf(" %d %4.1f %s\n", + fib, + length_avg(lengths), + length_histogram(lengths).c_str()); } + } void rate_new_fib(int fib) diff --git a/src/repetitionrate.hpp b/src/repetitionrate.hpp index b795351..529fff4 100644 --- a/src/repetitionrate.hpp +++ b/src/repetitionrate.hpp @@ -32,6 +32,9 @@ void rate_announce_fig(int figtype, int figextension, bool complete, uint8_t fig */ void rate_new_fib(int fib); +/* Tell how many bytes in this fib were used */ +void rate_announce_fig_byte_count(int fib, uint8_t byte_count); + /* Print analysis. * per_second: if true, rates are calculated in FIGs per second. * If false, rate is given in frames per FIG |
