Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/videolan/dav1d.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorHenrik Gramner <gramner@twoorioles.com>2020-02-15 16:52:45 +0300
committerHenrik Gramner <gramner@twoorioles.com>2020-02-17 02:34:09 +0300
commit09d90658f13c87bcc4af03897731901843e57123 (patch)
tree8ffc9b88b68cd13bbafe04079c0c2a7006aa1d90 /tools
parenteb7077ed7773e1a1f06db58f77c7d52c05452d61 (diff)
cli: Implement line buffering in print_stats()
Console output is incredibly slow on Windows, which is aggravated by the lack of line buffering. As a result, a significant percentage of overall runtime is actually spent displaying the decoding progress. Doing the line buffering manually alleviates most of the issue.
Diffstat (limited to 'tools')
-rw-r--r--tools/dav1d.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/tools/dav1d.c b/tools/dav1d.c
index 72ee894..35cc68e 100644
--- a/tools/dav1d.c
+++ b/tools/dav1d.c
@@ -113,18 +113,24 @@ static void synchronize(const int realtime, const unsigned cache,
static void print_stats(const int istty, const unsigned n, const unsigned num,
const uint64_t elapsed, const double i_fps)
{
- if (istty) fputs("\r", stderr);
- const double d_fps = 1e9 * n / elapsed;
- const double speed = d_fps / i_fps;
- if (num == 0xFFFFFFFF) {
- fprintf(stderr, "Decoded %u frames", n);
- } else {
- fprintf(stderr, "Decoded %u/%u frames (%.1lf%%)", n, num,
- 100.0 * n / num);
+ char buf[80], *b = buf, *const end = buf + 80;
+
+ if (istty)
+ *b++ = '\r';
+ if (num == 0xFFFFFFFF)
+ b += snprintf(b, end - b, "Decoded %u frames", n);
+ else
+ b += snprintf(b, end - b, "Decoded %u/%u frames (%.1lf%%)",
+ n, num, 100.0 * n / num);
+ if (i_fps && b < end) {
+ const double d_fps = 1e9 * n / elapsed;
+ const double speed = d_fps / i_fps;
+ b += snprintf(b, end - b, " - %.2lf/%.2lf fps (%.2lfx)",
+ d_fps, i_fps, speed);
}
- if (i_fps)
- fprintf(stderr, " - %.2lf/%.2lf fps (%.2lfx)", d_fps, i_fps, speed);
- if (!istty) fputs("\n", stderr);
+ if (!istty)
+ strcpy(b > end - 2 ? end - 2 : b, "\n");
+ fputs(buf, stderr);
}
int main(const int argc, char *const *const argv) {