summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/resize_test.cc22
-rw-r--r--vp9/encoder/vp9_onyx_if.c13
2 files changed, 24 insertions, 11 deletions
diff --git a/test/resize_test.cc b/test/resize_test.cc
index 2fe8884bc..2c62dafe3 100644
--- a/test/resize_test.cc
+++ b/test/resize_test.cc
@@ -101,7 +101,7 @@ TEST_P(ResizeTest, TestExternalResizeWorks) {
class ResizeInternalTest : public ResizeTest {
protected:
- ResizeInternalTest() : ResizeTest() {}
+ ResizeInternalTest() : ResizeTest(), frame0_psnr_(0.0) {}
virtual void PreEncodeFrameHook(libvpx_test::VideoSource *video,
libvpx_test::Encoder *encoder) {
@@ -109,19 +109,33 @@ class ResizeInternalTest : public ResizeTest {
struct vpx_scaling_mode mode = {VP8E_FOURFIVE, VP8E_THREEFIVE};
encoder->Control(VP8E_SET_SCALEMODE, &mode);
}
+ if (video->frame() == 6) {
+ struct vpx_scaling_mode mode = {VP8E_NORMAL, VP8E_NORMAL};
+ encoder->Control(VP8E_SET_SCALEMODE, &mode);
+ }
}
+
+ virtual void PSNRPktHook(const vpx_codec_cx_pkt_t *pkt) {
+ if (!frame0_psnr_)
+ frame0_psnr_ = pkt->data.psnr.psnr[0];
+ ASSERT_NEAR(pkt->data.psnr.psnr[0], frame0_psnr_, 0.025*frame0_psnr_);
+ }
+
+ double frame0_psnr_;
};
TEST_P(ResizeInternalTest, TestInternalResizeWorks) {
::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
- 30, 1, 0, 6);
- cfg_.rc_target_bitrate = 5000;
+ 30, 1, 0, 10);
+ init_flags_ = VPX_CODEC_USE_PSNR;
+ // q picked such that initial keyframe on this clip is ~30dB PSNR
+ cfg_.rc_min_quantizer = cfg_.rc_max_quantizer = 48;
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) {
+ if (pts >= 3 && pts < 6) {
ASSERT_EQ(282U, info->w) << "Frame " << pts << " had unexpected width";
ASSERT_EQ(173U, info->h) << "Frame " << pts << " had unexpected height";
} else {
diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c
index 1fec0cc1d..45ab6cd8c 100644
--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -4123,20 +4123,19 @@ int vp9_set_internal_size(VP9_PTR comp,
VP9_COMP *cpi = (VP9_COMP *) comp;
VP9_COMMON *cm = &cpi->common;
- if (horiz_mode <= ONETWO)
- cm->horiz_scale = horiz_mode;
- else
+ if (horiz_mode > ONETWO)
return -1;
- if (vert_mode <= ONETWO)
- cm->vert_scale = vert_mode;
- else
+ if (vert_mode > ONETWO)
return -1;
- if (cm->horiz_scale != NORMAL || cm->vert_scale != NORMAL) {
+ if (cm->horiz_scale != horiz_mode || cm->vert_scale != vert_mode) {
int UNINITIALIZED_IS_SAFE(hr), UNINITIALIZED_IS_SAFE(hs);
int UNINITIALIZED_IS_SAFE(vr), UNINITIALIZED_IS_SAFE(vs);
+ cm->horiz_scale = horiz_mode;
+ cm->vert_scale = vert_mode;
+
Scale2Ratio(cm->horiz_scale, &hr, &hs);
Scale2Ratio(cm->vert_scale, &vr, &vs);