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

Side by Side Diff: source/libvpx/examples/vpx_temporal_svc_encoder.c

Issue 394353005: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « source/libvpx/examples/vp8cx_set_ref.c ('k') | source/libvpx/test/active_map_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 14 matching lines...) Expand all
25 25
26 #include "./tools_common.h" 26 #include "./tools_common.h"
27 #include "./video_writer.h" 27 #include "./video_writer.h"
28 28
29 static const char *exec_name; 29 static const char *exec_name;
30 30
31 void usage_exit() { 31 void usage_exit() {
32 exit(EXIT_FAILURE); 32 exit(EXIT_FAILURE);
33 } 33 }
34 34
35 // Denoiser states, for temporal denoising.
36 enum denoiserState {
37 kDenoiserOff,
38 kDenoiserOnYOnly,
39 kDenoiserOnYUV,
40 kDenoiserOnYUVAggressive // Aggressive mode not implemented currently.
41 };
42
35 static int mode_to_num_layers[12] = {1, 2, 2, 3, 3, 3, 3, 5, 2, 3, 3, 3}; 43 static int mode_to_num_layers[12] = {1, 2, 2, 3, 3, 3, 3, 5, 2, 3, 3, 3};
36 44
37 // For rate control encoding stats. 45 // For rate control encoding stats.
38 struct RateControlMetrics { 46 struct RateControlMetrics {
39 // Number of input frames per layer. 47 // Number of input frames per layer.
40 int layer_input_frames[VPX_TS_MAX_LAYERS]; 48 int layer_input_frames[VPX_TS_MAX_LAYERS];
41 // Total (cumulative) number of encoded frames per layer. 49 // Total (cumulative) number of encoded frames per layer.
42 int layer_tot_enc_frames[VPX_TS_MAX_LAYERS]; 50 int layer_tot_enc_frames[VPX_TS_MAX_LAYERS];
43 // Number of encoded non-key frames per layer. 51 // Number of encoded non-key frames per layer.
44 int layer_enc_frames[VPX_TS_MAX_LAYERS]; 52 int layer_enc_frames[VPX_TS_MAX_LAYERS];
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 if (argc < 11) { 467 if (argc < 11) {
460 die("Usage: %s <infile> <outfile> <codec_type(vp8/vp9)> <width> <height> " 468 die("Usage: %s <infile> <outfile> <codec_type(vp8/vp9)> <width> <height> "
461 "<rate_num> <rate_den> <speed> <frame_drop_threshold> <mode> " 469 "<rate_num> <rate_den> <speed> <frame_drop_threshold> <mode> "
462 "<Rate_0> ... <Rate_nlayers-1> \n", argv[0]); 470 "<Rate_0> ... <Rate_nlayers-1> \n", argv[0]);
463 } 471 }
464 472
465 encoder = get_vpx_encoder_by_name(argv[3]); 473 encoder = get_vpx_encoder_by_name(argv[3]);
466 if (!encoder) 474 if (!encoder)
467 die("Unsupported codec."); 475 die("Unsupported codec.");
468 476
469 printf("Using %s\n", vpx_codec_iface_name(encoder->interface())); 477 printf("Using %s\n", vpx_codec_iface_name(encoder->codec_interface()));
470 478
471 width = strtol(argv[4], NULL, 0); 479 width = strtol(argv[4], NULL, 0);
472 height = strtol(argv[5], NULL, 0); 480 height = strtol(argv[5], NULL, 0);
473 if (width < 16 || width % 2 || height < 16 || height % 2) { 481 if (width < 16 || width % 2 || height < 16 || height % 2) {
474 die("Invalid resolution: %d x %d", width, height); 482 die("Invalid resolution: %d x %d", width, height);
475 } 483 }
476 484
477 layering_mode = strtol(argv[10], NULL, 0); 485 layering_mode = strtol(argv[10], NULL, 0);
478 if (layering_mode < 0 || layering_mode > 12) { 486 if (layering_mode < 0 || layering_mode > 12) {
479 die("Invalid layering mode (0..12) %s", argv[10]); 487 die("Invalid layering mode (0..12) %s", argv[10]);
480 } 488 }
481 489
482 if (argc != 11 + mode_to_num_layers[layering_mode]) { 490 if (argc != 11 + mode_to_num_layers[layering_mode]) {
483 die("Invalid number of arguments"); 491 die("Invalid number of arguments");
484 } 492 }
485 493
486 if (!vpx_img_alloc(&raw, VPX_IMG_FMT_I420, width, height, 32)) { 494 if (!vpx_img_alloc(&raw, VPX_IMG_FMT_I420, width, height, 32)) {
487 die("Failed to allocate image", width, height); 495 die("Failed to allocate image", width, height);
488 } 496 }
489 497
490 // Populate encoder configuration. 498 // Populate encoder configuration.
491 res = vpx_codec_enc_config_default(encoder->interface(), &cfg, 0); 499 res = vpx_codec_enc_config_default(encoder->codec_interface(), &cfg, 0);
492 if (res) { 500 if (res) {
493 printf("Failed to get config: %s\n", vpx_codec_err_to_string(res)); 501 printf("Failed to get config: %s\n", vpx_codec_err_to_string(res));
494 return EXIT_FAILURE; 502 return EXIT_FAILURE;
495 } 503 }
496 504
497 // Update the default configuration with our settings. 505 // Update the default configuration with our settings.
498 cfg.g_w = width; 506 cfg.g_w = width;
499 cfg.g_h = height; 507 cfg.g_h = height;
500 508
501 // Timebase format e.g. 30fps: numerator=1, demoninator = 30. 509 // Timebase format e.g. 30fps: numerator=1, demoninator = 30.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 567
560 snprintf(file_name, sizeof(file_name), "%s_%d.ivf", argv[2], i); 568 snprintf(file_name, sizeof(file_name), "%s_%d.ivf", argv[2], i);
561 outfile[i] = vpx_video_writer_open(file_name, kContainerIVF, &info); 569 outfile[i] = vpx_video_writer_open(file_name, kContainerIVF, &info);
562 if (!outfile[i]) 570 if (!outfile[i])
563 die("Failed to open %s for writing", file_name); 571 die("Failed to open %s for writing", file_name);
564 } 572 }
565 // No spatial layers in this encoder. 573 // No spatial layers in this encoder.
566 cfg.ss_number_layers = 1; 574 cfg.ss_number_layers = 1;
567 575
568 // Initialize codec. 576 // Initialize codec.
569 if (vpx_codec_enc_init(&codec, encoder->interface(), &cfg, 0)) 577 if (vpx_codec_enc_init(&codec, encoder->codec_interface(), &cfg, 0))
570 die_codec(&codec, "Failed to initialize encoder"); 578 die_codec(&codec, "Failed to initialize encoder");
571 579
572 if (strncmp(encoder->name, "vp8", 3) == 0) { 580 if (strncmp(encoder->name, "vp8", 3) == 0) {
573 vpx_codec_control(&codec, VP8E_SET_CPUUSED, -speed); 581 vpx_codec_control(&codec, VP8E_SET_CPUUSED, -speed);
574 vpx_codec_control(&codec, VP8E_SET_NOISE_SENSITIVITY, 1); 582 vpx_codec_control(&codec, VP8E_SET_NOISE_SENSITIVITY, kDenoiserOnYOnly);
575 } else if (strncmp(encoder->name, "vp9", 3) == 0) { 583 } else if (strncmp(encoder->name, "vp9", 3) == 0) {
576 vpx_codec_control(&codec, VP8E_SET_CPUUSED, speed); 584 vpx_codec_control(&codec, VP8E_SET_CPUUSED, speed);
577 vpx_codec_control(&codec, VP9E_SET_AQ_MODE, 3); 585 vpx_codec_control(&codec, VP9E_SET_AQ_MODE, 3);
578 vpx_codec_control(&codec, VP9E_SET_FRAME_PERIODIC_BOOST, 0); 586 vpx_codec_control(&codec, VP9E_SET_FRAME_PERIODIC_BOOST, 0);
579 vpx_codec_control(&codec, VP8E_SET_NOISE_SENSITIVITY, 0); 587 vpx_codec_control(&codec, VP8E_SET_NOISE_SENSITIVITY, 0);
580 if (vpx_codec_control(&codec, VP9E_SET_SVC, 1)) { 588 if (vpx_codec_control(&codec, VP9E_SET_SVC, 1)) {
581 die_codec(&codec, "Failed to set SVC"); 589 die_codec(&codec, "Failed to set SVC");
582 } 590 }
583 } 591 }
584 vpx_codec_control(&codec, VP8E_SET_STATIC_THRESHOLD, 1); 592 vpx_codec_control(&codec, VP8E_SET_STATIC_THRESHOLD, 1);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 if (vpx_codec_destroy(&codec)) 667 if (vpx_codec_destroy(&codec))
660 die_codec(&codec, "Failed to destroy codec"); 668 die_codec(&codec, "Failed to destroy codec");
661 669
662 // Try to rewrite the output file headers with the actual frame count. 670 // Try to rewrite the output file headers with the actual frame count.
663 for (i = 0; i < cfg.ts_number_layers; ++i) 671 for (i = 0; i < cfg.ts_number_layers; ++i)
664 vpx_video_writer_close(outfile[i]); 672 vpx_video_writer_close(outfile[i]);
665 673
666 vpx_img_free(&raw); 674 vpx_img_free(&raw);
667 return EXIT_SUCCESS; 675 return EXIT_SUCCESS;
668 } 676 }
OLDNEW
« no previous file with comments | « source/libvpx/examples/vp8cx_set_ref.c ('k') | source/libvpx/test/active_map_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698