VP9 dynamic resizing unit test.
Verify the dynamic resizer behavior for real time, 1 pass CBR mode. Run at low bitrate, with resize_allowed = 1, and verify that we get one resize down event. Change-Id: Ic347be60972fa87f7d68310da2a055679788929d
This commit is contained in:
parent
eb53c69ece
commit
9ac42bc15c
@ -81,6 +81,15 @@ static void write_ivf_frame_header(const vpx_codec_cx_pkt_t *const pkt,
|
||||
const unsigned int kInitialWidth = 320;
|
||||
const unsigned int kInitialHeight = 240;
|
||||
|
||||
struct FrameInfo {
|
||||
FrameInfo(vpx_codec_pts_t _pts, unsigned int _w, unsigned int _h)
|
||||
: pts(_pts), w(_w), h(_h) {}
|
||||
|
||||
vpx_codec_pts_t pts;
|
||||
unsigned int w;
|
||||
unsigned int h;
|
||||
};
|
||||
|
||||
unsigned int ScaleForFrameNumber(unsigned int frame, unsigned int val) {
|
||||
if (frame < 10)
|
||||
return val;
|
||||
@ -120,15 +129,6 @@ class ResizeTest : public ::libvpx_test::EncoderTest,
|
||||
|
||||
virtual ~ResizeTest() {}
|
||||
|
||||
struct FrameInfo {
|
||||
FrameInfo(vpx_codec_pts_t _pts, unsigned int _w, unsigned int _h)
|
||||
: pts(_pts), w(_w), h(_h) {}
|
||||
|
||||
vpx_codec_pts_t pts;
|
||||
unsigned int w;
|
||||
unsigned int h;
|
||||
};
|
||||
|
||||
virtual void SetUp() {
|
||||
InitializeConfig();
|
||||
SetMode(GET_PARAM(1));
|
||||
@ -261,6 +261,87 @@ TEST_P(ResizeInternalTest, TestInternalResizeWorks) {
|
||||
}
|
||||
}
|
||||
|
||||
class ResizeInternalRealtimeTest : public ::libvpx_test::EncoderTest,
|
||||
public ::libvpx_test::CodecTestWith2Params<libvpx_test::TestMode, int> {
|
||||
protected:
|
||||
ResizeInternalRealtimeTest() : EncoderTest(GET_PARAM(0)) {}
|
||||
virtual ~ResizeInternalRealtimeTest() {}
|
||||
|
||||
virtual void PreEncodeFrameHook(libvpx_test::VideoSource *video,
|
||||
libvpx_test::Encoder *encoder) {
|
||||
if (video->frame() == 0) {
|
||||
encoder->Control(VP9E_SET_AQ_MODE, 3);
|
||||
encoder->Control(VP8E_SET_CPUUSED, set_cpu_used_);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void SetUp() {
|
||||
InitializeConfig();
|
||||
SetMode(GET_PARAM(1));
|
||||
set_cpu_used_ = GET_PARAM(2);
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
void DefaultConfig() {
|
||||
cfg_.g_w = 352;
|
||||
cfg_.g_h = 288;
|
||||
cfg_.rc_buf_initial_sz = 500;
|
||||
cfg_.rc_buf_optimal_sz = 600;
|
||||
cfg_.rc_buf_sz = 1000;
|
||||
cfg_.rc_min_quantizer = 2;
|
||||
cfg_.rc_max_quantizer = 56;
|
||||
cfg_.rc_undershoot_pct = 50;
|
||||
cfg_.rc_overshoot_pct = 50;
|
||||
cfg_.rc_end_usage = VPX_CBR;
|
||||
cfg_.kf_mode = VPX_KF_AUTO;
|
||||
cfg_.g_lag_in_frames = 0;
|
||||
cfg_.kf_min_dist = cfg_.kf_max_dist = 3000;
|
||||
// Enable dropped frames.
|
||||
cfg_.rc_dropframe_thresh = 1;
|
||||
// Enable error_resilience mode.
|
||||
cfg_.g_error_resilient = 1;
|
||||
// Enable dynamic resizing.
|
||||
cfg_.rc_resize_allowed = 1;
|
||||
// Run at low bitrate.
|
||||
cfg_.rc_target_bitrate = 200;
|
||||
}
|
||||
|
||||
std::vector< FrameInfo > frame_info_list_;
|
||||
int set_cpu_used_;
|
||||
};
|
||||
|
||||
// Verify the dynamic resizer behavior for real time, 1 pass CBR mode.
|
||||
// Run at low bitrate, with resize_allowed = 1, and verify that we get
|
||||
// one resize down event.
|
||||
TEST_P(ResizeInternalRealtimeTest, TestInternalRealtimeResizeDown) {
|
||||
::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
|
||||
30, 1, 0, 299);
|
||||
DefaultConfig();
|
||||
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
|
||||
|
||||
unsigned int last_w = cfg_.g_w;
|
||||
unsigned int last_h = cfg_.g_h;
|
||||
int resize_count = 0;
|
||||
for (std::vector<FrameInfo>::const_iterator info = frame_info_list_.begin();
|
||||
info != frame_info_list_.end(); ++info) {
|
||||
if (info->w != last_w || info->h != last_h) {
|
||||
// Verify that resize down occurs.
|
||||
ASSERT_LT(info->w, last_w);
|
||||
ASSERT_LT(info->h, last_h);
|
||||
last_w = info->w;
|
||||
last_h = info->h;
|
||||
resize_count++;
|
||||
}
|
||||
}
|
||||
|
||||
// Verify that we get 1 resize down event in this test.
|
||||
ASSERT_EQ(1, resize_count) << "Resizing should occur.";
|
||||
}
|
||||
|
||||
vpx_img_fmt_t CspForFrameNumber(int frame) {
|
||||
if (frame < 10)
|
||||
return VPX_IMG_FMT_I420;
|
||||
@ -371,6 +452,9 @@ VP9_INSTANTIATE_TEST_CASE(ResizeTest,
|
||||
::testing::Values(::libvpx_test::kRealTime));
|
||||
VP9_INSTANTIATE_TEST_CASE(ResizeInternalTest,
|
||||
::testing::Values(::libvpx_test::kOnePassBest));
|
||||
VP9_INSTANTIATE_TEST_CASE(ResizeInternalRealtimeTest,
|
||||
::testing::Values(::libvpx_test::kRealTime),
|
||||
::testing::Range(5, 9));
|
||||
VP9_INSTANTIATE_TEST_CASE(ResizeCspTest,
|
||||
::testing::Values(::libvpx_test::kRealTime));
|
||||
} // namespace
|
||||
|
Loading…
x
Reference in New Issue
Block a user