Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Unified Diff: source/libvpx/examples/vpx_temporal_svc_encoder.c

Issue 668403002: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « source/libvpx/examples/vp9_spatial_svc_encoder.c ('k') | source/libvpx/test/convolve_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: source/libvpx/examples/vpx_temporal_svc_encoder.c
===================================================================
--- source/libvpx/examples/vpx_temporal_svc_encoder.c (revision 292608)
+++ source/libvpx/examples/vpx_temporal_svc_encoder.c (working copy)
@@ -461,13 +461,27 @@
FILE *infile = NULL;
struct RateControlMetrics rc;
int64_t cx_time = 0;
+ const int min_args_base = 11;
+#if CONFIG_VP9_HIGHBITDEPTH
+ vpx_bit_depth_t bit_depth = VPX_BITS_8;
+ int input_bit_depth = 8;
+ const int min_args = min_args_base + 1;
+#else
+ const int min_args = min_args_base;
+#endif // CONFIG_VP9_HIGHBITDEPTH
exec_name = argv[0];
// Check usage and arguments.
- if (argc < 11) {
+ if (argc < min_args) {
+#if CONFIG_VP9_HIGHBITDEPTH
die("Usage: %s <infile> <outfile> <codec_type(vp8/vp9)> <width> <height> "
"<rate_num> <rate_den> <speed> <frame_drop_threshold> <mode> "
+ "<Rate_0> ... <Rate_nlayers-1> <bit-depth> \n", argv[0]);
+#else
+ die("Usage: %s <infile> <outfile> <codec_type(vp8/vp9)> <width> <height> "
+ "<rate_num> <rate_den> <speed> <frame_drop_threshold> <mode> "
"<Rate_0> ... <Rate_nlayers-1> \n", argv[0]);
+#endif // CONFIG_VP9_HIGHBITDEPTH
}
encoder = get_vpx_encoder_by_name(argv[3]);
@@ -487,13 +501,38 @@
die("Invalid layering mode (0..12) %s", argv[10]);
}
- if (argc != 11 + mode_to_num_layers[layering_mode]) {
+ if (argc != min_args + mode_to_num_layers[layering_mode]) {
die("Invalid number of arguments");
}
+#if CONFIG_VP9_HIGHBITDEPTH
+ switch (strtol(argv[argc-1], NULL, 0)) {
+ case 8:
+ bit_depth = VPX_BITS_8;
+ input_bit_depth = 8;
+ break;
+ case 10:
+ bit_depth = VPX_BITS_10;
+ input_bit_depth = 10;
+ break;
+ case 12:
+ bit_depth = VPX_BITS_12;
+ input_bit_depth = 12;
+ break;
+ default:
+ die("Invalid bit depth (8, 10, 12) %s", argv[argc-1]);
+ }
+ if (!vpx_img_alloc(&raw,
+ bit_depth == VPX_BITS_8 ? VPX_IMG_FMT_I420 :
+ VPX_IMG_FMT_I42016,
+ width, height, 32)) {
+ die("Failed to allocate image", width, height);
+ }
+#else
if (!vpx_img_alloc(&raw, VPX_IMG_FMT_I420, width, height, 32)) {
die("Failed to allocate image", width, height);
}
+#endif // CONFIG_VP9_HIGHBITDEPTH
// Populate encoder configuration.
res = vpx_codec_enc_config_default(encoder->codec_interface(), &cfg, 0);
@@ -506,6 +545,14 @@
cfg.g_w = width;
cfg.g_h = height;
+#if CONFIG_VP9_HIGHBITDEPTH
+ if (bit_depth != VPX_BITS_8) {
+ cfg.g_bit_depth = bit_depth;
+ cfg.g_input_bit_depth = input_bit_depth;
+ cfg.g_profile = 2;
+ }
+#endif // CONFIG_VP9_HIGHBITDEPTH
+
// Timebase format e.g. 30fps: numerator=1, demoninator = 30.
cfg.g_timebase.num = strtol(argv[6], NULL, 0);
cfg.g_timebase.den = strtol(argv[7], NULL, 0);
@@ -515,7 +562,9 @@
die("Invalid speed setting: must be positive");
}
- for (i = 11; (int)i < 11 + mode_to_num_layers[layering_mode]; ++i) {
+ for (i = min_args_base;
+ (int)i < min_args_base + mode_to_num_layers[layering_mode];
+ ++i) {
cfg.ts_target_bitrate[i - 11] = strtol(argv[i], NULL, 0);
}
@@ -576,7 +625,13 @@
cfg.ss_number_layers = 1;
// Initialize codec.
+#if CONFIG_VP9_HIGHBITDEPTH
+ if (vpx_codec_enc_init(
+ &codec, encoder->codec_interface(), &cfg,
+ bit_depth == VPX_BITS_8 ? 0 : VPX_CODEC_USE_HIGHBITDEPTH))
+#else
if (vpx_codec_enc_init(&codec, encoder->codec_interface(), &cfg, 0))
+#endif // CONFIG_VP9_HIGHBITDEPTH
die_codec(&codec, "Failed to initialize encoder");
if (strncmp(encoder->name, "vp8", 3) == 0) {
« no previous file with comments | « source/libvpx/examples/vp9_spatial_svc_encoder.c ('k') | source/libvpx/test/convolve_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698