| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 | 67 |
| 68 virtual void TearDown() { | 68 virtual void TearDown() { |
| 69 ReleaseEncoder(); | 69 ReleaseEncoder(); |
| 70 delete(decoder_); | 70 delete(decoder_); |
| 71 } | 71 } |
| 72 | 72 |
| 73 void InitializeEncoder() { | 73 void InitializeEncoder() { |
| 74 const vpx_codec_err_t res = | 74 const vpx_codec_err_t res = |
| 75 vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); | 75 vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); |
| 76 EXPECT_EQ(VPX_CODEC_OK, res); | 76 EXPECT_EQ(VPX_CODEC_OK, res); |
| 77 vpx_codec_control(&codec_, VP8E_SET_CPUUSED, 4); // Make the test faster |
| 77 codec_initialized_ = true; | 78 codec_initialized_ = true; |
| 78 } | 79 } |
| 79 | 80 |
| 80 void ReleaseEncoder() { | 81 void ReleaseEncoder() { |
| 81 vpx_svc_release(&svc_); | 82 vpx_svc_release(&svc_); |
| 82 if (codec_initialized_) vpx_codec_destroy(&codec_); | 83 if (codec_initialized_) vpx_codec_destroy(&codec_); |
| 83 codec_initialized_ = false; | 84 codec_initialized_ = false; |
| 84 } | 85 } |
| 85 | 86 |
| 87 void GetStatsData(std::string *const stats_buf) { |
| 88 vpx_codec_iter_t iter = NULL; |
| 89 const vpx_codec_cx_pkt_t *cx_pkt; |
| 90 |
| 91 while ((cx_pkt = vpx_codec_get_cx_data(&codec_, &iter)) != NULL) { |
| 92 if (cx_pkt->kind == VPX_CODEC_STATS_PKT) { |
| 93 EXPECT_GT(cx_pkt->data.twopass_stats.sz, 0U); |
| 94 ASSERT_TRUE(cx_pkt->data.twopass_stats.buf != NULL); |
| 95 stats_buf->append(static_cast<char*>(cx_pkt->data.twopass_stats.buf), |
| 96 cx_pkt->data.twopass_stats.sz); |
| 97 } |
| 98 } |
| 99 } |
| 100 |
| 86 void Pass1EncodeNFrames(const int n, const int layers, | 101 void Pass1EncodeNFrames(const int n, const int layers, |
| 87 std::string *const stats_buf) { | 102 std::string *const stats_buf) { |
| 88 vpx_codec_err_t res; | 103 vpx_codec_err_t res; |
| 89 size_t stats_size = 0; | |
| 90 const char *stats_data = NULL; | |
| 91 | 104 |
| 92 ASSERT_GT(n, 0); | 105 ASSERT_GT(n, 0); |
| 93 ASSERT_GT(layers, 0); | 106 ASSERT_GT(layers, 0); |
| 94 svc_.spatial_layers = layers; | 107 svc_.spatial_layers = layers; |
| 95 codec_enc_.g_pass = VPX_RC_FIRST_PASS; | 108 codec_enc_.g_pass = VPX_RC_FIRST_PASS; |
| 96 InitializeEncoder(); | 109 InitializeEncoder(); |
| 97 | 110 |
| 98 libvpx_test::I420VideoSource video(test_file_name_, kWidth, kHeight, | 111 libvpx_test::I420VideoSource video(test_file_name_, kWidth, kHeight, |
| 99 codec_enc_.g_timebase.den, | 112 codec_enc_.g_timebase.den, |
| 100 codec_enc_.g_timebase.num, 0, 30); | 113 codec_enc_.g_timebase.num, 0, 30); |
| 101 video.Begin(); | 114 video.Begin(); |
| 102 | 115 |
| 103 for (int i = 0; i < n; ++i) { | 116 for (int i = 0; i < n; ++i) { |
| 104 res = vpx_svc_encode(&svc_, &codec_, video.img(), video.pts(), | 117 res = vpx_svc_encode(&svc_, &codec_, video.img(), video.pts(), |
| 105 video.duration(), VPX_DL_GOOD_QUALITY); | 118 video.duration(), VPX_DL_GOOD_QUALITY); |
| 106 ASSERT_EQ(VPX_CODEC_OK, res); | 119 ASSERT_EQ(VPX_CODEC_OK, res); |
| 107 stats_size = vpx_svc_get_rc_stats_buffer_size(&svc_); | 120 GetStatsData(stats_buf); |
| 108 EXPECT_GT(stats_size, 0U); | |
| 109 stats_data = vpx_svc_get_rc_stats_buffer(&svc_); | |
| 110 ASSERT_TRUE(stats_data != NULL); | |
| 111 stats_buf->append(stats_data, stats_size); | |
| 112 video.Next(); | 121 video.Next(); |
| 113 } | 122 } |
| 114 | 123 |
| 115 // Flush encoder and test EOS packet. | 124 // Flush encoder and test EOS packet. |
| 116 res = vpx_svc_encode(&svc_, &codec_, NULL, video.pts(), | 125 res = vpx_svc_encode(&svc_, &codec_, NULL, video.pts(), |
| 117 video.duration(), VPX_DL_GOOD_QUALITY); | 126 video.duration(), VPX_DL_GOOD_QUALITY); |
| 118 stats_size = vpx_svc_get_rc_stats_buffer_size(&svc_); | 127 ASSERT_EQ(VPX_CODEC_OK, res); |
| 119 EXPECT_GT(stats_size, 0U); | 128 GetStatsData(stats_buf); |
| 120 stats_data = vpx_svc_get_rc_stats_buffer(&svc_); | |
| 121 ASSERT_TRUE(stats_data != NULL); | |
| 122 stats_buf->append(stats_data, stats_size); | |
| 123 | 129 |
| 124 ReleaseEncoder(); | 130 ReleaseEncoder(); |
| 125 } | 131 } |
| 126 | 132 |
| 127 void StoreFrames(const size_t max_frame_received, | 133 void StoreFrames(const size_t max_frame_received, |
| 128 struct vpx_fixed_buf *const outputs, | 134 struct vpx_fixed_buf *const outputs, |
| 129 size_t *const frame_received) { | 135 size_t *const frame_received) { |
| 130 size_t frame_size; | 136 vpx_codec_iter_t iter = NULL; |
| 131 while ((frame_size = vpx_svc_get_frame_size(&svc_)) > 0) { | 137 const vpx_codec_cx_pkt_t *cx_pkt; |
| 132 ASSERT_LT(*frame_received, max_frame_received); | |
| 133 | 138 |
| 134 if (*frame_received == 0) { | 139 while ((cx_pkt = vpx_codec_get_cx_data(&codec_, &iter)) != NULL) { |
| 135 EXPECT_EQ(1, vpx_svc_is_keyframe(&svc_)); | 140 if (cx_pkt->kind == VPX_CODEC_CX_FRAME_PKT) { |
| 141 const size_t frame_size = cx_pkt->data.frame.sz; |
| 142 |
| 143 EXPECT_GT(frame_size, 0U); |
| 144 ASSERT_TRUE(cx_pkt->data.frame.buf != NULL); |
| 145 ASSERT_LT(*frame_received, max_frame_received); |
| 146 |
| 147 if (*frame_received == 0) |
| 148 EXPECT_EQ(1, !!(cx_pkt->data.frame.flags & VPX_FRAME_IS_KEY)); |
| 149 |
| 150 outputs[*frame_received].buf = malloc(frame_size + 16); |
| 151 ASSERT_TRUE(outputs[*frame_received].buf != NULL); |
| 152 memcpy(outputs[*frame_received].buf, cx_pkt->data.frame.buf, |
| 153 frame_size); |
| 154 outputs[*frame_received].sz = frame_size; |
| 155 ++(*frame_received); |
| 136 } | 156 } |
| 137 | |
| 138 outputs[*frame_received].buf = malloc(frame_size + 16); | |
| 139 ASSERT_TRUE(outputs[*frame_received].buf != NULL); | |
| 140 memcpy(outputs[*frame_received].buf, vpx_svc_get_buffer(&svc_), | |
| 141 frame_size); | |
| 142 outputs[*frame_received].sz = frame_size; | |
| 143 ++(*frame_received); | |
| 144 } | 157 } |
| 145 } | 158 } |
| 146 | 159 |
| 147 void Pass2EncodeNFrames(std::string *const stats_buf, | 160 void Pass2EncodeNFrames(std::string *const stats_buf, |
| 148 const int n, const int layers, | 161 const int n, const int layers, |
| 149 struct vpx_fixed_buf *const outputs) { | 162 struct vpx_fixed_buf *const outputs) { |
| 150 vpx_codec_err_t res; | 163 vpx_codec_err_t res; |
| 151 size_t frame_received = 0; | 164 size_t frame_received = 0; |
| 152 | 165 |
| 153 ASSERT_TRUE(outputs != NULL); | 166 ASSERT_TRUE(outputs != NULL); |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 res = vpx_svc_init(&svc_, &codec_, codec_iface_, &codec_enc_); | 392 res = vpx_svc_init(&svc_, &codec_, codec_iface_, &codec_enc_); |
| 380 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); | 393 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); |
| 381 | 394 |
| 382 svc_.spatial_layers = 0; // use default layers | 395 svc_.spatial_layers = 0; // use default layers |
| 383 InitializeEncoder(); | 396 InitializeEncoder(); |
| 384 EXPECT_EQ(VPX_SS_DEFAULT_LAYERS, svc_.spatial_layers); | 397 EXPECT_EQ(VPX_SS_DEFAULT_LAYERS, svc_.spatial_layers); |
| 385 } | 398 } |
| 386 | 399 |
| 387 TEST_F(SvcTest, InitTwoLayers) { | 400 TEST_F(SvcTest, InitTwoLayers) { |
| 388 svc_.spatial_layers = 2; | 401 svc_.spatial_layers = 2; |
| 389 vpx_svc_set_scale_factors(&svc_, "4/16,16*16"); // invalid scale values | |
| 390 vpx_codec_err_t res = vpx_svc_init(&svc_, &codec_, codec_iface_, &codec_enc_); | |
| 391 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); | |
| 392 | |
| 393 vpx_svc_set_scale_factors(&svc_, "4/16,16/16"); // valid scale values | |
| 394 InitializeEncoder(); | 402 InitializeEncoder(); |
| 395 } | 403 } |
| 396 | 404 |
| 397 TEST_F(SvcTest, InvalidOptions) { | 405 TEST_F(SvcTest, InvalidOptions) { |
| 398 vpx_codec_err_t res = vpx_svc_set_options(&svc_, NULL); | 406 vpx_codec_err_t res = vpx_svc_set_options(&svc_, NULL); |
| 399 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); | 407 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); |
| 400 | 408 |
| 401 res = vpx_svc_set_options(&svc_, "not-an-option=1"); | 409 res = vpx_svc_set_options(&svc_, "not-an-option=1"); |
| 402 EXPECT_EQ(VPX_CODEC_OK, res); | 410 EXPECT_EQ(VPX_CODEC_OK, res); |
| 403 res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); | 411 res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 420 } | 428 } |
| 421 | 429 |
| 422 TEST_F(SvcTest, SetScaleFactorsOption) { | 430 TEST_F(SvcTest, SetScaleFactorsOption) { |
| 423 svc_.spatial_layers = 2; | 431 svc_.spatial_layers = 2; |
| 424 vpx_codec_err_t res = | 432 vpx_codec_err_t res = |
| 425 vpx_svc_set_options(&svc_, "scale-factors=not-scale-factors"); | 433 vpx_svc_set_options(&svc_, "scale-factors=not-scale-factors"); |
| 426 EXPECT_EQ(VPX_CODEC_OK, res); | 434 EXPECT_EQ(VPX_CODEC_OK, res); |
| 427 res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); | 435 res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); |
| 428 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); | 436 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); |
| 429 | 437 |
| 438 res = vpx_svc_set_options(&svc_, "scale-factors=1/3, 3*3"); |
| 439 EXPECT_EQ(VPX_CODEC_OK, res); |
| 440 res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); |
| 441 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); |
| 442 |
| 443 res = vpx_svc_set_options(&svc_, "scale-factors=1/3"); |
| 444 EXPECT_EQ(VPX_CODEC_OK, res); |
| 445 res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); |
| 446 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); |
| 447 |
| 430 res = vpx_svc_set_options(&svc_, "scale-factors=1/3,2/3"); | 448 res = vpx_svc_set_options(&svc_, "scale-factors=1/3,2/3"); |
| 431 EXPECT_EQ(VPX_CODEC_OK, res); | 449 EXPECT_EQ(VPX_CODEC_OK, res); |
| 432 InitializeEncoder(); | 450 InitializeEncoder(); |
| 433 } | 451 } |
| 434 | 452 |
| 435 TEST_F(SvcTest, SetQuantizersOption) { | 453 TEST_F(SvcTest, SetQuantizersOption) { |
| 436 svc_.spatial_layers = 2; | 454 svc_.spatial_layers = 2; |
| 437 vpx_codec_err_t res = vpx_svc_set_options(&svc_, "quantizers=not-quantizers"); | 455 vpx_codec_err_t res = vpx_svc_set_options(&svc_, "max-quantizers=nothing"); |
| 438 EXPECT_EQ(VPX_CODEC_OK, res); | 456 EXPECT_EQ(VPX_CODEC_OK, res); |
| 439 res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); | 457 res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); |
| 440 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); | 458 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); |
| 441 | 459 |
| 442 vpx_svc_set_options(&svc_, "quantizers=40,45"); | 460 res = vpx_svc_set_options(&svc_, "min-quantizers=nothing"); |
| 461 EXPECT_EQ(VPX_CODEC_OK, res); |
| 462 res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); |
| 463 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); |
| 464 |
| 465 res = vpx_svc_set_options(&svc_, "max-quantizers=40"); |
| 466 EXPECT_EQ(VPX_CODEC_OK, res); |
| 467 res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); |
| 468 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); |
| 469 |
| 470 res = vpx_svc_set_options(&svc_, "min-quantizers=40"); |
| 471 EXPECT_EQ(VPX_CODEC_OK, res); |
| 472 res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); |
| 473 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); |
| 474 |
| 475 res = vpx_svc_set_options(&svc_, "max-quantizers=30,30 min-quantizers=40,40"); |
| 476 EXPECT_EQ(VPX_CODEC_OK, res); |
| 477 res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); |
| 478 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); |
| 479 |
| 480 res = vpx_svc_set_options(&svc_, "max-quantizers=40,40 min-quantizers=30,30"); |
| 443 InitializeEncoder(); | 481 InitializeEncoder(); |
| 444 } | 482 } |
| 445 | 483 |
| 446 TEST_F(SvcTest, SetAutoAltRefOption) { | 484 TEST_F(SvcTest, SetAutoAltRefOption) { |
| 447 svc_.spatial_layers = 5; | 485 svc_.spatial_layers = 5; |
| 448 vpx_codec_err_t res = vpx_svc_set_options(&svc_, "auto-alt-refs=none"); | 486 vpx_codec_err_t res = vpx_svc_set_options(&svc_, "auto-alt-refs=none"); |
| 449 EXPECT_EQ(VPX_CODEC_OK, res); | 487 EXPECT_EQ(VPX_CODEC_OK, res); |
| 450 res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); | 488 res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); |
| 451 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); | 489 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); |
| 452 | 490 |
| 453 res = vpx_svc_set_options(&svc_, "auto-alt-refs=1,1,1,1,0"); | 491 res = vpx_svc_set_options(&svc_, "auto-alt-refs=1,1,1,1,0"); |
| 454 EXPECT_EQ(VPX_CODEC_OK, res); | 492 EXPECT_EQ(VPX_CODEC_OK, res); |
| 455 res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); | 493 res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); |
| 456 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); | 494 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); |
| 457 | 495 |
| 458 vpx_svc_set_options(&svc_, "auto-alt-refs=0,1,1,1,0"); | 496 vpx_svc_set_options(&svc_, "auto-alt-refs=0,1,1,1,0"); |
| 459 InitializeEncoder(); | 497 InitializeEncoder(); |
| 460 } | 498 } |
| 461 | 499 |
| 462 TEST_F(SvcTest, SetQuantizers) { | |
| 463 vpx_codec_err_t res = vpx_svc_set_quantizers(NULL, "40,30"); | |
| 464 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); | |
| 465 | |
| 466 res = vpx_svc_set_quantizers(&svc_, NULL); | |
| 467 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); | |
| 468 | |
| 469 svc_.spatial_layers = 2; | |
| 470 res = vpx_svc_set_quantizers(&svc_, "40"); | |
| 471 EXPECT_EQ(VPX_CODEC_OK, res); | |
| 472 res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); | |
| 473 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); | |
| 474 | |
| 475 res = vpx_svc_set_quantizers(&svc_, "40,30"); | |
| 476 EXPECT_EQ(VPX_CODEC_OK, res); | |
| 477 InitializeEncoder(); | |
| 478 } | |
| 479 | |
| 480 TEST_F(SvcTest, SetScaleFactors) { | |
| 481 vpx_codec_err_t res = vpx_svc_set_scale_factors(NULL, "4/16,16/16"); | |
| 482 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); | |
| 483 | |
| 484 res = vpx_svc_set_scale_factors(&svc_, NULL); | |
| 485 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); | |
| 486 | |
| 487 svc_.spatial_layers = 2; | |
| 488 res = vpx_svc_set_scale_factors(&svc_, "4/16"); | |
| 489 EXPECT_EQ(VPX_CODEC_OK, res); | |
| 490 res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); | |
| 491 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); | |
| 492 | |
| 493 res = vpx_svc_set_scale_factors(&svc_, "4/16,16/16"); | |
| 494 EXPECT_EQ(VPX_CODEC_OK, res); | |
| 495 InitializeEncoder(); | |
| 496 } | |
| 497 | |
| 498 // Test that decoder can handle an SVC frame as the first frame in a sequence. | 500 // Test that decoder can handle an SVC frame as the first frame in a sequence. |
| 499 TEST_F(SvcTest, OnePassEncodeOneFrame) { | 501 TEST_F(SvcTest, OnePassEncodeOneFrame) { |
| 500 codec_enc_.g_pass = VPX_RC_ONE_PASS; | 502 codec_enc_.g_pass = VPX_RC_ONE_PASS; |
| 501 vpx_fixed_buf output = {0}; | 503 vpx_fixed_buf output = {0}; |
| 502 Pass2EncodeNFrames(NULL, 1, 2, &output); | 504 Pass2EncodeNFrames(NULL, 1, 2, &output); |
| 503 DecodeNFrames(&output, 1); | 505 DecodeNFrames(&output, 1); |
| 504 FreeBitstreamBuffers(&output, 1); | 506 FreeBitstreamBuffers(&output, 1); |
| 505 } | 507 } |
| 506 | 508 |
| 507 TEST_F(SvcTest, OnePassEncodeThreeFrames) { | 509 TEST_F(SvcTest, OnePassEncodeThreeFrames) { |
| 508 codec_enc_.g_pass = VPX_RC_ONE_PASS; | 510 codec_enc_.g_pass = VPX_RC_ONE_PASS; |
| 509 vpx_fixed_buf outputs[3]; | 511 vpx_fixed_buf outputs[3]; |
| 510 memset(&outputs[0], 0, sizeof(outputs)); | 512 memset(&outputs[0], 0, sizeof(outputs)); |
| 511 Pass2EncodeNFrames(NULL, 3, 2, &outputs[0]); | 513 Pass2EncodeNFrames(NULL, 3, 2, &outputs[0]); |
| 512 DecodeNFrames(&outputs[0], 3); | 514 DecodeNFrames(&outputs[0], 3); |
| 513 FreeBitstreamBuffers(&outputs[0], 3); | 515 FreeBitstreamBuffers(&outputs[0], 3); |
| 514 } | 516 } |
| 515 | 517 |
| 516 TEST_F(SvcTest, GetLayerResolution) { | |
| 517 svc_.spatial_layers = 2; | |
| 518 vpx_svc_set_scale_factors(&svc_, "4/16,8/16"); | |
| 519 vpx_svc_set_quantizers(&svc_, "40,30"); | |
| 520 | |
| 521 InitializeEncoder(); | |
| 522 | |
| 523 // ensure that requested layer is a valid layer | |
| 524 uint32_t layer_width, layer_height; | |
| 525 vpx_codec_err_t res = vpx_svc_get_layer_resolution(&svc_, svc_.spatial_layers, | |
| 526 &layer_width, &layer_height); | |
| 527 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); | |
| 528 | |
| 529 res = vpx_svc_get_layer_resolution(NULL, 0, &layer_width, &layer_height); | |
| 530 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); | |
| 531 | |
| 532 res = vpx_svc_get_layer_resolution(&svc_, 0, NULL, &layer_height); | |
| 533 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); | |
| 534 | |
| 535 res = vpx_svc_get_layer_resolution(&svc_, 0, &layer_width, NULL); | |
| 536 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); | |
| 537 | |
| 538 res = vpx_svc_get_layer_resolution(&svc_, 0, &layer_width, &layer_height); | |
| 539 EXPECT_EQ(VPX_CODEC_OK, res); | |
| 540 EXPECT_EQ(kWidth * 4 / 16, layer_width); | |
| 541 EXPECT_EQ(kHeight * 4 / 16, layer_height); | |
| 542 | |
| 543 res = vpx_svc_get_layer_resolution(&svc_, 1, &layer_width, &layer_height); | |
| 544 EXPECT_EQ(VPX_CODEC_OK, res); | |
| 545 EXPECT_EQ(kWidth * 8 / 16, layer_width); | |
| 546 EXPECT_EQ(kHeight * 8 / 16, layer_height); | |
| 547 } | |
| 548 | |
| 549 TEST_F(SvcTest, TwoPassEncode10Frames) { | 518 TEST_F(SvcTest, TwoPassEncode10Frames) { |
| 550 // First pass encode | 519 // First pass encode |
| 551 std::string stats_buf; | 520 std::string stats_buf; |
| 552 Pass1EncodeNFrames(10, 2, &stats_buf); | 521 Pass1EncodeNFrames(10, 2, &stats_buf); |
| 553 | 522 |
| 554 // Second pass encode | 523 // Second pass encode |
| 555 codec_enc_.g_pass = VPX_RC_LAST_PASS; | 524 codec_enc_.g_pass = VPX_RC_LAST_PASS; |
| 556 vpx_fixed_buf outputs[10]; | 525 vpx_fixed_buf outputs[10]; |
| 557 memset(&outputs[0], 0, sizeof(outputs)); | 526 memset(&outputs[0], 0, sizeof(outputs)); |
| 558 Pass2EncodeNFrames(&stats_buf, 10, 2, &outputs[0]); | 527 Pass2EncodeNFrames(&stats_buf, 10, 2, &outputs[0]); |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 | 818 |
| 850 vpx_fixed_buf base_layer[5]; | 819 vpx_fixed_buf base_layer[5]; |
| 851 for (int i = 0; i < 5; ++i) | 820 for (int i = 0; i < 5; ++i) |
| 852 base_layer[i] = outputs[i * 2]; | 821 base_layer[i] = outputs[i * 2]; |
| 853 | 822 |
| 854 DecodeNFrames(&base_layer[0], 5); | 823 DecodeNFrames(&base_layer[0], 5); |
| 855 FreeBitstreamBuffers(&outputs[0], 10); | 824 FreeBitstreamBuffers(&outputs[0], 10); |
| 856 } | 825 } |
| 857 | 826 |
| 858 } // namespace | 827 } // namespace |
| OLD | NEW |