OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebM project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 stats->file = fdopen(fd, "rb"); | 34 stats->file = fdopen(fd, "rb"); |
35 fstat(fd, &stat_buf); | 35 fstat(fd, &stat_buf); |
36 stats->buf.sz = stat_buf.st_size; | 36 stats->buf.sz = stat_buf.st_size; |
37 stats->buf.buf = mmap(NULL, stats->buf.sz, PROT_READ, MAP_PRIVATE, fd, 0); | 37 stats->buf.buf = mmap(NULL, stats->buf.sz, PROT_READ, MAP_PRIVATE, fd, 0); |
38 res = (stats->buf.buf != NULL); | 38 res = (stats->buf.buf != NULL); |
39 #else | 39 #else |
40 size_t nbytes; | 40 size_t nbytes; |
41 | 41 |
42 stats->file = fopen(fpf, "rb"); | 42 stats->file = fopen(fpf, "rb"); |
43 | 43 |
| 44 if (stats->file == NULL) |
| 45 fatal("First-pass stats file does not exist!"); |
| 46 |
44 if (fseek(stats->file, 0, SEEK_END)) | 47 if (fseek(stats->file, 0, SEEK_END)) |
45 fatal("First-pass stats file must be seekable!"); | 48 fatal("First-pass stats file must be seekable!"); |
46 | 49 |
47 stats->buf.sz = stats->buf_alloc_sz = ftell(stats->file); | 50 stats->buf.sz = stats->buf_alloc_sz = ftell(stats->file); |
48 rewind(stats->file); | 51 rewind(stats->file); |
49 | 52 |
50 stats->buf.buf = malloc(stats->buf_alloc_sz); | 53 stats->buf.buf = malloc(stats->buf_alloc_sz); |
51 | 54 |
52 if (!stats->buf.buf) | 55 if (!stats->buf.buf) |
53 fatal("Failed to allocate first-pass stats buffer (%lu bytes)", | 56 fatal("Failed to allocate first-pass stats buffer (%lu bytes)", |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 | 116 |
114 memcpy(stats->buf_ptr, pkt, len); | 117 memcpy(stats->buf_ptr, pkt, len); |
115 stats->buf.sz += len; | 118 stats->buf.sz += len; |
116 stats->buf_ptr += len; | 119 stats->buf_ptr += len; |
117 } | 120 } |
118 } | 121 } |
119 | 122 |
120 vpx_fixed_buf_t stats_get(stats_io_t *stats) { | 123 vpx_fixed_buf_t stats_get(stats_io_t *stats) { |
121 return stats->buf; | 124 return stats->buf; |
122 } | 125 } |
OLD | NEW |