| Index: source/libvpx/examples/vp9_spatial_svc_encoder.c
|
| ===================================================================
|
| --- source/libvpx/examples/vp9_spatial_svc_encoder.c (revision 292608)
|
| +++ source/libvpx/examples/vp9_spatial_svc_encoder.c (working copy)
|
| @@ -61,12 +61,30 @@
|
| static const arg_def_t max_bitrate_arg =
|
| ARG_DEF(NULL, "max-bitrate", 1, "Maximum bitrate");
|
|
|
| +#if CONFIG_VP9_HIGHBITDEPTH
|
| +static const struct arg_enum_list bitdepth_enum[] = {
|
| + {"8", VPX_BITS_8},
|
| + {"10", VPX_BITS_10},
|
| + {"12", VPX_BITS_12},
|
| + {NULL, 0}
|
| +};
|
| +
|
| +static const arg_def_t bitdepth_arg =
|
| + ARG_DEF_ENUM("d", "bit-depth", 1, "Bit depth for codec 8, 10 or 12. ",
|
| + bitdepth_enum);
|
| +#endif // CONFIG_VP9_HIGHBITDEPTH
|
| +
|
| +
|
| static const arg_def_t *svc_args[] = {
|
| &frames_arg, &width_arg, &height_arg,
|
| &timebase_arg, &bitrate_arg, &skip_frames_arg, &spatial_layers_arg,
|
| &kf_dist_arg, &scale_factors_arg, &passes_arg, &pass_arg,
|
| &fpf_name_arg, &min_q_arg, &max_q_arg, &min_bitrate_arg,
|
| - &max_bitrate_arg, &temporal_layers_arg, NULL
|
| + &max_bitrate_arg, &temporal_layers_arg,
|
| +#if CONFIG_VP9_HIGHBITDEPTH
|
| + &bitdepth_arg,
|
| +#endif
|
| + NULL
|
| };
|
|
|
| static const uint32_t default_frames_to_skip = 0;
|
| @@ -165,7 +183,7 @@
|
| enc_cfg->kf_min_dist = arg_parse_uint(&arg);
|
| enc_cfg->kf_max_dist = enc_cfg->kf_min_dist;
|
| } else if (arg_match(&arg, &scale_factors_arg, argi)) {
|
| - snprintf(string_options, 1024, "%s scale-factors=%s",
|
| + snprintf(string_options, sizeof(string_options), "%s scale-factors=%s",
|
| string_options, arg.val);
|
| } else if (arg_match(&arg, &passes_arg, argi)) {
|
| passes = arg_parse_uint(&arg);
|
| @@ -180,15 +198,36 @@
|
| } else if (arg_match(&arg, &fpf_name_arg, argi)) {
|
| fpf_file_name = arg.val;
|
| } else if (arg_match(&arg, &min_q_arg, argi)) {
|
| - snprintf(string_options, 1024, "%s min-quantizers=%s",
|
| + snprintf(string_options, sizeof(string_options), "%s min-quantizers=%s",
|
| string_options, arg.val);
|
| } else if (arg_match(&arg, &max_q_arg, argi)) {
|
| - snprintf(string_options, 1024, "%s max-quantizers=%s",
|
| + snprintf(string_options, sizeof(string_options), "%s max-quantizers=%s",
|
| string_options, arg.val);
|
| } else if (arg_match(&arg, &min_bitrate_arg, argi)) {
|
| min_bitrate = arg_parse_uint(&arg);
|
| } else if (arg_match(&arg, &max_bitrate_arg, argi)) {
|
| max_bitrate = arg_parse_uint(&arg);
|
| +#if CONFIG_VP9_HIGHBITDEPTH
|
| + } else if (arg_match(&arg, &bitdepth_arg, argi)) {
|
| + enc_cfg->g_bit_depth = arg_parse_enum_or_int(&arg);
|
| + switch (enc_cfg->g_bit_depth) {
|
| + case VPX_BITS_8:
|
| + enc_cfg->g_input_bit_depth = 8;
|
| + enc_cfg->g_profile = 0;
|
| + break;
|
| + case VPX_BITS_10:
|
| + enc_cfg->g_input_bit_depth = 10;
|
| + enc_cfg->g_profile = 2;
|
| + break;
|
| + case VPX_BITS_12:
|
| + enc_cfg->g_input_bit_depth = 12;
|
| + enc_cfg->g_profile = 2;
|
| + break;
|
| + default:
|
| + die("Error: Invalid bit depth selected (%d)\n", enc_cfg->g_bit_depth);
|
| + break;
|
| + }
|
| +#endif // CONFIG_VP9_HIGHBITDEPTH
|
| } else {
|
| ++argj;
|
| }
|
| @@ -291,8 +330,17 @@
|
| parse_command_line(argc, argv, &app_input, &svc_ctx, &enc_cfg);
|
|
|
| // Allocate image buffer
|
| - if (!vpx_img_alloc(&raw, VPX_IMG_FMT_I420, enc_cfg.g_w, enc_cfg.g_h, 32))
|
| +#if CONFIG_VP9_HIGHBITDEPTH
|
| + if (!vpx_img_alloc(&raw, enc_cfg.g_input_bit_depth == 8 ?
|
| + VPX_IMG_FMT_I420 : VPX_IMG_FMT_I42016,
|
| + enc_cfg.g_w, enc_cfg.g_h, 32)) {
|
| die("Failed to allocate image %dx%d\n", enc_cfg.g_w, enc_cfg.g_h);
|
| + }
|
| +#else
|
| + if (!vpx_img_alloc(&raw, VPX_IMG_FMT_I420, enc_cfg.g_w, enc_cfg.g_h, 32)) {
|
| + die("Failed to allocate image %dx%d\n", enc_cfg.g_w, enc_cfg.g_h);
|
| + }
|
| +#endif // CONFIG_VP9_HIGHBITDEPTH
|
|
|
| if (!(infile = fopen(app_input.input_filename, "rb")))
|
| die("Failed to open %s for reading\n", app_input.input_filename);
|
|
|