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

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

Issue 958693004: libvpx: Pull from upstream (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libvpx.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « source/libvpx/examples/vp9_spatial_svc_encoder.c ('k') | source/libvpx/libs.mk » ('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
11 // This is an example demonstrating how to implement a multi-layer VPx 11 // This is an example demonstrating how to implement a multi-layer VPx
12 // encoding scheme based on temporal scalability for video applications 12 // encoding scheme based on temporal scalability for video applications
13 // that benefit from a scalable bitstream. 13 // that benefit from a scalable bitstream.
14 14
15 #include <assert.h> 15 #include <assert.h>
16 #include <math.h> 16 #include <math.h>
17 #include <stdio.h> 17 #include <stdio.h>
18 #include <stdlib.h> 18 #include <stdlib.h>
19 #include <string.h> 19 #include <string.h>
20 20
21 #include "./vpx_config.h" 21 #include "./vpx_config.h"
22 #include "vpx_ports/vpx_timer.h" 22 #include "../vpx_ports/vpx_timer.h"
23 #include "vpx/vp8cx.h" 23 #include "vpx/vp8cx.h"
24 #include "vpx/vpx_encoder.h" 24 #include "vpx/vpx_encoder.h"
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. 35 // Denoiser states, for temporal denoising.
36 enum denoiserState { 36 enum denoiserState {
37 kDenoiserOff, 37 kDenoiserOff,
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 ++i) { 595 ++i) {
596 cfg.ts_target_bitrate[i - 11] = strtol(argv[i], NULL, 0); 596 cfg.ts_target_bitrate[i - 11] = strtol(argv[i], NULL, 0);
597 } 597 }
598 598
599 // Real time parameters. 599 // Real time parameters.
600 cfg.rc_dropframe_thresh = strtol(argv[9], NULL, 0); 600 cfg.rc_dropframe_thresh = strtol(argv[9], NULL, 0);
601 cfg.rc_end_usage = VPX_CBR; 601 cfg.rc_end_usage = VPX_CBR;
602 cfg.rc_resize_allowed = 0; 602 cfg.rc_resize_allowed = 0;
603 cfg.rc_min_quantizer = 2; 603 cfg.rc_min_quantizer = 2;
604 cfg.rc_max_quantizer = 56; 604 cfg.rc_max_quantizer = 56;
605 if (strncmp(encoder->name, "vp9", 3) == 0)
606 cfg.rc_max_quantizer = 52;
605 cfg.rc_undershoot_pct = 50; 607 cfg.rc_undershoot_pct = 50;
606 cfg.rc_overshoot_pct = 50; 608 cfg.rc_overshoot_pct = 50;
607 cfg.rc_buf_initial_sz = 500; 609 cfg.rc_buf_initial_sz = 500;
608 cfg.rc_buf_optimal_sz = 600; 610 cfg.rc_buf_optimal_sz = 600;
609 cfg.rc_buf_sz = 1000; 611 cfg.rc_buf_sz = 1000;
610 612
611 // Enable error resilient mode. 613 // Enable error resilient mode.
612 cfg.g_error_resilient = 1; 614 cfg.g_error_resilient = 1;
613 cfg.g_lag_in_frames = 0; 615 cfg.g_lag_in_frames = 0;
614 cfg.kf_mode = VPX_KF_AUTO; 616 cfg.kf_mode = VPX_KF_AUTO;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 &codec, encoder->codec_interface(), &cfg, 661 &codec, encoder->codec_interface(), &cfg,
660 bit_depth == VPX_BITS_8 ? 0 : VPX_CODEC_USE_HIGHBITDEPTH)) 662 bit_depth == VPX_BITS_8 ? 0 : VPX_CODEC_USE_HIGHBITDEPTH))
661 #else 663 #else
662 if (vpx_codec_enc_init(&codec, encoder->codec_interface(), &cfg, 0)) 664 if (vpx_codec_enc_init(&codec, encoder->codec_interface(), &cfg, 0))
663 #endif // CONFIG_VP9_HIGHBITDEPTH 665 #endif // CONFIG_VP9_HIGHBITDEPTH
664 die_codec(&codec, "Failed to initialize encoder"); 666 die_codec(&codec, "Failed to initialize encoder");
665 667
666 if (strncmp(encoder->name, "vp8", 3) == 0) { 668 if (strncmp(encoder->name, "vp8", 3) == 0) {
667 vpx_codec_control(&codec, VP8E_SET_CPUUSED, -speed); 669 vpx_codec_control(&codec, VP8E_SET_CPUUSED, -speed);
668 vpx_codec_control(&codec, VP8E_SET_NOISE_SENSITIVITY, kDenoiserOnYOnly); 670 vpx_codec_control(&codec, VP8E_SET_NOISE_SENSITIVITY, kDenoiserOnYOnly);
671 vpx_codec_control(&codec, VP8E_SET_STATIC_THRESHOLD, 1);
669 } else if (strncmp(encoder->name, "vp9", 3) == 0) { 672 } else if (strncmp(encoder->name, "vp9", 3) == 0) {
670 vpx_codec_control(&codec, VP8E_SET_CPUUSED, speed); 673 vpx_codec_control(&codec, VP8E_SET_CPUUSED, speed);
671 vpx_codec_control(&codec, VP9E_SET_AQ_MODE, 3); 674 vpx_codec_control(&codec, VP9E_SET_AQ_MODE, 3);
672 vpx_codec_control(&codec, VP9E_SET_FRAME_PERIODIC_BOOST, 0); 675 vpx_codec_control(&codec, VP9E_SET_FRAME_PERIODIC_BOOST, 0);
673 vpx_codec_control(&codec, VP9E_SET_NOISE_SENSITIVITY, 0); 676 vpx_codec_control(&codec, VP9E_SET_NOISE_SENSITIVITY, 0);
677 vpx_codec_control(&codec, VP8E_SET_STATIC_THRESHOLD, 0);
674 if (vpx_codec_control(&codec, VP9E_SET_SVC, layering_mode > 0 ? 1: 0)) { 678 if (vpx_codec_control(&codec, VP9E_SET_SVC, layering_mode > 0 ? 1: 0)) {
675 die_codec(&codec, "Failed to set SVC"); 679 die_codec(&codec, "Failed to set SVC");
676 } 680 }
677 } 681 }
678 if (strncmp(encoder->name, "vp8", 3) == 0) { 682 if (strncmp(encoder->name, "vp8", 3) == 0) {
679 vpx_codec_control(&codec, VP8E_SET_SCREEN_CONTENT_MODE, 0); 683 vpx_codec_control(&codec, VP8E_SET_SCREEN_CONTENT_MODE, 0);
680 } 684 }
681 vpx_codec_control(&codec, VP8E_SET_STATIC_THRESHOLD, 1);
682 vpx_codec_control(&codec, VP8E_SET_TOKEN_PARTITIONS, 1); 685 vpx_codec_control(&codec, VP8E_SET_TOKEN_PARTITIONS, 1);
683 // This controls the maximum target size of the key frame. 686 // This controls the maximum target size of the key frame.
684 // For generating smaller key frames, use a smaller max_intra_size_pct 687 // For generating smaller key frames, use a smaller max_intra_size_pct
685 // value, like 100 or 200. 688 // value, like 100 or 200.
686 { 689 {
687 const int max_intra_size_pct = 900; 690 const int max_intra_size_pct = 900;
688 vpx_codec_control(&codec, VP8E_SET_MAX_INTRA_BITRATE_PCT, 691 vpx_codec_control(&codec, VP8E_SET_MAX_INTRA_BITRATE_PCT,
689 max_intra_size_pct); 692 max_intra_size_pct);
690 } 693 }
691 694
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 if (vpx_codec_destroy(&codec)) 789 if (vpx_codec_destroy(&codec))
787 die_codec(&codec, "Failed to destroy codec"); 790 die_codec(&codec, "Failed to destroy codec");
788 791
789 // Try to rewrite the output file headers with the actual frame count. 792 // Try to rewrite the output file headers with the actual frame count.
790 for (i = 0; i < cfg.ts_number_layers; ++i) 793 for (i = 0; i < cfg.ts_number_layers; ++i)
791 vpx_video_writer_close(outfile[i]); 794 vpx_video_writer_close(outfile[i]);
792 795
793 vpx_img_free(&raw); 796 vpx_img_free(&raw);
794 return EXIT_SUCCESS; 797 return EXIT_SUCCESS;
795 } 798 }
OLDNEW
« no previous file with comments | « source/libvpx/examples/vp9_spatial_svc_encoder.c ('k') | source/libvpx/libs.mk » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698