The new test will run a SVC bitstream which has non ref frames. It checks the number of buffer acquired and released to make sure all external frame buffers are released. Add a new test bitstream: vp90-2-22-svc_1280x720_1.webm which has 400 frames in total, and 1 spatial layer and 2 temporal layers. There is one non ref frame every other frame. Disabled for now. Will be enabled with the fix. BUG=b/68819248
Showing the changes to test/external_frame_buffer_test.cc (1 of 4 files). Show all
Unified · Split
| @@ -34,7 +34,8 @@ struct ExternalFrameBuffer { · 33 unmodified lines | ||
| 34 | 34 | // Class to manipulate a list of external frame buffers. |
| 35 | 35 | class ExternalFrameBufferList { |
| 36 | 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 | 40 | virtual ~ExternalFrameBufferList() { |
| 40 | 41 | for (int i = 0; i < num_buffers_; ++i) { |
| @@ -71,6 +72,8 @@ class ExternalFrameBufferList { · 30 unmodified lines | ||
| 71 | 72 | } |
| 72 | 73 | |
| 73 | 74 | SetFrameBuffer(idx, fb); |
| 75 | + | |
| 76 | + num_used_buffers_++; | |
| 74 | 77 | return 0; |
| 75 | 78 | } |
| 76 | 79 | |
| @@ -106,6 +109,7 @@ class ExternalFrameBufferList { · 29 unmodified lines | ||
| 106 | 109 | } |
| 107 | 110 | EXPECT_EQ(1, ext_fb->in_use); |
| 108 | 111 | ext_fb->in_use = 0; |
| 112 | + num_used_buffers_--; | |
| 109 | 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 | 130 | private: |
| 125 | 131 | // Returns the index of the first free frame buffer. Returns |num_buffers_| |
| 126 | 132 | // if there are no free frame buffers. |
| @@ -145,6 +151,7 @@ class ExternalFrameBufferList { · 18 unmodified lines | ||
| 145 | 151 | } |
| 146 | 152 | |
| 147 | 153 | int num_buffers_; |
| 154 | + int num_used_buffers_; | |
| 148 | 155 | ExternalFrameBuffer *ext_fb_list_; |
| 149 | 156 | }; |
| 150 | 157 | |
| @@ -273,6 +280,7 @@ class ExternalFrameBufferMD5Test · 122 unmodified lines | ||
| 273 | 280 | |
| 274 | 281 | #if CONFIG_WEBM_IO |
| 275 | 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 | 285 | // Class for testing passing in external frame buffers to libvpx. |
| 278 | 286 | class ExternalFrameBufferTest : public ::testing::Test { |
| @@ -292,7 +300,9 @@ class ExternalFrameBufferTest : public ::testing::Test { · 13 unmodified lines | ||
| 292 | 300 | |
| 293 | 301 | virtual void TearDown() { |
| 294 | 302 | delete decoder_; |
| 303 | + decoder_ = NULL; | |
| 295 | 304 | delete video_; |
| 305 | + video_ = NULL; | |
| 296 | 306 | } |
| 297 | 307 | |
| 298 | 308 | // Passes the external frame buffer information to libvpx. |
| @@ -325,7 +335,7 @@ class ExternalFrameBufferTest : public ::testing::Test { · 26 unmodified lines | ||
| 325 | 335 | return VPX_CODEC_OK; |
| 326 | 336 | } |
| 327 | 337 | |
| 328 | − private: | |
| 338 | + protected: | |
| 329 | 339 | void CheckDecodedFrames() { |
| 330 | 340 | libvpx_test::DxDataIterator dec_iter = decoder_->GetDxData(); |
| 331 | 341 | const vpx_image_t *img = NULL; |
| @@ -341,6 +351,25 @@ class ExternalFrameBufferTest : public ::testing::Test { · 9 unmodified lines | ||
| 341 | 351 | int num_buffers_; |
| 342 | 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 | 373 | #endif // CONFIG_WEBM_IO |
| 345 | 374 | |
| 346 | 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 | 448 | SetFrameBufferFunctions(num_buffers, get_vp9_frame_buffer, |
| 420 | 449 | release_vp9_frame_buffer)); |
| 421 | 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 | 453 | ASSERT_EQ(VPX_CODEC_MEM_ERROR, DecodeRemainingFrames()); |
| 423 | 454 | } |
| 424 | 455 | |
| @@ -467,6 +498,15 @@ TEST_F(ExternalFrameBufferTest, SetAfterDecode) { · 42 unmodified lines | ||
| 467 | 498 | SetFrameBufferFunctions(num_buffers, get_vp9_frame_buffer, |
| 468 | 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 | 510 | #endif // CONFIG_WEBM_IO |
| 471 | 511 | |
| 472 | 512 | VP9_INSTANTIATE_TEST_CASE( |