| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 ARG_DEF(NULL, "fpf", 1, "First pass statistics file name"); | 54 ARG_DEF(NULL, "fpf", 1, "First pass statistics file name"); |
| 55 static const arg_def_t min_q_arg = | 55 static const arg_def_t min_q_arg = |
| 56 ARG_DEF(NULL, "min-q", 1, "Minimum quantizer"); | 56 ARG_DEF(NULL, "min-q", 1, "Minimum quantizer"); |
| 57 static const arg_def_t max_q_arg = | 57 static const arg_def_t max_q_arg = |
| 58 ARG_DEF(NULL, "max-q", 1, "Maximum quantizer"); | 58 ARG_DEF(NULL, "max-q", 1, "Maximum quantizer"); |
| 59 static const arg_def_t min_bitrate_arg = | 59 static const arg_def_t min_bitrate_arg = |
| 60 ARG_DEF(NULL, "min-bitrate", 1, "Minimum bitrate"); | 60 ARG_DEF(NULL, "min-bitrate", 1, "Minimum bitrate"); |
| 61 static const arg_def_t max_bitrate_arg = | 61 static const arg_def_t max_bitrate_arg = |
| 62 ARG_DEF(NULL, "max-bitrate", 1, "Maximum bitrate"); | 62 ARG_DEF(NULL, "max-bitrate", 1, "Maximum bitrate"); |
| 63 | 63 |
| 64 #if CONFIG_VP9_HIGHBITDEPTH |
| 65 static const struct arg_enum_list bitdepth_enum[] = { |
| 66 {"8", VPX_BITS_8}, |
| 67 {"10", VPX_BITS_10}, |
| 68 {"12", VPX_BITS_12}, |
| 69 {NULL, 0} |
| 70 }; |
| 71 |
| 72 static const arg_def_t bitdepth_arg = |
| 73 ARG_DEF_ENUM("d", "bit-depth", 1, "Bit depth for codec 8, 10 or 12. ", |
| 74 bitdepth_enum); |
| 75 #endif // CONFIG_VP9_HIGHBITDEPTH |
| 76 |
| 77 |
| 64 static const arg_def_t *svc_args[] = { | 78 static const arg_def_t *svc_args[] = { |
| 65 &frames_arg, &width_arg, &height_arg, | 79 &frames_arg, &width_arg, &height_arg, |
| 66 &timebase_arg, &bitrate_arg, &skip_frames_arg, &spatial_layers_arg, | 80 &timebase_arg, &bitrate_arg, &skip_frames_arg, &spatial_layers_arg, |
| 67 &kf_dist_arg, &scale_factors_arg, &passes_arg, &pass_arg, | 81 &kf_dist_arg, &scale_factors_arg, &passes_arg, &pass_arg, |
| 68 &fpf_name_arg, &min_q_arg, &max_q_arg, &min_bitrate_arg, | 82 &fpf_name_arg, &min_q_arg, &max_q_arg, &min_bitrate_arg, |
| 69 &max_bitrate_arg, &temporal_layers_arg, NULL | 83 &max_bitrate_arg, &temporal_layers_arg, |
| 84 #if CONFIG_VP9_HIGHBITDEPTH |
| 85 &bitdepth_arg, |
| 86 #endif |
| 87 NULL |
| 70 }; | 88 }; |
| 71 | 89 |
| 72 static const uint32_t default_frames_to_skip = 0; | 90 static const uint32_t default_frames_to_skip = 0; |
| 73 static const uint32_t default_frames_to_code = 60 * 60; | 91 static const uint32_t default_frames_to_code = 60 * 60; |
| 74 static const uint32_t default_width = 1920; | 92 static const uint32_t default_width = 1920; |
| 75 static const uint32_t default_height = 1080; | 93 static const uint32_t default_height = 1080; |
| 76 static const uint32_t default_timebase_num = 1; | 94 static const uint32_t default_timebase_num = 1; |
| 77 static const uint32_t default_timebase_den = 60; | 95 static const uint32_t default_timebase_den = 60; |
| 78 static const uint32_t default_bitrate = 1000; | 96 static const uint32_t default_bitrate = 1000; |
| 79 static const uint32_t default_spatial_layers = 5; | 97 static const uint32_t default_spatial_layers = 5; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 } else if (arg_match(&arg, &skip_frames_arg, argi)) { | 176 } else if (arg_match(&arg, &skip_frames_arg, argi)) { |
| 159 app_input->frames_to_skip = arg_parse_uint(&arg); | 177 app_input->frames_to_skip = arg_parse_uint(&arg); |
| 160 } else if (arg_match(&arg, &spatial_layers_arg, argi)) { | 178 } else if (arg_match(&arg, &spatial_layers_arg, argi)) { |
| 161 svc_ctx->spatial_layers = arg_parse_uint(&arg); | 179 svc_ctx->spatial_layers = arg_parse_uint(&arg); |
| 162 } else if (arg_match(&arg, &temporal_layers_arg, argi)) { | 180 } else if (arg_match(&arg, &temporal_layers_arg, argi)) { |
| 163 svc_ctx->temporal_layers = arg_parse_uint(&arg); | 181 svc_ctx->temporal_layers = arg_parse_uint(&arg); |
| 164 } else if (arg_match(&arg, &kf_dist_arg, argi)) { | 182 } else if (arg_match(&arg, &kf_dist_arg, argi)) { |
| 165 enc_cfg->kf_min_dist = arg_parse_uint(&arg); | 183 enc_cfg->kf_min_dist = arg_parse_uint(&arg); |
| 166 enc_cfg->kf_max_dist = enc_cfg->kf_min_dist; | 184 enc_cfg->kf_max_dist = enc_cfg->kf_min_dist; |
| 167 } else if (arg_match(&arg, &scale_factors_arg, argi)) { | 185 } else if (arg_match(&arg, &scale_factors_arg, argi)) { |
| 168 snprintf(string_options, 1024, "%s scale-factors=%s", | 186 snprintf(string_options, sizeof(string_options), "%s scale-factors=%s", |
| 169 string_options, arg.val); | 187 string_options, arg.val); |
| 170 } else if (arg_match(&arg, &passes_arg, argi)) { | 188 } else if (arg_match(&arg, &passes_arg, argi)) { |
| 171 passes = arg_parse_uint(&arg); | 189 passes = arg_parse_uint(&arg); |
| 172 if (passes < 1 || passes > 2) { | 190 if (passes < 1 || passes > 2) { |
| 173 die("Error: Invalid number of passes (%d)\n", passes); | 191 die("Error: Invalid number of passes (%d)\n", passes); |
| 174 } | 192 } |
| 175 } else if (arg_match(&arg, &pass_arg, argi)) { | 193 } else if (arg_match(&arg, &pass_arg, argi)) { |
| 176 pass = arg_parse_uint(&arg); | 194 pass = arg_parse_uint(&arg); |
| 177 if (pass < 1 || pass > 2) { | 195 if (pass < 1 || pass > 2) { |
| 178 die("Error: Invalid pass selected (%d)\n", pass); | 196 die("Error: Invalid pass selected (%d)\n", pass); |
| 179 } | 197 } |
| 180 } else if (arg_match(&arg, &fpf_name_arg, argi)) { | 198 } else if (arg_match(&arg, &fpf_name_arg, argi)) { |
| 181 fpf_file_name = arg.val; | 199 fpf_file_name = arg.val; |
| 182 } else if (arg_match(&arg, &min_q_arg, argi)) { | 200 } else if (arg_match(&arg, &min_q_arg, argi)) { |
| 183 snprintf(string_options, 1024, "%s min-quantizers=%s", | 201 snprintf(string_options, sizeof(string_options), "%s min-quantizers=%s", |
| 184 string_options, arg.val); | 202 string_options, arg.val); |
| 185 } else if (arg_match(&arg, &max_q_arg, argi)) { | 203 } else if (arg_match(&arg, &max_q_arg, argi)) { |
| 186 snprintf(string_options, 1024, "%s max-quantizers=%s", | 204 snprintf(string_options, sizeof(string_options), "%s max-quantizers=%s", |
| 187 string_options, arg.val); | 205 string_options, arg.val); |
| 188 } else if (arg_match(&arg, &min_bitrate_arg, argi)) { | 206 } else if (arg_match(&arg, &min_bitrate_arg, argi)) { |
| 189 min_bitrate = arg_parse_uint(&arg); | 207 min_bitrate = arg_parse_uint(&arg); |
| 190 } else if (arg_match(&arg, &max_bitrate_arg, argi)) { | 208 } else if (arg_match(&arg, &max_bitrate_arg, argi)) { |
| 191 max_bitrate = arg_parse_uint(&arg); | 209 max_bitrate = arg_parse_uint(&arg); |
| 210 #if CONFIG_VP9_HIGHBITDEPTH |
| 211 } else if (arg_match(&arg, &bitdepth_arg, argi)) { |
| 212 enc_cfg->g_bit_depth = arg_parse_enum_or_int(&arg); |
| 213 switch (enc_cfg->g_bit_depth) { |
| 214 case VPX_BITS_8: |
| 215 enc_cfg->g_input_bit_depth = 8; |
| 216 enc_cfg->g_profile = 0; |
| 217 break; |
| 218 case VPX_BITS_10: |
| 219 enc_cfg->g_input_bit_depth = 10; |
| 220 enc_cfg->g_profile = 2; |
| 221 break; |
| 222 case VPX_BITS_12: |
| 223 enc_cfg->g_input_bit_depth = 12; |
| 224 enc_cfg->g_profile = 2; |
| 225 break; |
| 226 default: |
| 227 die("Error: Invalid bit depth selected (%d)\n", enc_cfg->g_bit_depth); |
| 228 break; |
| 229 } |
| 230 #endif // CONFIG_VP9_HIGHBITDEPTH |
| 192 } else { | 231 } else { |
| 193 ++argj; | 232 ++argj; |
| 194 } | 233 } |
| 195 } | 234 } |
| 196 | 235 |
| 197 // There will be a space in front of the string options | 236 // There will be a space in front of the string options |
| 198 if (strlen(string_options) > 0) | 237 if (strlen(string_options) > 0) |
| 199 vpx_svc_set_options(svc_ctx, string_options + 1); | 238 vpx_svc_set_options(svc_ctx, string_options + 1); |
| 200 | 239 |
| 201 if (passes == 0 || passes == 1) { | 240 if (passes == 0 || passes == 1) { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 FILE *infile = NULL; | 323 FILE *infile = NULL; |
| 285 int end_of_stream = 0; | 324 int end_of_stream = 0; |
| 286 int frames_received = 0; | 325 int frames_received = 0; |
| 287 | 326 |
| 288 memset(&svc_ctx, 0, sizeof(svc_ctx)); | 327 memset(&svc_ctx, 0, sizeof(svc_ctx)); |
| 289 svc_ctx.log_print = 1; | 328 svc_ctx.log_print = 1; |
| 290 exec_name = argv[0]; | 329 exec_name = argv[0]; |
| 291 parse_command_line(argc, argv, &app_input, &svc_ctx, &enc_cfg); | 330 parse_command_line(argc, argv, &app_input, &svc_ctx, &enc_cfg); |
| 292 | 331 |
| 293 // Allocate image buffer | 332 // Allocate image buffer |
| 294 if (!vpx_img_alloc(&raw, VPX_IMG_FMT_I420, enc_cfg.g_w, enc_cfg.g_h, 32)) | 333 #if CONFIG_VP9_HIGHBITDEPTH |
| 334 if (!vpx_img_alloc(&raw, enc_cfg.g_input_bit_depth == 8 ? |
| 335 VPX_IMG_FMT_I420 : VPX_IMG_FMT_I42016, |
| 336 enc_cfg.g_w, enc_cfg.g_h, 32)) { |
| 295 die("Failed to allocate image %dx%d\n", enc_cfg.g_w, enc_cfg.g_h); | 337 die("Failed to allocate image %dx%d\n", enc_cfg.g_w, enc_cfg.g_h); |
| 338 } |
| 339 #else |
| 340 if (!vpx_img_alloc(&raw, VPX_IMG_FMT_I420, enc_cfg.g_w, enc_cfg.g_h, 32)) { |
| 341 die("Failed to allocate image %dx%d\n", enc_cfg.g_w, enc_cfg.g_h); |
| 342 } |
| 343 #endif // CONFIG_VP9_HIGHBITDEPTH |
| 296 | 344 |
| 297 if (!(infile = fopen(app_input.input_filename, "rb"))) | 345 if (!(infile = fopen(app_input.input_filename, "rb"))) |
| 298 die("Failed to open %s for reading\n", app_input.input_filename); | 346 die("Failed to open %s for reading\n", app_input.input_filename); |
| 299 | 347 |
| 300 // Initialize codec | 348 // Initialize codec |
| 301 if (vpx_svc_init(&svc_ctx, &codec, vpx_codec_vp9_cx(), &enc_cfg) != | 349 if (vpx_svc_init(&svc_ctx, &codec, vpx_codec_vp9_cx(), &enc_cfg) != |
| 302 VPX_CODEC_OK) | 350 VPX_CODEC_OK) |
| 303 die("Failed to initialize encoder\n"); | 351 die("Failed to initialize encoder\n"); |
| 304 | 352 |
| 305 info.codec_fourcc = VP9_FOURCC; | 353 info.codec_fourcc = VP9_FOURCC; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 | 430 |
| 383 vpx_img_free(&raw); | 431 vpx_img_free(&raw); |
| 384 | 432 |
| 385 // display average size, psnr | 433 // display average size, psnr |
| 386 printf("%s", vpx_svc_dump_statistics(&svc_ctx)); | 434 printf("%s", vpx_svc_dump_statistics(&svc_ctx)); |
| 387 | 435 |
| 388 vpx_svc_release(&svc_ctx); | 436 vpx_svc_release(&svc_ctx); |
| 389 | 437 |
| 390 return EXIT_SUCCESS; | 438 return EXIT_SUCCESS; |
| 391 } | 439 } |
| OLD | NEW |