diff options
Diffstat (limited to 'media/libaom/src/test/external_frame_buffer_test.cc')
-rw-r--r-- | media/libaom/src/test/external_frame_buffer_test.cc | 82 |
1 files changed, 55 insertions, 27 deletions
diff --git a/media/libaom/src/test/external_frame_buffer_test.cc b/media/libaom/src/test/external_frame_buffer_test.cc index c2af059a4e..1d726a4f1c 100644 --- a/media/libaom/src/test/external_frame_buffer_test.cc +++ b/media/libaom/src/test/external_frame_buffer_test.cc @@ -8,8 +8,9 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include <memory> #include <string> - +#include "common/tools_common.h" #include "config/aom_config.h" #include "test/codec_factory.h" #include "test/decode_test_driver.h" @@ -57,7 +58,7 @@ class ExternalFrameBufferList { // Searches the frame buffer list for a free frame buffer. Makes sure // that the frame buffer is at least |min_size| in bytes. Marks that the - // frame buffer is in use by libvpx. Finally sets |fb| to point to the + // frame buffer is in use by libaom. Finally sets |fb| to point to the // external frame buffer. Returns < 0 on an error. int GetFreeFrameBuffer(size_t min_size, aom_codec_frame_buffer_t *fb) { EXPECT_TRUE(fb != NULL); @@ -113,16 +114,14 @@ class ExternalFrameBufferList { return 0; } - // Checks that the ximage data is contained within the external frame buffer - // private data passed back in the ximage. - void CheckXImageFrameBuffer(const aom_image_t *img) { - if (img->fb_priv != NULL) { - const struct ExternalFrameBuffer *const ext_fb = - reinterpret_cast<ExternalFrameBuffer *>(img->fb_priv); + // Checks that the aom_image_t data is contained within the external frame + // buffer private data passed back in the aom_image_t. + void CheckImageFrameBuffer(const aom_image_t *img) { + const struct ExternalFrameBuffer *const ext_fb = + reinterpret_cast<ExternalFrameBuffer *>(img->fb_priv); - ASSERT_TRUE(img->planes[0] >= ext_fb->data && - img->planes[0] < (ext_fb->data + ext_fb->size)); - } + ASSERT_TRUE(img->planes[0] >= ext_fb->data && + img->planes[0] < (ext_fb->data + ext_fb->size)); } int num_used_buffers() const { return num_used_buffers_; } @@ -157,7 +156,7 @@ class ExternalFrameBufferList { #if CONFIG_WEBM_IO -// Callback used by libvpx to request the application to return a frame +// Callback used by libaom to request the application to return a frame // buffer of at least |min_size| in bytes. int get_aom_frame_buffer(void *user_priv, size_t min_size, aom_codec_frame_buffer_t *fb) { @@ -166,7 +165,7 @@ int get_aom_frame_buffer(void *user_priv, size_t min_size, return fb_list->GetFreeFrameBuffer(min_size, fb); } -// Callback used by libvpx to tell the application that |fb| is not needed +// Callback used by libaom to tell the application that |fb| is not needed // anymore. int release_aom_frame_buffer(void *user_priv, aom_codec_frame_buffer_t *fb) { ExternalFrameBufferList *const fb_list = @@ -217,7 +216,7 @@ class ExternalFrameBufferMD5Test const libaom_test::CompressedVideoSource &video, libaom_test::Decoder *decoder) { if (num_buffers_ > 0 && video.frame_number() == 0) { - // Have libvpx use frame buffers we create. + // Have libaom use frame buffers we create. ASSERT_TRUE(fb_list_.CreateBufferList(num_buffers_)); ASSERT_EQ(AOM_CODEC_OK, decoder->SetFrameBufferFunctions(GetAV1FrameBuffer, @@ -243,12 +242,34 @@ class ExternalFrameBufferMD5Test expected_md5[32] = '\0'; ::libaom_test::MD5 md5_res; - md5_res.Add(&img); +#if FORCE_HIGHBITDEPTH_DECODING + const aom_img_fmt_t shifted_fmt = + (aom_img_fmt)(img.fmt & ~AOM_IMG_FMT_HIGHBITDEPTH); + if (img.bit_depth == 8 && shifted_fmt != img.fmt) { + aom_image_t *img_shifted = + aom_img_alloc(NULL, shifted_fmt, img.d_w, img.d_h, 16); + img_shifted->bit_depth = img.bit_depth; + img_shifted->monochrome = img.monochrome; + aom_img_downshift(img_shifted, &img, 0); + md5_res.Add(img_shifted); + aom_img_free(img_shifted); + } else { +#endif + md5_res.Add(&img); +#if FORCE_HIGHBITDEPTH_DECODING + } +#endif const char *const actual_md5 = md5_res.Get(); // Check md5 match. ASSERT_STREQ(expected_md5, actual_md5) << "Md5 checksums don't match: frame number = " << frame_number; + + const struct ExternalFrameBuffer *const ext_fb = + reinterpret_cast<ExternalFrameBuffer *>(img.fb_priv); + + ASSERT_TRUE(img.planes[0] >= ext_fb->data && + img.planes[0] < (ext_fb->data + ext_fb->size)); } // Callback to get a free external frame buffer. Return value < 0 is an @@ -279,21 +300,22 @@ class ExternalFrameBufferMD5Test }; #if CONFIG_WEBM_IO -const char kAV1TestFile[] = "av1-1-b8-01-size-226x226.ivf"; +const char kAV1TestFile[] = "av1-1-b8-03-sizeup.mkv"; const char kAV1NonRefTestFile[] = "av1-1-b8-01-size-226x226.ivf"; -// Class for testing passing in external frame buffers to libvpx. +// Class for testing passing in external frame buffers to libaom. class ExternalFrameBufferTest : public ::testing::Test { protected: ExternalFrameBufferTest() : video_(NULL), decoder_(NULL), num_buffers_(0) {} virtual void SetUp() { - video_ = new libaom_test::IVFVideoSource(kAV1TestFile); + video_ = new libaom_test::WebMVideoSource(kAV1TestFile); ASSERT_TRUE(video_ != NULL); video_->Init(); video_->Begin(); aom_codec_dec_cfg_t cfg = aom_codec_dec_cfg_t(); + cfg.allow_lowbitdepth = !FORCE_HIGHBITDEPTH_DECODING; decoder_ = new libaom_test::AV1Decoder(cfg, 0); ASSERT_TRUE(decoder_ != NULL); } @@ -305,7 +327,7 @@ class ExternalFrameBufferTest : public ::testing::Test { video_ = NULL; } - // Passes the external frame buffer information to libvpx. + // Passes the external frame buffer information to libaom. aom_codec_err_t SetFrameBufferFunctions( int num_buffers, aom_get_frame_buffer_cb_fn_t cb_get, aom_release_frame_buffer_cb_fn_t cb_release) { @@ -342,11 +364,11 @@ class ExternalFrameBufferTest : public ::testing::Test { // Get decompressed data while ((img = dec_iter.Next()) != NULL) { - fb_list_.CheckXImageFrameBuffer(img); + fb_list_.CheckImageFrameBuffer(img); } } - libaom_test::IVFVideoSource *video_; + libaom_test::CompressedVideoSource *video_; libaom_test::AV1Decoder *decoder_; int num_buffers_; ExternalFrameBufferList fb_list_; @@ -361,6 +383,7 @@ class ExternalFrameBufferNonRefTest : public ExternalFrameBufferTest { video_->Begin(); aom_codec_dec_cfg_t cfg = aom_codec_dec_cfg_t(); + cfg.allow_lowbitdepth = !FORCE_HIGHBITDEPTH_DECODING; decoder_ = new libaom_test::AV1Decoder(cfg, 0); ASSERT_TRUE(decoder_ != NULL); } @@ -373,12 +396,13 @@ class ExternalFrameBufferNonRefTest : public ExternalFrameBufferTest { #endif // CONFIG_WEBM_IO // This test runs through the set of test vectors, and decodes them. -// Libvpx will call into the application to allocate a frame buffer when +// Libaom will call into the application to allocate a frame buffer when // needed. The md5 checksums are computed for each frame in the video file. // If md5 checksums match the correct md5 data, then the test is passed. // Otherwise, the test failed. -TEST_P(ExternalFrameBufferMD5Test, DISABLED_ExtFBMD5Match) { +TEST_P(ExternalFrameBufferMD5Test, ExtFBMD5Match) { const std::string filename = GET_PARAM(kVideoNameParam); + aom_codec_dec_cfg_t cfg = aom_codec_dec_cfg_t(); // Number of buffers equals #AOM_MAXIMUM_REF_BUFFERS + // #AOM_MAXIMUM_WORK_BUFFERS + four jitter buffers. @@ -388,7 +412,7 @@ TEST_P(ExternalFrameBufferMD5Test, DISABLED_ExtFBMD5Match) { set_num_buffers(num_buffers); // Open compressed video file. - testing::internal::scoped_ptr<libaom_test::CompressedVideoSource> video; + std::unique_ptr<libaom_test::CompressedVideoSource> video; if (filename.substr(filename.length() - 3, 3) == "ivf") { video.reset(new libaom_test::IVFVideoSource(filename)); } else { @@ -407,8 +431,12 @@ TEST_P(ExternalFrameBufferMD5Test, DISABLED_ExtFBMD5Match) { const std::string md5_filename = filename + ".md5"; OpenMD5File(md5_filename); + // Set decode config. + cfg.allow_lowbitdepth = !FORCE_HIGHBITDEPTH_DECODING; + set_cfg(cfg); + // Decode frame, and check the md5 matching. - ASSERT_NO_FATAL_FAILURE(RunLoop(video.get())); + ASSERT_NO_FATAL_FAILURE(RunLoop(video.get(), cfg)); } #if CONFIG_WEBM_IO @@ -434,7 +462,7 @@ TEST_F(ExternalFrameBufferTest, EightJitterBuffers) { ASSERT_EQ(AOM_CODEC_OK, DecodeRemainingFrames()); } -TEST_F(ExternalFrameBufferTest, DISABLED_NotEnoughBuffers) { +TEST_F(ExternalFrameBufferTest, NotEnoughBuffers) { // Minimum number of external frame buffers for AV1 is // #AOM_MAXIMUM_REF_BUFFERS + #AOM_MAXIMUM_WORK_BUFFERS. Most files will // only use 5 frame buffers at one time. @@ -448,7 +476,7 @@ TEST_F(ExternalFrameBufferTest, DISABLED_NotEnoughBuffers) { ASSERT_EQ(AOM_CODEC_MEM_ERROR, DecodeRemainingFrames()); } -TEST_F(ExternalFrameBufferTest, DISABLED_NoRelease) { +TEST_F(ExternalFrameBufferTest, NoRelease) { const int num_buffers = AOM_MAXIMUM_REF_BUFFERS + AOM_MAXIMUM_WORK_BUFFERS; ASSERT_EQ(AOM_CODEC_OK, SetFrameBufferFunctions(num_buffers, get_aom_frame_buffer, |