Commit ed9e0d0b authored by Sebastien Alaiwan's avatar Sebastien Alaiwan

Unify the many definitions of NELEMENTS

Change-Id: Ie52ce24ca9eca272dfacfb17483ec7b7f2c126d4
parent 49bb8f8c
......@@ -61,4 +61,6 @@ typedef size_t uintptr_t;
#include <inttypes.h>
#endif
#define NELEMENTS(x) (int)(sizeof(x) / sizeof(x[0]))
#endif // AOM_AOM_INTEGER_H_
......@@ -31,8 +31,6 @@ extern "C" {
#define AOMMIN(x, y) (((x) < (y)) ? (x) : (y))
#define AOMMAX(x, y) (((x) > (y)) ? (x) : (y))
#define NELEMENTS(x) (sizeof((x)) / sizeof((x)[0]))
#define IMPLIES(a, b) (!(a) || (b)) // Logical 'a implies b' (or 'a -> b')
#define IS_POWER_OF_TWO(x) (((x) & ((x)-1)) == 0)
......
......@@ -145,7 +145,7 @@ class Av1ConvolveTest : public ::testing::TestWithParam<ConvolveParam> {
};
int bsize_ls[] = { 1, 2, 4, 8, 16, 32, 64, 3, 7, 15, 31, 63 };
int bsize_num = sizeof(bsize_ls) / sizeof(bsize_ls[0]);
int bsize_num = NELEMENTS(bsize_ls);
TEST_P(Av1ConvolveTest, av1_convolve_vert) {
const int y_step_q4 = 16;
......
......@@ -47,7 +47,7 @@ const int8_t range_bit[12] = { 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32 };
TEST(av1_inv_txfm1d, round_trip) {
ACMRandom rnd(ACMRandom::DeterministicSeed());
for (int si = 0; si < ARRAY_SIZE(fwd_txfm_func_ls); ++si) {
for (int si = 0; si < NELEMENTS(fwd_txfm_func_ls); ++si) {
int txfm_size = txfm_size_ls[si];
for (int ti = 0; ti < txfm_type_num; ++ti) {
......@@ -63,7 +63,7 @@ TEST(av1_inv_txfm1d, round_trip) {
int32_t output[64];
int32_t round_trip_output[64];
assert(txfm_size <= ARRAY_SIZE(input));
assert(txfm_size <= NELEMENTS(input));
for (int ni = 0; ni < txfm_size; ++ni) {
input[ni] = rnd.Rand16() % input_base - rnd.Rand16() % input_base;
......
......@@ -56,7 +56,7 @@ class AV1InvTxfm2d : public ::testing::TestWithParam<AV1InvTxfm2dParam> {
for (int ci = 0; ci < count; ci++) {
int16_t expected[64 * 64] = { 0 };
assert(txfm2d_size_ < ARRAY_SIZE(expected));
assert(txfm2d_size_ < NELEMENTS(expected));
for (int ni = 0; ni < txfm2d_size_; ++ni) {
if (ci == 0) {
......@@ -68,11 +68,11 @@ class AV1InvTxfm2d : public ::testing::TestWithParam<AV1InvTxfm2dParam> {
}
int32_t coeffs[64 * 64] = { 0 };
assert(txfm2d_size_ < ARRAY_SIZE(coeffs));
assert(txfm2d_size_ < NELEMENTS(coeffs));
fwd_txfm_func(expected, coeffs, txfm1d_size_, tx_type_, bd);
uint16_t actual[64 * 64] = { 0 };
assert(txfm2d_size_ < ARRAY_SIZE(actual));
assert(txfm2d_size_ < NELEMENTS(actual));
inv_txfm_func(coeffs, actual, txfm1d_size_, tx_type_, bd);
for (int ni = 0; ni < txfm2d_size_; ++ni) {
......
......@@ -13,13 +13,12 @@
#include "./aom_config.h"
#include "test/ivf_video_source.h"
#include "test/util.h"
#include "aom/aomdx.h"
#include "aom/aom_decoder.h"
namespace {
#define NELEMENTS(x) static_cast<int>(sizeof(x) / sizeof(x[0]))
TEST(DecodeAPI, InvalidParams) {
static const aom_codec_iface_t *kCodecs[] = {
#if CONFIG_AV1_DECODER
......
......@@ -12,13 +12,12 @@
#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
#include "./aom_config.h"
#include "test/util.h"
#include "aom/aomcx.h"
#include "aom/aom_encoder.h"
namespace {
#define NELEMENTS(x) static_cast<int>(sizeof(x) / sizeof(x[0]))
TEST(EncodeAPI, InvalidParams) {
static const aom_codec_iface_t *kCodecs[] = {
#if CONFIG_AV1_ENCODER
......
......@@ -53,8 +53,6 @@ const EncodePerfTestVideo kAV1EncodePerfTestVectors[] = {
const int kEncodePerfTestSpeeds[] = { 5, 6, 7, 8 };
const int kEncodePerfTestThreads[] = { 1, 2, 4 };
#define NELEMENTS(x) (sizeof((x)) / sizeof((x)[0]))
class AV1EncodePerfTest
: public ::libaom_test::CodecTestWithParam<libaom_test::TestMode>,
public ::libaom_test::EncoderTest {
......
......@@ -15,10 +15,9 @@
#include <stdio.h>
#include <math.h>
#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
#include "aom/aom_integer.h"
#include "aom/aom_image.h"
#define ARRAY_SIZE(x) (int)(sizeof(x) / sizeof(x[0]))
// Macros
#define GET_PARAM(k) std::tr1::get<k>(GetParam())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment