| 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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); | 227 vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); |
| 228 EXPECT_EQ(VPX_CODEC_OK, res); | 228 EXPECT_EQ(VPX_CODEC_OK, res); |
| 229 codec_initialized_ = true; | 229 codec_initialized_ = true; |
| 230 | 230 |
| 231 libvpx_test::I420VideoSource video(test_file_name_, kWidth, kHeight, | 231 libvpx_test::I420VideoSource video(test_file_name_, kWidth, kHeight, |
| 232 codec_enc_.g_timebase.den, | 232 codec_enc_.g_timebase.den, |
| 233 codec_enc_.g_timebase.num, 0, 30); | 233 codec_enc_.g_timebase.num, 0, 30); |
| 234 video.Begin(); | 234 video.Begin(); |
| 235 | 235 |
| 236 res = vpx_svc_encode(&svc_, &codec_, video.img(), video.pts(), | 236 res = vpx_svc_encode(&svc_, &codec_, video.img(), video.pts(), |
| 237 video.duration(), VPX_DL_REALTIME); | 237 video.duration(), VPX_DL_GOOD_QUALITY); |
| 238 EXPECT_EQ(VPX_CODEC_OK, res); | 238 EXPECT_EQ(VPX_CODEC_OK, res); |
| 239 | 239 |
| 240 const vpx_codec_err_t res_dec = decoder_->DecodeFrame( | 240 const vpx_codec_err_t res_dec = decoder_->DecodeFrame( |
| 241 static_cast<const uint8_t *>(vpx_svc_get_buffer(&svc_)), | 241 static_cast<const uint8_t *>(vpx_svc_get_buffer(&svc_)), |
| 242 vpx_svc_get_frame_size(&svc_)); | 242 vpx_svc_get_frame_size(&svc_)); |
| 243 | 243 |
| 244 // this test fails with a decoder error | 244 // this test fails with a decoder error |
| 245 ASSERT_EQ(VPX_CODEC_OK, res_dec) << decoder_->DecodeError(); | 245 ASSERT_EQ(VPX_CODEC_OK, res_dec) << decoder_->DecodeError(); |
| 246 } | 246 } |
| 247 | 247 |
| 248 TEST_F(SvcTest, EncodeThreeFrames) { | 248 TEST_F(SvcTest, EncodeThreeFrames) { |
| 249 svc_.spatial_layers = 2; | 249 svc_.spatial_layers = 2; |
| 250 vpx_svc_set_scale_factors(&svc_, "4/16,16/16"); | 250 vpx_svc_set_scale_factors(&svc_, "4/16,16/16"); |
| 251 vpx_svc_set_quantizers(&svc_, "40,30"); | 251 vpx_svc_set_quantizers(&svc_, "40,30"); |
| 252 | 252 |
| 253 vpx_codec_err_t res = | 253 vpx_codec_err_t res = |
| 254 vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); | 254 vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); |
| 255 ASSERT_EQ(VPX_CODEC_OK, res); | 255 ASSERT_EQ(VPX_CODEC_OK, res); |
| 256 codec_initialized_ = true; | 256 codec_initialized_ = true; |
| 257 | 257 |
| 258 libvpx_test::I420VideoSource video(test_file_name_, kWidth, kHeight, | 258 libvpx_test::I420VideoSource video(test_file_name_, kWidth, kHeight, |
| 259 codec_enc_.g_timebase.den, | 259 codec_enc_.g_timebase.den, |
| 260 codec_enc_.g_timebase.num, 0, 30); | 260 codec_enc_.g_timebase.num, 0, 30); |
| 261 // FRAME 0 | 261 // FRAME 0 |
| 262 video.Begin(); | 262 video.Begin(); |
| 263 // This frame is a keyframe. | 263 // This frame is a keyframe. |
| 264 res = vpx_svc_encode(&svc_, &codec_, video.img(), video.pts(), | 264 res = vpx_svc_encode(&svc_, &codec_, video.img(), video.pts(), |
| 265 video.duration(), VPX_DL_REALTIME); | 265 video.duration(), VPX_DL_GOOD_QUALITY); |
| 266 ASSERT_EQ(VPX_CODEC_OK, res); | 266 ASSERT_EQ(VPX_CODEC_OK, res); |
| 267 EXPECT_EQ(1, vpx_svc_is_keyframe(&svc_)); | 267 EXPECT_EQ(1, vpx_svc_is_keyframe(&svc_)); |
| 268 | 268 |
| 269 vpx_codec_err_t res_dec = decoder_->DecodeFrame( | 269 vpx_codec_err_t res_dec = decoder_->DecodeFrame( |
| 270 static_cast<const uint8_t *>(vpx_svc_get_buffer(&svc_)), | 270 static_cast<const uint8_t *>(vpx_svc_get_buffer(&svc_)), |
| 271 vpx_svc_get_frame_size(&svc_)); | 271 vpx_svc_get_frame_size(&svc_)); |
| 272 ASSERT_EQ(VPX_CODEC_OK, res_dec) << decoder_->DecodeError(); | 272 ASSERT_EQ(VPX_CODEC_OK, res_dec) << decoder_->DecodeError(); |
| 273 | 273 |
| 274 // FRAME 1 | 274 // FRAME 1 |
| 275 video.Next(); | 275 video.Next(); |
| 276 // This is a P-frame. | 276 // This is a P-frame. |
| 277 res = vpx_svc_encode(&svc_, &codec_, video.img(), video.pts(), | 277 res = vpx_svc_encode(&svc_, &codec_, video.img(), video.pts(), |
| 278 video.duration(), VPX_DL_REALTIME); | 278 video.duration(), VPX_DL_GOOD_QUALITY); |
| 279 ASSERT_EQ(VPX_CODEC_OK, res); | 279 ASSERT_EQ(VPX_CODEC_OK, res); |
| 280 EXPECT_EQ(0, vpx_svc_is_keyframe(&svc_)); | 280 EXPECT_EQ(0, vpx_svc_is_keyframe(&svc_)); |
| 281 | 281 |
| 282 res_dec = decoder_->DecodeFrame( | 282 res_dec = decoder_->DecodeFrame( |
| 283 static_cast<const uint8_t *>(vpx_svc_get_buffer(&svc_)), | 283 static_cast<const uint8_t *>(vpx_svc_get_buffer(&svc_)), |
| 284 vpx_svc_get_frame_size(&svc_)); | 284 vpx_svc_get_frame_size(&svc_)); |
| 285 ASSERT_EQ(VPX_CODEC_OK, res_dec) << decoder_->DecodeError(); | 285 ASSERT_EQ(VPX_CODEC_OK, res_dec) << decoder_->DecodeError(); |
| 286 | 286 |
| 287 // FRAME 2 | 287 // FRAME 2 |
| 288 video.Next(); | 288 video.Next(); |
| 289 // This is a P-frame. | 289 // This is a P-frame. |
| 290 res = vpx_svc_encode(&svc_, &codec_, video.img(), video.pts(), | 290 res = vpx_svc_encode(&svc_, &codec_, video.img(), video.pts(), |
| 291 video.duration(), VPX_DL_REALTIME); | 291 video.duration(), VPX_DL_GOOD_QUALITY); |
| 292 ASSERT_EQ(VPX_CODEC_OK, res); | 292 ASSERT_EQ(VPX_CODEC_OK, res); |
| 293 EXPECT_EQ(0, vpx_svc_is_keyframe(&svc_)); | 293 EXPECT_EQ(0, vpx_svc_is_keyframe(&svc_)); |
| 294 | 294 |
| 295 res_dec = decoder_->DecodeFrame( | 295 res_dec = decoder_->DecodeFrame( |
| 296 static_cast<const uint8_t *>(vpx_svc_get_buffer(&svc_)), | 296 static_cast<const uint8_t *>(vpx_svc_get_buffer(&svc_)), |
| 297 vpx_svc_get_frame_size(&svc_)); | 297 vpx_svc_get_frame_size(&svc_)); |
| 298 ASSERT_EQ(VPX_CODEC_OK, res_dec) << decoder_->DecodeError(); | 298 ASSERT_EQ(VPX_CODEC_OK, res_dec) << decoder_->DecodeError(); |
| 299 } | 299 } |
| 300 | 300 |
| 301 TEST_F(SvcTest, GetLayerResolution) { | 301 TEST_F(SvcTest, GetLayerResolution) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 328 EXPECT_EQ(kWidth * 4 / 16, layer_width); | 328 EXPECT_EQ(kWidth * 4 / 16, layer_width); |
| 329 EXPECT_EQ(kHeight * 4 / 16, layer_height); | 329 EXPECT_EQ(kHeight * 4 / 16, layer_height); |
| 330 | 330 |
| 331 res = vpx_svc_get_layer_resolution(&svc_, 1, &layer_width, &layer_height); | 331 res = vpx_svc_get_layer_resolution(&svc_, 1, &layer_width, &layer_height); |
| 332 EXPECT_EQ(VPX_CODEC_OK, res); | 332 EXPECT_EQ(VPX_CODEC_OK, res); |
| 333 EXPECT_EQ(kWidth * 8 / 16, layer_width); | 333 EXPECT_EQ(kWidth * 8 / 16, layer_width); |
| 334 EXPECT_EQ(kHeight * 8 / 16, layer_height); | 334 EXPECT_EQ(kHeight * 8 / 16, layer_height); |
| 335 } | 335 } |
| 336 | 336 |
| 337 } // namespace | 337 } // namespace |
| OLD | NEW |