| 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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 static const arg_def_t q_hist_n = ARG_DEF(NULL, "q-hist", 1, | 224 static const arg_def_t q_hist_n = ARG_DEF(NULL, "q-hist", 1, |
| 225 "Show quantizer histogram (n-b
uckets)"); | 225 "Show quantizer histogram (n-b
uckets)"); |
| 226 static const arg_def_t rate_hist_n = ARG_DEF(NULL, "rate-hist", 1, | 226 static const arg_def_t rate_hist_n = ARG_DEF(NULL, "rate-hist", 1, |
| 227 "Show rate histogram (n-buc
kets)"); | 227 "Show rate histogram (n-buc
kets)"); |
| 228 static const arg_def_t disable_warnings = | 228 static const arg_def_t disable_warnings = |
| 229 ARG_DEF(NULL, "disable-warnings", 0, | 229 ARG_DEF(NULL, "disable-warnings", 0, |
| 230 "Disable warnings about potentially incorrect encode settings."); | 230 "Disable warnings about potentially incorrect encode settings."); |
| 231 static const arg_def_t disable_warning_prompt = | 231 static const arg_def_t disable_warning_prompt = |
| 232 ARG_DEF("y", "disable-warning-prompt", 0, | 232 ARG_DEF("y", "disable-warning-prompt", 0, |
| 233 "Display warnings, but do not prompt user to continue."); | 233 "Display warnings, but do not prompt user to continue."); |
| 234 static const arg_def_t experimental_bitstream = |
| 235 ARG_DEF(NULL, "experimental-bitstream", 0, |
| 236 "Allow experimental bitstream features."); |
| 237 |
| 234 | 238 |
| 235 static const arg_def_t *main_args[] = { | 239 static const arg_def_t *main_args[] = { |
| 236 &debugmode, | 240 &debugmode, |
| 237 &outputfile, &codecarg, &passes, &pass_arg, &fpf_name, &limit, &skip, | 241 &outputfile, &codecarg, &passes, &pass_arg, &fpf_name, &limit, &skip, |
| 238 &deadline, &best_dl, &good_dl, &rt_dl, | 242 &deadline, &best_dl, &good_dl, &rt_dl, |
| 239 &quietarg, &verbosearg, &psnrarg, &use_ivf, &out_part, &q_hist_n, | 243 &quietarg, &verbosearg, &psnrarg, &use_ivf, &out_part, &q_hist_n, |
| 240 &rate_hist_n, &disable_warnings, &disable_warning_prompt, | 244 &rate_hist_n, &disable_warnings, &disable_warning_prompt, |
| 241 NULL | 245 NULL |
| 242 }; | 246 }; |
| 243 | 247 |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 else if (arg_match(&arg, &debugmode, argi)) | 710 else if (arg_match(&arg, &debugmode, argi)) |
| 707 global->debug = 1; | 711 global->debug = 1; |
| 708 else if (arg_match(&arg, &q_hist_n, argi)) | 712 else if (arg_match(&arg, &q_hist_n, argi)) |
| 709 global->show_q_hist_buckets = arg_parse_uint(&arg); | 713 global->show_q_hist_buckets = arg_parse_uint(&arg); |
| 710 else if (arg_match(&arg, &rate_hist_n, argi)) | 714 else if (arg_match(&arg, &rate_hist_n, argi)) |
| 711 global->show_rate_hist_buckets = arg_parse_uint(&arg); | 715 global->show_rate_hist_buckets = arg_parse_uint(&arg); |
| 712 else if (arg_match(&arg, &disable_warnings, argi)) | 716 else if (arg_match(&arg, &disable_warnings, argi)) |
| 713 global->disable_warnings = 1; | 717 global->disable_warnings = 1; |
| 714 else if (arg_match(&arg, &disable_warning_prompt, argi)) | 718 else if (arg_match(&arg, &disable_warning_prompt, argi)) |
| 715 global->disable_warning_prompt = 1; | 719 global->disable_warning_prompt = 1; |
| 720 else if (arg_match(&arg, &experimental_bitstream, argi)) |
| 721 global->experimental_bitstream = 1; |
| 716 else | 722 else |
| 717 argj++; | 723 argj++; |
| 718 } | 724 } |
| 719 | 725 |
| 720 /* Validate global config */ | |
| 721 if (global->passes == 0) { | |
| 722 #if CONFIG_VP9_ENCODER | |
| 723 // Make default VP9 passes = 2 until there is a better quality 1-pass | |
| 724 // encoder | |
| 725 global->passes = strcmp(global->codec->name, "vp9") == 0 ? 2 : 1; | |
| 726 #else | |
| 727 global->passes = 1; | |
| 728 #endif | |
| 729 } | |
| 730 | |
| 731 if (global->pass) { | 726 if (global->pass) { |
| 732 /* DWIM: Assume the user meant passes=2 if pass=2 is specified */ | 727 /* DWIM: Assume the user meant passes=2 if pass=2 is specified */ |
| 733 if (global->pass > global->passes) { | 728 if (global->pass > global->passes) { |
| 734 warn("Assuming --pass=%d implies --passes=%d\n", | 729 warn("Assuming --pass=%d implies --passes=%d\n", |
| 735 global->pass, global->pass); | 730 global->pass, global->pass); |
| 736 global->passes = global->pass; | 731 global->passes = global->pass; |
| 737 } | 732 } |
| 738 } | 733 } |
| 734 /* Validate global config */ |
| 735 if (global->passes == 0) { |
| 736 #if CONFIG_VP9_ENCODER |
| 737 // Make default VP9 passes = 2 until there is a better quality 1-pass |
| 738 // encoder |
| 739 global->passes = (strcmp(global->codec->name, "vp9") == 0 && |
| 740 global->deadline != VPX_DL_REALTIME) ? 2 : 1; |
| 741 #else |
| 742 global->passes = 1; |
| 743 #endif |
| 744 } |
| 745 |
| 746 if (global->deadline == VPX_DL_REALTIME && |
| 747 global->passes > 1) { |
| 748 warn("Enforcing one-pass encoding in realtime mode\n"); |
| 749 global->passes = 1; |
| 750 } |
| 739 } | 751 } |
| 740 | 752 |
| 741 | 753 |
| 742 void open_input_file(struct VpxInputContext *input) { | 754 void open_input_file(struct VpxInputContext *input) { |
| 743 /* Parse certain options from the input file, if possible */ | 755 /* Parse certain options from the input file, if possible */ |
| 744 input->file = strcmp(input->filename, "-") | 756 input->file = strcmp(input->filename, "-") |
| 745 ? fopen(input->filename, "rb") : set_binary_mode(stdin); | 757 ? fopen(input->filename, "rb") : set_binary_mode(stdin); |
| 746 | 758 |
| 747 if (!input->file) | 759 if (!input->file) |
| 748 fatal("Failed to open input file"); | 760 fatal("Failed to open input file"); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 stream->config.cfg.g_w = 0; | 831 stream->config.cfg.g_w = 0; |
| 820 stream->config.cfg.g_h = 0; | 832 stream->config.cfg.g_h = 0; |
| 821 | 833 |
| 822 /* Initialize remaining stream parameters */ | 834 /* Initialize remaining stream parameters */ |
| 823 stream->config.stereo_fmt = STEREO_FORMAT_MONO; | 835 stream->config.stereo_fmt = STEREO_FORMAT_MONO; |
| 824 stream->config.write_webm = 1; | 836 stream->config.write_webm = 1; |
| 825 stream->ebml.last_pts_ms = -1; | 837 stream->ebml.last_pts_ms = -1; |
| 826 | 838 |
| 827 /* Allows removal of the application version from the EBML tags */ | 839 /* Allows removal of the application version from the EBML tags */ |
| 828 stream->ebml.debug = global->debug; | 840 stream->ebml.debug = global->debug; |
| 841 |
| 842 /* Default lag_in_frames is 0 in realtime mode */ |
| 843 if (global->deadline == VPX_DL_REALTIME) |
| 844 stream->config.cfg.g_lag_in_frames = 0; |
| 829 } | 845 } |
| 830 | 846 |
| 831 /* Output files must be specified for each stream */ | 847 /* Output files must be specified for each stream */ |
| 832 stream->config.out_fn = NULL; | 848 stream->config.out_fn = NULL; |
| 833 | 849 |
| 834 stream->next = NULL; | 850 stream->next = NULL; |
| 835 return stream; | 851 return stream; |
| 836 } | 852 } |
| 837 | 853 |
| 838 | 854 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 867 * shifting arguments but not consuming them. | 883 * shifting arguments but not consuming them. |
| 868 */ | 884 */ |
| 869 if (eos_mark_found) { | 885 if (eos_mark_found) { |
| 870 argj++; | 886 argj++; |
| 871 continue; | 887 continue; |
| 872 } else if (!strcmp(*argj, "--")) { | 888 } else if (!strcmp(*argj, "--")) { |
| 873 eos_mark_found = 1; | 889 eos_mark_found = 1; |
| 874 continue; | 890 continue; |
| 875 } | 891 } |
| 876 | 892 |
| 877 if (0); | 893 if (0) { |
| 878 else if (arg_match(&arg, &outputfile, argi)) | 894 } else if (arg_match(&arg, &outputfile, argi)) { |
| 879 config->out_fn = arg.val; | 895 config->out_fn = arg.val; |
| 880 else if (arg_match(&arg, &fpf_name, argi)) | 896 } else if (arg_match(&arg, &fpf_name, argi)) { |
| 881 config->stats_fn = arg.val; | 897 config->stats_fn = arg.val; |
| 882 else if (arg_match(&arg, &use_ivf, argi)) | 898 } else if (arg_match(&arg, &use_ivf, argi)) { |
| 883 config->write_webm = 0; | 899 config->write_webm = 0; |
| 884 else if (arg_match(&arg, &threads, argi)) | 900 } else if (arg_match(&arg, &threads, argi)) { |
| 885 config->cfg.g_threads = arg_parse_uint(&arg); | 901 config->cfg.g_threads = arg_parse_uint(&arg); |
| 886 else if (arg_match(&arg, &profile, argi)) | 902 } else if (arg_match(&arg, &profile, argi)) { |
| 887 config->cfg.g_profile = arg_parse_uint(&arg); | 903 config->cfg.g_profile = arg_parse_uint(&arg); |
| 888 else if (arg_match(&arg, &width, argi)) | 904 } else if (arg_match(&arg, &width, argi)) { |
| 889 config->cfg.g_w = arg_parse_uint(&arg); | 905 config->cfg.g_w = arg_parse_uint(&arg); |
| 890 else if (arg_match(&arg, &height, argi)) | 906 } else if (arg_match(&arg, &height, argi)) { |
| 891 config->cfg.g_h = arg_parse_uint(&arg); | 907 config->cfg.g_h = arg_parse_uint(&arg); |
| 892 else if (arg_match(&arg, &stereo_mode, argi)) | 908 } else if (arg_match(&arg, &stereo_mode, argi)) { |
| 893 config->stereo_fmt = arg_parse_enum_or_int(&arg); | 909 config->stereo_fmt = arg_parse_enum_or_int(&arg); |
| 894 else if (arg_match(&arg, &timebase, argi)) { | 910 } else if (arg_match(&arg, &timebase, argi)) { |
| 895 config->cfg.g_timebase = arg_parse_rational(&arg); | 911 config->cfg.g_timebase = arg_parse_rational(&arg); |
| 896 validate_positive_rational(arg.name, &config->cfg.g_timebase); | 912 validate_positive_rational(arg.name, &config->cfg.g_timebase); |
| 897 } else if (arg_match(&arg, &error_resilient, argi)) | 913 } else if (arg_match(&arg, &error_resilient, argi)) { |
| 898 config->cfg.g_error_resilient = arg_parse_uint(&arg); | 914 config->cfg.g_error_resilient = arg_parse_uint(&arg); |
| 899 else if (arg_match(&arg, &lag_in_frames, argi)) | 915 } else if (arg_match(&arg, &lag_in_frames, argi)) { |
| 900 config->cfg.g_lag_in_frames = arg_parse_uint(&arg); | 916 config->cfg.g_lag_in_frames = arg_parse_uint(&arg); |
| 901 else if (arg_match(&arg, &dropframe_thresh, argi)) | 917 if (global->deadline == VPX_DL_REALTIME && |
| 918 config->cfg.g_lag_in_frames != 0) { |
| 919 warn("non-zero %s option ignored in realtime mode.\n", arg.name); |
| 920 config->cfg.g_lag_in_frames = 0; |
| 921 } |
| 922 } else if (arg_match(&arg, &dropframe_thresh, argi)) { |
| 902 config->cfg.rc_dropframe_thresh = arg_parse_uint(&arg); | 923 config->cfg.rc_dropframe_thresh = arg_parse_uint(&arg); |
| 903 else if (arg_match(&arg, &resize_allowed, argi)) | 924 } else if (arg_match(&arg, &resize_allowed, argi)) { |
| 904 config->cfg.rc_resize_allowed = arg_parse_uint(&arg); | 925 config->cfg.rc_resize_allowed = arg_parse_uint(&arg); |
| 905 else if (arg_match(&arg, &resize_up_thresh, argi)) | 926 } else if (arg_match(&arg, &resize_up_thresh, argi)) { |
| 906 config->cfg.rc_resize_up_thresh = arg_parse_uint(&arg); | 927 config->cfg.rc_resize_up_thresh = arg_parse_uint(&arg); |
| 907 else if (arg_match(&arg, &resize_down_thresh, argi)) | 928 } else if (arg_match(&arg, &resize_down_thresh, argi)) { |
| 908 config->cfg.rc_resize_down_thresh = arg_parse_uint(&arg); | 929 config->cfg.rc_resize_down_thresh = arg_parse_uint(&arg); |
| 909 else if (arg_match(&arg, &end_usage, argi)) | 930 } else if (arg_match(&arg, &end_usage, argi)) { |
| 910 config->cfg.rc_end_usage = arg_parse_enum_or_int(&arg); | 931 config->cfg.rc_end_usage = arg_parse_enum_or_int(&arg); |
| 911 else if (arg_match(&arg, &target_bitrate, argi)) | 932 } else if (arg_match(&arg, &target_bitrate, argi)) { |
| 912 config->cfg.rc_target_bitrate = arg_parse_uint(&arg); | 933 config->cfg.rc_target_bitrate = arg_parse_uint(&arg); |
| 913 else if (arg_match(&arg, &min_quantizer, argi)) | 934 } else if (arg_match(&arg, &min_quantizer, argi)) { |
| 914 config->cfg.rc_min_quantizer = arg_parse_uint(&arg); | 935 config->cfg.rc_min_quantizer = arg_parse_uint(&arg); |
| 915 else if (arg_match(&arg, &max_quantizer, argi)) | 936 } else if (arg_match(&arg, &max_quantizer, argi)) { |
| 916 config->cfg.rc_max_quantizer = arg_parse_uint(&arg); | 937 config->cfg.rc_max_quantizer = arg_parse_uint(&arg); |
| 917 else if (arg_match(&arg, &undershoot_pct, argi)) | 938 } else if (arg_match(&arg, &undershoot_pct, argi)) { |
| 918 config->cfg.rc_undershoot_pct = arg_parse_uint(&arg); | 939 config->cfg.rc_undershoot_pct = arg_parse_uint(&arg); |
| 919 else if (arg_match(&arg, &overshoot_pct, argi)) | 940 } else if (arg_match(&arg, &overshoot_pct, argi)) { |
| 920 config->cfg.rc_overshoot_pct = arg_parse_uint(&arg); | 941 config->cfg.rc_overshoot_pct = arg_parse_uint(&arg); |
| 921 else if (arg_match(&arg, &buf_sz, argi)) | 942 } else if (arg_match(&arg, &buf_sz, argi)) { |
| 922 config->cfg.rc_buf_sz = arg_parse_uint(&arg); | 943 config->cfg.rc_buf_sz = arg_parse_uint(&arg); |
| 923 else if (arg_match(&arg, &buf_initial_sz, argi)) | 944 } else if (arg_match(&arg, &buf_initial_sz, argi)) { |
| 924 config->cfg.rc_buf_initial_sz = arg_parse_uint(&arg); | 945 config->cfg.rc_buf_initial_sz = arg_parse_uint(&arg); |
| 925 else if (arg_match(&arg, &buf_optimal_sz, argi)) | 946 } else if (arg_match(&arg, &buf_optimal_sz, argi)) { |
| 926 config->cfg.rc_buf_optimal_sz = arg_parse_uint(&arg); | 947 config->cfg.rc_buf_optimal_sz = arg_parse_uint(&arg); |
| 927 else if (arg_match(&arg, &bias_pct, argi)) { | 948 } else if (arg_match(&arg, &bias_pct, argi)) { |
| 928 config->cfg.rc_2pass_vbr_bias_pct = arg_parse_uint(&arg); | 949 config->cfg.rc_2pass_vbr_bias_pct = arg_parse_uint(&arg); |
| 929 | |
| 930 if (global->passes < 2) | 950 if (global->passes < 2) |
| 931 warn("option %s ignored in one-pass mode.\n", arg.name); | 951 warn("option %s ignored in one-pass mode.\n", arg.name); |
| 932 } else if (arg_match(&arg, &minsection_pct, argi)) { | 952 } else if (arg_match(&arg, &minsection_pct, argi)) { |
| 933 config->cfg.rc_2pass_vbr_minsection_pct = arg_parse_uint(&arg); | 953 config->cfg.rc_2pass_vbr_minsection_pct = arg_parse_uint(&arg); |
| 934 | 954 |
| 935 if (global->passes < 2) | 955 if (global->passes < 2) |
| 936 warn("option %s ignored in one-pass mode.\n", arg.name); | 956 warn("option %s ignored in one-pass mode.\n", arg.name); |
| 937 } else if (arg_match(&arg, &maxsection_pct, argi)) { | 957 } else if (arg_match(&arg, &maxsection_pct, argi)) { |
| 938 config->cfg.rc_2pass_vbr_maxsection_pct = arg_parse_uint(&arg); | 958 config->cfg.rc_2pass_vbr_maxsection_pct = arg_parse_uint(&arg); |
| 939 | 959 |
| 940 if (global->passes < 2) | 960 if (global->passes < 2) |
| 941 warn("option %s ignored in one-pass mode.\n", arg.name); | 961 warn("option %s ignored in one-pass mode.\n", arg.name); |
| 942 } else if (arg_match(&arg, &kf_min_dist, argi)) | 962 } else if (arg_match(&arg, &kf_min_dist, argi)) { |
| 943 config->cfg.kf_min_dist = arg_parse_uint(&arg); | 963 config->cfg.kf_min_dist = arg_parse_uint(&arg); |
| 944 else if (arg_match(&arg, &kf_max_dist, argi)) { | 964 } else if (arg_match(&arg, &kf_max_dist, argi)) { |
| 945 config->cfg.kf_max_dist = arg_parse_uint(&arg); | 965 config->cfg.kf_max_dist = arg_parse_uint(&arg); |
| 946 config->have_kf_max_dist = 1; | 966 config->have_kf_max_dist = 1; |
| 947 } else if (arg_match(&arg, &kf_disabled, argi)) | 967 } else if (arg_match(&arg, &kf_disabled, argi)) { |
| 948 config->cfg.kf_mode = VPX_KF_DISABLED; | 968 config->cfg.kf_mode = VPX_KF_DISABLED; |
| 949 else { | 969 } else { |
| 950 int i, match = 0; | 970 int i, match = 0; |
| 951 | |
| 952 for (i = 0; ctrl_args[i]; i++) { | 971 for (i = 0; ctrl_args[i]; i++) { |
| 953 if (arg_match(&arg, ctrl_args[i], argi)) { | 972 if (arg_match(&arg, ctrl_args[i], argi)) { |
| 954 int j; | 973 int j; |
| 955 match = 1; | 974 match = 1; |
| 956 | 975 |
| 957 /* Point either to the next free element or the first | 976 /* Point either to the next free element or the first |
| 958 * instance of this control. | 977 * instance of this control. |
| 959 */ | 978 */ |
| 960 for (j = 0; j < config->arg_ctrl_cnt; j++) | 979 for (j = 0; j < config->arg_ctrl_cnt; j++) |
| 961 if (config->arg_ctrls[j][0] == ctrl_args_map[i]) | 980 if (config->arg_ctrls[j][0] == ctrl_args_map[i]) |
| 962 break; | 981 break; |
| 963 | 982 |
| 964 /* Update/insert */ | 983 /* Update/insert */ |
| 965 assert(j < ARG_CTRL_CNT_MAX); | 984 assert(j < ARG_CTRL_CNT_MAX); |
| 966 if (j < ARG_CTRL_CNT_MAX) { | 985 if (j < ARG_CTRL_CNT_MAX) { |
| 967 config->arg_ctrls[j][0] = ctrl_args_map[i]; | 986 config->arg_ctrls[j][0] = ctrl_args_map[i]; |
| 968 config->arg_ctrls[j][1] = arg_parse_enum_or_int(&arg); | 987 config->arg_ctrls[j][1] = arg_parse_enum_or_int(&arg); |
| 969 if (j == config->arg_ctrl_cnt) | 988 if (j == config->arg_ctrl_cnt) |
| 970 config->arg_ctrl_cnt++; | 989 config->arg_ctrl_cnt++; |
| 971 } | 990 } |
| 972 | 991 |
| 973 } | 992 } |
| 974 } | 993 } |
| 975 | |
| 976 if (!match) | 994 if (!match) |
| 977 argj++; | 995 argj++; |
| 978 } | 996 } |
| 979 } | 997 } |
| 980 | |
| 981 return eos_mark_found; | 998 return eos_mark_found; |
| 982 } | 999 } |
| 983 | 1000 |
| 984 | 1001 |
| 985 #define FOREACH_STREAM(func) \ | 1002 #define FOREACH_STREAM(func) \ |
| 986 do { \ | 1003 do { \ |
| 987 struct stream_state *stream; \ | 1004 struct stream_state *stream; \ |
| 988 for (stream = streams; stream; stream = stream->next) { \ | 1005 for (stream = streams; stream; stream = stream->next) { \ |
| 989 func; \ | 1006 func; \ |
| 990 } \ | 1007 } \ |
| 991 } while (0) | 1008 } while (0) |
| 992 | 1009 |
| 993 | 1010 |
| 994 static void validate_stream_config(struct stream_state *stream) { | 1011 static void validate_stream_config(const struct stream_state *stream, |
| 995 struct stream_state *streami; | 1012 const struct VpxEncoderConfig *global) { |
| 1013 const struct stream_state *streami; |
| 996 | 1014 |
| 997 if (!stream->config.cfg.g_w || !stream->config.cfg.g_h) | 1015 if (!stream->config.cfg.g_w || !stream->config.cfg.g_h) |
| 998 fatal("Stream %d: Specify stream dimensions with --width (-w) " | 1016 fatal("Stream %d: Specify stream dimensions with --width (-w) " |
| 999 " and --height (-h)", stream->index); | 1017 " and --height (-h)", stream->index); |
| 1000 | 1018 |
| 1019 if (stream->config.cfg.g_profile != 0 && !global->experimental_bitstream) { |
| 1020 fatal("Stream %d: profile %d is experimental and requires the --%s flag", |
| 1021 stream->index, stream->config.cfg.g_profile, |
| 1022 experimental_bitstream.long_name); |
| 1023 } |
| 1024 |
| 1001 for (streami = stream; streami; streami = streami->next) { | 1025 for (streami = stream; streami; streami = streami->next) { |
| 1002 /* All streams require output files */ | 1026 /* All streams require output files */ |
| 1003 if (!streami->config.out_fn) | 1027 if (!streami->config.out_fn) |
| 1004 fatal("Stream %d: Output file is required (specify with -o)", | 1028 fatal("Stream %d: Output file is required (specify with -o)", |
| 1005 streami->index); | 1029 streami->index); |
| 1006 | 1030 |
| 1007 /* Check for two streams outputting to the same file */ | 1031 /* Check for two streams outputting to the same file */ |
| 1008 if (streami != stream) { | 1032 if (streami != stream) { |
| 1009 const char *a = stream->config.out_fn; | 1033 const char *a = stream->config.out_fn; |
| 1010 const char *b = streami->config.out_fn; | 1034 const char *b = streami->config.out_fn; |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1368 | 1392 |
| 1369 | 1393 |
| 1370 static void show_psnr(struct stream_state *stream) { | 1394 static void show_psnr(struct stream_state *stream) { |
| 1371 int i; | 1395 int i; |
| 1372 double ovpsnr; | 1396 double ovpsnr; |
| 1373 | 1397 |
| 1374 if (!stream->psnr_count) | 1398 if (!stream->psnr_count) |
| 1375 return; | 1399 return; |
| 1376 | 1400 |
| 1377 fprintf(stderr, "Stream %d PSNR (Overall/Avg/Y/U/V)", stream->index); | 1401 fprintf(stderr, "Stream %d PSNR (Overall/Avg/Y/U/V)", stream->index); |
| 1378 ovpsnr = vp8_mse2psnr((double)stream->psnr_samples_total, 255.0, | 1402 ovpsnr = sse_to_psnr((double)stream->psnr_samples_total, 255.0, |
| 1379 (double)stream->psnr_sse_total); | 1403 (double)stream->psnr_sse_total); |
| 1380 fprintf(stderr, " %.3f", ovpsnr); | 1404 fprintf(stderr, " %.3f", ovpsnr); |
| 1381 | 1405 |
| 1382 for (i = 0; i < 4; i++) { | 1406 for (i = 0; i < 4; i++) { |
| 1383 fprintf(stderr, " %.3f", stream->psnr_totals[i] / stream->psnr_count); | 1407 fprintf(stderr, " %.3f", stream->psnr_totals[i] / stream->psnr_count); |
| 1384 } | 1408 } |
| 1385 fprintf(stderr, "\n"); | 1409 fprintf(stderr, "\n"); |
| 1386 } | 1410 } |
| 1387 | 1411 |
| 1388 | 1412 |
| 1389 static float usec_to_fps(uint64_t usec, unsigned int frames) { | 1413 static float usec_to_fps(uint64_t usec, unsigned int frames) { |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1522 | 1546 |
| 1523 FOREACH_STREAM(check_encoder_config(global.disable_warning_prompt, | 1547 FOREACH_STREAM(check_encoder_config(global.disable_warning_prompt, |
| 1524 &global, &stream->config.cfg);); | 1548 &global, &stream->config.cfg);); |
| 1525 | 1549 |
| 1526 /* Handle non-option arguments */ | 1550 /* Handle non-option arguments */ |
| 1527 input.filename = argv[0]; | 1551 input.filename = argv[0]; |
| 1528 | 1552 |
| 1529 if (!input.filename) | 1553 if (!input.filename) |
| 1530 usage_exit(); | 1554 usage_exit(); |
| 1531 | 1555 |
| 1532 #if CONFIG_NON420 | |
| 1533 /* Decide if other chroma subsamplings than 4:2:0 are supported */ | 1556 /* Decide if other chroma subsamplings than 4:2:0 are supported */ |
| 1534 if (global.codec->fourcc == VP9_FOURCC) | 1557 if (global.codec->fourcc == VP9_FOURCC) |
| 1535 input.only_i420 = 0; | 1558 input.only_i420 = 0; |
| 1536 #endif | |
| 1537 | 1559 |
| 1538 for (pass = global.pass ? global.pass - 1 : 0; pass < global.passes; pass++) { | 1560 for (pass = global.pass ? global.pass - 1 : 0; pass < global.passes; pass++) { |
| 1539 int frames_in = 0, seen_frames = 0; | 1561 int frames_in = 0, seen_frames = 0; |
| 1540 int64_t estimated_time_left = -1; | 1562 int64_t estimated_time_left = -1; |
| 1541 int64_t average_rate = -1; | 1563 int64_t average_rate = -1; |
| 1542 off_t lagged_count = 0; | 1564 off_t lagged_count = 0; |
| 1543 | 1565 |
| 1544 open_input_file(&input); | 1566 open_input_file(&input); |
| 1545 | 1567 |
| 1546 /* If the input file doesn't specify its w/h (raw files), try to get | 1568 /* If the input file doesn't specify its w/h (raw files), try to get |
| 1547 * the data from the first stream's configuration. | 1569 * the data from the first stream's configuration. |
| 1548 */ | 1570 */ |
| 1549 if (!input.width || !input.height) | 1571 if (!input.width || !input.height) |
| 1550 FOREACH_STREAM( { | 1572 FOREACH_STREAM( { |
| 1551 if (stream->config.cfg.g_w && stream->config.cfg.g_h) { | 1573 if (stream->config.cfg.g_w && stream->config.cfg.g_h) { |
| 1552 input.width = stream->config.cfg.g_w; | 1574 input.width = stream->config.cfg.g_w; |
| 1553 input.height = stream->config.cfg.g_h; | 1575 input.height = stream->config.cfg.g_h; |
| 1554 break; | 1576 break; |
| 1555 } | 1577 } |
| 1556 }); | 1578 }); |
| 1557 | 1579 |
| 1558 /* Update stream configurations from the input file's parameters */ | 1580 /* Update stream configurations from the input file's parameters */ |
| 1559 if (!input.width || !input.height) | 1581 if (!input.width || !input.height) |
| 1560 fatal("Specify stream dimensions with --width (-w) " | 1582 fatal("Specify stream dimensions with --width (-w) " |
| 1561 " and --height (-h)"); | 1583 " and --height (-h)"); |
| 1562 FOREACH_STREAM(set_stream_dimensions(stream, input.width, input.height)); | 1584 FOREACH_STREAM(set_stream_dimensions(stream, input.width, input.height)); |
| 1563 FOREACH_STREAM(validate_stream_config(stream)); | 1585 FOREACH_STREAM(validate_stream_config(stream, &global)); |
| 1564 | 1586 |
| 1565 /* Ensure that --passes and --pass are consistent. If --pass is set and | 1587 /* Ensure that --passes and --pass are consistent. If --pass is set and |
| 1566 * --passes=2, ensure --fpf was set. | 1588 * --passes=2, ensure --fpf was set. |
| 1567 */ | 1589 */ |
| 1568 if (global.pass && global.passes == 2) | 1590 if (global.pass && global.passes == 2) |
| 1569 FOREACH_STREAM( { | 1591 FOREACH_STREAM( { |
| 1570 if (!stream->config.stats_fn) | 1592 if (!stream->config.stats_fn) |
| 1571 die("Stream %d: Must specify --fpf when --pass=%d" | 1593 die("Stream %d: Must specify --fpf when --pass=%d" |
| 1572 " and --passes=2\n", stream->index, global.pass); | 1594 " and --passes=2\n", stream->index, global.pass); |
| 1573 }); | 1595 }); |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1757 } | 1779 } |
| 1758 fclose(f); | 1780 fclose(f); |
| 1759 }); | 1781 }); |
| 1760 #endif | 1782 #endif |
| 1761 | 1783 |
| 1762 vpx_img_free(&raw); | 1784 vpx_img_free(&raw); |
| 1763 free(argv); | 1785 free(argv); |
| 1764 free(streams); | 1786 free(streams); |
| 1765 return res ? EXIT_FAILURE : EXIT_SUCCESS; | 1787 return res ? EXIT_FAILURE : EXIT_SUCCESS; |
| 1766 } | 1788 } |
| OLD | NEW |