ref: 9615fd8f39488ad0d3143bfde188bf9936db2665
parent: d8e68bd14b9d34231af0619d23dfc31060173038
 parent: b683eecf6dfe9fc947394df6f0e047e2fcbea43e
	author: John Koleszar <jkoleszar@google.com>
	date: Wed Feb 27 05:25:51 EST 2013
	
Merge "Test upscaling as well as downscaling" into experimental
--- a/test/resize_test.cc
+++ b/test/resize_test.cc
@@ -101,7 +101,7 @@
 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 @@
       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 {--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -4123,19 +4123,18 @@
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);
--
⑨