2 Copyright (c) 2012 The WebM project authors. All Rights Reserved.
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
6 tree. An additional intellectual property rights grant can be found
7 in the file PATENTS. All contributing project authors may
8 be found in the AUTHORS file in the root of the source tree.
11 #include "third_party/googletest/src/include/gtest/gtest.h"
12 #include "test/codec_factory.h"
13 #include "test/encode_test_driver.h"
14 #include "test/i420_video_source.h"
15 #include "test/util.h"
19 const int kMaxPsnr = 100;
21 class LossLessTest : public ::libvpx_test::EncoderTest,
22 public ::libvpx_test::CodecTestWithParam<libvpx_test::TestMode> {
24 LossLessTest() : EncoderTest(GET_PARAM(0)),
27 encoding_mode_(GET_PARAM(1)) {
30 virtual ~LossLessTest() {}
32 virtual void SetUp() {
34 SetMode(encoding_mode_);
37 virtual void BeginPassHook(unsigned int /*pass*/) {
42 virtual void PSNRPktHook(const vpx_codec_cx_pkt_t *pkt) {
43 if (pkt->data.psnr.psnr[0] < psnr_)
44 psnr_= pkt->data.psnr.psnr[0];
47 double GetMinPsnr() const {
53 unsigned int nframes_;
54 libvpx_test::TestMode encoding_mode_;
57 TEST_P(LossLessTest, TestLossLessEncoding) {
58 const vpx_rational timebase = { 33333333, 1000000000 };
59 cfg_.g_timebase = timebase;
60 cfg_.rc_target_bitrate = 2000;
61 cfg_.g_lag_in_frames = 25;
62 cfg_.rc_min_quantizer = 0;
63 cfg_.rc_max_quantizer = 0;
65 init_flags_ = VPX_CODEC_USE_PSNR;
67 // intentionally changed the dimension for better testing coverage
68 libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 356, 284,
69 timebase.den, timebase.num, 0, 30);
71 const double psnr_lossless = GetMinPsnr();
72 EXPECT_GE(psnr_lossless, kMaxPsnr);
74 VP9_INSTANTIATE_TEST_CASE(LossLessTest, ALL_TEST_MODES);