summaryrefslogtreecommitdiffstats
path: root/third_party/aom/test/webmenc_test.cc
blob: acd795f2ecbf82ca1fb72adeb82837d8b3837614 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
 * Copyright (c) 2020, Alliance for Open Media. All rights reserved
 *
 * 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.
 */

#include <string>
#include "common/webmenc.h"
#include "third_party/googletest/src/googletest/include/gtest/gtest.h"

namespace {

#if CONFIG_WEBM_IO

class WebmencTest : public ::testing::Test {};

// All of these variations on output should be identical.
TEST(WebmencTest, ExtractEncoderSettingsOutput1) {
  const char *argv[] = { "aomenc", "-o", "output", "input",
                         "--target-bitrate=300" };
  int argc = 5;
  const std::string expected("version:1.2.3 --target-bitrate=300");
  char *result = extract_encoder_settings("1.2.3", argv, argc, "input");
  ASSERT_EQ(expected, std::string(result));
  free(result);
}

TEST(WebmencTest, ExtractEncoderSettingsOutput2) {
  const char *argv[] = { "aomenc", "--output", "bar", "foo", "--cpu-used=3" };
  int argc = 5;
  const std::string expected("version:abc --cpu-used=3");
  char *result = extract_encoder_settings("abc", argv, argc, "foo");
  ASSERT_EQ(expected, std::string(result));
  free(result);
}

TEST(WebmencTest, ExtractEncoderSettingsOutput3) {
  const char *argv[] = { "aomenc", "--cq-level=63", "--end-usage=q",
                         "--output=foo", "baz" };
  int argc = 5;
  const std::string expected("version:23 --cq-level=63 --end-usage=q");
  char *result = extract_encoder_settings("23", argv, argc, "baz");
  ASSERT_EQ(expected, std::string(result));
  free(result);
}

TEST(WebmencTest, ExtractEncoderSettingsInput) {
  // Check that input filename is filtered regardless of position.
  const char *argv[] = { "aomenc", "-o", "out", "input", "-p", "2" };
  int argc = 6;
  const char version[] = "1.0.0";
  const std::string expected("version:1.0.0 -p 2");
  char *result = extract_encoder_settings(version, argv, argc, "input");
  ASSERT_EQ(expected, std::string(result));
  free(result);

  const char *argv2[] = { "aomenc", "input", "-o", "out", "-p", "2" };
  result = extract_encoder_settings(version, argv2, argc, "input");
  ASSERT_EQ(expected, std::string(result));
  free(result);
}

#endif  // CONFIG_WEBM_IO
}  // namespace