OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2010 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 |
11 #include "vpx_config.h" | 11 #include "vpx_config.h" |
12 | 12 |
13 #if defined(_WIN32) || !CONFIG_OS_SUPPORT | 13 #if defined(_WIN32) || defined(__OS2__) || !CONFIG_OS_SUPPORT |
14 #define USE_POSIX_MMAP 0 | 14 #define USE_POSIX_MMAP 0 |
15 #else | 15 #else |
16 #define USE_POSIX_MMAP 1 | 16 #define USE_POSIX_MMAP 1 |
17 #endif | 17 #endif |
18 | 18 |
19 #include <stdio.h> | 19 #include <stdio.h> |
20 #include <stdlib.h> | 20 #include <stdlib.h> |
21 #include <stdarg.h> | 21 #include <stdarg.h> |
22 #include <string.h> | 22 #include <string.h> |
23 #include <limits.h> | 23 #include <limits.h> |
(...skipping 16 matching lines...) Expand all Loading... |
40 #if CONFIG_VP8_DECODER || CONFIG_VP9_DECODER | 40 #if CONFIG_VP8_DECODER || CONFIG_VP9_DECODER |
41 #include "vpx/vp8dx.h" | 41 #include "vpx/vp8dx.h" |
42 #endif | 42 #endif |
43 | 43 |
44 #include "vpx_ports/mem_ops.h" | 44 #include "vpx_ports/mem_ops.h" |
45 #include "vpx_ports/vpx_timer.h" | 45 #include "vpx_ports/vpx_timer.h" |
46 #include "tools_common.h" | 46 #include "tools_common.h" |
47 #include "y4minput.h" | 47 #include "y4minput.h" |
48 #include "libmkv/EbmlWriter.h" | 48 #include "libmkv/EbmlWriter.h" |
49 #include "libmkv/EbmlIDs.h" | 49 #include "libmkv/EbmlIDs.h" |
| 50 #include "third_party/libyuv/include/libyuv/scale.h" |
50 | 51 |
51 /* Need special handling of these functions on Windows */ | 52 /* Need special handling of these functions on Windows */ |
52 #if defined(_MSC_VER) | 53 #if defined(_MSC_VER) |
53 /* MSVS doesn't define off_t, and uses _f{seek,tell}i64 */ | 54 /* MSVS doesn't define off_t, and uses _f{seek,tell}i64 */ |
54 typedef __int64 off_t; | 55 typedef __int64 off_t; |
55 #define fseeko _fseeki64 | 56 #define fseeko _fseeki64 |
56 #define ftello _ftelli64 | 57 #define ftello _ftelli64 |
57 #elif defined(_WIN32) | 58 #elif defined(_WIN32) |
58 /* MinGW defines off_t as long | 59 /* MinGW defines off_t as long |
59 and uses f{seek,tell}o64/off64_t for large files */ | 60 and uses f{seek,tell}o64/off64_t for large files */ |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 LOG_ERROR("Fatal"); | 133 LOG_ERROR("Fatal"); |
133 exit(EXIT_FAILURE); | 134 exit(EXIT_FAILURE); |
134 } | 135 } |
135 | 136 |
136 | 137 |
137 void warn(const char *fmt, ...) { | 138 void warn(const char *fmt, ...) { |
138 LOG_ERROR("Warning"); | 139 LOG_ERROR("Warning"); |
139 } | 140 } |
140 | 141 |
141 | 142 |
142 static void ctx_exit_on_error(vpx_codec_ctx_t *ctx, const char *s, ...) { | 143 static void warn_or_exit_on_errorv(vpx_codec_ctx_t *ctx, int fatal, |
143 va_list ap; | 144 const char *s, va_list ap) { |
144 | |
145 va_start(ap, s); | |
146 if (ctx->err) { | 145 if (ctx->err) { |
147 const char *detail = vpx_codec_error_detail(ctx); | 146 const char *detail = vpx_codec_error_detail(ctx); |
148 | 147 |
149 vfprintf(stderr, s, ap); | 148 vfprintf(stderr, s, ap); |
150 fprintf(stderr, ": %s\n", vpx_codec_error(ctx)); | 149 fprintf(stderr, ": %s\n", vpx_codec_error(ctx)); |
151 | 150 |
152 if (detail) | 151 if (detail) |
153 fprintf(stderr, " %s\n", detail); | 152 fprintf(stderr, " %s\n", detail); |
154 | 153 |
155 exit(EXIT_FAILURE); | 154 if (fatal) |
| 155 exit(EXIT_FAILURE); |
156 } | 156 } |
157 } | 157 } |
158 | 158 |
| 159 static void ctx_exit_on_error(vpx_codec_ctx_t *ctx, const char *s, ...) { |
| 160 va_list ap; |
| 161 |
| 162 va_start(ap, s); |
| 163 warn_or_exit_on_errorv(ctx, 1, s, ap); |
| 164 va_end(ap); |
| 165 } |
| 166 |
| 167 static void warn_or_exit_on_error(vpx_codec_ctx_t *ctx, int fatal, |
| 168 const char *s, ...) { |
| 169 va_list ap; |
| 170 |
| 171 va_start(ap, s); |
| 172 warn_or_exit_on_errorv(ctx, fatal, s, ap); |
| 173 va_end(ap); |
| 174 } |
| 175 |
159 /* This structure is used to abstract the different ways of handling | 176 /* This structure is used to abstract the different ways of handling |
160 * first pass statistics. | 177 * first pass statistics. |
161 */ | 178 */ |
162 typedef struct { | 179 typedef struct { |
163 vpx_fixed_buf_t buf; | 180 vpx_fixed_buf_t buf; |
164 int pass; | 181 int pass; |
165 FILE *file; | 182 FILE *file; |
166 char *buf_ptr; | 183 char *buf_ptr; |
167 size_t buf_alloc_sz; | 184 size_t buf_alloc_sz; |
168 } stats_io_t; | 185 } stats_io_t; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 struct detect_buffer { | 311 struct detect_buffer { |
295 char buf[4]; | 312 char buf[4]; |
296 size_t buf_read; | 313 size_t buf_read; |
297 size_t position; | 314 size_t position; |
298 }; | 315 }; |
299 | 316 |
300 | 317 |
301 struct input_state { | 318 struct input_state { |
302 char *fn; | 319 char *fn; |
303 FILE *file; | 320 FILE *file; |
| 321 off_t length; |
304 y4m_input y4m; | 322 y4m_input y4m; |
305 struct detect_buffer detect; | 323 struct detect_buffer detect; |
306 enum video_file_type file_type; | 324 enum video_file_type file_type; |
307 unsigned int w; | 325 unsigned int w; |
308 unsigned int h; | 326 unsigned int h; |
309 struct vpx_rational framerate; | 327 struct vpx_rational framerate; |
310 int use_i420; | 328 int use_i420; |
311 }; | 329 }; |
312 | 330 |
313 | 331 |
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
942 static const arg_def_t good_dl = ARG_DEF(NULL, "good", 0, | 960 static const arg_def_t good_dl = ARG_DEF(NULL, "good", 0, |
943 "Use Good Quality Deadline"); | 961 "Use Good Quality Deadline"); |
944 static const arg_def_t rt_dl = ARG_DEF(NULL, "rt", 0, | 962 static const arg_def_t rt_dl = ARG_DEF(NULL, "rt", 0, |
945 "Use Realtime Quality Deadline
"); | 963 "Use Realtime Quality Deadline
"); |
946 static const arg_def_t quietarg = ARG_DEF("q", "quiet", 0, | 964 static const arg_def_t quietarg = ARG_DEF("q", "quiet", 0, |
947 "Do not print encode progress"
); | 965 "Do not print encode progress"
); |
948 static const arg_def_t verbosearg = ARG_DEF("v", "verbose", 0, | 966 static const arg_def_t verbosearg = ARG_DEF("v", "verbose", 0, |
949 "Show encoder parameters"); | 967 "Show encoder parameters"); |
950 static const arg_def_t psnrarg = ARG_DEF(NULL, "psnr", 0, | 968 static const arg_def_t psnrarg = ARG_DEF(NULL, "psnr", 0, |
951 "Show PSNR in status line"); | 969 "Show PSNR in status line"); |
952 static const arg_def_t recontest = ARG_DEF(NULL, "test-decode", 0, | 970 enum TestDecodeFatality { |
953 "Test encode/decode mismatch")
; | 971 TEST_DECODE_OFF, |
| 972 TEST_DECODE_FATAL, |
| 973 TEST_DECODE_WARN, |
| 974 }; |
| 975 static const struct arg_enum_list test_decode_enum[] = { |
| 976 {"off", TEST_DECODE_OFF}, |
| 977 {"fatal", TEST_DECODE_FATAL}, |
| 978 {"warn", TEST_DECODE_WARN}, |
| 979 {NULL, 0} |
| 980 }; |
| 981 static const arg_def_t recontest = ARG_DEF_ENUM(NULL, "test-decode", 1, |
| 982 "Test encode/decode mismatch", |
| 983 test_decode_enum); |
954 static const arg_def_t framerate = ARG_DEF(NULL, "fps", 1, | 984 static const arg_def_t framerate = ARG_DEF(NULL, "fps", 1, |
955 "Stream frame rate (rate/scale
)"); | 985 "Stream frame rate (rate/scale
)"); |
956 static const arg_def_t use_ivf = ARG_DEF(NULL, "ivf", 0, | 986 static const arg_def_t use_ivf = ARG_DEF(NULL, "ivf", 0, |
957 "Output IVF (default is WebM)"
); | 987 "Output IVF (default is WebM)"
); |
958 static const arg_def_t out_part = ARG_DEF("P", "output-partitions", 0, | 988 static const arg_def_t out_part = ARG_DEF("P", "output-partitions", 0, |
959 "Makes encoder output partitions. Requ
ires IVF output!"); | 989 "Makes encoder output partitions. Requ
ires IVF output!"); |
960 static const arg_def_t q_hist_n = ARG_DEF(NULL, "q-hist", 1, | 990 static const arg_def_t q_hist_n = ARG_DEF(NULL, "q-hist", 1, |
961 "Show quantizer histogram (n-b
uckets)"); | 991 "Show quantizer histogram (n-b
uckets)"); |
962 static const arg_def_t rate_hist_n = ARG_DEF(NULL, "rate-hist", 1, | 992 static const arg_def_t rate_hist_n = ARG_DEF(NULL, "rate-hist", 1, |
963 "Show rate histogram (n-buc
kets)"); | 993 "Show rate histogram (n-buc
kets)"); |
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1558 int passes; | 1588 int passes; |
1559 int pass; | 1589 int pass; |
1560 int usage; | 1590 int usage; |
1561 int deadline; | 1591 int deadline; |
1562 int use_i420; | 1592 int use_i420; |
1563 int quiet; | 1593 int quiet; |
1564 int verbose; | 1594 int verbose; |
1565 int limit; | 1595 int limit; |
1566 int skip_frames; | 1596 int skip_frames; |
1567 int show_psnr; | 1597 int show_psnr; |
1568 int test_decode; | 1598 enum TestDecodeFatality test_decode; |
1569 int have_framerate; | 1599 int have_framerate; |
1570 struct vpx_rational framerate; | 1600 struct vpx_rational framerate; |
1571 int out_part; | 1601 int out_part; |
1572 int debug; | 1602 int debug; |
1573 int show_q_hist_buckets; | 1603 int show_q_hist_buckets; |
1574 int show_rate_hist_buckets; | 1604 int show_rate_hist_buckets; |
1575 }; | 1605 }; |
1576 | 1606 |
1577 | 1607 |
1578 /* Per-stream configuration */ | 1608 /* Per-stream configuration */ |
(...skipping 20 matching lines...) Expand all Loading... |
1599 uint64_t psnr_sse_total; | 1629 uint64_t psnr_sse_total; |
1600 uint64_t psnr_samples_total; | 1630 uint64_t psnr_samples_total; |
1601 double psnr_totals[4]; | 1631 double psnr_totals[4]; |
1602 int psnr_count; | 1632 int psnr_count; |
1603 int counts[64]; | 1633 int counts[64]; |
1604 vpx_codec_ctx_t encoder; | 1634 vpx_codec_ctx_t encoder; |
1605 unsigned int frames_out; | 1635 unsigned int frames_out; |
1606 uint64_t cx_time; | 1636 uint64_t cx_time; |
1607 size_t nbytes; | 1637 size_t nbytes; |
1608 stats_io_t stats; | 1638 stats_io_t stats; |
| 1639 struct vpx_image *img; |
1609 vpx_codec_ctx_t decoder; | 1640 vpx_codec_ctx_t decoder; |
1610 vpx_ref_frame_t ref_enc; | 1641 vpx_ref_frame_t ref_enc; |
1611 vpx_ref_frame_t ref_dec; | 1642 vpx_ref_frame_t ref_dec; |
1612 int mismatch_seen; | 1643 int mismatch_seen; |
1613 }; | 1644 }; |
1614 | 1645 |
1615 | 1646 |
1616 void validate_positive_rational(const char *msg, | 1647 void validate_positive_rational(const char *msg, |
1617 struct vpx_rational *rat) { | 1648 struct vpx_rational *rat) { |
1618 if (rat->den < 0) { | 1649 if (rat->den < 0) { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1683 global->quiet = 1; | 1714 global->quiet = 1; |
1684 else if (arg_match(&arg, &verbosearg, argi)) | 1715 else if (arg_match(&arg, &verbosearg, argi)) |
1685 global->verbose = 1; | 1716 global->verbose = 1; |
1686 else if (arg_match(&arg, &limit, argi)) | 1717 else if (arg_match(&arg, &limit, argi)) |
1687 global->limit = arg_parse_uint(&arg); | 1718 global->limit = arg_parse_uint(&arg); |
1688 else if (arg_match(&arg, &skip, argi)) | 1719 else if (arg_match(&arg, &skip, argi)) |
1689 global->skip_frames = arg_parse_uint(&arg); | 1720 global->skip_frames = arg_parse_uint(&arg); |
1690 else if (arg_match(&arg, &psnrarg, argi)) | 1721 else if (arg_match(&arg, &psnrarg, argi)) |
1691 global->show_psnr = 1; | 1722 global->show_psnr = 1; |
1692 else if (arg_match(&arg, &recontest, argi)) | 1723 else if (arg_match(&arg, &recontest, argi)) |
1693 global->test_decode = 1; | 1724 global->test_decode = arg_parse_enum_or_int(&arg); |
1694 else if (arg_match(&arg, &framerate, argi)) { | 1725 else if (arg_match(&arg, &framerate, argi)) { |
1695 global->framerate = arg_parse_rational(&arg); | 1726 global->framerate = arg_parse_rational(&arg); |
1696 validate_positive_rational(arg.name, &global->framerate); | 1727 validate_positive_rational(arg.name, &global->framerate); |
1697 global->have_framerate = 1; | 1728 global->have_framerate = 1; |
1698 } else if (arg_match(&arg, &out_part, argi)) | 1729 } else if (arg_match(&arg, &out_part, argi)) |
1699 global->out_part = 1; | 1730 global->out_part = 1; |
1700 else if (arg_match(&arg, &debugmode, argi)) | 1731 else if (arg_match(&arg, &debugmode, argi)) |
1701 global->debug = 1; | 1732 global->debug = 1; |
1702 else if (arg_match(&arg, &q_hist_n, argi)) | 1733 else if (arg_match(&arg, &q_hist_n, argi)) |
1703 global->show_q_hist_buckets = arg_parse_uint(&arg); | 1734 global->show_q_hist_buckets = arg_parse_uint(&arg); |
(...skipping 19 matching lines...) Expand all Loading... |
1723 void open_input_file(struct input_state *input) { | 1754 void open_input_file(struct input_state *input) { |
1724 unsigned int fourcc; | 1755 unsigned int fourcc; |
1725 | 1756 |
1726 /* Parse certain options from the input file, if possible */ | 1757 /* Parse certain options from the input file, if possible */ |
1727 input->file = strcmp(input->fn, "-") ? fopen(input->fn, "rb") | 1758 input->file = strcmp(input->fn, "-") ? fopen(input->fn, "rb") |
1728 : set_binary_mode(stdin); | 1759 : set_binary_mode(stdin); |
1729 | 1760 |
1730 if (!input->file) | 1761 if (!input->file) |
1731 fatal("Failed to open input file"); | 1762 fatal("Failed to open input file"); |
1732 | 1763 |
| 1764 if (!fseeko(input->file, 0, SEEK_END)) { |
| 1765 /* Input file is seekable. Figure out how long it is, so we can get |
| 1766 * progress info. |
| 1767 */ |
| 1768 input->length = ftello(input->file); |
| 1769 rewind(input->file); |
| 1770 } |
| 1771 |
1733 /* For RAW input sources, these bytes will applied on the first frame | 1772 /* For RAW input sources, these bytes will applied on the first frame |
1734 * in read_frame(). | 1773 * in read_frame(). |
1735 */ | 1774 */ |
1736 input->detect.buf_read = fread(input->detect.buf, 1, 4, input->file); | 1775 input->detect.buf_read = fread(input->detect.buf, 1, 4, input->file); |
1737 input->detect.position = 0; | 1776 input->detect.position = 0; |
1738 | 1777 |
1739 if (input->detect.buf_read == 4 | 1778 if (input->detect.buf_read == 4 |
1740 && file_is_y4m(input->file, &input->y4m, input->detect.buf)) { | 1779 && file_is_y4m(input->file, &input->y4m, input->detect.buf)) { |
1741 if (y4m_input_open(&input->y4m, input->file, input->detect.buf, 4) >= 0) { | 1780 if (y4m_input_open(&input->y4m, input->file, input->detect.buf, 4) >= 0) { |
1742 input->file_type = FILE_TYPE_Y4M; | 1781 input->file_type = FILE_TYPE_Y4M; |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2006 fatal("Stream %d: duplicate stats file (from stream %d)", | 2045 fatal("Stream %d: duplicate stats file (from stream %d)", |
2007 streami->index, stream->index); | 2046 streami->index, stream->index); |
2008 } | 2047 } |
2009 } | 2048 } |
2010 } | 2049 } |
2011 | 2050 |
2012 | 2051 |
2013 static void set_stream_dimensions(struct stream_state *stream, | 2052 static void set_stream_dimensions(struct stream_state *stream, |
2014 unsigned int w, | 2053 unsigned int w, |
2015 unsigned int h) { | 2054 unsigned int h) { |
2016 if ((stream->config.cfg.g_w && stream->config.cfg.g_w != w) | 2055 if (!stream->config.cfg.g_w) { |
2017 || (stream->config.cfg.g_h && stream->config.cfg.g_h != h)) | 2056 if (!stream->config.cfg.g_h) |
2018 fatal("Stream %d: Resizing not yet supported", stream->index); | 2057 stream->config.cfg.g_w = w; |
2019 stream->config.cfg.g_w = w; | 2058 else |
2020 stream->config.cfg.g_h = h; | 2059 stream->config.cfg.g_w = w * stream->config.cfg.g_h / h; |
| 2060 } |
| 2061 if (!stream->config.cfg.g_h) { |
| 2062 stream->config.cfg.g_h = h * stream->config.cfg.g_w / w; |
| 2063 } |
2021 } | 2064 } |
2022 | 2065 |
2023 | 2066 |
2024 static void set_default_kf_interval(struct stream_state *stream, | 2067 static void set_default_kf_interval(struct stream_state *stream, |
2025 struct global_config *global) { | 2068 struct global_config *global) { |
2026 /* Use a max keyframe interval of 5 seconds, if none was | 2069 /* Use a max keyframe interval of 5 seconds, if none was |
2027 * specified on the command line. | 2070 * specified on the command line. |
2028 */ | 2071 */ |
2029 if (!stream->config.have_kf_max_dist) { | 2072 if (!stream->config.have_kf_max_dist) { |
2030 double framerate = (double)global->framerate.num / global->framerate.den; | 2073 double framerate = (double)global->framerate.num / global->framerate.den; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2170 int ctrl = stream->config.arg_ctrls[i][0]; | 2213 int ctrl = stream->config.arg_ctrls[i][0]; |
2171 int value = stream->config.arg_ctrls[i][1]; | 2214 int value = stream->config.arg_ctrls[i][1]; |
2172 if (vpx_codec_control_(&stream->encoder, ctrl, value)) | 2215 if (vpx_codec_control_(&stream->encoder, ctrl, value)) |
2173 fprintf(stderr, "Error: Tried to set control %d = %d\n", | 2216 fprintf(stderr, "Error: Tried to set control %d = %d\n", |
2174 ctrl, value); | 2217 ctrl, value); |
2175 | 2218 |
2176 ctx_exit_on_error(&stream->encoder, "Failed to control codec"); | 2219 ctx_exit_on_error(&stream->encoder, "Failed to control codec"); |
2177 } | 2220 } |
2178 | 2221 |
2179 #if CONFIG_DECODERS | 2222 #if CONFIG_DECODERS |
2180 if (global->test_decode) { | 2223 if (global->test_decode != TEST_DECODE_OFF) { |
2181 int width, height; | 2224 int width, height; |
2182 | 2225 |
2183 vpx_codec_dec_init(&stream->decoder, global->codec->dx_iface(), NULL, 0); | 2226 vpx_codec_dec_init(&stream->decoder, global->codec->dx_iface(), NULL, 0); |
2184 | 2227 |
2185 width = (stream->config.cfg.g_w + 15) & ~15; | 2228 width = (stream->config.cfg.g_w + 15) & ~15; |
2186 height = (stream->config.cfg.g_h + 15) & ~15; | 2229 height = (stream->config.cfg.g_h + 15) & ~15; |
2187 vpx_img_alloc(&stream->ref_enc.img, VPX_IMG_FMT_I420, width, height, 1); | 2230 vpx_img_alloc(&stream->ref_enc.img, VPX_IMG_FMT_I420, width, height, 1); |
2188 vpx_img_alloc(&stream->ref_dec.img, VPX_IMG_FMT_I420, width, height, 1); | 2231 vpx_img_alloc(&stream->ref_dec.img, VPX_IMG_FMT_I420, width, height, 1); |
2189 stream->ref_enc.frame_type = VP8_LAST_FRAME; | 2232 stream->ref_enc.frame_type = VP8_LAST_FRAME; |
2190 stream->ref_dec.frame_type = VP8_LAST_FRAME; | 2233 stream->ref_dec.frame_type = VP8_LAST_FRAME; |
2191 } | 2234 } |
2192 #endif | 2235 #endif |
2193 } | 2236 } |
2194 | 2237 |
2195 | 2238 |
2196 static void encode_frame(struct stream_state *stream, | 2239 static void encode_frame(struct stream_state *stream, |
2197 struct global_config *global, | 2240 struct global_config *global, |
2198 struct vpx_image *img, | 2241 struct vpx_image *img, |
2199 unsigned int frames_in) { | 2242 unsigned int frames_in) { |
2200 vpx_codec_pts_t frame_start, next_frame_start; | 2243 vpx_codec_pts_t frame_start, next_frame_start; |
2201 struct vpx_codec_enc_cfg *cfg = &stream->config.cfg; | 2244 struct vpx_codec_enc_cfg *cfg = &stream->config.cfg; |
2202 struct vpx_usec_timer timer; | 2245 struct vpx_usec_timer timer; |
2203 | 2246 |
2204 frame_start = (cfg->g_timebase.den * (int64_t)(frames_in - 1) | 2247 frame_start = (cfg->g_timebase.den * (int64_t)(frames_in - 1) |
2205 * global->framerate.den) | 2248 * global->framerate.den) |
2206 / cfg->g_timebase.num / global->framerate.num; | 2249 / cfg->g_timebase.num / global->framerate.num; |
2207 next_frame_start = (cfg->g_timebase.den * (int64_t)(frames_in) | 2250 next_frame_start = (cfg->g_timebase.den * (int64_t)(frames_in) |
2208 * global->framerate.den) | 2251 * global->framerate.den) |
2209 / cfg->g_timebase.num / global->framerate.num; | 2252 / cfg->g_timebase.num / global->framerate.num; |
| 2253 |
| 2254 /* Scale if necessary */ |
| 2255 if (img && (img->d_w != cfg->g_w || img->d_h != cfg->g_h)) { |
| 2256 if (!stream->img) |
| 2257 stream->img = vpx_img_alloc(NULL, VPX_IMG_FMT_I420, |
| 2258 cfg->g_w, cfg->g_h, 16); |
| 2259 I420Scale(img->planes[VPX_PLANE_Y], img->stride[VPX_PLANE_Y], |
| 2260 img->planes[VPX_PLANE_U], img->stride[VPX_PLANE_U], |
| 2261 img->planes[VPX_PLANE_V], img->stride[VPX_PLANE_V], |
| 2262 img->d_w, img->d_h, |
| 2263 stream->img->planes[VPX_PLANE_Y], |
| 2264 stream->img->stride[VPX_PLANE_Y], |
| 2265 stream->img->planes[VPX_PLANE_U], |
| 2266 stream->img->stride[VPX_PLANE_U], |
| 2267 stream->img->planes[VPX_PLANE_V], |
| 2268 stream->img->stride[VPX_PLANE_V], |
| 2269 stream->img->d_w, stream->img->d_h, |
| 2270 kFilterBox); |
| 2271 |
| 2272 img = stream->img; |
| 2273 } |
| 2274 |
2210 vpx_usec_timer_start(&timer); | 2275 vpx_usec_timer_start(&timer); |
2211 vpx_codec_encode(&stream->encoder, img, frame_start, | 2276 vpx_codec_encode(&stream->encoder, img, frame_start, |
2212 (unsigned long)(next_frame_start - frame_start), | 2277 (unsigned long)(next_frame_start - frame_start), |
2213 0, global->deadline); | 2278 0, global->deadline); |
2214 vpx_usec_timer_mark(&timer); | 2279 vpx_usec_timer_mark(&timer); |
2215 stream->cx_time += vpx_usec_timer_elapsed(&timer); | 2280 stream->cx_time += vpx_usec_timer_elapsed(&timer); |
2216 ctx_exit_on_error(&stream->encoder, "Stream %d: Failed to encode frame", | 2281 ctx_exit_on_error(&stream->encoder, "Stream %d: Failed to encode frame", |
2217 stream->index); | 2282 stream->index); |
2218 } | 2283 } |
2219 | 2284 |
(...skipping 19 matching lines...) Expand all Loading... |
2239 *got_data = 0; | 2304 *got_data = 0; |
2240 while ((pkt = vpx_codec_get_cx_data(&stream->encoder, &iter))) { | 2305 while ((pkt = vpx_codec_get_cx_data(&stream->encoder, &iter))) { |
2241 static size_t fsize = 0; | 2306 static size_t fsize = 0; |
2242 static off_t ivf_header_pos = 0; | 2307 static off_t ivf_header_pos = 0; |
2243 | 2308 |
2244 switch (pkt->kind) { | 2309 switch (pkt->kind) { |
2245 case VPX_CODEC_CX_FRAME_PKT: | 2310 case VPX_CODEC_CX_FRAME_PKT: |
2246 if (!(pkt->data.frame.flags & VPX_FRAME_IS_FRAGMENT)) { | 2311 if (!(pkt->data.frame.flags & VPX_FRAME_IS_FRAGMENT)) { |
2247 stream->frames_out++; | 2312 stream->frames_out++; |
2248 } | 2313 } |
2249 if (!global->quiet) | |
2250 fprintf(stderr, " %6luF", | |
2251 (unsigned long)pkt->data.frame.sz); | |
2252 | 2314 |
2253 update_rate_histogram(&stream->rate_hist, cfg, pkt); | 2315 update_rate_histogram(&stream->rate_hist, cfg, pkt); |
2254 if (stream->config.write_webm) { | 2316 if (stream->config.write_webm) { |
2255 /* Update the hash */ | 2317 /* Update the hash */ |
2256 if (!stream->ebml.debug) | 2318 if (!stream->ebml.debug) |
2257 stream->hash = murmur(pkt->data.frame.buf, | 2319 stream->hash = murmur(pkt->data.frame.buf, |
2258 (int)pkt->data.frame.sz, | 2320 (int)pkt->data.frame.sz, |
2259 stream->hash); | 2321 stream->hash); |
2260 | 2322 |
2261 write_webm_block(&stream->ebml, cfg, pkt); | 2323 write_webm_block(&stream->ebml, cfg, pkt); |
(...skipping 14 matching lines...) Expand all Loading... |
2276 } | 2338 } |
2277 } | 2339 } |
2278 | 2340 |
2279 (void) fwrite(pkt->data.frame.buf, 1, pkt->data.frame.sz, | 2341 (void) fwrite(pkt->data.frame.buf, 1, pkt->data.frame.sz, |
2280 stream->file); | 2342 stream->file); |
2281 } | 2343 } |
2282 stream->nbytes += pkt->data.raw.sz; | 2344 stream->nbytes += pkt->data.raw.sz; |
2283 | 2345 |
2284 *got_data = 1; | 2346 *got_data = 1; |
2285 #if CONFIG_DECODERS | 2347 #if CONFIG_DECODERS |
2286 if (global->test_decode) { | 2348 if (global->test_decode != TEST_DECODE_OFF && !stream->mismatch_seen) { |
2287 vpx_codec_decode(&stream->decoder, pkt->data.frame.buf, | 2349 vpx_codec_decode(&stream->decoder, pkt->data.frame.buf, |
2288 pkt->data.frame.sz, NULL, 0); | 2350 pkt->data.frame.sz, NULL, 0); |
2289 ctx_exit_on_error(&stream->decoder, "Failed to decode frame"); | 2351 if (stream->decoder.err) { |
| 2352 warn_or_exit_on_error(&stream->decoder, |
| 2353 global->test_decode == TEST_DECODE_FATAL, |
| 2354 "Failed to decode frame %d in stream %d", |
| 2355 stream->frames_out + 1, stream->index); |
| 2356 stream->mismatch_seen = stream->frames_out + 1; |
| 2357 } |
2290 } | 2358 } |
2291 #endif | 2359 #endif |
2292 break; | 2360 break; |
2293 case VPX_CODEC_STATS_PKT: | 2361 case VPX_CODEC_STATS_PKT: |
2294 stream->frames_out++; | 2362 stream->frames_out++; |
2295 if (!global->quiet) | |
2296 fprintf(stderr, " %6luS", | |
2297 (unsigned long)pkt->data.twopass_stats.sz); | |
2298 stats_write(&stream->stats, | 2363 stats_write(&stream->stats, |
2299 pkt->data.twopass_stats.buf, | 2364 pkt->data.twopass_stats.buf, |
2300 pkt->data.twopass_stats.sz); | 2365 pkt->data.twopass_stats.sz); |
2301 stream->nbytes += pkt->data.raw.sz; | 2366 stream->nbytes += pkt->data.raw.sz; |
2302 break; | 2367 break; |
2303 case VPX_CODEC_PSNR_PKT: | 2368 case VPX_CODEC_PSNR_PKT: |
2304 | 2369 |
2305 if (global->show_psnr) { | 2370 if (global->show_psnr) { |
2306 int i; | 2371 int i; |
2307 | 2372 |
2308 stream->psnr_sse_total += pkt->data.psnr.sse[0]; | 2373 stream->psnr_sse_total += pkt->data.psnr.sse[0]; |
2309 stream->psnr_samples_total += pkt->data.psnr.samples[0]; | 2374 stream->psnr_samples_total += pkt->data.psnr.samples[0]; |
2310 for (i = 0; i < 4; i++) { | 2375 for (i = 0; i < 4; i++) { |
2311 if (!global->quiet) | |
2312 fprintf(stderr, "%.3f ", pkt->data.psnr.psnr[i]); | |
2313 stream->psnr_totals[i] += pkt->data.psnr.psnr[i]; | 2376 stream->psnr_totals[i] += pkt->data.psnr.psnr[i]; |
2314 } | 2377 } |
2315 stream->psnr_count++; | 2378 stream->psnr_count++; |
2316 } | 2379 } |
2317 | 2380 |
2318 break; | 2381 break; |
2319 default: | 2382 default: |
2320 break; | 2383 break; |
2321 } | 2384 } |
2322 } | 2385 } |
(...skipping 12 matching lines...) Expand all Loading... |
2335 (double)stream->psnr_sse_total); | 2398 (double)stream->psnr_sse_total); |
2336 fprintf(stderr, " %.3f", ovpsnr); | 2399 fprintf(stderr, " %.3f", ovpsnr); |
2337 | 2400 |
2338 for (i = 0; i < 4; i++) { | 2401 for (i = 0; i < 4; i++) { |
2339 fprintf(stderr, " %.3f", stream->psnr_totals[i] / stream->psnr_count); | 2402 fprintf(stderr, " %.3f", stream->psnr_totals[i] / stream->psnr_count); |
2340 } | 2403 } |
2341 fprintf(stderr, "\n"); | 2404 fprintf(stderr, "\n"); |
2342 } | 2405 } |
2343 | 2406 |
2344 | 2407 |
2345 float usec_to_fps(uint64_t usec, unsigned int frames) { | 2408 static float usec_to_fps(uint64_t usec, unsigned int frames) { |
2346 return (float)(usec > 0 ? frames * 1000000.0 / (float)usec : 0); | 2409 return (float)(usec > 0 ? frames * 1000000.0 / (float)usec : 0); |
2347 } | 2410 } |
2348 | 2411 |
2349 | 2412 |
2350 static void test_decode(struct stream_state *stream) { | 2413 static void test_decode(struct stream_state *stream, |
| 2414 enum TestDecodeFatality fatal) { |
| 2415 if (stream->mismatch_seen) |
| 2416 return; |
| 2417 |
2351 vpx_codec_control(&stream->encoder, VP8_COPY_REFERENCE, &stream->ref_enc); | 2418 vpx_codec_control(&stream->encoder, VP8_COPY_REFERENCE, &stream->ref_enc); |
2352 ctx_exit_on_error(&stream->encoder, "Failed to get encoder reference frame"); | 2419 ctx_exit_on_error(&stream->encoder, "Failed to get encoder reference frame"); |
2353 vpx_codec_control(&stream->decoder, VP8_COPY_REFERENCE, &stream->ref_dec); | 2420 vpx_codec_control(&stream->decoder, VP8_COPY_REFERENCE, &stream->ref_dec); |
2354 ctx_exit_on_error(&stream->decoder, "Failed to get decoder reference frame"); | 2421 ctx_exit_on_error(&stream->decoder, "Failed to get decoder reference frame"); |
2355 | 2422 |
2356 if (!stream->mismatch_seen | 2423 if (!compare_img(&stream->ref_enc.img, &stream->ref_dec.img)) { |
2357 && !compare_img(&stream->ref_enc.img, &stream->ref_dec.img)) { | |
2358 /* TODO(jkoleszar): make fatal. */ | |
2359 int y[2], u[2], v[2]; | 2424 int y[2], u[2], v[2]; |
2360 find_mismatch(&stream->ref_enc.img, &stream->ref_dec.img, | 2425 find_mismatch(&stream->ref_enc.img, &stream->ref_dec.img, |
2361 y, u, v); | 2426 y, u, v); |
2362 warn("Stream %d: Encode/decode mismatch on frame %d" | 2427 warn_or_exit_on_error(&stream->decoder, fatal == TEST_DECODE_FATAL, |
2363 " at Y[%d, %d], U[%d, %d], V[%d, %d]", | 2428 "Stream %d: Encode/decode mismatch on frame %d" |
2364 stream->index, stream->frames_out, | 2429 " at Y[%d, %d], U[%d, %d], V[%d, %d]", |
2365 y[0], y[1], u[0], u[1], v[0], v[1]); | 2430 stream->index, stream->frames_out, |
| 2431 y[0], y[1], u[0], u[1], v[0], v[1]); |
2366 stream->mismatch_seen = stream->frames_out; | 2432 stream->mismatch_seen = stream->frames_out; |
2367 } | 2433 } |
2368 } | 2434 } |
2369 | 2435 |
| 2436 |
| 2437 static void print_time(const char *label, int64_t etl) { |
| 2438 int hours, mins, secs; |
| 2439 |
| 2440 if (etl >= 0) { |
| 2441 hours = etl / 3600; |
| 2442 etl -= hours * 3600; |
| 2443 mins = etl / 60; |
| 2444 etl -= mins * 60; |
| 2445 secs = etl; |
| 2446 |
| 2447 fprintf(stderr, "[%3s %2d:%02d:%02d] ", |
| 2448 label, hours, mins, secs); |
| 2449 } else { |
| 2450 fprintf(stderr, "[%3s unknown] ", label); |
| 2451 } |
| 2452 } |
| 2453 |
2370 int main(int argc, const char **argv_) { | 2454 int main(int argc, const char **argv_) { |
2371 int pass; | 2455 int pass; |
2372 vpx_image_t raw; | 2456 vpx_image_t raw; |
2373 int frame_avail, got_data; | 2457 int frame_avail, got_data; |
2374 | 2458 |
2375 struct input_state input = {0}; | 2459 struct input_state input = {0}; |
2376 struct global_config global; | 2460 struct global_config global; |
2377 struct stream_state *streams = NULL; | 2461 struct stream_state *streams = NULL; |
2378 char **argv, **argi; | 2462 char **argv, **argi; |
2379 unsigned long cx_time = 0; | 2463 uint64_t cx_time = 0; |
2380 int stream_cnt = 0; | 2464 int stream_cnt = 0; |
| 2465 int res = 0; |
2381 | 2466 |
2382 exec_name = argv_[0]; | 2467 exec_name = argv_[0]; |
2383 | 2468 |
2384 if (argc < 3) | 2469 if (argc < 3) |
2385 usage_exit(); | 2470 usage_exit(); |
2386 | 2471 |
2387 /* Setup default input stream settings */ | 2472 /* Setup default input stream settings */ |
2388 input.framerate.num = 30; | 2473 input.framerate.num = 30; |
2389 input.framerate.den = 1; | 2474 input.framerate.den = 1; |
2390 input.use_i420 = 1; | 2475 input.use_i420 = 1; |
(...skipping 25 matching lines...) Expand all Loading... |
2416 if (argi[0][0] == '-' && argi[0][1]) | 2501 if (argi[0][0] == '-' && argi[0][1]) |
2417 die("Error: Unrecognized option %s\n", *argi); | 2502 die("Error: Unrecognized option %s\n", *argi); |
2418 | 2503 |
2419 /* Handle non-option arguments */ | 2504 /* Handle non-option arguments */ |
2420 input.fn = argv[0]; | 2505 input.fn = argv[0]; |
2421 | 2506 |
2422 if (!input.fn) | 2507 if (!input.fn) |
2423 usage_exit(); | 2508 usage_exit(); |
2424 | 2509 |
2425 for (pass = global.pass ? global.pass - 1 : 0; pass < global.passes; pass++) { | 2510 for (pass = global.pass ? global.pass - 1 : 0; pass < global.passes; pass++) { |
2426 int frames_in = 0; | 2511 int frames_in = 0, seen_frames = 0; |
| 2512 int64_t estimated_time_left = -1; |
| 2513 int64_t average_rate = -1; |
| 2514 off_t lagged_count = 0; |
2427 | 2515 |
2428 open_input_file(&input); | 2516 open_input_file(&input); |
2429 | 2517 |
2430 /* If the input file doesn't specify its w/h (raw files), try to get | 2518 /* If the input file doesn't specify its w/h (raw files), try to get |
2431 * the data from the first stream's configuration. | 2519 * the data from the first stream's configuration. |
2432 */ | 2520 */ |
2433 if (!input.w || !input.h) | 2521 if (!input.w || !input.h) |
2434 FOREACH_STREAM( { | 2522 FOREACH_STREAM( { |
2435 if (stream->config.cfg.g_w && stream->config.cfg.g_h) { | 2523 if (stream->config.cfg.g_w && stream->config.cfg.g_h) { |
2436 input.w = stream->config.cfg.g_w; | 2524 input.w = stream->config.cfg.g_w; |
2437 input.h = stream->config.cfg.g_h; | 2525 input.h = stream->config.cfg.g_h; |
2438 break; | 2526 break; |
2439 } | 2527 } |
2440 }); | 2528 }); |
2441 | 2529 |
2442 /* Update stream configurations from the input file's parameters */ | 2530 /* Update stream configurations from the input file's parameters */ |
| 2531 if (!input.w || !input.h) |
| 2532 fatal("Specify stream dimensions with --width (-w) " |
| 2533 " and --height (-h)"); |
2443 FOREACH_STREAM(set_stream_dimensions(stream, input.w, input.h)); | 2534 FOREACH_STREAM(set_stream_dimensions(stream, input.w, input.h)); |
2444 FOREACH_STREAM(validate_stream_config(stream)); | 2535 FOREACH_STREAM(validate_stream_config(stream)); |
2445 | 2536 |
2446 /* Ensure that --passes and --pass are consistent. If --pass is set and | 2537 /* Ensure that --passes and --pass are consistent. If --pass is set and |
2447 * --passes=2, ensure --fpf was set. | 2538 * --passes=2, ensure --fpf was set. |
2448 */ | 2539 */ |
2449 if (global.pass && global.passes == 2) | 2540 if (global.pass && global.passes == 2) |
2450 FOREACH_STREAM( { | 2541 FOREACH_STREAM( { |
2451 if (!stream->config.stats_fn) | 2542 if (!stream->config.stats_fn) |
2452 die("Stream %d: Must specify --fpf when --pass=%d" | 2543 die("Stream %d: Must specify --fpf when --pass=%d" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2491 got_data = 0; | 2582 got_data = 0; |
2492 | 2583 |
2493 while (frame_avail || got_data) { | 2584 while (frame_avail || got_data) { |
2494 struct vpx_usec_timer timer; | 2585 struct vpx_usec_timer timer; |
2495 | 2586 |
2496 if (!global.limit || frames_in < global.limit) { | 2587 if (!global.limit || frames_in < global.limit) { |
2497 frame_avail = read_frame(&input, &raw); | 2588 frame_avail = read_frame(&input, &raw); |
2498 | 2589 |
2499 if (frame_avail) | 2590 if (frame_avail) |
2500 frames_in++; | 2591 frames_in++; |
| 2592 seen_frames = frames_in > global.skip_frames ? |
| 2593 frames_in - global.skip_frames : 0; |
2501 | 2594 |
2502 if (!global.quiet) { | 2595 if (!global.quiet) { |
| 2596 float fps = usec_to_fps(cx_time, seen_frames); |
| 2597 fprintf(stderr, "\rPass %d/%d ", pass + 1, global.passes); |
| 2598 |
2503 if (stream_cnt == 1) | 2599 if (stream_cnt == 1) |
2504 fprintf(stderr, | 2600 fprintf(stderr, |
2505 "\rPass %d/%d frame %4d/%-4d %7"PRId64"B \033[K", | 2601 "frame %4d/%-4d %7"PRId64"B ", |
2506 pass + 1, global.passes, frames_in, | 2602 frames_in, streams->frames_out, (int64_t)streams->nbytes); |
2507 streams->frames_out, (int64_t)streams->nbytes); | |
2508 else | 2603 else |
2509 fprintf(stderr, | 2604 fprintf(stderr, "frame %4d ", frames_in); |
2510 "\rPass %d/%d frame %4d %7lu %s (%.2f fps)\033[K", | 2605 |
2511 pass + 1, global.passes, frames_in, | 2606 fprintf(stderr, "%7"PRId64" %s %.2f %s ", |
2512 cx_time > 9999999 ? cx_time / 1000 : cx_time, | 2607 cx_time > 9999999 ? cx_time / 1000 : cx_time, |
2513 cx_time > 9999999 ? "ms" : "us", | 2608 cx_time > 9999999 ? "ms" : "us", |
2514 usec_to_fps(cx_time, frames_in)); | 2609 fps >= 1.0 ? fps : 1000.0 / fps, |
| 2610 fps >= 1.0 ? "fps" : "ms/f"); |
| 2611 print_time("ETA", estimated_time_left); |
| 2612 fprintf(stderr, "\033[K"); |
2515 } | 2613 } |
2516 | 2614 |
2517 } else | 2615 } else |
2518 frame_avail = 0; | 2616 frame_avail = 0; |
2519 | 2617 |
2520 if (frames_in > global.skip_frames) { | 2618 if (frames_in > global.skip_frames) { |
2521 vpx_usec_timer_start(&timer); | 2619 vpx_usec_timer_start(&timer); |
2522 FOREACH_STREAM(encode_frame(stream, &global, | 2620 FOREACH_STREAM(encode_frame(stream, &global, |
2523 frame_avail ? &raw : NULL, | 2621 frame_avail ? &raw : NULL, |
2524 frames_in)); | 2622 frames_in)); |
2525 vpx_usec_timer_mark(&timer); | 2623 vpx_usec_timer_mark(&timer); |
2526 cx_time += (unsigned long)vpx_usec_timer_elapsed(&timer); | 2624 cx_time += vpx_usec_timer_elapsed(&timer); |
2527 | 2625 |
2528 FOREACH_STREAM(update_quantizer_histogram(stream)); | 2626 FOREACH_STREAM(update_quantizer_histogram(stream)); |
2529 | 2627 |
2530 got_data = 0; | 2628 got_data = 0; |
2531 FOREACH_STREAM(get_cx_data(stream, &global, &got_data)); | 2629 FOREACH_STREAM(get_cx_data(stream, &global, &got_data)); |
2532 | 2630 |
2533 if (got_data && global.test_decode) | 2631 if (!got_data && input.length && !streams->frames_out) { |
2534 FOREACH_STREAM(test_decode(stream)); | 2632 lagged_count = global.limit ? seen_frames : ftello(input.file); |
| 2633 } else if (input.length) { |
| 2634 int64_t remaining; |
| 2635 int64_t rate; |
| 2636 |
| 2637 if (global.limit) { |
| 2638 int frame_in_lagged = (seen_frames - lagged_count) * 1000; |
| 2639 |
| 2640 rate = cx_time ? frame_in_lagged * (int64_t)1000000 / cx_time : 0; |
| 2641 remaining = 1000 * (global.limit - global.skip_frames |
| 2642 - seen_frames + lagged_count); |
| 2643 } else { |
| 2644 off_t input_pos = ftello(input.file); |
| 2645 off_t input_pos_lagged = input_pos - lagged_count; |
| 2646 int64_t limit = input.length; |
| 2647 |
| 2648 rate = cx_time ? input_pos_lagged * (int64_t)1000000 / cx_time : 0; |
| 2649 remaining = limit - input_pos + lagged_count; |
| 2650 } |
| 2651 |
| 2652 average_rate = (average_rate <= 0) |
| 2653 ? rate |
| 2654 : (average_rate * 7 + rate) / 8; |
| 2655 estimated_time_left = average_rate ? remaining / average_rate : -1; |
| 2656 } |
| 2657 |
| 2658 if (got_data && global.test_decode != TEST_DECODE_OFF) |
| 2659 FOREACH_STREAM(test_decode(stream, global.test_decode)); |
2535 } | 2660 } |
2536 | 2661 |
2537 fflush(stdout); | 2662 fflush(stdout); |
2538 } | 2663 } |
2539 | 2664 |
2540 if (stream_cnt > 1) | 2665 if (stream_cnt > 1) |
2541 fprintf(stderr, "\n"); | 2666 fprintf(stderr, "\n"); |
2542 | 2667 |
2543 if (!global.quiet) | 2668 if (!global.quiet) |
2544 FOREACH_STREAM(fprintf( | 2669 FOREACH_STREAM(fprintf( |
2545 stderr, | 2670 stderr, |
2546 "\rPass %d/%d frame %4d/%-4d %7"PRId64"B %7lub/f %7"PRId6
4"b/s" | 2671 "\rPass %d/%d frame %4d/%-4d %7"PRId64"B %7lub/f %7"PRId6
4"b/s" |
2547 " %7"PRId64" %s (%.2f fps)\033[K\n", pass + 1, | 2672 " %7"PRId64" %s (%.2f fps)\033[K\n", pass + 1, |
2548 global.passes, frames_in, stream->frames_out, (int64_t)st
ream->nbytes, | 2673 global.passes, frames_in, stream->frames_out, (int64_t)st
ream->nbytes, |
2549 frames_in ? (unsigned long)(stream->nbytes * 8 / frames_i
n) : 0, | 2674 seen_frames ? (unsigned long)(stream->nbytes * 8 / seen_f
rames) : 0, |
2550 frames_in ? (int64_t)stream->nbytes * 8 | 2675 seen_frames ? (int64_t)stream->nbytes * 8 |
2551 * (int64_t)global.framerate.num / global.framerate.den | 2676 * (int64_t)global.framerate.num / global.framerate.den |
2552 / frames_in | 2677 / seen_frames |
2553 : 0, | 2678 : 0, |
2554 stream->cx_time > 9999999 ? stream->cx_time / 1000 : stre
am->cx_time, | 2679 stream->cx_time > 9999999 ? stream->cx_time / 1000 : stre
am->cx_time, |
2555 stream->cx_time > 9999999 ? "ms" : "us", | 2680 stream->cx_time > 9999999 ? "ms" : "us", |
2556 usec_to_fps(stream->cx_time, frames_in)); | 2681 usec_to_fps(stream->cx_time, seen_frames)); |
2557 ); | 2682 ); |
2558 | 2683 |
2559 if (global.show_psnr) | 2684 if (global.show_psnr) |
2560 FOREACH_STREAM(show_psnr(stream)); | 2685 FOREACH_STREAM(show_psnr(stream)); |
2561 | 2686 |
2562 FOREACH_STREAM(vpx_codec_destroy(&stream->encoder)); | 2687 FOREACH_STREAM(vpx_codec_destroy(&stream->encoder)); |
2563 | 2688 |
2564 if (global.test_decode) { | 2689 if (global.test_decode != TEST_DECODE_OFF) { |
2565 FOREACH_STREAM(vpx_codec_destroy(&stream->decoder)); | 2690 FOREACH_STREAM(vpx_codec_destroy(&stream->decoder)); |
2566 FOREACH_STREAM(vpx_img_free(&stream->ref_enc.img)); | 2691 FOREACH_STREAM(vpx_img_free(&stream->ref_enc.img)); |
2567 FOREACH_STREAM(vpx_img_free(&stream->ref_dec.img)); | 2692 FOREACH_STREAM(vpx_img_free(&stream->ref_dec.img)); |
2568 } | 2693 } |
2569 | 2694 |
2570 close_input_file(&input); | 2695 close_input_file(&input); |
2571 | 2696 |
| 2697 if (global.test_decode == TEST_DECODE_FATAL) { |
| 2698 FOREACH_STREAM(res |= stream->mismatch_seen); |
| 2699 } |
2572 FOREACH_STREAM(close_output_file(stream, global.codec->fourcc)); | 2700 FOREACH_STREAM(close_output_file(stream, global.codec->fourcc)); |
2573 | 2701 |
2574 FOREACH_STREAM(stats_close(&stream->stats, global.passes - 1)); | 2702 FOREACH_STREAM(stats_close(&stream->stats, global.passes - 1)); |
2575 | 2703 |
2576 if (global.pass) | 2704 if (global.pass) |
2577 break; | 2705 break; |
2578 } | 2706 } |
2579 | 2707 |
2580 if (global.show_q_hist_buckets) | 2708 if (global.show_q_hist_buckets) |
2581 FOREACH_STREAM(show_q_histogram(stream->counts, | 2709 FOREACH_STREAM(show_q_histogram(stream->counts, |
(...skipping 17 matching lines...) Expand all Loading... |
2599 } else { | 2727 } else { |
2600 fprintf(f, "No mismatch detected in recon buffers\n"); | 2728 fprintf(f, "No mismatch detected in recon buffers\n"); |
2601 } | 2729 } |
2602 fclose(f); | 2730 fclose(f); |
2603 }); | 2731 }); |
2604 #endif | 2732 #endif |
2605 | 2733 |
2606 vpx_img_free(&raw); | 2734 vpx_img_free(&raw); |
2607 free(argv); | 2735 free(argv); |
2608 free(streams); | 2736 free(streams); |
2609 return EXIT_SUCCESS; | 2737 return res ? EXIT_FAILURE : EXIT_SUCCESS; |
2610 } | 2738 } |
OLD | NEW |