Add NELEMENTS() macro in aom_dsp/aom_dsp_common.h
Change-Id: Ia8da431c7a1faa43e130ce71da9561957c5556e7
diff --git a/aom_dsp/aom_dsp_common.h b/aom_dsp/aom_dsp_common.h
index 47ffbeb..82f9a95 100644
--- a/aom_dsp/aom_dsp_common.h
+++ b/aom_dsp/aom_dsp_common.h
@@ -31,6 +31,8 @@
#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)
diff --git a/aomenc.c b/aomenc.c
index 26c3866..c268656 100644
--- a/aomenc.c
+++ b/aomenc.c
@@ -45,6 +45,7 @@
#include "./rate_hist.h"
#include "./warnings.h"
#include "aom/aom_integer.h"
+#include "aom_dsp/aom_dsp_common.h"
#include "aom_ports/aom_timer.h"
#include "aom_ports/mem_ops.h"
#if CONFIG_WEBM_IO
@@ -627,7 +628,6 @@
exit(EXIT_FAILURE);
}
-#define NELEMENTS(x) (sizeof(x) / sizeof(x[0]))
#if CONFIG_AV1_ENCODER
#define ARG_CTRL_CNT_MAX NELEMENTS(av1_arg_ctrl_map)
#endif
diff --git a/av1/common/av1_loopfilter.c b/av1/common/av1_loopfilter.c
index da914cf..7dddb3b 100644
--- a/av1/common/av1_loopfilter.c
+++ b/av1/common/av1_loopfilter.c
@@ -348,8 +348,6 @@
}
#endif
-#define NELEMENTS(x) (sizeof((x)) / sizeof((x)[0]))
-
void av1_loop_filter_init(AV1_COMMON *cm) {
assert(MB_MODE_COUNT == NELEMENTS(mode_lf_lut));
loop_filter_info_n *lfi = &cm->lf_info;