OLD | NEW |
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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 EXPECT_EQ(VPX_CODEC_OK, res); | 160 EXPECT_EQ(VPX_CODEC_OK, res); |
161 res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); | 161 res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); |
162 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); | 162 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); |
163 | 163 |
164 vpx_svc_set_options(&svc_, "quantizers=40,45"); | 164 vpx_svc_set_options(&svc_, "quantizers=40,45"); |
165 res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); | 165 res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); |
166 EXPECT_EQ(VPX_CODEC_OK, res); | 166 EXPECT_EQ(VPX_CODEC_OK, res); |
167 codec_initialized_ = true; | 167 codec_initialized_ = true; |
168 } | 168 } |
169 | 169 |
| 170 TEST_F(SvcTest, SetAutoAltRefOption) { |
| 171 svc_.spatial_layers = 5; |
| 172 vpx_codec_err_t res = vpx_svc_set_options(&svc_, "auto-alt-refs=none"); |
| 173 EXPECT_EQ(VPX_CODEC_OK, res); |
| 174 res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); |
| 175 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); |
| 176 |
| 177 res = vpx_svc_set_options(&svc_, "auto-alt-refs=1,1,1,1,0"); |
| 178 EXPECT_EQ(VPX_CODEC_OK, res); |
| 179 res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); |
| 180 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); |
| 181 |
| 182 vpx_svc_set_options(&svc_, "auto-alt-refs=0,1,1,1,0"); |
| 183 res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); |
| 184 EXPECT_EQ(VPX_CODEC_OK, res); |
| 185 codec_initialized_ = true; |
| 186 } |
| 187 |
170 TEST_F(SvcTest, SetQuantizers) { | 188 TEST_F(SvcTest, SetQuantizers) { |
171 vpx_codec_err_t res = vpx_svc_set_quantizers(NULL, "40,30"); | 189 vpx_codec_err_t res = vpx_svc_set_quantizers(NULL, "40,30"); |
172 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); | 190 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); |
173 | 191 |
174 res = vpx_svc_set_quantizers(&svc_, NULL); | 192 res = vpx_svc_set_quantizers(&svc_, NULL); |
175 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); | 193 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); |
176 | 194 |
177 svc_.spatial_layers = 2; | 195 svc_.spatial_layers = 2; |
178 res = vpx_svc_set_quantizers(&svc_, "40"); | 196 res = vpx_svc_set_quantizers(&svc_, "40"); |
179 EXPECT_EQ(VPX_CODEC_OK, res); | 197 EXPECT_EQ(VPX_CODEC_OK, res); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 EXPECT_EQ(kHeight * 8 / 16, layer_height); | 373 EXPECT_EQ(kHeight * 8 / 16, layer_height); |
356 } | 374 } |
357 | 375 |
358 TEST_F(SvcTest, TwoPassEncode) { | 376 TEST_F(SvcTest, TwoPassEncode) { |
359 // First pass encode | 377 // First pass encode |
360 std::string stats_buf; | 378 std::string stats_buf; |
361 svc_.spatial_layers = 2; | 379 svc_.spatial_layers = 2; |
362 codec_enc_.g_pass = VPX_RC_FIRST_PASS; | 380 codec_enc_.g_pass = VPX_RC_FIRST_PASS; |
363 vpx_svc_set_scale_factors(&svc_, "4/16,16/16"); | 381 vpx_svc_set_scale_factors(&svc_, "4/16,16/16"); |
364 vpx_svc_set_quantizers(&svc_, "40,30"); | 382 vpx_svc_set_quantizers(&svc_, "40,30"); |
| 383 vpx_svc_set_options(&svc_, "auto-alt-refs=1,1"); |
365 | 384 |
366 vpx_codec_err_t res = | 385 vpx_codec_err_t res = |
367 vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); | 386 vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); |
368 ASSERT_EQ(VPX_CODEC_OK, res); | 387 ASSERT_EQ(VPX_CODEC_OK, res); |
369 codec_initialized_ = true; | 388 codec_initialized_ = true; |
370 | 389 |
371 libvpx_test::I420VideoSource video(test_file_name_, kWidth, kHeight, | 390 libvpx_test::I420VideoSource video(test_file_name_, kWidth, kHeight, |
372 codec_enc_.g_timebase.den, | 391 codec_enc_.g_timebase.den, |
373 codec_enc_.g_timebase.num, 0, 30); | 392 codec_enc_.g_timebase.num, 0, 30); |
374 // FRAME 0 | 393 // FRAME 0 |
(...skipping 28 matching lines...) Expand all Loading... |
403 | 422 |
404 // Tear down encoder | 423 // Tear down encoder |
405 vpx_svc_release(&svc_); | 424 vpx_svc_release(&svc_); |
406 vpx_codec_destroy(&codec_); | 425 vpx_codec_destroy(&codec_); |
407 | 426 |
408 // Second pass encode | 427 // Second pass encode |
409 int decoded_frames = 0; | 428 int decoded_frames = 0; |
410 vpx_codec_err_t res_dec; | 429 vpx_codec_err_t res_dec; |
411 int frame_size; | 430 int frame_size; |
412 codec_enc_.g_pass = VPX_RC_LAST_PASS; | 431 codec_enc_.g_pass = VPX_RC_LAST_PASS; |
| 432 vpx_svc_set_scale_factors(&svc_, "4/16,16/16"); |
| 433 vpx_svc_set_quantizers(&svc_, "40,30"); |
| 434 vpx_svc_set_options(&svc_, "auto-alt-refs=1,1"); |
413 codec_enc_.rc_twopass_stats_in.buf = &stats_buf[0]; | 435 codec_enc_.rc_twopass_stats_in.buf = &stats_buf[0]; |
414 codec_enc_.rc_twopass_stats_in.sz = stats_buf.size(); | 436 codec_enc_.rc_twopass_stats_in.sz = stats_buf.size(); |
415 | 437 |
416 res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); | 438 res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); |
417 ASSERT_EQ(VPX_CODEC_OK, res); | 439 ASSERT_EQ(VPX_CODEC_OK, res); |
418 codec_initialized_ = true; | 440 codec_initialized_ = true; |
419 | 441 |
420 // FRAME 0 | 442 // FRAME 0 |
421 video.Begin(); | 443 video.Begin(); |
422 // This frame is a keyframe. | 444 // This frame is a keyframe. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 res_dec = decoder_->DecodeFrame( | 494 res_dec = decoder_->DecodeFrame( |
473 static_cast<const uint8_t *>(vpx_svc_get_buffer(&svc_)), frame_size); | 495 static_cast<const uint8_t *>(vpx_svc_get_buffer(&svc_)), frame_size); |
474 ASSERT_EQ(VPX_CODEC_OK, res_dec) << decoder_->DecodeError(); | 496 ASSERT_EQ(VPX_CODEC_OK, res_dec) << decoder_->DecodeError(); |
475 ++decoded_frames; | 497 ++decoded_frames; |
476 } | 498 } |
477 | 499 |
478 EXPECT_EQ(decoded_frames, 3); | 500 EXPECT_EQ(decoded_frames, 3); |
479 } | 501 } |
480 | 502 |
481 } // namespace | 503 } // namespace |
OLD | NEW |