Lines Matching full:stats
19 int stats_open_file(stats_io_t *stats, const char *fpf, int pass) { in stats_open_file() argument
21 stats->pass = pass; in stats_open_file()
24 stats->file = fopen(fpf, "wb"); in stats_open_file()
25 stats->buf.sz = 0; in stats_open_file()
26 stats->buf.buf = NULL; in stats_open_file()
27 res = (stats->file != NULL); in stats_open_file()
31 stats->file = fopen(fpf, "rb"); in stats_open_file()
33 if (stats->file == NULL) fatal("First-pass stats file does not exist!"); in stats_open_file()
35 if (fseek(stats->file, 0, SEEK_END)) in stats_open_file()
36 fatal("First-pass stats file must be seekable!"); in stats_open_file()
38 stats->buf.sz = stats->buf_alloc_sz = ftell(stats->file); in stats_open_file()
39 rewind(stats->file); in stats_open_file()
41 stats->buf.buf = malloc(stats->buf_alloc_sz); in stats_open_file()
43 if (!stats->buf.buf) in stats_open_file()
44 fatal("Failed to allocate first-pass stats buffer (%lu bytes)", in stats_open_file()
45 (unsigned int)stats->buf_alloc_sz); in stats_open_file()
47 nbytes = fread(stats->buf.buf, 1, stats->buf.sz, stats->file); in stats_open_file()
48 res = (nbytes == stats->buf.sz); in stats_open_file()
54 int stats_open_mem(stats_io_t *stats, int pass) { in stats_open_mem() argument
56 stats->pass = pass; in stats_open_mem()
59 stats->buf.sz = 0; in stats_open_mem()
60 stats->buf_alloc_sz = 64 * 1024; in stats_open_mem()
61 stats->buf.buf = malloc(stats->buf_alloc_sz); in stats_open_mem()
64 stats->buf_ptr = stats->buf.buf; in stats_open_mem()
65 res = (stats->buf.buf != NULL); in stats_open_mem()
69 void stats_close(stats_io_t *stats, int last_pass) { in stats_close() argument
70 if (stats->file) { in stats_close()
71 if (stats->pass == last_pass) { in stats_close()
72 free(stats->buf.buf); in stats_close()
75 fclose(stats->file); in stats_close()
76 stats->file = NULL; in stats_close()
78 if (stats->pass == last_pass) free(stats->buf.buf); in stats_close()
82 void stats_write(stats_io_t *stats, const void *pkt, size_t len) { in stats_write() argument
83 if (stats->file) { in stats_write()
84 (void)fwrite(pkt, 1, len, stats->file); in stats_write()
86 if (stats->buf.sz + len > stats->buf_alloc_sz) { in stats_write()
87 size_t new_sz = stats->buf_alloc_sz + 64 * 1024; in stats_write()
88 char *new_ptr = realloc(stats->buf.buf, new_sz); in stats_write()
91 stats->buf_ptr = new_ptr + (stats->buf_ptr - (char *)stats->buf.buf); in stats_write()
92 stats->buf.buf = new_ptr; in stats_write()
93 stats->buf_alloc_sz = new_sz; in stats_write()
95 fatal("Failed to realloc firstpass stats buffer."); in stats_write()
99 memcpy(stats->buf_ptr, pkt, len); in stats_write()
100 stats->buf.sz += len; in stats_write()
101 stats->buf_ptr += len; in stats_write()
105 vpx_fixed_buf_t stats_get(stats_io_t *stats) { return stats->buf; } in stats_get() argument