Refactor prob_diff_update_savings_search_model
[aom.git] / test / encode_api_test.cc
bloba7200e653a0d63fa10d00a5151bab5df81c7bd9b
1 /*
2 * Copyright (c) 2016 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.
9 */
11 #include "third_party/googletest/src/include/gtest/gtest.h"
13 #include "./vpx_config.h"
14 #include "vpx/vp8cx.h"
15 #include "vpx/vpx_encoder.h"
17 namespace {
19 #define NELEMENTS(x) static_cast<int>(sizeof(x) / sizeof(x[0]))
21 TEST(EncodeAPI, InvalidParams) {
22 static const vpx_codec_iface_t *kCodecs[] = {
23 #if CONFIG_VP8_ENCODER
24 &vpx_codec_vp8_cx_algo,
25 #endif
26 #if CONFIG_VP9_ENCODER
27 &vpx_codec_vp9_cx_algo,
28 #endif
29 #if CONFIG_VP10_ENCODER
30 &vpx_codec_vp10_cx_algo,
31 #endif
33 uint8_t buf[1] = {0};
34 vpx_image_t img;
35 vpx_codec_ctx_t enc;
36 vpx_codec_enc_cfg_t cfg;
38 EXPECT_EQ(&img, vpx_img_wrap(&img, VPX_IMG_FMT_I420, 1, 1, 1, buf));
40 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, vpx_codec_enc_init(NULL, NULL, NULL, 0));
41 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, vpx_codec_enc_init(&enc, NULL, NULL, 0));
42 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, vpx_codec_encode(NULL, NULL, 0, 0, 0, 0));
43 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, vpx_codec_encode(NULL, &img, 0, 0, 0, 0));
44 EXPECT_EQ(VPX_CODEC_INVALID_PARAM, vpx_codec_destroy(NULL));
45 EXPECT_EQ(VPX_CODEC_INVALID_PARAM,
46 vpx_codec_enc_config_default(NULL, NULL, 0));
47 EXPECT_EQ(VPX_CODEC_INVALID_PARAM,
48 vpx_codec_enc_config_default(NULL, &cfg, 0));
49 EXPECT_TRUE(vpx_codec_error(NULL) != NULL);
51 for (int i = 0; i < NELEMENTS(kCodecs); ++i) {
52 SCOPED_TRACE(vpx_codec_iface_name(kCodecs[i]));
53 EXPECT_EQ(VPX_CODEC_INVALID_PARAM,
54 vpx_codec_enc_init(NULL, kCodecs[i], NULL, 0));
55 EXPECT_EQ(VPX_CODEC_INVALID_PARAM,
56 vpx_codec_enc_init(&enc, kCodecs[i], NULL, 0));
57 EXPECT_EQ(VPX_CODEC_INVALID_PARAM,
58 vpx_codec_enc_config_default(kCodecs[i], &cfg, 1));
60 EXPECT_EQ(VPX_CODEC_OK, vpx_codec_enc_config_default(kCodecs[i], &cfg, 0));
61 EXPECT_EQ(VPX_CODEC_OK, vpx_codec_enc_init(&enc, kCodecs[i], &cfg, 0));
62 EXPECT_EQ(VPX_CODEC_OK, vpx_codec_encode(&enc, NULL, 0, 0, 0, 0));
64 EXPECT_EQ(VPX_CODEC_OK, vpx_codec_destroy(&enc));
68 } // namespace