frame_size_tests.cc 2.42 KB
Newer Older
1
/*
Yaowu Xu's avatar
Yaowu Xu committed
2
 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
3
 *
Yaowu Xu's avatar
Yaowu Xu committed
4
5
6
7
8
9
10
11
 * This source code is subject to the terms of the BSD 2 Clause License and
 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
 * was not distributed with this source code in the LICENSE file, you can
 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
 * Media Patent License 1.0 was not distributed with this source code in the
 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
*/

12
#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
13
#include "test/codec_factory.h"
James Zern's avatar
James Zern committed
14
#include "test/video_source.h"
15
16
17

namespace {

18
19
class AV1FrameSizeTests : public ::testing::Test,
                          public ::libaom_test::EncoderTest {
20
 protected:
21
  AV1FrameSizeTests()
Yaowu Xu's avatar
Yaowu Xu committed
22
      : EncoderTest(&::libaom_test::kAV1), expected_res_(AOM_CODEC_OK) {}
23
  virtual ~AV1FrameSizeTests() {}
24
25
26

  virtual void SetUp() {
    InitializeConfig();
27
    SetMode(::libaom_test::kRealTime);
28
29
  }

Yaowu Xu's avatar
Yaowu Xu committed
30
  virtual bool HandleDecodeResult(const aom_codec_err_t res_dec,
31
                                  libaom_test::Decoder *decoder) {
James Zern's avatar
James Zern committed
32
    EXPECT_EQ(expected_res_, res_dec) << decoder->DecodeError();
33
34
35
    return !::testing::Test::HasFailure();
  }

36
37
  virtual void PreEncodeFrameHook(::libaom_test::VideoSource *video,
                                  ::libaom_test::Encoder *encoder) {
38
    if (video->frame() == 1) {
Yaowu Xu's avatar
Yaowu Xu committed
39
40
41
42
      encoder->Control(AOME_SET_CPUUSED, 7);
      encoder->Control(AOME_SET_ENABLEAUTOALTREF, 1);
      encoder->Control(AOME_SET_ARNR_MAXFRAMES, 7);
      encoder->Control(AOME_SET_ARNR_STRENGTH, 5);
43
44
45
46
47
48
    }
  }

  int expected_res_;
};

Yaowu Xu's avatar
Yaowu Xu committed
49
#if CONFIG_SIZE_LIMIT
50
TEST_F(AV1FrameSizeTests, TestInvalidSizes) {
51
  ::libaom_test::RandomVideoSource video;
52
53
54

  video.SetSize(DECODE_WIDTH_LIMIT + 16, DECODE_HEIGHT_LIMIT + 16);
  video.set_limit(2);
Yaowu Xu's avatar
Yaowu Xu committed
55
  expected_res_ = AOM_CODEC_CORRUPT_FRAME;
56
57
58
  ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
}

59
TEST_F(AV1FrameSizeTests, LargeValidSizes) {
60
  ::libaom_test::RandomVideoSource video;
61
62
63

  video.SetSize(DECODE_WIDTH_LIMIT, DECODE_HEIGHT_LIMIT);
  video.set_limit(2);
Yaowu Xu's avatar
Yaowu Xu committed
64
  expected_res_ = AOM_CODEC_OK;
65
66
  ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
}
Yaowu Xu's avatar
Yaowu Xu committed
67
#endif
Alex Converse's avatar
Alex Converse committed
68

69
TEST_F(AV1FrameSizeTests, OneByOneVideo) {
70
  ::libaom_test::RandomVideoSource video;
Alex Converse's avatar
Alex Converse committed
71
72
73

  video.SetSize(1, 1);
  video.set_limit(2);
Yaowu Xu's avatar
Yaowu Xu committed
74
  expected_res_ = AOM_CODEC_OK;
Alex Converse's avatar
Alex Converse committed
75
76
  ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
}
77
#undef ONE_BY_ONE_VIDEO_NAME
78
}  // namespace