| @@ -34,7 +34,8 @@ struct ExternalFrameBuffer { · 33 unmodified lines |
| 34 | // Class to manipulate a list of external frame buffers. | 34 | // Class to manipulate a list of external frame buffers. |
| 35 | class ExternalFrameBufferList { | 35 | class ExternalFrameBufferList { |
| 36 | public: | 36 | public: |
| 37 | ExternalFrameBufferList() : num_buffers_(0), ext_fb_list_(NULL) {} | 37 | ExternalFrameBufferList() |
| | 38 | : num_buffers_(0), num_used_buffers_(0), ext_fb_list_(NULL) {} |
| 38 | | 39 | |
| 39 | virtual ~ExternalFrameBufferList() { | 40 | virtual ~ExternalFrameBufferList() { |
| 40 | for (int i = 0; i < num_buffers_; ++i) { | 41 | for (int i = 0; i < num_buffers_; ++i) { |
| @@ -71,6 +72,8 @@ class ExternalFrameBufferList { · 30 unmodified lines |
| 71 | } | 72 | } |
| 72 | | 73 | |
| 73 | SetFrameBuffer(idx, fb); | 74 | SetFrameBuffer(idx, fb); |
| | 75 | |
| | 76 | num_used_buffers_++; |
| 74 | return 0; | 77 | return 0; |
| 75 | } | 78 | } |
| 76 | | 79 | |
| @@ -106,6 +109,7 @@ class ExternalFrameBufferList { · 29 unmodified lines |
| 106 | } | 109 | } |
| 107 | EXPECT_EQ(1, ext_fb->in_use); | 110 | EXPECT_EQ(1, ext_fb->in_use); |
| 108 | ext_fb->in_use = 0; | 111 | ext_fb->in_use = 0; |
| | 112 | num_used_buffers_--; |
| 109 | return 0; | 113 | return 0; |
| 110 | } | 114 | } |
| 111 | | 115 | |
| @@ -121,6 +125,8 @@ class ExternalFrameBufferList { · 9 unmodified lines |
| 121 | } | 125 | } |
| 122 | } | 126 | } |
| 123 | | 127 | |
| | 128 | int num_used_buffers() const { return num_used_buffers_; } |
| | 129 | |
| 124 | private: | 130 | private: |
| 125 | // Returns the index of the first free frame buffer. Returns |num_buffers_| | 131 | // Returns the index of the first free frame buffer. Returns |num_buffers_| |
| 126 | // if there are no free frame buffers. | 132 | // if there are no free frame buffers. |
| @@ -145,6 +151,7 @@ class ExternalFrameBufferList { · 18 unmodified lines |
| 145 | } | 151 | } |
| 146 | | 152 | |
| 147 | int num_buffers_; | 153 | int num_buffers_; |
| | 154 | int num_used_buffers_; |
| 148 | ExternalFrameBuffer *ext_fb_list_; | 155 | ExternalFrameBuffer *ext_fb_list_; |
| 149 | }; | 156 | }; |
| 150 | | 157 | |
| @@ -273,6 +280,7 @@ class ExternalFrameBufferMD5Test · 122 unmodified lines |
| 273 | | 280 | |
| 274 | #if CONFIG_WEBM_IO | 281 | #if CONFIG_WEBM_IO |
| 275 | const char kVP9TestFile[] = "vp90-2-02-size-lf-1920x1080.webm"; | 282 | const char kVP9TestFile[] = "vp90-2-02-size-lf-1920x1080.webm"; |
| | 283 | const char kVP9NonRefTestFile[] = "vp90-2-22-svc_1280x720_1.webm"; |
| 276 | | 284 | |
| 277 | // Class for testing passing in external frame buffers to libvpx. | 285 | // Class for testing passing in external frame buffers to libvpx. |
| 278 | class ExternalFrameBufferTest : public ::testing::Test { | 286 | class ExternalFrameBufferTest : public ::testing::Test { |
| @@ -292,7 +300,9 @@ class ExternalFrameBufferTest : public ::testing::Test { · 13 unmodified lines |
| 292 | | 300 | |
| 293 | virtual void TearDown() { | 301 | virtual void TearDown() { |
| 294 | delete decoder_; | 302 | delete decoder_; |
| | 303 | decoder_ = NULL; |
| 295 | delete video_; | 304 | delete video_; |
| | 305 | video_ = NULL; |
| 296 | } | 306 | } |
| 297 | | 307 | |
| 298 | // Passes the external frame buffer information to libvpx. | 308 | // Passes the external frame buffer information to libvpx. |
| @@ -325,7 +335,7 @@ class ExternalFrameBufferTest : public ::testing::Test { · 26 unmodified lines |
| 325 | return VPX_CODEC_OK; | 335 | return VPX_CODEC_OK; |
| 326 | } | 336 | } |
| 327 | | 337 | |
| 328 | private: | 338 | protected: |
| 329 | void CheckDecodedFrames() { | 339 | void CheckDecodedFrames() { |
| 330 | libvpx_test::DxDataIterator dec_iter = decoder_->GetDxData(); | 340 | libvpx_test::DxDataIterator dec_iter = decoder_->GetDxData(); |
| 331 | const vpx_image_t *img = NULL; | 341 | const vpx_image_t *img = NULL; |
| @@ -341,6 +351,25 @@ class ExternalFrameBufferTest : public ::testing::Test { · 9 unmodified lines |
| 341 | int num_buffers_; | 351 | int num_buffers_; |
| 342 | ExternalFrameBufferList fb_list_; | 352 | ExternalFrameBufferList fb_list_; |
| 343 | }; | 353 | }; |
| | 354 | |
| | 355 | class ExternalFrameBufferNonRefTest : public ExternalFrameBufferTest { |
| | 356 | protected: |
| | 357 | virtual void SetUp() { |
| | 358 | video_ = new libvpx_test::WebMVideoSource(kVP9NonRefTestFile); |
| | 359 | ASSERT_TRUE(video_ != NULL); |
| | 360 | video_->Init(); |
| | 361 | video_->Begin(); |
| | 362 | |
| | 363 | vpx_codec_dec_cfg_t cfg = vpx_codec_dec_cfg_t(); |
| | 364 | decoder_ = new libvpx_test::VP9Decoder(cfg, 0); |
| | 365 | ASSERT_TRUE(decoder_ != NULL); |
| | 366 | } |
| | 367 | |
| | 368 | virtual void CheckFrameBufferRelease() { |
| | 369 | TearDown(); |
| | 370 | ASSERT_EQ(0, fb_list_.num_used_buffers()); |
| | 371 | } |
| | 372 | }; |
| 344 | #endif // CONFIG_WEBM_IO | 373 | #endif // CONFIG_WEBM_IO |
| 345 | | 374 | |
| 346 | // This test runs through the set of test vectors, and decodes them. | 375 | // This test runs through the set of test vectors, and decodes them. |
| @@ -419,6 +448,8 @@ TEST_F(ExternalFrameBufferTest, NotEnoughBuffers) { · 72 unmodified lines |
| 419 | SetFrameBufferFunctions(num_buffers, get_vp9_frame_buffer, | 448 | SetFrameBufferFunctions(num_buffers, get_vp9_frame_buffer, |
| 420 | release_vp9_frame_buffer)); | 449 | release_vp9_frame_buffer)); |
| 421 | ASSERT_EQ(VPX_CODEC_OK, DecodeOneFrame()); | 450 | ASSERT_EQ(VPX_CODEC_OK, DecodeOneFrame()); |
| | 451 | // Only run this on long clips. Decoding a very short clip will return |
| | 452 | // VPX_CODEC_OK even with only 2 buffers. |
| 422 | ASSERT_EQ(VPX_CODEC_MEM_ERROR, DecodeRemainingFrames()); | 453 | ASSERT_EQ(VPX_CODEC_MEM_ERROR, DecodeRemainingFrames()); |
| 423 | } | 454 | } |
| 424 | | 455 | |
| @@ -467,6 +498,15 @@ TEST_F(ExternalFrameBufferTest, SetAfterDecode) { · 42 unmodified lines |
| 467 | SetFrameBufferFunctions(num_buffers, get_vp9_frame_buffer, | 498 | SetFrameBufferFunctions(num_buffers, get_vp9_frame_buffer, |
| 468 | release_vp9_frame_buffer)); | 499 | release_vp9_frame_buffer)); |
| 469 | } | 500 | } |
| | 501 | |
| | 502 | TEST_F(ExternalFrameBufferNonRefTest, DISABLED_ReleaseNonRefFrameBuffer) { |
| | 503 | const int num_buffers = VP9_MAXIMUM_REF_BUFFERS + VPX_MAXIMUM_WORK_BUFFERS; |
| | 504 | ASSERT_EQ(VPX_CODEC_OK, |
| | 505 | SetFrameBufferFunctions(num_buffers, get_vp9_frame_buffer, |
| | 506 | release_vp9_frame_buffer)); |
| | 507 | ASSERT_EQ(VPX_CODEC_OK, DecodeRemainingFrames()); |
| | 508 | CheckFrameBufferRelease(); |
| | 509 | } |
| 470 | #endif // CONFIG_WEBM_IO | 510 | #endif // CONFIG_WEBM_IO |
| 471 | | 511 | |
| 472 | VP9_INSTANTIATE_TEST_CASE( | 512 | VP9_INSTANTIATE_TEST_CASE( |