OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebM project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 #include "./vpx_config.h" | 10 #include "./vpx_config.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 encoding_mode_(GET_PARAM(1)) { | 29 encoding_mode_(GET_PARAM(1)) { |
30 } | 30 } |
31 | 31 |
32 virtual ~LosslessTestLarge() {} | 32 virtual ~LosslessTestLarge() {} |
33 | 33 |
34 virtual void SetUp() { | 34 virtual void SetUp() { |
35 InitializeConfig(); | 35 InitializeConfig(); |
36 SetMode(encoding_mode_); | 36 SetMode(encoding_mode_); |
37 } | 37 } |
38 | 38 |
| 39 virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video, |
| 40 ::libvpx_test::Encoder *encoder) { |
| 41 if (video->frame() == 1) { |
| 42 // Only call Control if quantizer > 0 to verify that using quantizer |
| 43 // alone will activate lossless |
| 44 if (cfg_.rc_max_quantizer > 0 || cfg_.rc_min_quantizer > 0) { |
| 45 encoder->Control(VP9E_SET_LOSSLESS, 1); |
| 46 } |
| 47 } |
| 48 } |
| 49 |
39 virtual void BeginPassHook(unsigned int /*pass*/) { | 50 virtual void BeginPassHook(unsigned int /*pass*/) { |
40 psnr_ = kMaxPsnr; | 51 psnr_ = kMaxPsnr; |
41 nframes_ = 0; | 52 nframes_ = 0; |
42 } | 53 } |
43 | 54 |
44 virtual void PSNRPktHook(const vpx_codec_cx_pkt_t *pkt) { | 55 virtual void PSNRPktHook(const vpx_codec_cx_pkt_t *pkt) { |
45 if (pkt->data.psnr.psnr[0] < psnr_) | 56 if (pkt->data.psnr.psnr[0] < psnr_) |
46 psnr_= pkt->data.psnr.psnr[0]; | 57 psnr_= pkt->data.psnr.psnr[0]; |
47 } | 58 } |
48 | 59 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 cfg_.rc_min_quantizer = 0; | 95 cfg_.rc_min_quantizer = 0; |
85 cfg_.rc_max_quantizer = 0; | 96 cfg_.rc_max_quantizer = 0; |
86 | 97 |
87 init_flags_ = VPX_CODEC_USE_PSNR; | 98 init_flags_ = VPX_CODEC_USE_PSNR; |
88 | 99 |
89 ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); | 100 ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); |
90 const double psnr_lossless = GetMinPsnr(); | 101 const double psnr_lossless = GetMinPsnr(); |
91 EXPECT_GE(psnr_lossless, kMaxPsnr); | 102 EXPECT_GE(psnr_lossless, kMaxPsnr); |
92 } | 103 } |
93 | 104 |
| 105 TEST_P(LosslessTestLarge, TestLossLessEncodingCtrl) { |
| 106 const vpx_rational timebase = { 33333333, 1000000000 }; |
| 107 cfg_.g_timebase = timebase; |
| 108 cfg_.rc_target_bitrate = 2000; |
| 109 cfg_.g_lag_in_frames = 25; |
| 110 // Intentionally set Q > 0, to make sure control can be used to activate |
| 111 // lossless |
| 112 cfg_.rc_min_quantizer = 10; |
| 113 cfg_.rc_max_quantizer = 20; |
| 114 |
| 115 init_flags_ = VPX_CODEC_USE_PSNR; |
| 116 |
| 117 libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288, |
| 118 timebase.den, timebase.num, 0, 10); |
| 119 ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); |
| 120 const double psnr_lossless = GetMinPsnr(); |
| 121 EXPECT_GE(psnr_lossless, kMaxPsnr); |
| 122 } |
| 123 |
94 VP9_INSTANTIATE_TEST_CASE(LosslessTestLarge, ALL_TEST_MODES); | 124 VP9_INSTANTIATE_TEST_CASE(LosslessTestLarge, ALL_TEST_MODES); |
95 } // namespace | 125 } // namespace |
OLD | NEW |