ref: 1b6f2e3f99913a2486d1e9d66cf24137e6ee3be2
parent: fa2509d7292a886e6efa4130c2424916f155a61f
author: Jerome Jiang <jianj@google.com>
date: Wed Aug 28 06:22:04 EDT 2019
Add resize test for smaller width bigger size. Stack trace is the same as that in the bug. BUG=webm:1642 Change-Id: I9d88c18a40af8df4a679727620070b13f1606f14
--- a/test/resize_test.cc
+++ b/test/resize_test.cc
@@ -93,7 +93,21 @@
void ScaleForFrameNumber(unsigned int frame, unsigned int initial_w,
unsigned int initial_h, unsigned int *w,
- unsigned int *h, int flag_codec) {
+ unsigned int *h, bool flag_codec,
+ bool smaller_width_larger_size_) {
+ if (smaller_width_larger_size_) {
+ if (frame < 30) {
+ *w = initial_w;
+ *h = initial_h;
+ return;
+ }
+ if (frame < 100) {
+ *w = initial_w * 7 / 10;
+ *h = initial_h * 16 / 10;
+ return;
+ }
+ return;
+ }
if (frame < 10) {
*w = initial_w;
*h = initial_h;
@@ -248,8 +262,10 @@
ResizingVideoSource() {
SetSize(kInitialWidth, kInitialHeight);
limit_ = 350;
+ smaller_width_larger_size_ = false;
}
- int flag_codec_;
+ bool flag_codec_;
+ bool smaller_width_larger_size_;
virtual ~ResizingVideoSource() {}
protected:
@@ -258,7 +274,7 @@
unsigned int width;
unsigned int height;
ScaleForFrameNumber(frame_, kInitialWidth, kInitialHeight, &width, &height,
- flag_codec_);
+ flag_codec_, smaller_width_larger_size_);
SetSize(width, height);
FillFrame();
}
@@ -304,7 +320,8 @@
TEST_P(ResizeTest, TestExternalResizeWorks) {
ResizingVideoSource video;
- video.flag_codec_ = 0;
+ video.flag_codec_ = false;
+ video.smaller_width_larger_size_ = false;
cfg_.g_lag_in_frames = 0;
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
@@ -317,7 +334,8 @@
ASSERT_EQ(info->w, GetFrameWidth(idx));
ASSERT_EQ(info->h, GetFrameHeight(idx));
ScaleForFrameNumber(frame, kInitialWidth, kInitialHeight, &expected_w,
- &expected_h, 0);
+ &expected_h, video.flag_codec_,
+ video.smaller_width_larger_size_);
EXPECT_EQ(expected_w, info->w)
<< "Frame " << frame << " had unexpected width";
EXPECT_EQ(expected_h, info->h)
@@ -534,7 +552,8 @@
TEST_P(ResizeRealtimeTest, TestExternalResizeWorks) {
ResizingVideoSource video;
- video.flag_codec_ = 1;
+ video.flag_codec_ = true;
+ video.smaller_width_larger_size_ = false;
DefaultConfig();
// Disable internal resize for this test.
cfg_.rc_resize_allowed = 0;
@@ -549,7 +568,36 @@
unsigned int expected_w;
unsigned int expected_h;
ScaleForFrameNumber(frame, kInitialWidth, kInitialHeight, &expected_w,
- &expected_h, 1);
+ &expected_h, video.flag_codec_,
+ video.smaller_width_larger_size_);
+ EXPECT_EQ(expected_w, info->w)
+ << "Frame " << frame << " had unexpected width";
+ EXPECT_EQ(expected_h, info->h)
+ << "Frame " << frame << " had unexpected height";
+ EXPECT_EQ(static_cast<unsigned int>(0), GetMismatchFrames());
+ }
+}
+
+TEST_P(ResizeRealtimeTest, DISABLED_TestExternalResizeSmallerWidthBiggerSize) {
+ ResizingVideoSource video;
+ video.flag_codec_ = true;
+ video.smaller_width_larger_size_ = true;
+ DefaultConfig();
+ // Disable internal resize for this test.
+ cfg_.rc_resize_allowed = 0;
+ change_bitrate_ = false;
+ mismatch_psnr_ = 0.0;
+ mismatch_nframes_ = 0;
+ ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
+
+ for (std::vector<FrameInfo>::const_iterator info = frame_info_list_.begin();
+ info != frame_info_list_.end(); ++info) {
+ const unsigned int frame = static_cast<unsigned>(info->pts);
+ unsigned int expected_w;
+ unsigned int expected_h;
+ ScaleForFrameNumber(frame, kInitialWidth, kInitialHeight, &expected_w,
+ &expected_h, video.flag_codec_,
+ video.smaller_width_larger_size_);
EXPECT_EQ(expected_w, info->w)
<< "Frame " << frame << " had unexpected width";
EXPECT_EQ(expected_h, info->h)