Commit a9b174bd authored by Urvang Joshi's avatar Urvang Joshi
Browse files

InterpFilter type: Create an enum.

We use a single enum instead of multiple #defines.
- Ensures better type checking
- Enum values are generated implicitly, and hard-coded #defines are not
required.
- We use ATTRIBUTE_PACKED to indicate that the enum should still use the
smallest integral type.

Change-Id: I7532428da31744d3441b363bd932a7f233ee7ab5
parent 0a79a1b1
......@@ -21,49 +21,45 @@
extern "C" {
#endif
#define EIGHTTAP_REGULAR 0
#define EIGHTTAP_SMOOTH 1
#define MULTITAP_SHARP 2
#define USE_TEMPORALFILTER_12TAP 1
typedef enum ATTRIBUTE_PACKED {
EIGHTTAP_REGULAR,
EIGHTTAP_SMOOTH,
MULTITAP_SHARP,
#if CONFIG_DUAL_FILTER
EIGHTTAP_SMOOTH2,
#endif // CONFIG_DUAL_FILTER
BILINEAR,
#if CONFIG_DUAL_FILTER
#define EIGHTTAP_SMOOTH2 3
EIGHTTAP_SHARP,
FILTER_REGULAR_UV,
FILTER_SMOOTH_UV,
FILTER_SHARP_UV,
FILTER_SMOOTH2_UV,
#endif // CONFIG_DUAL_FILTER
INTERP_FILTERS_ALL,
SWITCHABLE_FILTERS = BILINEAR,
SWITCHABLE = SWITCHABLE_FILTERS + 1, /* the last switchable one */
EXTRA_FILTERS = INTERP_FILTERS_ALL - SWITCHABLE_FILTERS,
#if USE_TEMPORALFILTER_12TAP
TEMPORALFILTER_12TAP = SWITCHABLE_FILTERS + EXTRA_FILTERS,
#endif
} InterpFilter;
#if CONFIG_DUAL_FILTER
#define MAX_SUBPEL_TAPS 12
#define SWITCHABLE_FILTERS 4 /* Number of switchable filters */
#define LOG_SWITCHABLE_FILTERS \
3 /* (1 << LOG_SWITCHABLE_FILTERS) > SWITCHABLE_FILTERS */
#define EIGHTTAP_SHARP (SWITCHABLE_FILTERS + 1)
#define FILTER_REGULAR_UV (SWITCHABLE_FILTERS + 2)
#define FILTER_SMOOTH_UV (SWITCHABLE_FILTERS + 3)
#define FILTER_SHARP_UV (SWITCHABLE_FILTERS + 4)
#define FILTER_SMOOTH2_UV (SWITCHABLE_FILTERS + 5)
#define EXTRA_FILTERS 6
#define SWITCHABLE_FILTER_CONTEXTS ((SWITCHABLE_FILTERS + 1) * 4)
#define INTER_FILTER_COMP_OFFSET (SWITCHABLE_FILTERS + 1)
#define INTER_FILTER_DIR_OFFSET ((SWITCHABLE_FILTERS + 1) * 2)
#else // CONFIG_DUAL_FILTER
#define SWITCHABLE_FILTERS 3 /* Number of switchable filters */
#define LOG_SWITCHABLE_FILTERS \
2 /* (1 << LOG_SWITCHABLE_FILTERS) > SWITCHABLE_FILTERS */
#define SWITCHABLE_FILTER_CONTEXTS (SWITCHABLE_FILTERS + 1)
#define EXTRA_FILTERS 1
#endif // CONFIG_DUAL_FILTER
#define USE_TEMPORALFILTER_12TAP 1
#if USE_TEMPORALFILTER_12TAP
#define TEMPORALFILTER_12TAP (SWITCHABLE_FILTERS + EXTRA_FILTERS)
#endif
#define BILINEAR (SWITCHABLE_FILTERS)
#define SWITCHABLE (SWITCHABLE_FILTERS + 1) /* the last one */
typedef uint8_t InterpFilter;
#if CONFIG_EXT_INTRA
#if CONFIG_INTRA_INTERP
typedef enum {
......
......@@ -106,7 +106,7 @@ class AV1ConvolveOptimzTest : public ::testing::TestWithParam<ConvParams> {
uint8_t *dst_ref_;
int width_;
int height_;
int filter_;
InterpFilter filter_;
int subpel_;
ConvolveParams conv_params_;
};
......@@ -218,7 +218,7 @@ const BlockDimension kBlockDim[] = {
};
// 10/12-tap filters
const InterpFilter kFilter[] = { 6, 4, 2 };
const InterpFilter kFilter[] = { FILTER_REGULAR_UV, BILINEAR, MULTITAP_SHARP };
const int kSubpelQ4[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
......@@ -283,7 +283,7 @@ class AV1HbdConvolveOptimzTest : public TestWithHbdConvParams {
uint16_t *dst_ref_;
int width_;
int height_;
int filter_;
InterpFilter filter_;
int subpel_;
int avg_;
int bit_depth_;
......
......@@ -637,11 +637,12 @@ const int kNumFilters = 16;
TEST(ConvolveTest, FiltersWontSaturateWhenAddedPairwise) {
for (int filter_bank = 0; filter_bank < kNumFilterBanks; ++filter_bank) {
const InterpFilter filter = (InterpFilter)filter_bank;
const InterpKernel *filters =
(const InterpKernel *)av1_get_interp_filter_kernel(filter_bank);
(const InterpKernel *)av1_get_interp_filter_kernel(filter);
#if CONFIG_DUAL_FILTER
const InterpFilterParams filter_params =
av1_get_interp_filter_params(filter_bank);
av1_get_interp_filter_params(filter);
if (filter_params.taps != SUBPEL_TAPS) continue;
#endif
for (int i = 0; i < kNumFilters; i++) {
......@@ -680,11 +681,12 @@ TEST_P(ConvolveTest, MatchesReferenceSubpixelFilter) {
#endif
for (int filter_bank = 0; filter_bank < kNumFilterBanks; ++filter_bank) {
const InterpFilter filter = (InterpFilter)filter_bank;
const InterpKernel *filters =
(const InterpKernel *)av1_get_interp_filter_kernel(filter_bank);
(const InterpKernel *)av1_get_interp_filter_kernel(filter);
#if CONFIG_DUAL_FILTER
const InterpFilterParams filter_params =
av1_get_interp_filter_params(filter_bank);
av1_get_interp_filter_params(filter);
if (filter_params.taps != SUBPEL_TAPS) continue;
#endif
......@@ -762,11 +764,12 @@ TEST_P(ConvolveTest, MatchesReferenceAveragingSubpixelFilter) {
}
for (int filter_bank = 0; filter_bank < kNumFilterBanks; ++filter_bank) {
const InterpFilter filter = (InterpFilter)filter_bank;
const InterpKernel *filters =
(const InterpKernel *)av1_get_interp_filter_kernel(filter_bank);
(const InterpKernel *)av1_get_interp_filter_kernel(filter);
#if CONFIG_DUAL_FILTER
const InterpFilterParams filter_params =
av1_get_interp_filter_params(filter_bank);
av1_get_interp_filter_params(filter);
if (filter_params.taps != SUBPEL_TAPS) continue;
#endif
......@@ -864,11 +867,12 @@ TEST_P(ConvolveTest, FilterExtremes) {
if (axis) seed_val += 8;
for (int filter_bank = 0; filter_bank < kNumFilterBanks; ++filter_bank) {
const InterpFilter filter = (InterpFilter)filter_bank;
const InterpKernel *filters =
(const InterpKernel *)av1_get_interp_filter_kernel(filter_bank);
(const InterpKernel *)av1_get_interp_filter_kernel(filter);
#if CONFIG_DUAL_FILTER
const InterpFilterParams filter_params =
av1_get_interp_filter_params(filter_bank);
av1_get_interp_filter_params(filter);
if (filter_params.taps != SUBPEL_TAPS) continue;
#endif
for (int filter_x = 0; filter_x < kNumFilters; ++filter_x) {
......
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