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 |
(...skipping 24 matching lines...) Expand all Loading... |
35 #if CONFIG_VP8_DECODER || CONFIG_VP9_DECODER | 35 #if CONFIG_VP8_DECODER || CONFIG_VP9_DECODER |
36 #include "vpx/vp8dx.h" | 36 #include "vpx/vp8dx.h" |
37 #endif | 37 #endif |
38 | 38 |
39 #include "vpx/vpx_integer.h" | 39 #include "vpx/vpx_integer.h" |
40 #include "vpx_ports/mem_ops.h" | 40 #include "vpx_ports/mem_ops.h" |
41 #include "vpx_ports/vpx_timer.h" | 41 #include "vpx_ports/vpx_timer.h" |
42 #include "./rate_hist.h" | 42 #include "./rate_hist.h" |
43 #include "./vpxstats.h" | 43 #include "./vpxstats.h" |
44 #include "./warnings.h" | 44 #include "./warnings.h" |
| 45 #if CONFIG_WEBM_IO |
45 #include "./webmenc.h" | 46 #include "./webmenc.h" |
| 47 #endif |
46 #include "./y4minput.h" | 48 #include "./y4minput.h" |
47 | 49 |
48 /* Swallow warnings about unused results of fread/fwrite */ | 50 /* Swallow warnings about unused results of fread/fwrite */ |
49 static size_t wrap_fread(void *ptr, size_t size, size_t nmemb, | 51 static size_t wrap_fread(void *ptr, size_t size, size_t nmemb, |
50 FILE *stream) { | 52 FILE *stream) { |
51 return fread(ptr, size, nmemb, stream); | 53 return fread(ptr, size, nmemb, stream); |
52 } | 54 } |
53 #define fread wrap_fread | 55 #define fread wrap_fread |
54 | 56 |
55 static size_t wrap_fwrite(const void *ptr, size_t size, size_t nmemb, | 57 static size_t wrap_fwrite(const void *ptr, size_t size, size_t nmemb, |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 static const arg_def_t usage = ARG_DEF("u", "usage", 1, | 202 static const arg_def_t usage = ARG_DEF("u", "usage", 1, |
201 "Usage profile number to use")
; | 203 "Usage profile number to use")
; |
202 static const arg_def_t threads = ARG_DEF("t", "threads", 1, | 204 static const arg_def_t threads = ARG_DEF("t", "threads", 1, |
203 "Max number of threads to use"
); | 205 "Max number of threads to use"
); |
204 static const arg_def_t profile = ARG_DEF(NULL, "profile", 1, | 206 static const arg_def_t profile = ARG_DEF(NULL, "profile", 1, |
205 "Bitstream profile number to u
se"); | 207 "Bitstream profile number to u
se"); |
206 static const arg_def_t width = ARG_DEF("w", "width", 1, | 208 static const arg_def_t width = ARG_DEF("w", "width", 1, |
207 "Frame width"); | 209 "Frame width"); |
208 static const arg_def_t height = ARG_DEF("h", "height", 1, | 210 static const arg_def_t height = ARG_DEF("h", "height", 1, |
209 "Frame height"); | 211 "Frame height"); |
| 212 #if CONFIG_WEBM_IO |
210 static const struct arg_enum_list stereo_mode_enum[] = { | 213 static const struct arg_enum_list stereo_mode_enum[] = { |
211 {"mono", STEREO_FORMAT_MONO}, | 214 {"mono", STEREO_FORMAT_MONO}, |
212 {"left-right", STEREO_FORMAT_LEFT_RIGHT}, | 215 {"left-right", STEREO_FORMAT_LEFT_RIGHT}, |
213 {"bottom-top", STEREO_FORMAT_BOTTOM_TOP}, | 216 {"bottom-top", STEREO_FORMAT_BOTTOM_TOP}, |
214 {"top-bottom", STEREO_FORMAT_TOP_BOTTOM}, | 217 {"top-bottom", STEREO_FORMAT_TOP_BOTTOM}, |
215 {"right-left", STEREO_FORMAT_RIGHT_LEFT}, | 218 {"right-left", STEREO_FORMAT_RIGHT_LEFT}, |
216 {NULL, 0} | 219 {NULL, 0} |
217 }; | 220 }; |
218 static const arg_def_t stereo_mode = ARG_DEF_ENUM(NULL, "stereo-mode", 1, | 221 static const arg_def_t stereo_mode = ARG_DEF_ENUM(NULL, "stereo-mode", 1, |
219 "Stereo 3D video format",
stereo_mode_enum); | 222 "Stereo 3D video format",
stereo_mode_enum); |
| 223 #endif |
220 static const arg_def_t timebase = ARG_DEF(NULL, "timebase", 1, | 224 static const arg_def_t timebase = ARG_DEF(NULL, "timebase", 1, |
221 "Output timestamp precision (f
ractional seconds)"); | 225 "Output timestamp precision (f
ractional seconds)"); |
222 static const arg_def_t error_resilient = ARG_DEF(NULL, "error-resilient", 1, | 226 static const arg_def_t error_resilient = ARG_DEF(NULL, "error-resilient", 1, |
223 "Enable error resiliency featu
res"); | 227 "Enable error resiliency featu
res"); |
224 static const arg_def_t lag_in_frames = ARG_DEF(NULL, "lag-in-frames", 1, | 228 static const arg_def_t lag_in_frames = ARG_DEF(NULL, "lag-in-frames", 1, |
225 "Max number of frames to lag")
; | 229 "Max number of frames to lag")
; |
226 | 230 |
227 static const arg_def_t *global_args[] = { | 231 static const arg_def_t *global_args[] = { |
228 &use_yv12, &use_i420, &usage, &threads, &profile, | 232 &use_yv12, &use_i420, &usage, &threads, &profile, |
229 &width, &height, &stereo_mode, &timebase, &framerate, | 233 &width, &height, |
| 234 #if CONFIG_WEBM_IO |
| 235 &stereo_mode, |
| 236 #endif |
| 237 &timebase, &framerate, |
230 &error_resilient, | 238 &error_resilient, |
231 &lag_in_frames, NULL | 239 &lag_in_frames, NULL |
232 }; | 240 }; |
233 | 241 |
234 static const arg_def_t dropframe_thresh = ARG_DEF(NULL, "drop-frame", 1, | 242 static const arg_def_t dropframe_thresh = ARG_DEF(NULL, "drop-frame", 1, |
235 "Temporal resampling thresho
ld (buf %)"); | 243 "Temporal resampling thresho
ld (buf %)"); |
236 static const arg_def_t resize_allowed = ARG_DEF(NULL, "resize-allowed", 1, | 244 static const arg_def_t resize_allowed = ARG_DEF(NULL, "resize-allowed", 1, |
237 "Spatial resampling enabled
(bool)"); | 245 "Spatial resampling enabled
(bool)"); |
238 static const arg_def_t resize_width = ARG_DEF(NULL, "resize-width", 1, | 246 static const arg_def_t resize_width = ARG_DEF(NULL, "resize-width", 1, |
239 "Width of encoded frame"); | 247 "Width of encoded frame"); |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 #define MAX(x,y) ((x)>(y)?(x):(y)) | 555 #define MAX(x,y) ((x)>(y)?(x):(y)) |
548 #if CONFIG_VP8_ENCODER && !CONFIG_VP9_ENCODER | 556 #if CONFIG_VP8_ENCODER && !CONFIG_VP9_ENCODER |
549 #define ARG_CTRL_CNT_MAX NELEMENTS(vp8_arg_ctrl_map) | 557 #define ARG_CTRL_CNT_MAX NELEMENTS(vp8_arg_ctrl_map) |
550 #elif !CONFIG_VP8_ENCODER && CONFIG_VP9_ENCODER | 558 #elif !CONFIG_VP8_ENCODER && CONFIG_VP9_ENCODER |
551 #define ARG_CTRL_CNT_MAX NELEMENTS(vp9_arg_ctrl_map) | 559 #define ARG_CTRL_CNT_MAX NELEMENTS(vp9_arg_ctrl_map) |
552 #else | 560 #else |
553 #define ARG_CTRL_CNT_MAX MAX(NELEMENTS(vp8_arg_ctrl_map), \ | 561 #define ARG_CTRL_CNT_MAX MAX(NELEMENTS(vp8_arg_ctrl_map), \ |
554 NELEMENTS(vp9_arg_ctrl_map)) | 562 NELEMENTS(vp9_arg_ctrl_map)) |
555 #endif | 563 #endif |
556 | 564 |
| 565 #if !CONFIG_WEBM_IO |
| 566 typedef int stereo_format_t; |
| 567 struct EbmlGlobal { int debug; }; |
| 568 #endif |
| 569 |
557 /* Per-stream configuration */ | 570 /* Per-stream configuration */ |
558 struct stream_config { | 571 struct stream_config { |
559 struct vpx_codec_enc_cfg cfg; | 572 struct vpx_codec_enc_cfg cfg; |
560 const char *out_fn; | 573 const char *out_fn; |
561 const char *stats_fn; | 574 const char *stats_fn; |
562 stereo_format_t stereo_fmt; | 575 stereo_format_t stereo_fmt; |
563 int arg_ctrls[ARG_CTRL_CNT_MAX][2]; | 576 int arg_ctrls[ARG_CTRL_CNT_MAX][2]; |
564 int arg_ctrl_cnt; | 577 int arg_ctrl_cnt; |
565 int write_webm; | 578 int write_webm; |
566 int have_kf_max_dist; | 579 int have_kf_max_dist; |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 */ | 798 */ |
786 stream->config.cfg.g_timebase.den = 1000; | 799 stream->config.cfg.g_timebase.den = 1000; |
787 | 800 |
788 /* Never use the library's default resolution, require it be parsed | 801 /* Never use the library's default resolution, require it be parsed |
789 * from the file or set on the command line. | 802 * from the file or set on the command line. |
790 */ | 803 */ |
791 stream->config.cfg.g_w = 0; | 804 stream->config.cfg.g_w = 0; |
792 stream->config.cfg.g_h = 0; | 805 stream->config.cfg.g_h = 0; |
793 | 806 |
794 /* Initialize remaining stream parameters */ | 807 /* Initialize remaining stream parameters */ |
795 stream->config.stereo_fmt = STEREO_FORMAT_MONO; | |
796 stream->config.write_webm = 1; | 808 stream->config.write_webm = 1; |
797 #if CONFIG_WEBM_IO | 809 #if CONFIG_WEBM_IO |
| 810 stream->config.stereo_fmt = STEREO_FORMAT_MONO; |
798 stream->ebml.last_pts_ns = -1; | 811 stream->ebml.last_pts_ns = -1; |
799 stream->ebml.writer = NULL; | 812 stream->ebml.writer = NULL; |
800 stream->ebml.segment = NULL; | 813 stream->ebml.segment = NULL; |
801 #endif | 814 #endif |
802 | 815 |
803 /* Allows removal of the application version from the EBML tags */ | 816 /* Allows removal of the application version from the EBML tags */ |
804 stream->ebml.debug = global->debug; | 817 stream->ebml.debug = global->debug; |
805 | 818 |
806 /* Default lag_in_frames is 0 in realtime mode */ | 819 /* Default lag_in_frames is 0 in realtime mode */ |
807 if (global->deadline == VPX_DL_REALTIME) | 820 if (global->deadline == VPX_DL_REALTIME) |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
862 } else if (arg_match(&arg, &use_ivf, argi)) { | 875 } else if (arg_match(&arg, &use_ivf, argi)) { |
863 config->write_webm = 0; | 876 config->write_webm = 0; |
864 } else if (arg_match(&arg, &threads, argi)) { | 877 } else if (arg_match(&arg, &threads, argi)) { |
865 config->cfg.g_threads = arg_parse_uint(&arg); | 878 config->cfg.g_threads = arg_parse_uint(&arg); |
866 } else if (arg_match(&arg, &profile, argi)) { | 879 } else if (arg_match(&arg, &profile, argi)) { |
867 config->cfg.g_profile = arg_parse_uint(&arg); | 880 config->cfg.g_profile = arg_parse_uint(&arg); |
868 } else if (arg_match(&arg, &width, argi)) { | 881 } else if (arg_match(&arg, &width, argi)) { |
869 config->cfg.g_w = arg_parse_uint(&arg); | 882 config->cfg.g_w = arg_parse_uint(&arg); |
870 } else if (arg_match(&arg, &height, argi)) { | 883 } else if (arg_match(&arg, &height, argi)) { |
871 config->cfg.g_h = arg_parse_uint(&arg); | 884 config->cfg.g_h = arg_parse_uint(&arg); |
| 885 #if CONFIG_WEBM_IO |
872 } else if (arg_match(&arg, &stereo_mode, argi)) { | 886 } else if (arg_match(&arg, &stereo_mode, argi)) { |
873 config->stereo_fmt = arg_parse_enum_or_int(&arg); | 887 config->stereo_fmt = arg_parse_enum_or_int(&arg); |
| 888 #endif |
874 } else if (arg_match(&arg, &timebase, argi)) { | 889 } else if (arg_match(&arg, &timebase, argi)) { |
875 config->cfg.g_timebase = arg_parse_rational(&arg); | 890 config->cfg.g_timebase = arg_parse_rational(&arg); |
876 validate_positive_rational(arg.name, &config->cfg.g_timebase); | 891 validate_positive_rational(arg.name, &config->cfg.g_timebase); |
877 } else if (arg_match(&arg, &error_resilient, argi)) { | 892 } else if (arg_match(&arg, &error_resilient, argi)) { |
878 config->cfg.g_error_resilient = arg_parse_uint(&arg); | 893 config->cfg.g_error_resilient = arg_parse_uint(&arg); |
879 } else if (arg_match(&arg, &lag_in_frames, argi)) { | 894 } else if (arg_match(&arg, &lag_in_frames, argi)) { |
880 config->cfg.g_lag_in_frames = arg_parse_uint(&arg); | 895 config->cfg.g_lag_in_frames = arg_parse_uint(&arg); |
881 if (global->deadline == VPX_DL_REALTIME && | 896 if (global->deadline == VPX_DL_REALTIME && |
882 config->cfg.g_lag_in_frames != 0) { | 897 config->cfg.g_lag_in_frames != 0) { |
883 warn("non-zero %s option ignored in realtime mode.\n", arg.name); | 898 warn("non-zero %s option ignored in realtime mode.\n", arg.name); |
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1760 } | 1775 } |
1761 fclose(f); | 1776 fclose(f); |
1762 }); | 1777 }); |
1763 #endif | 1778 #endif |
1764 | 1779 |
1765 vpx_img_free(&raw); | 1780 vpx_img_free(&raw); |
1766 free(argv); | 1781 free(argv); |
1767 free(streams); | 1782 free(streams); |
1768 return res ? EXIT_FAILURE : EXIT_SUCCESS; | 1783 return res ? EXIT_FAILURE : EXIT_SUCCESS; |
1769 } | 1784 } |
OLD | NEW |