Replace LOOP_FILTER_BITMASK with a cmake config
This commit replaces the macro with a cmake config to allow the
feature be easily enabled/disabled using cmake at command line
without modifying code. The feature is defualt disabled, can be
enabled by adding -DCONFIG_LPF_MASK=1 to cmake command, e.g.
cmake -DCONFIG_LPF_MASK=1 ./aom
Change-Id: I592c575949226c98fb60e53d5678e726c723265f
diff --git a/av1/common/alloccommon.c b/av1/common/alloccommon.c
index 1c8528a..f0412fc 100644
--- a/av1/common/alloccommon.c
+++ b/av1/common/alloccommon.c
@@ -31,7 +31,7 @@
return mb_rows * mb_cols;
}
-#if LOOP_FILTER_BITMASK
+#if CONFIG_LPF_MASK
static int alloc_loop_filter_mask(AV1_COMMON *cm) {
aom_free(cm->lf.lfm);
cm->lf.lfm = NULL;
@@ -80,7 +80,7 @@
cm->mb_rows = (cm->mi_rows + 2) >> 2;
cm->MBs = cm->mb_rows * cm->mb_cols;
-#if LOOP_FILTER_BITMASK
+#if CONFIG_LPF_MASK
alloc_loop_filter_mask(cm);
#endif
}
@@ -222,7 +222,7 @@
av1_free_above_context_buffers(cm, cm->num_allocated_above_contexts);
-#if LOOP_FILTER_BITMASK
+#if CONFIG_LPF_MASK
free_loop_filter_mask(cm);
#endif
}
diff --git a/av1/common/av1_loopfilter.c b/av1/common/av1_loopfilter.c
index 14ca735..0ed09b5 100644
--- a/av1/common/av1_loopfilter.c
+++ b/av1/common/av1_loopfilter.c
@@ -606,7 +606,7 @@
static void loop_filter_rows(YV12_BUFFER_CONFIG *frame_buffer, AV1_COMMON *cm,
MACROBLOCKD *xd, int start, int stop,
-#if LOOP_FILTER_BITMASK
+#if CONFIG_LPF_MASK
int is_decoding,
#endif
int plane_start, int plane_end) {
@@ -616,7 +616,7 @@
int mi_row, mi_col;
int plane;
-#if LOOP_FILTER_BITMASK
+#if CONFIG_LPF_MASK
if (is_decoding) {
cm->is_decoding = is_decoding;
for (plane = plane_start; plane < plane_end; plane++) {
@@ -715,7 +715,7 @@
void av1_loop_filter_frame(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm,
MACROBLOCKD *xd,
-#if LOOP_FILTER_BITMASK
+#if CONFIG_LPF_MASK
int is_decoding,
#endif
int plane_start, int plane_end, int partial_frame) {
@@ -731,7 +731,7 @@
end_mi_row = start_mi_row + mi_rows_to_filter;
av1_loop_filter_frame_init(cm, plane_start, plane_end);
loop_filter_rows(frame, cm, xd, start_mi_row, end_mi_row,
-#if LOOP_FILTER_BITMASK
+#if CONFIG_LPF_MASK
is_decoding,
#endif
plane_start, plane_end);
diff --git a/av1/common/av1_loopfilter.h b/av1/common/av1_loopfilter.h
index 49a99eb..7c46fb0 100644
--- a/av1/common/av1_loopfilter.h
+++ b/av1/common/av1_loopfilter.h
@@ -38,7 +38,7 @@
uint64_t bits[4];
} FilterMask;
-#if LOOP_FILTER_BITMASK
+#if CONFIG_LPF_MASK
// This structure holds bit masks for all 4x4 blocks in a 64x64 region.
// Each 1 bit represents a position in which we want to apply the loop filter.
// For Y plane, 4x4 in 64x64 requires 16x16 = 256 bit, therefore we use 4
@@ -77,7 +77,7 @@
FilterMask tx_size_ver[2][5];
FilterMask tx_size_hor[2][5];
} LoopFilterMask;
-#endif // LOOP_FILTER_BITMASK
+#endif // CONFIG_LPF_MASK
struct loopfilter {
int filter_level[2];
@@ -98,11 +98,11 @@
int combine_vert_horz_lf;
-#if LOOP_FILTER_BITMASK
+#if CONFIG_LPF_MASK
LoopFilterMask *lfm;
size_t lfm_num;
int lfm_stride;
-#endif // LOOP_FILTER_BITMASK
+#endif // CONFIG_LPF_MASK
};
// Need to align this structure so when it is declared and
@@ -128,7 +128,7 @@
void av1_loop_filter_frame_init(struct AV1Common *cm, int plane_start,
int plane_end);
-#if LOOP_FILTER_BITMASK
+#if CONFIG_LPF_MASK
void av1_loop_filter_frame(YV12_BUFFER_CONFIG *frame, struct AV1Common *cm,
struct macroblockd *mbd, int is_decoding,
int plane_start, int plane_end, int partial_frame);
@@ -160,7 +160,7 @@
uint8_t av1_get_filter_level(const struct AV1Common *cm,
const loop_filter_info_n *lfi_n, const int dir_idx,
int plane, const MB_MODE_INFO *mbmi);
-#if LOOP_FILTER_BITMASK
+#if CONFIG_LPF_MASK
void av1_filter_block_plane_ver(struct AV1Common *const cm,
struct macroblockd_plane *const plane_ptr,
int pl, int mi_row, int mi_col);
@@ -199,7 +199,7 @@
void av1_store_bitmask_vartx(struct AV1Common *cm, int mi_row, int mi_col,
BLOCK_SIZE bsize, TX_SIZE tx_size,
MB_MODE_INFO *mbmi);
-#endif // LOOP_FILTER_BITMASK
+#endif // CONFIG_LPF_MASK
#ifdef __cplusplus
} // extern "C"
diff --git a/av1/common/enums.h b/av1/common/enums.h
index 500c56d..d7df402 100644
--- a/av1/common/enums.h
+++ b/av1/common/enums.h
@@ -73,11 +73,6 @@
#define DIST_PRECISION_BITS 4
#define DIST_PRECISION (1 << DIST_PRECISION_BITS) // 16
-// TODO(chengchen): Temporal flag serve as experimental flag for WIP
-// bitmask construction.
-// Shall be removed when bitmask code is completely checkedin
-#define LOOP_FILTER_BITMASK 0
-
#define PROFILE_BITS 3
// The following three profiles are currently defined.
// Profile 0. 8-bit and 10-bit 4:2:0 and 4:0:0 only.
diff --git a/av1/common/loopfiltermask.c b/av1/common/loopfiltermask.c
index 9bd89fd..41d5186 100644
--- a/av1/common/loopfiltermask.c
+++ b/av1/common/loopfiltermask.c
@@ -77,7 +77,7 @@
// 00000000|00000000
//
// A loopfilter should be applied to every other 4x4 horizontally.
-#if LOOP_FILTER_BITMASK
+#if CONFIG_LPF_MASK
static const int mask_id_table_tx_4x4[BLOCK_SIZES_ALL] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, -1, -1, -1, 13, 14, 15, 16, 17, 18
};
@@ -1431,4 +1431,4 @@
sizeof(uint8_t) * mi_size_wide[bsize]);
}
}
-#endif // LOOP_FILTER_BITMASK
+#endif // CONFIG_LPF_MASK
diff --git a/av1/common/thread_common.c b/av1/common/thread_common.c
index 14406e6..82ae952 100644
--- a/av1/common/thread_common.c
+++ b/av1/common/thread_common.c
@@ -206,7 +206,7 @@
static void enqueue_lf_jobs(AV1LfSync *lf_sync, AV1_COMMON *cm, int start,
int stop,
-#if LOOP_FILTER_BITMASK
+#if CONFIG_LPF_MASK
int is_decoding,
#endif
int plane_start, int plane_end) {
@@ -223,7 +223,7 @@
continue;
else if (plane == 2 && !(cm->lf.filter_level_v))
continue;
-#if LOOP_FILTER_BITMASK
+#if CONFIG_LPF_MASK
int step = MAX_MIB_SIZE;
if (is_decoding) {
step = MI_SIZE_64X64;
@@ -325,7 +325,7 @@
return 1;
}
-#if LOOP_FILTER_BITMASK
+#if CONFIG_LPF_MASK
static INLINE void thread_loop_filter_bitmask_rows(
const YV12_BUFFER_CONFIG *const frame_buffer, AV1_COMMON *const cm,
struct macroblockd_plane *planes, MACROBLOCKD *xd,
@@ -388,18 +388,18 @@
lf_data->planes, lf_data->xd, lf_sync);
return 1;
}
-#endif // LOOP_FILTER_BITMASK
+#endif // CONFIG_LPF_MASK
static void loop_filter_rows_mt(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm,
MACROBLOCKD *xd, int start, int stop,
int plane_start, int plane_end,
-#if LOOP_FILTER_BITMASK
+#if CONFIG_LPF_MASK
int is_decoding,
#endif
AVxWorker *workers, int nworkers,
AV1LfSync *lf_sync) {
const AVxWorkerInterface *const winterface = aom_get_worker_interface();
-#if LOOP_FILTER_BITMASK
+#if CONFIG_LPF_MASK
int sb_rows;
if (is_decoding) {
sb_rows =
@@ -429,7 +429,7 @@
}
enqueue_lf_jobs(lf_sync, cm, start, stop,
-#if LOOP_FILTER_BITMASK
+#if CONFIG_LPF_MASK
is_decoding,
#endif
plane_start, plane_end);
@@ -439,7 +439,7 @@
AVxWorker *const worker = &workers[i];
LFWorkerData *const lf_data = &lf_sync->lfdata[i];
-#if LOOP_FILTER_BITMASK
+#if CONFIG_LPF_MASK
if (is_decoding) {
worker->hook = loop_filter_bitmask_row_worker;
} else {
@@ -471,7 +471,7 @@
void av1_loop_filter_frame_mt(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm,
MACROBLOCKD *xd, int plane_start, int plane_end,
int partial_frame,
-#if LOOP_FILTER_BITMASK
+#if CONFIG_LPF_MASK
int is_decoding,
#endif
AVxWorker *workers, int num_workers,
@@ -488,7 +488,7 @@
end_mi_row = start_mi_row + mi_rows_to_filter;
av1_loop_filter_frame_init(cm, plane_start, plane_end);
-#if LOOP_FILTER_BITMASK
+#if CONFIG_LPF_MASK
if (is_decoding) {
cm->is_decoding = is_decoding;
// TODO(chengchen): currently use one thread to build bitmasks for the
diff --git a/av1/common/thread_common.h b/av1/common/thread_common.h
index e7dbb8b..71133c8 100644
--- a/av1/common/thread_common.h
+++ b/av1/common/thread_common.h
@@ -103,7 +103,7 @@
void av1_loop_filter_frame_mt(YV12_BUFFER_CONFIG *frame, struct AV1Common *cm,
struct macroblockd *mbd, int plane_start,
int plane_end, int partial_frame,
-#if LOOP_FILTER_BITMASK
+#if CONFIG_LPF_MASK
int is_decoding,
#endif
AVxWorker *workers, int num_workers,
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index 36f823f..1074b89 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -1250,7 +1250,7 @@
static void read_tx_size_vartx(MACROBLOCKD *xd, MB_MODE_INFO *mbmi,
TX_SIZE tx_size, int depth,
-#if LOOP_FILTER_BITMASK
+#if CONFIG_LPF_MASK
AV1_COMMON *cm, int mi_row, int mi_col,
int store_bitmask,
#endif
@@ -1295,7 +1295,7 @@
mbmi->tx_size = sub_txs;
txfm_partition_update(xd->above_txfm_context + blk_col,
xd->left_txfm_context + blk_row, sub_txs, tx_size);
-#if LOOP_FILTER_BITMASK
+#if CONFIG_LPF_MASK
if (store_bitmask) {
av1_store_bitmask_vartx(cm, mi_row + blk_row, mi_col + blk_col,
txsize_to_bsize[tx_size], TX_4X4, mbmi);
@@ -1303,7 +1303,7 @@
#endif
return;
}
-#if LOOP_FILTER_BITMASK
+#if CONFIG_LPF_MASK
if (depth + 1 == MAX_VARTX_DEPTH && store_bitmask) {
av1_store_bitmask_vartx(cm, mi_row + blk_row, mi_col + blk_col,
txsize_to_bsize[tx_size], sub_txs, mbmi);
@@ -1317,7 +1317,7 @@
int offsetr = blk_row + row;
int offsetc = blk_col + col;
read_tx_size_vartx(xd, mbmi, sub_txs, depth + 1,
-#if LOOP_FILTER_BITMASK
+#if CONFIG_LPF_MASK
cm, mi_row, mi_col, store_bitmask,
#endif
offsetr, offsetc, r);
@@ -1329,7 +1329,7 @@
mbmi->tx_size = tx_size;
txfm_partition_update(xd->above_txfm_context + blk_col,
xd->left_txfm_context + blk_row, tx_size, tx_size);
-#if LOOP_FILTER_BITMASK
+#if CONFIG_LPF_MASK
if (store_bitmask) {
av1_store_bitmask_vartx(cm, mi_row + blk_row, mi_col + blk_col,
txsize_to_bsize[tx_size], tx_size, mbmi);
@@ -1396,7 +1396,7 @@
for (int idy = 0; idy < height; idy += bh)
for (int idx = 0; idx < width; idx += bw)
read_tx_size_vartx(xd, mbmi, max_tx_size, 0,
-#if LOOP_FILTER_BITMASK
+#if CONFIG_LPF_MASK
cm, mi_row, mi_col, 1,
#endif
idy, idx, r);
@@ -1406,7 +1406,7 @@
memset(mbmi->inter_tx_size, mbmi->tx_size, sizeof(mbmi->inter_tx_size));
set_txfm_ctxs(mbmi->tx_size, xd->n4_w, xd->n4_h,
mbmi->skip && is_inter_block(mbmi), xd);
-#if LOOP_FILTER_BITMASK
+#if CONFIG_LPF_MASK
const int w = mi_size_wide[bsize];
const int h = mi_size_high[bsize];
if (w <= mi_size_wide[BLOCK_64X64] && h <= mi_size_high[BLOCK_64X64]) {
@@ -1421,7 +1421,7 @@
}
#endif
}
-#if LOOP_FILTER_BITMASK
+#if CONFIG_LPF_MASK
const int w = mi_size_wide[bsize];
const int h = mi_size_high[bsize];
if (w <= mi_size_wide[BLOCK_64X64] && h <= mi_size_high[BLOCK_64X64]) {
@@ -5386,7 +5386,7 @@
if (initialize_flag) setup_frame_info(pbi);
const int num_planes = av1_num_planes(cm);
-#if LOOP_FILTER_BITMASK
+#if CONFIG_LPF_MASK
av1_loop_filter_frame_init(cm, 0, num_planes);
#endif
@@ -5414,13 +5414,13 @@
if (pbi->num_workers > 1) {
av1_loop_filter_frame_mt(
&cm->cur_frame->buf, cm, &pbi->mb, 0, num_planes, 0,
-#if LOOP_FILTER_BITMASK
+#if CONFIG_LPF_MASK
1,
#endif
pbi->tile_workers, pbi->num_workers, &pbi->lf_row_sync);
} else {
av1_loop_filter_frame(&cm->cur_frame->buf, cm, &pbi->mb,
-#if LOOP_FILTER_BITMASK
+#if CONFIG_LPF_MASK
1,
#endif
0, num_planes, 0);
@@ -5478,7 +5478,7 @@
}
}
}
-#if LOOP_FILTER_BITMASK
+#if CONFIG_LPF_MASK
av1_zero_array(cm->lf.lfm, cm->lf.lfm_num);
#endif
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index 397e1c7..27c91de 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -4041,14 +4041,14 @@
if (lf->filter_level[0] || lf->filter_level[1]) {
if (cpi->num_workers > 1)
av1_loop_filter_frame_mt(&cm->cur_frame->buf, cm, xd, 0, num_planes, 0,
-#if LOOP_FILTER_BITMASK
+#if CONFIG_LPF_MASK
0,
#endif
cpi->workers, cpi->num_workers,
&cpi->lf_row_sync);
else
av1_loop_filter_frame(&cm->cur_frame->buf, cm, xd,
-#if LOOP_FILTER_BITMASK
+#if CONFIG_LPF_MASK
0,
#endif
0, num_planes, 0);
diff --git a/av1/encoder/picklpf.c b/av1/encoder/picklpf.c
index 29639d7..101f47a 100644
--- a/av1/encoder/picklpf.c
+++ b/av1/encoder/picklpf.c
@@ -72,13 +72,13 @@
if (cpi->num_workers > 1)
av1_loop_filter_frame_mt(&cm->cur_frame->buf, cm, &cpi->td.mb.e_mbd, plane,
plane + 1, partial_frame,
-#if LOOP_FILTER_BITMASK
+#if CONFIG_LPF_MASK
0,
#endif
cpi->workers, cpi->num_workers, &cpi->lf_row_sync);
else
av1_loop_filter_frame(&cm->cur_frame->buf, cm, &cpi->td.mb.e_mbd,
-#if LOOP_FILTER_BITMASK
+#if CONFIG_LPF_MASK
0,
#endif
plane, plane + 1, partial_frame);