Lines Matching refs:stats
121 int stats_open_file(stats_io_t *stats, const char *fpf, int pass)
125 stats->pass = pass;
129 stats->file = fopen(fpf, "wb");
130 stats->buf.sz = 0;
131 stats->buf.buf = NULL,
132 res = (stats->file != NULL);
142 stats->file = fdopen(fd, "rb");
144 stats->buf.sz = stat_buf.st_size;
145 stats->buf.buf = mmap(NULL, stats->buf.sz, PROT_READ, MAP_PRIVATE,
147 res = (stats->buf.buf != NULL);
151 stats->file = fopen(fpf, "rb");
153 if (fseek(stats->file, 0, SEEK_END))
155 fprintf(stderr, "First-pass stats file must be seekable!\n");
159 stats->buf.sz = stats->buf_alloc_sz = ftell(stats->file);
160 rewind(stats->file);
162 stats->buf.buf = malloc(stats->buf_alloc_sz);
164 if (!stats->buf.buf)
166 fprintf(stderr, "Failed to allocate first-pass stats buffer (%lu bytes)\n",
167 (unsigned long)stats->buf_alloc_sz);
171 nbytes = fread(stats->buf.buf, 1, stats->buf.sz, stats->file);
172 res = (nbytes == stats->buf.sz);
179 int stats_open_mem(stats_io_t *stats, int pass)
182 stats->pass = pass;
186 stats->buf.sz = 0;
187 stats->buf_alloc_sz = 64 * 1024;
188 stats->buf.buf = malloc(stats->buf_alloc_sz);
191 stats->buf_ptr = stats->buf.buf;
192 res = (stats->buf.buf != NULL);
197 void stats_close(stats_io_t *stats, int last_pass)
199 if (stats->file)
201 if (stats->pass == last_pass)
205 munmap(stats->buf.buf, stats->buf.sz);
207 free(stats->buf.buf);
211 fclose(stats->file);
212 stats->file = NULL;
216 if (stats->pass == last_pass)
217 free(stats->buf.buf);
221 void stats_write(stats_io_t *stats, const void *pkt, size_t len)
223 if (stats->file)
225 if(fwrite(pkt, 1, len, stats->file));
229 if (stats->buf.sz + len > stats->buf_alloc_sz)
231 size_t new_sz = stats->buf_alloc_sz + 64 * 1024;
232 char *new_ptr = realloc(stats->buf.buf, new_sz);
236 stats->buf_ptr = new_ptr + (stats->buf_ptr - (char *)stats->buf.buf);
237 stats->buf.buf = new_ptr;
238 stats->buf_alloc_sz = new_sz;
243 "\nFailed to realloc firstpass stats buffer.\n");
248 memcpy(stats->buf_ptr, pkt, len);
249 stats->buf.sz += len;
250 stats->buf_ptr += len;
254 vpx_fixed_buf_t stats_get(stats_io_t *stats)
256 return stats->buf;
1097 stats_io_t stats;
1383 memset(&stats, 0, sizeof(stats));
1530 if (!stats_open_file(&stats, stats_fn, pass))
1538 if (!stats_open_mem(&stats, pass))
1552 cfg.rc_twopass_stats_in = stats_get(&stats);
1656 stats_write(&stats,
1725 stats_close(&stats, arg_passes-1);