Public bug reported:
Environment
___________
- D-ITG version: 2.8.1-r1023
- File: `src/ITGDec/ITGDecod.cpp`
- Affected options: `-c` (combined stats interval), `-b` (bitrate interval)
Description
___________
When using `ITGDec -c <interval>`, the bitrate reported in the last
sampling window may be underestimated. The issue lies in
`src/ITGDec/ITGDecod.cpp` at the end-of-file handler: the last (partial)
window is written using the full interval duration as divisor, even
though it may contain less data than a complete window.
Root cause
__________
In `ITGDecod.cpp`, when `fread` returns 0 (end of log file), the last
window is flushed as follows:
```cpp
// Line 1316
if (size == 0) {
if (flagbit)
fprintf(outfilebit, "%lf %lf\n",
intclosedbit * (double) msbitrate / 1000,
tempbitrate * 8 / msbitrate); // BUG
```
The divisor `msbitrate` assumes the window is fully filled (e.g. 1000
ms), but at end-of-flow the last window is partial. `tempbitrate` only
accumulates bytes for the actual elapsed time of that window, so
dividing by the full interval produces a lower-than-real bitrate.
This is identical to the formula used for complete windows (line 1372),
which is correct there since `tempbitrate` is reset to 0 at each window
boundary, but incorrect here for a partial last window.
Reproducing
___________
Run any flow with `-t <duration>` and decode with `ITGDec -c <interval>`. The
last sample in the output `.dat` file will show a bitrate lower than the
average, proportional to how much of the last window was actually filled.
Proposed fix
____________
Replace the last-window bitrate output with a division by the actual
elapsed time in that window:
```cpp
if (size == 0) {
if (flagbit) {
double lastWindowMs = (secrxTime - secinitbitrate) * 1000;
fprintf(outfilebit, "%lf %lf\n",
intclosedbit * (double) msbitrate / 1000,
(lastWindowMs > 0) ? tempbitrate * 8 / lastWindowMs : 0.0);
}
```
The proposed fix references secrxTime, which is declared but
uninitialised in elabsplit (double secrxTime, secfirstline_loc =
90000;). On an empty flow file, this would result in garbage values
being read, so to ensure the > 0 guard works reliably, it should be
initialised (e.g., double secrxTime = 0, ...).
** Affects: d-itg (Ubuntu)
Importance: Undecided
Status: New
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2166913
Title:
Last sampling window bitrate is underestimated in ITGDec
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/d-itg/+bug/2166913/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs