| 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 EXPECT_EQ(VPX_CODEC_OK, res); | 170 EXPECT_EQ(VPX_CODEC_OK, res); |
| 171 res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); | 171 res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); |
| 172 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); | 172 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); |
| 173 | 173 |
| 174 vpx_svc_set_options(&svc_, "quantizers=40,45"); | 174 vpx_svc_set_options(&svc_, "quantizers=40,45"); |
| 175 res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); | 175 res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); |
| 176 EXPECT_EQ(VPX_CODEC_OK, res); | 176 EXPECT_EQ(VPX_CODEC_OK, res); |
| 177 codec_initialized_ = true; | 177 codec_initialized_ = true; |
| 178 } | 178 } |
| 179 | 179 |
| 180 TEST_F(SvcTest, SetKeyFrameQuantizersOption) { |
| 181 svc_.spatial_layers = 2; |
| 182 vpx_codec_err_t res = vpx_svc_set_options(&svc_, |
| 183 "quantizers-keyframe=not-quantizers"); |
| 184 EXPECT_EQ(VPX_CODEC_OK, res); |
| 185 res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); |
| 186 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); |
| 187 |
| 188 vpx_svc_set_options(&svc_, "quantizers-keyframe=40,45"); |
| 189 res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); |
| 190 EXPECT_EQ(VPX_CODEC_OK, res); |
| 191 codec_initialized_ = true; |
| 192 } |
| 193 |
| 180 TEST_F(SvcTest, SetQuantizers) { | 194 TEST_F(SvcTest, SetQuantizers) { |
| 181 vpx_codec_err_t res = vpx_svc_set_quantizers(NULL, "40,30"); | 195 vpx_codec_err_t res = vpx_svc_set_quantizers(NULL, "40,30", 0); |
| 182 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); | 196 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); |
| 183 | 197 |
| 184 res = vpx_svc_set_quantizers(&svc_, NULL); | 198 res = vpx_svc_set_quantizers(&svc_, NULL, 0); |
| 185 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); | 199 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); |
| 186 | 200 |
| 187 svc_.spatial_layers = 2; | 201 svc_.spatial_layers = 2; |
| 188 res = vpx_svc_set_quantizers(&svc_, "40"); | 202 res = vpx_svc_set_quantizers(&svc_, "40", 0); |
| 189 EXPECT_EQ(VPX_CODEC_OK, res); | 203 EXPECT_EQ(VPX_CODEC_OK, res); |
| 190 res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); | 204 res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); |
| 191 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); | 205 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); |
| 192 | 206 |
| 193 res = vpx_svc_set_quantizers(&svc_, "40,30"); | 207 res = vpx_svc_set_quantizers(&svc_, "40,30", 0); |
| 208 EXPECT_EQ(VPX_CODEC_OK, res); |
| 209 res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); |
| 210 EXPECT_EQ(VPX_CODEC_OK, res); |
| 211 codec_initialized_ = true; |
| 212 } |
| 213 |
| 214 TEST_F(SvcTest, SetKeyFrameQuantizers) { |
| 215 vpx_codec_err_t res = vpx_svc_set_quantizers(NULL, "40,31", 1); |
| 216 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); |
| 217 |
| 218 res = vpx_svc_set_quantizers(&svc_, NULL, 1); |
| 219 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); |
| 220 |
| 221 res = vpx_svc_set_quantizers(&svc_, "40,30", 1); |
| 194 EXPECT_EQ(VPX_CODEC_OK, res); | 222 EXPECT_EQ(VPX_CODEC_OK, res); |
| 195 res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); | 223 res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); |
| 196 EXPECT_EQ(VPX_CODEC_OK, res); | 224 EXPECT_EQ(VPX_CODEC_OK, res); |
| 197 codec_initialized_ = true; | 225 codec_initialized_ = true; |
| 198 } | 226 } |
| 199 | 227 |
| 200 TEST_F(SvcTest, SetScaleFactors) { | 228 TEST_F(SvcTest, SetScaleFactors) { |
| 201 vpx_codec_err_t res = vpx_svc_set_scale_factors(NULL, "4/16,16/16"); | 229 vpx_codec_err_t res = vpx_svc_set_scale_factors(NULL, "4/16,16/16"); |
| 202 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); | 230 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res); |
| 203 | 231 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 214 EXPECT_EQ(VPX_CODEC_OK, res); | 242 EXPECT_EQ(VPX_CODEC_OK, res); |
| 215 res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); | 243 res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); |
| 216 EXPECT_EQ(VPX_CODEC_OK, res); | 244 EXPECT_EQ(VPX_CODEC_OK, res); |
| 217 codec_initialized_ = true; | 245 codec_initialized_ = true; |
| 218 } | 246 } |
| 219 | 247 |
| 220 // Test that decoder can handle an SVC frame as the first frame in a sequence. | 248 // Test that decoder can handle an SVC frame as the first frame in a sequence. |
| 221 TEST_F(SvcTest, FirstFrameHasLayers) { | 249 TEST_F(SvcTest, FirstFrameHasLayers) { |
| 222 svc_.spatial_layers = 2; | 250 svc_.spatial_layers = 2; |
| 223 vpx_svc_set_scale_factors(&svc_, "4/16,16/16"); | 251 vpx_svc_set_scale_factors(&svc_, "4/16,16/16"); |
| 224 vpx_svc_set_quantizers(&svc_, "40,30"); | 252 vpx_svc_set_quantizers(&svc_, "40,30", 0); |
| 225 | 253 |
| 226 vpx_codec_err_t res = | 254 vpx_codec_err_t res = |
| 227 vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); | 255 vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); |
| 228 EXPECT_EQ(VPX_CODEC_OK, res); | 256 EXPECT_EQ(VPX_CODEC_OK, res); |
| 229 codec_initialized_ = true; | 257 codec_initialized_ = true; |
| 230 | 258 |
| 231 libvpx_test::I420VideoSource video(test_file_name_, kWidth, kHeight, | 259 libvpx_test::I420VideoSource video(test_file_name_, kWidth, kHeight, |
| 232 codec_enc_.g_timebase.den, | 260 codec_enc_.g_timebase.den, |
| 233 codec_enc_.g_timebase.num, 0, 30); | 261 codec_enc_.g_timebase.num, 0, 30); |
| 234 video.Begin(); | 262 video.Begin(); |
| 235 | 263 |
| 236 res = vpx_svc_encode(&svc_, &codec_, video.img(), video.pts(), | 264 res = vpx_svc_encode(&svc_, &codec_, video.img(), video.pts(), |
| 237 video.duration(), VPX_DL_GOOD_QUALITY); | 265 video.duration(), VPX_DL_GOOD_QUALITY); |
| 238 EXPECT_EQ(VPX_CODEC_OK, res); | 266 EXPECT_EQ(VPX_CODEC_OK, res); |
| 239 | 267 |
| 240 const vpx_codec_err_t res_dec = decoder_->DecodeFrame( | 268 const vpx_codec_err_t res_dec = decoder_->DecodeFrame( |
| 241 static_cast<const uint8_t *>(vpx_svc_get_buffer(&svc_)), | 269 static_cast<const uint8_t *>(vpx_svc_get_buffer(&svc_)), |
| 242 vpx_svc_get_frame_size(&svc_)); | 270 vpx_svc_get_frame_size(&svc_)); |
| 243 | 271 |
| 244 // this test fails with a decoder error | 272 // this test fails with a decoder error |
| 245 ASSERT_EQ(VPX_CODEC_OK, res_dec) << decoder_->DecodeError(); | 273 ASSERT_EQ(VPX_CODEC_OK, res_dec) << decoder_->DecodeError(); |
| 246 } | 274 } |
| 247 | 275 |
| 248 TEST_F(SvcTest, EncodeThreeFrames) { | 276 TEST_F(SvcTest, EncodeThreeFrames) { |
| 249 svc_.spatial_layers = 2; | 277 svc_.spatial_layers = 2; |
| 250 vpx_svc_set_scale_factors(&svc_, "4/16,16/16"); | 278 vpx_svc_set_scale_factors(&svc_, "4/16,16/16"); |
| 251 vpx_svc_set_quantizers(&svc_, "40,30"); | 279 vpx_svc_set_quantizers(&svc_, "40,30", 0); |
| 252 | 280 |
| 253 vpx_codec_err_t res = | 281 vpx_codec_err_t res = |
| 254 vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); | 282 vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); |
| 255 ASSERT_EQ(VPX_CODEC_OK, res); | 283 ASSERT_EQ(VPX_CODEC_OK, res); |
| 256 codec_initialized_ = true; | 284 codec_initialized_ = true; |
| 257 | 285 |
| 258 libvpx_test::I420VideoSource video(test_file_name_, kWidth, kHeight, | 286 libvpx_test::I420VideoSource video(test_file_name_, kWidth, kHeight, |
| 259 codec_enc_.g_timebase.den, | 287 codec_enc_.g_timebase.den, |
| 260 codec_enc_.g_timebase.num, 0, 30); | 288 codec_enc_.g_timebase.num, 0, 30); |
| 261 // FRAME 0 | 289 // FRAME 0 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 | 322 |
| 295 res_dec = decoder_->DecodeFrame( | 323 res_dec = decoder_->DecodeFrame( |
| 296 static_cast<const uint8_t *>(vpx_svc_get_buffer(&svc_)), | 324 static_cast<const uint8_t *>(vpx_svc_get_buffer(&svc_)), |
| 297 vpx_svc_get_frame_size(&svc_)); | 325 vpx_svc_get_frame_size(&svc_)); |
| 298 ASSERT_EQ(VPX_CODEC_OK, res_dec) << decoder_->DecodeError(); | 326 ASSERT_EQ(VPX_CODEC_OK, res_dec) << decoder_->DecodeError(); |
| 299 } | 327 } |
| 300 | 328 |
| 301 TEST_F(SvcTest, GetLayerResolution) { | 329 TEST_F(SvcTest, GetLayerResolution) { |
| 302 svc_.spatial_layers = 2; | 330 svc_.spatial_layers = 2; |
| 303 vpx_svc_set_scale_factors(&svc_, "4/16,8/16"); | 331 vpx_svc_set_scale_factors(&svc_, "4/16,8/16"); |
| 304 vpx_svc_set_quantizers(&svc_, "40,30"); | 332 vpx_svc_set_quantizers(&svc_, "40,30", 0); |
| 305 | 333 |
| 306 vpx_codec_err_t res = | 334 vpx_codec_err_t res = |
| 307 vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); | 335 vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_); |
| 308 EXPECT_EQ(VPX_CODEC_OK, res); | 336 EXPECT_EQ(VPX_CODEC_OK, res); |
| 309 codec_initialized_ = true; | 337 codec_initialized_ = true; |
| 310 | 338 |
| 311 // ensure that requested layer is a valid layer | 339 // ensure that requested layer is a valid layer |
| 312 uint32_t layer_width, layer_height; | 340 uint32_t layer_width, layer_height; |
| 313 res = vpx_svc_get_layer_resolution(&svc_, svc_.spatial_layers, | 341 res = vpx_svc_get_layer_resolution(&svc_, svc_.spatial_layers, |
| 314 &layer_width, &layer_height); | 342 &layer_width, &layer_height); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 328 EXPECT_EQ(kWidth * 4 / 16, layer_width); | 356 EXPECT_EQ(kWidth * 4 / 16, layer_width); |
| 329 EXPECT_EQ(kHeight * 4 / 16, layer_height); | 357 EXPECT_EQ(kHeight * 4 / 16, layer_height); |
| 330 | 358 |
| 331 res = vpx_svc_get_layer_resolution(&svc_, 1, &layer_width, &layer_height); | 359 res = vpx_svc_get_layer_resolution(&svc_, 1, &layer_width, &layer_height); |
| 332 EXPECT_EQ(VPX_CODEC_OK, res); | 360 EXPECT_EQ(VPX_CODEC_OK, res); |
| 333 EXPECT_EQ(kWidth * 8 / 16, layer_width); | 361 EXPECT_EQ(kWidth * 8 / 16, layer_width); |
| 334 EXPECT_EQ(kHeight * 8 / 16, layer_height); | 362 EXPECT_EQ(kHeight * 8 / 16, layer_height); |
| 335 } | 363 } |
| 336 | 364 |
| 337 } // namespace | 365 } // namespace |
| OLD | NEW |