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

Side by Side Diff: source/libvpx/test/svc_test.cc

Issue 1124333011: libvpx: Pull from upstream (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libvpx.git@master
Patch Set: only update to last nights LKGR Created 5 years, 7 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/test/set_roi.cc ('k') | source/libvpx/test/test.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) 2013 The WebM project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 codec_enc_.g_w = kWidth; 56 codec_enc_.g_w = kWidth;
57 codec_enc_.g_h = kHeight; 57 codec_enc_.g_h = kHeight;
58 codec_enc_.g_timebase.num = 1; 58 codec_enc_.g_timebase.num = 1;
59 codec_enc_.g_timebase.den = 60; 59 codec_enc_.g_timebase.den = 60;
60 codec_enc_.kf_min_dist = 100; 60 codec_enc_.kf_min_dist = 100;
61 codec_enc_.kf_max_dist = 100; 61 codec_enc_.kf_max_dist = 100;
62 62
63 vpx_codec_dec_cfg_t dec_cfg = vpx_codec_dec_cfg_t(); 63 vpx_codec_dec_cfg_t dec_cfg = vpx_codec_dec_cfg_t();
64 VP9CodecFactory codec_factory; 64 VP9CodecFactory codec_factory;
65 decoder_ = codec_factory.CreateDecoder(dec_cfg, 0); 65 decoder_ = codec_factory.CreateDecoder(dec_cfg, 0);
66
67 tile_columns_ = 0;
68 tile_rows_ = 0;
66 } 69 }
67 70
68 virtual void TearDown() { 71 virtual void TearDown() {
69 ReleaseEncoder(); 72 ReleaseEncoder();
70 delete(decoder_); 73 delete(decoder_);
71 } 74 }
72 75
73 void InitializeEncoder() { 76 void InitializeEncoder() {
74 const vpx_codec_err_t res = 77 const vpx_codec_err_t res =
75 vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); 78 vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_);
76 EXPECT_EQ(VPX_CODEC_OK, res); 79 EXPECT_EQ(VPX_CODEC_OK, res);
77 vpx_codec_control(&codec_, VP8E_SET_CPUUSED, 4); // Make the test faster 80 vpx_codec_control(&codec_, VP8E_SET_CPUUSED, 4); // Make the test faster
81 vpx_codec_control(&codec_, VP9E_SET_TILE_COLUMNS, tile_columns_);
82 vpx_codec_control(&codec_, VP9E_SET_TILE_ROWS, tile_rows_);
78 codec_initialized_ = true; 83 codec_initialized_ = true;
79 } 84 }
80 85
81 void ReleaseEncoder() { 86 void ReleaseEncoder() {
82 vpx_svc_release(&svc_); 87 vpx_svc_release(&svc_);
83 if (codec_initialized_) vpx_codec_destroy(&codec_); 88 if (codec_initialized_) vpx_codec_destroy(&codec_);
84 codec_initialized_ = false; 89 codec_initialized_ = false;
85 } 90 }
86 91
87 void GetStatsData(std::string *const stats_buf) { 92 void GetStatsData(std::string *const stats_buf) {
(...skipping 13 matching lines...) Expand all
101 void Pass1EncodeNFrames(const int n, const int layers, 106 void Pass1EncodeNFrames(const int n, const int layers,
102 std::string *const stats_buf) { 107 std::string *const stats_buf) {
103 vpx_codec_err_t res; 108 vpx_codec_err_t res;
104 109
105 ASSERT_GT(n, 0); 110 ASSERT_GT(n, 0);
106 ASSERT_GT(layers, 0); 111 ASSERT_GT(layers, 0);
107 svc_.spatial_layers = layers; 112 svc_.spatial_layers = layers;
108 codec_enc_.g_pass = VPX_RC_FIRST_PASS; 113 codec_enc_.g_pass = VPX_RC_FIRST_PASS;
109 InitializeEncoder(); 114 InitializeEncoder();
110 115
111 libvpx_test::I420VideoSource video(test_file_name_, kWidth, kHeight, 116 libvpx_test::I420VideoSource video(test_file_name_,
117 codec_enc_.g_w, codec_enc_.g_h,
112 codec_enc_.g_timebase.den, 118 codec_enc_.g_timebase.den,
113 codec_enc_.g_timebase.num, 0, 30); 119 codec_enc_.g_timebase.num, 0, 30);
114 video.Begin(); 120 video.Begin();
115 121
116 for (int i = 0; i < n; ++i) { 122 for (int i = 0; i < n; ++i) {
117 res = vpx_svc_encode(&svc_, &codec_, video.img(), video.pts(), 123 res = vpx_svc_encode(&svc_, &codec_, video.img(), video.pts(),
118 video.duration(), VPX_DL_GOOD_QUALITY); 124 video.duration(), VPX_DL_GOOD_QUALITY);
119 ASSERT_EQ(VPX_CODEC_OK, res); 125 ASSERT_EQ(VPX_CODEC_OK, res);
120 GetStatsData(stats_buf); 126 GetStatsData(stats_buf);
121 video.Next(); 127 video.Next();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 svc_.spatial_layers = layers; 175 svc_.spatial_layers = layers;
170 codec_enc_.rc_target_bitrate = 500; 176 codec_enc_.rc_target_bitrate = 500;
171 if (codec_enc_.g_pass == VPX_RC_LAST_PASS) { 177 if (codec_enc_.g_pass == VPX_RC_LAST_PASS) {
172 ASSERT_TRUE(stats_buf != NULL); 178 ASSERT_TRUE(stats_buf != NULL);
173 ASSERT_GT(stats_buf->size(), 0U); 179 ASSERT_GT(stats_buf->size(), 0U);
174 codec_enc_.rc_twopass_stats_in.buf = &(*stats_buf)[0]; 180 codec_enc_.rc_twopass_stats_in.buf = &(*stats_buf)[0];
175 codec_enc_.rc_twopass_stats_in.sz = stats_buf->size(); 181 codec_enc_.rc_twopass_stats_in.sz = stats_buf->size();
176 } 182 }
177 InitializeEncoder(); 183 InitializeEncoder();
178 184
179 libvpx_test::I420VideoSource video(test_file_name_, kWidth, kHeight, 185 libvpx_test::I420VideoSource video(test_file_name_,
186 codec_enc_.g_w, codec_enc_.g_h,
180 codec_enc_.g_timebase.den, 187 codec_enc_.g_timebase.den,
181 codec_enc_.g_timebase.num, 0, 30); 188 codec_enc_.g_timebase.num, 0, 30);
182 video.Begin(); 189 video.Begin();
183 190
184 for (int i = 0; i < n; ++i) { 191 for (int i = 0; i < n; ++i) {
185 res = vpx_svc_encode(&svc_, &codec_, video.img(), video.pts(), 192 res = vpx_svc_encode(&svc_, &codec_, video.img(), video.pts(),
186 video.duration(), VPX_DL_GOOD_QUALITY); 193 video.duration(), VPX_DL_GOOD_QUALITY);
187 ASSERT_EQ(VPX_CODEC_OK, res); 194 ASSERT_EQ(VPX_CODEC_OK, res);
188 StoreFrames(n, outputs, &frame_received); 195 StoreFrames(n, outputs, &frame_received);
189 video.Next(); 196 video.Next();
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 } 310 }
304 } 311 }
305 312
306 SvcContext svc_; 313 SvcContext svc_;
307 vpx_codec_ctx_t codec_; 314 vpx_codec_ctx_t codec_;
308 struct vpx_codec_enc_cfg codec_enc_; 315 struct vpx_codec_enc_cfg codec_enc_;
309 vpx_codec_iface_t *codec_iface_; 316 vpx_codec_iface_t *codec_iface_;
310 std::string test_file_name_; 317 std::string test_file_name_;
311 bool codec_initialized_; 318 bool codec_initialized_;
312 Decoder *decoder_; 319 Decoder *decoder_;
320 int tile_columns_;
321 int tile_rows_;
313 }; 322 };
314 323
315 TEST_F(SvcTest, SvcInit) { 324 TEST_F(SvcTest, SvcInit) {
316 // test missing parameters 325 // test missing parameters
317 vpx_codec_err_t res = vpx_svc_init(NULL, &codec_, codec_iface_, &codec_enc_); 326 vpx_codec_err_t res = vpx_svc_init(NULL, &codec_, codec_iface_, &codec_enc_);
318 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); 327 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res);
319 res = vpx_svc_init(&svc_, NULL, codec_iface_, &codec_enc_); 328 res = vpx_svc_init(&svc_, NULL, codec_iface_, &codec_enc_);
320 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); 329 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res);
321 res = vpx_svc_init(&svc_, &codec_, NULL, &codec_enc_); 330 res = vpx_svc_init(&svc_, &codec_, NULL, &codec_enc_);
322 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); 331 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res);
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 Pass2EncodeNFrames(&stats_buf, 10, 1, &outputs[0]); 739 Pass2EncodeNFrames(&stats_buf, 10, 1, &outputs[0]);
731 740
732 vpx_fixed_buf base_layer[5]; 741 vpx_fixed_buf base_layer[5];
733 for (int i = 0; i < 5; ++i) 742 for (int i = 0; i < 5; ++i)
734 base_layer[i] = outputs[i * 2]; 743 base_layer[i] = outputs[i * 2];
735 744
736 DecodeNFrames(&base_layer[0], 5); 745 DecodeNFrames(&base_layer[0], 5);
737 FreeBitstreamBuffers(&outputs[0], 10); 746 FreeBitstreamBuffers(&outputs[0], 10);
738 } 747 }
739 748
749 TEST_F(SvcTest, TwoPassEncode2TemporalLayersWithTiles) {
750 // First pass encode
751 std::string stats_buf;
752 vpx_svc_set_options(&svc_, "scale-factors=1/1");
753 svc_.temporal_layers = 2;
754 Pass1EncodeNFrames(10, 1, &stats_buf);
755
756 // Second pass encode
757 codec_enc_.g_pass = VPX_RC_LAST_PASS;
758 svc_.temporal_layers = 2;
759 vpx_svc_set_options(&svc_, "auto-alt-refs=1 scale-factors=1/1");
760 codec_enc_.g_w = 704;
761 codec_enc_.g_h = 144;
762 tile_columns_ = 1;
763 tile_rows_ = 1;
764 vpx_fixed_buf outputs[10];
765 memset(&outputs[0], 0, sizeof(outputs));
766 Pass2EncodeNFrames(&stats_buf, 10, 1, &outputs[0]);
767 DecodeNFrames(&outputs[0], 10);
768 FreeBitstreamBuffers(&outputs[0], 10);
769 }
770
771 TEST_F(SvcTest,
772 TwoPassEncode2TemporalLayersWithMultipleFrameContextsAndTiles) {
773 // First pass encode
774 std::string stats_buf;
775 vpx_svc_set_options(&svc_, "scale-factors=1/1");
776 svc_.temporal_layers = 2;
777 Pass1EncodeNFrames(10, 1, &stats_buf);
778
779 // Second pass encode
780 codec_enc_.g_pass = VPX_RC_LAST_PASS;
781 svc_.temporal_layers = 2;
782 codec_enc_.g_error_resilient = 0;
783 codec_enc_.g_w = 704;
784 codec_enc_.g_h = 144;
785 tile_columns_ = 1;
786 tile_rows_ = 1;
787 vpx_svc_set_options(&svc_, "auto-alt-refs=1 scale-factors=1/1 "
788 "multi-frame-contexts=1");
789 vpx_fixed_buf outputs[10];
790 memset(&outputs[0], 0, sizeof(outputs));
791 Pass2EncodeNFrames(&stats_buf, 10, 1, &outputs[0]);
792 DecodeNFrames(&outputs[0], 10);
793 FreeBitstreamBuffers(&outputs[0], 10);
794 }
795
740 } // namespace 796 } // namespace
OLDNEW
« no previous file with comments | « source/libvpx/test/set_roi.cc ('k') | source/libvpx/test/test.mk » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698