summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJohn Koleszar <jkoleszar@google.com>2013-02-08 14:20:05 -0800
committerGerrit Code Review <gerrit@gerrit.golo.chromium.org>2013-02-08 14:20:05 -0800
commit6dfc95fe63a52945350a7c8a234e87a4a55645db (patch)
tree9eee00f47c23b412ab1c181e71ffb816ac7b92f1 /test
parent3de8ee6ba1db38f14643c10793f57ed5d0b7122f (diff)
parent393b4856273c06aa0e7f0aec90a2b93a19aaf2d2 (diff)
downloadlibvpx-6dfc95fe63a52945350a7c8a234e87a4a55645db.tar
libvpx-6dfc95fe63a52945350a7c8a234e87a4a55645db.tar.gz
libvpx-6dfc95fe63a52945350a7c8a234e87a4a55645db.tar.bz2
libvpx-6dfc95fe63a52945350a7c8a234e87a4a55645db.zip
Merge changes Icd1a2a5a,I204d17a1,I3ed92117 into experimental
* changes: Initial support for resolution changes on P-frames Avoid allocating memory when resizing frames Adds a test for the VP8E_SET_SCALEMODE control
Diffstat (limited to 'test')
-rw-r--r--test/encode_test_driver.cc2
-rw-r--r--test/encode_test_driver.h9
-rw-r--r--test/resize_test.cc46
3 files changed, 48 insertions, 9 deletions
diff --git a/test/encode_test_driver.cc b/test/encode_test_driver.cc
index b2b6e0d6d..39d154b13 100644
--- a/test/encode_test_driver.cc
+++ b/test/encode_test_driver.cc
@@ -201,6 +201,8 @@ void EncoderTest::RunLoop(VideoSource *video) {
MismatchHook(img_enc, img_dec);
}
}
+ if (img_dec)
+ DecompressedFrameHook(*img_dec, video->pts());
}
if (!Continue())
break;
diff --git a/test/encode_test_driver.h b/test/encode_test_driver.h
index 0944dc2c6..35082a7fd 100644
--- a/test/encode_test_driver.h
+++ b/test/encode_test_driver.h
@@ -117,6 +117,11 @@ class Encoder {
ASSERT_EQ(VPX_CODEC_OK, res) << EncoderError();
}
+ void Control(int ctrl_id, struct vpx_scaling_mode *arg) {
+ const vpx_codec_err_t res = vpx_codec_control_(&encoder_, ctrl_id, arg);
+ ASSERT_EQ(VPX_CODEC_OK, res) << EncoderError();
+ }
+
void set_deadline(unsigned long deadline) {
deadline_ = deadline;
}
@@ -194,6 +199,10 @@ class EncoderTest {
virtual void MismatchHook(const vpx_image_t *img1,
const vpx_image_t *img2);
+ // Hook to be called on every decompressed frame.
+ virtual void DecompressedFrameHook(const vpx_image_t& img,
+ vpx_codec_pts_t pts) {}
+
bool abort_;
vpx_codec_enc_cfg_t cfg_;
unsigned int passes_;
diff --git a/test/resize_test.cc b/test/resize_test.cc
index 0ce8940a3..5e9234c38 100644
--- a/test/resize_test.cc
+++ b/test/resize_test.cc
@@ -12,6 +12,7 @@
#include "third_party/googletest/src/include/gtest/gtest.h"
#include "test/codec_factory.h"
#include "test/encode_test_driver.h"
+#include "test/i420_video_source.h"
#include "test/video_source.h"
#include "test/util.h"
@@ -73,15 +74,9 @@ class ResizeTest : public ::libvpx_test::EncoderTest,
return !HasFatalFailure() && !abort_;
}
- virtual void FramePktHook(const vpx_codec_cx_pkt_t *pkt) {
- if (pkt->data.frame.flags & VPX_FRAME_IS_KEY) {
- const unsigned char *buf =
- reinterpret_cast<const unsigned char *>(pkt->data.frame.buf);
- const unsigned int w = (buf[6] | (buf[7] << 8)) & 0x3fff;
- const unsigned int h = (buf[8] | (buf[9] << 8)) & 0x3fff;
-
- frame_info_list_.push_back(FrameInfo(pkt->data.frame.pts, w, h));
- }
+ virtual void DecompressedFrameHook(const vpx_image_t &img,
+ vpx_codec_pts_t pts) {
+ frame_info_list_.push_back(FrameInfo(pts, img.d_w, img.d_h));
}
std::vector< FrameInfo > frame_info_list_;
@@ -104,5 +99,38 @@ TEST_P(ResizeTest, TestExternalResizeWorks) {
}
}
+class ResizeInternalTest : public ResizeTest {
+ protected:
+ ResizeInternalTest() : ResizeTest() {}
+
+ virtual void PreEncodeFrameHook(libvpx_test::VideoSource *video,
+ libvpx_test::Encoder *encoder) {
+ if (video->frame() == 3) {
+ struct vpx_scaling_mode mode = {VP8E_FOURFIVE, VP8E_THREEFIVE};
+ encoder->Control(VP8E_SET_SCALEMODE, &mode);
+ }
+ }
+};
+
+TEST_P(ResizeInternalTest, TestInternalResizeWorks) {
+ ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
+ 30, 1, 0, 5);
+ ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
+
+ for (std::vector<FrameInfo>::iterator info = frame_info_list_.begin();
+ info != frame_info_list_.end(); ++info) {
+ const vpx_codec_pts_t pts = info->pts;
+ if (pts >= 3) {
+ ASSERT_EQ(282U, info->w) << "Frame " << pts << " had unexpected width";
+ ASSERT_EQ(173U, info->h) << "Frame " << pts << " had unexpected height";
+ } else {
+ EXPECT_EQ(352U, info->w) << "Frame " << pts << " had unexpected width";
+ EXPECT_EQ(288U, info->h) << "Frame " << pts << " had unexpected height";
+ }
+ }
+}
+
VP8_INSTANTIATE_TEST_CASE(ResizeTest, ONE_PASS_TEST_MODES);
+VP9_INSTANTIATE_TEST_CASE(ResizeInternalTest,
+ ::testing::Values(::libvpx_test::kOnePassBest));
} // namespace