Commit 482551b1 authored by Wei-Ting Lin's avatar Wei-Ting Lin Committed by Wei-ting Lin

ncobmc-adapt-weight: define data types used in the experiment

Also add another default probabilities and for two-modes

Change-Id: Ia503301e6d8e89c8d7c945ff25588807107d4807
parent 665e05db
......@@ -110,6 +110,22 @@ typedef struct PVQ_QUEUE {
} PVQ_QUEUE;
#endif
#if CONFIG_NCOBMC_ADAPT_WEIGHT
typedef struct superblock_mi_boundaries {
int mi_row_begin;
int mi_col_begin;
int mi_row_end;
int mi_col_end;
} SB_MI_BD;
typedef struct {
int KERNEL_TL[MAX_SB_SIZE][MAX_SB_SIZE];
int KERNEL_TR[MAX_SB_SIZE][MAX_SB_SIZE];
int KERNEL_BL[MAX_SB_SIZE][MAX_SB_SIZE];
int KERNEL_BR[MAX_SB_SIZE][MAX_SB_SIZE];
} NCOBMC_KERNELS;
#endif
typedef struct {
uint8_t *plane[MAX_MB_PLANE];
int stride[MAX_MB_PLANE];
......@@ -442,7 +458,7 @@ typedef struct MB_MODE_INFO {
// blocks. A rectangular block is divided into two squared blocks and each
// squared block has an interpolation mode.
NCOBMC_MODE ncobmc_mode[2];
#endif
#endif // CONFIG_NCOBMC_ADAPT_WEIGHT
#endif // CONFIG_MOTION_VAR
int_mv mv[2];
int_mv pred_mv[2];
......@@ -774,6 +790,12 @@ typedef struct macroblockd {
#if CONFIG_CFL
CFL_CTX *cfl;
#endif
#if CONFIG_NCOBMC_ADAPT_WEIGHT
uint8_t *ncobmc_pred_buf[MAX_MB_PLANE];
int ncobmc_pred_buf_stride[MAX_MB_PLANE];
SB_MI_BD sb_mi_bd;
#endif
} MACROBLOCKD;
static INLINE int get_bitdepth_data_path_index(const MACROBLOCKD *xd) {
......@@ -1569,10 +1591,10 @@ static INLINE MOTION_MODE motion_mode_allowed(
#if CONFIG_NCOBMC_ADAPT_WEIGHT && CONFIG_MOTION_VAR
static INLINE NCOBMC_MODE ncobmc_mode_allowed_bsize(BLOCK_SIZE bsize) {
if (bsize < BLOCK_8X8 || bsize > BLOCK_64X64)
if (bsize < BLOCK_8X8 || bsize >= BLOCK_64X64)
return NO_OVERLAP;
else
return (NCOBMC_MODE)(MAX_NCOBMC_MODES - 1);
return MAX_NCOBMC_MODES;
}
static INLINE MOTION_MODE
......@@ -1587,21 +1609,22 @@ motion_mode_allowed_wrapper(int for_mv_search,
const MB_MODE_INFO *mbmi = &mi->mbmi;
MOTION_MODE motion_mode_for_mv_search = motion_mode_allowed(
#if CONFIG_GLOBAL_MOTION
int block, const WarpedMotionParams *gm_params,
block, gm_params,
#endif
#if CONFIG_WARPED_MOTION
xd,
#endif
mi);
int ncobmc_mode_allowed =
ncobmc_mode_allowed_bsize(mbmi->sb_type) && is_inter_mode(mbmi->mode);
(ncobmc_mode_allowed_bsize(mbmi->sb_type) < NO_OVERLAP) &&
motion_mode_for_mv_search >= OBMC_CAUSAL;
if (for_mv_search)
return motion_mode_for_mv_search;
else
return ncobmc_mode_allowed ? NCOBMC_ADAPT_WEIGHT
: motion_mode_for_mv_search;
}
#endif
#endif // CONFIG_NCOBMC_ADAPT_WEIGHT && CONFIG_MOTION_VAR
static INLINE void assert_motion_mode_valid(MOTION_MODE mode,
#if CONFIG_GLOBAL_MOTION
......@@ -1618,6 +1641,9 @@ static INLINE void assert_motion_mode_valid(MOTION_MODE mode,
#if CONFIG_GLOBAL_MOTION
block, gm_params,
#endif // CONFIG_GLOBAL_MOTION
#if CONFIG_WARPED_MOTION
xd,
#endif
mi);
#else
const MOTION_MODE last_motion_mode_allowed = motion_mode_allowed(
......
......@@ -1901,6 +1901,19 @@ static const ADAPT_OVERLAP_BLOCK adapt_overlap_block_lookup[BLOCK_SIZES_ALL] = {
ADAPT_OVERLAP_BLOCK_INVALID, ADAPT_OVERLAP_BLOCK_INVALID,
ADAPT_OVERLAP_BLOCK_INVALID, ADAPT_OVERLAP_BLOCK_INVALID
};
static const BLOCK_SIZE bsize_2_sqr_bsize[BLOCK_SIZES] = {
#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
BLOCK_2X2, BLOCK_2X2, BLOCK_2X2,
#endif
BLOCK_4X4, BLOCK_4X4, BLOCK_4X4, BLOCK_8X8, BLOCK_8X8,
BLOCK_8X8, BLOCK_16X16, BLOCK_16X16, BLOCK_16X16, BLOCK_32X32,
BLOCK_32X32, BLOCK_32X32, BLOCK_64X64,
#if CONFIG_EXT_PARTITION
BLOCK_64X64, BLOCK_64X64,
#endif
};
#endif // CONFIG_NCOBMC_ADAPT_WEIGHT
#if CONFIG_ADAPT_SCAN
......
......@@ -732,40 +732,131 @@ static const aom_cdf_prob
#endif // CONFIG_EXT_INTER
#if CONFIG_NCOBMC_ADAPT_WEIGHT
#ifdef TWO_MODE
const aom_tree_index av1_ncobmc_mode_tree[TREE_SIZE(MAX_NCOBMC_MODES)] = {
-NO_OVERLAP, 2, -NCOBMC_MODE_1, 4,
-NCOBMC_MODE_2, 6, -NCOBMC_MODE_3, 8,
-NCOBMC_MODE_4, 10, -NCOBMC_MODE_5, 12,
-NCOBMC_MODE_6, 14, -NCOBMC_MODE_7, -NCOBMC_MODE_8
-NCOBMC_MODE_0, -NCOBMC_MODE_1
};
#else
const aom_tree_index av1_ncobmc_mode_tree[TREE_SIZE(MAX_NCOBMC_MODES)] = {
-NCOBMC_MODE_0, 2,
-NCOBMC_MODE_1, 4,
-NCOBMC_MODE_2, 6,
-NCOBMC_MODE_3, 8,
-NCOBMC_MODE_4, 10,
-NCOBMC_MODE_5, 12,
-NCOBMC_MODE_6, -NCOBMC_MODE_7
};
#endif // TWO_MODE
// TODO(weitinglin): find default prob
// right now setting the first mode with probability 1/255,
// the last eight modes with equal probabilities
static const aom_prob
default_ncobmc_mode_prob[ADAPT_OVERLAP_BLOCKS][MAX_NCOBMC_MODES - 1] = {
{ 23, 37, 37, 38, 65, 71, 81, 86 }, // 8x8
{ 28, 32, 37, 43, 51, 64, 85, 128 }, // 16X16 equal prob
{ 86, 22, 32, 25, 10, 40, 97, 65 }, // 32X32
{ 28, 32, 37, 43, 51, 64, 85, 128 } // 64X64 equal prob
#ifdef TWO_MODE
{ 127 }, { 127 }, { 127 }, { 127 }
#else
{ 32, 36, 43, 51, 64, 85, 128 }, // 8x8
{ 32, 36, 43, 51, 64, 85, 128 }, // 16X16
{ 32, 36, 43, 51, 64, 85, 128 }, // 32X32
{ 32, 36, 43, 51, 64, 85, 128 } // 64X64
#endif // TWO_MODE
};
static const aom_cdf_prob
default_ncobmc_mode_cdf[ADAPT_OVERLAP_BLOCKS][CDF_SIZE(MAX_NCOBMC_MODES)] =
{ { AOM_ICDF(127), AOM_ICDF(4207), AOM_ICDF(8287), AOM_ICDF(12367),
AOM_ICDF(16447), AOM_ICDF(20527), AOM_ICDF(24607), AOM_ICDF(28687),
AOM_ICDF(32768), 0 },
{ AOM_ICDF(127), AOM_ICDF(4207), AOM_ICDF(8287), AOM_ICDF(12367),
AOM_ICDF(16447), AOM_ICDF(20527), AOM_ICDF(24607), AOM_ICDF(28687),
AOM_ICDF(32768), 0 },
{ AOM_ICDF(127), AOM_ICDF(4207), AOM_ICDF(8287), AOM_ICDF(12367),
AOM_ICDF(16447), AOM_ICDF(20527), AOM_ICDF(24607), AOM_ICDF(28687),
AOM_ICDF(32768), 0 },
{ AOM_ICDF(127), AOM_ICDF(4207), AOM_ICDF(8287), AOM_ICDF(12367),
AOM_ICDF(16447), AOM_ICDF(20527), AOM_ICDF(24607), AOM_ICDF(28687),
AOM_ICDF(32768), 0 } };
#ifdef TWO_MODE
{ { AOM_ICDF(16256), AOM_ICDF(32768), 0 },
{ AOM_ICDF(16256), AOM_ICDF(32768), 0 },
{ AOM_ICDF(16256), AOM_ICDF(32768), 0 },
{ AOM_ICDF(16256), AOM_ICDF(32768), 0 } };
#else
{ { AOM_ICDF(4096), AOM_ICDF(8192), AOM_ICDF(12288), AOM_ICDF(16384),
AOM_ICDF(20480), AOM_ICDF(24576), AOM_ICDF(28672), AOM_ICDF(32768),
0 },
{ AOM_ICDF(4096), AOM_ICDF(8192), AOM_ICDF(12288), AOM_ICDF(16384),
AOM_ICDF(20480), AOM_ICDF(24576), AOM_ICDF(28672), AOM_ICDF(32768),
0 },
{ AOM_ICDF(4096), AOM_ICDF(8192), AOM_ICDF(12288), AOM_ICDF(16384),
AOM_ICDF(20480), AOM_ICDF(24576), AOM_ICDF(28672), AOM_ICDF(32768),
0 },
{ AOM_ICDF(4096), AOM_ICDF(8192), AOM_ICDF(12288), AOM_ICDF(16384),
AOM_ICDF(20480), AOM_ICDF(24576), AOM_ICDF(28672), AOM_ICDF(32768),
0 } };
#endif // TWO_MODEE
#endif // CONFIG_NCOBMC_ADAPT_WEIGHT
// Change this section appropriately once warped motion is supported
#if CONFIG_MOTION_VAR && !CONFIG_WARPED_MOTION
#if !CONFIG_NCOBMC_ADAPT_WEIGHT
#if CONFIG_NCOBMC_ADAPT_WEIGHT
const aom_tree_index av1_motion_mode_tree[TREE_SIZE(MOTION_MODES)] = {
-SIMPLE_TRANSLATION, 2, -OBMC_CAUSAL, -NCOBMC_ADAPT_WEIGHT,
};
static const aom_prob
default_motion_mode_prob[BLOCK_SIZES_ALL][MOTION_MODES - 1] = {
#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
{ 255, 255 },
{ 255, 255 },
{ 255, 255 },
#endif
{ 255, 255 },
{ 255, 255 },
{ 255, 255 },
/** Only these nine block sizes allow ncobmc_adapt_weight **/
{ 45, 207 },
{ 42, 211 },
{ 34, 207 },
{ 181, 123 },
{ 129, 141 },
{ 15, 209 },
{ 231, 122 },
{ 195, 190 },
{ 168, 190 },
/** ----------------------------------------------------- **/
{ 244, 255 },
#if CONFIG_EXT_PARTITION
{ 252, 255 },
{ 252, 255 },
{ 252, 255 },
#endif // CONFIG_EXT_PARTITION
{ 255, 200 },
{ 255, 200 },
{ 255, 200 },
{ 255, 200 },
};
static const aom_cdf_prob
default_motion_mode_cdf[BLOCK_SIZES_ALL][CDF_SIZE(MOTION_MODES)] = {
#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
{ AOM_ICDF(255 * 128), AOM_ICDF(32768), 0, 0 },
{ AOM_ICDF(255 * 128), AOM_ICDF(32768), 0, 0 },
{ AOM_ICDF(255 * 128), AOM_ICDF(32768), 0, 0 },
#endif
{ AOM_ICDF(255 * 128), AOM_ICDF(32768), 0, 0 },
{ AOM_ICDF(255 * 128), AOM_ICDF(32768), 0, 0 },
{ AOM_ICDF(255 * 128), AOM_ICDF(32768), 0, 0 },
/** Only these seven block sizes allow ncobmc_adapt_weight **/
{ AOM_ICDF(5702), AOM_ICDF(27555), AOM_ICDF(32768), 0 },
{ AOM_ICDF(5408), AOM_ICDF(27964), AOM_ICDF(32768), 0 },
{ AOM_ICDF(4330), AOM_ICDF(27298), AOM_ICDF(32768), 0 },
{ AOM_ICDF(23107), AOM_ICDF(27760), AOM_ICDF(32768), 0 },
{ AOM_ICDF(16490), AOM_ICDF(25461), AOM_ICDF(32768), 0 },
{ AOM_ICDF(1959), AOM_ICDF(27153), AOM_ICDF(32768), 0 },
{ AOM_ICDF(29530), AOM_ICDF(31073), AOM_ICDF(32768), 0 },
{ AOM_ICDF(25057), AOM_ICDF(30840), AOM_ICDF(32768), 0 },
{ AOM_ICDF(21588), AOM_ICDF(29940), AOM_ICDF(32768), 0 },
/** ----------------------------------------------------- **/
{ AOM_ICDF(244 * 128), AOM_ICDF(32768), AOM_ICDF(32768), 0 },
#if CONFIG_EXT_PARTITION
{ AOM_ICDF(32256), AOM_ICDF(32768), AOM_ICDF(32768), 0 },
{ AOM_ICDF(32256), AOM_ICDF(32768), AOM_ICDF(32768), 0 },
{ AOM_ICDF(32256), AOM_ICDF(32768), AOM_ICDF(32768), 0 },
#endif
{ AOM_ICDF(32640), AOM_ICDF(32740), AOM_ICDF(32768), 0 },
{ AOM_ICDF(32640), AOM_ICDF(32740), AOM_ICDF(32768), 0 },
{ AOM_ICDF(32640), AOM_ICDF(32740), AOM_ICDF(32768), 0 },
{ AOM_ICDF(32640), AOM_ICDF(32740), AOM_ICDF(32768), 0 },
{ AOM_ICDF(32640), AOM_ICDF(32740), AOM_ICDF(32768), 0 },
{ AOM_ICDF(32640), AOM_ICDF(32740), AOM_ICDF(32768), 0 }
};
#else // CONFIG_NCOBMC_ADAPT_WEIGHT
const aom_tree_index av1_motion_mode_tree[TREE_SIZE(MOTION_MODES)] = {
-SIMPLE_TRANSLATION, -OBMC_CAUSAL
};
......@@ -815,62 +906,6 @@ static const aom_cdf_prob
{ AOM_ICDF(255 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(255 * 128), AOM_ICDF(32768), 0 },
};
#else
// TODO(weitinglin): The default probability is copied from warped motion right
// now as a place holder. It needs to be fined tuned after
// NCOBMC_ADAPT_WEIGHT is actually implemented. Also needs to
// change this section appropriately once warped motion is
// supported.
const aom_tree_index av1_motion_mode_tree[TREE_SIZE(MOTION_MODES)] = {
-SIMPLE_TRANSLATION, 2, -OBMC_CAUSAL, -NCOBMC_ADAPT_WEIGHT,
};
static const aom_prob
default_motion_mode_prob[BLOCK_SIZES_ALL][MOTION_MODES - 1] = {
#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
{ 255, 200 }, { 255, 200 }, { 255, 200 },
#endif
{ 255, 200 }, { 255, 200 }, { 255, 200 }, { 151, 200 }, { 153, 200 },
{ 144, 200 }, { 178, 200 }, { 165, 200 }, { 160, 200 }, { 207, 200 },
{ 195, 200 }, { 168, 200 }, { 244, 200 },
#if CONFIG_EXT_PARTITION
{ 252, 200 }, { 252, 200 }, { 252, 200 },
#endif // CONFIG_EXT_PARTITION
{ 255, 200 }, { 255, 200 }, { 255, 200 }, { 255, 200 }, { 255, 200 },
{ 255, 200 },
};
static const aom_cdf_prob
default_motion_mode_cdf[BLOCK_SIZES_ALL][CDF_SIZE(MOTION_MODES)] = {
#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
{ AOM_ICDF(16384), AOM_ICDF(24576), AOM_ICDF(32768), 0 },
{ AOM_ICDF(16384), AOM_ICDF(24576), AOM_ICDF(32768), 0 },
{ AOM_ICDF(16384), AOM_ICDF(24576), AOM_ICDF(32768), 0 },
#endif
{ AOM_ICDF(16384), AOM_ICDF(24576), AOM_ICDF(32768), 0 },
{ AOM_ICDF(16384), AOM_ICDF(24576), AOM_ICDF(32768), 0 },
{ AOM_ICDF(16384), AOM_ICDF(24576), AOM_ICDF(32768), 0 },
{ AOM_ICDF(7936), AOM_ICDF(19091), AOM_ICDF(32768), 0 },
{ AOM_ICDF(4991), AOM_ICDF(19205), AOM_ICDF(32768), 0 },
{ AOM_ICDF(4992), AOM_ICDF(19314), AOM_ICDF(32768), 0 },
{ AOM_ICDF(15104), AOM_ICDF(21590), AOM_ICDF(32768), 0 },
{ AOM_ICDF(9855), AOM_ICDF(21043), AOM_ICDF(32768), 0 },
{ AOM_ICDF(12800), AOM_ICDF(22238), AOM_ICDF(32768), 0 },
{ AOM_ICDF(24320), AOM_ICDF(26498), AOM_ICDF(32768), 0 },
{ AOM_ICDF(26496), AOM_ICDF(28995), AOM_ICDF(32768), 0 },
{ AOM_ICDF(25216), AOM_ICDF(28166), AOM_ICDF(32768), 0 },
{ AOM_ICDF(30592), AOM_ICDF(31238), AOM_ICDF(32768), 0 },
#if CONFIG_EXT_PARTITION
{ AOM_ICDF(32256), AOM_ICDF(32656), AOM_ICDF(32768), 0 },
{ AOM_ICDF(32256), AOM_ICDF(32656), AOM_ICDF(32768), 0 },
{ AOM_ICDF(32256), AOM_ICDF(32656), AOM_ICDF(32768), 0 },
#endif
{ AOM_ICDF(32640), AOM_ICDF(32740), AOM_ICDF(32768), 0 },
{ AOM_ICDF(32640), AOM_ICDF(32740), AOM_ICDF(32768), 0 },
{ AOM_ICDF(32640), AOM_ICDF(32740), AOM_ICDF(32768), 0 },
{ AOM_ICDF(32640), AOM_ICDF(32740), AOM_ICDF(32768), 0 },
{ AOM_ICDF(32640), AOM_ICDF(32740), AOM_ICDF(32768), 0 },
{ AOM_ICDF(32640), AOM_ICDF(32740), AOM_ICDF(32768), 0 },
};
#endif // CONFIG_NCOBMC_ADAPT_WEIGHT
#elif !CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
......@@ -925,7 +960,6 @@ static const aom_cdf_prob
};
#elif CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
const aom_tree_index av1_motion_mode_tree[TREE_SIZE(MOTION_MODES)] = {
-SIMPLE_TRANSLATION, 2, -OBMC_CAUSAL, -WARPED_CAUSAL,
};
......
......@@ -22,6 +22,11 @@ extern "C" {
#undef MAX_SB_SIZE
#if CONFIG_NCOBMC_ADAPT_WEIGHT
#define TWO_MODE
// #define FOUR_MODE
#endif
// Max superblock size
#if CONFIG_EXT_PARTITION
#define MAX_SB_SIZE_LOG2 7
......@@ -196,9 +201,9 @@ typedef enum ATTRIBUTE_PACKED {
#define MAX_NUM_TXB (1 << (MAX_SB_SIZE_LOG2 - MIN_TX_SIZE_LOG2))
#if CONFIG_NCOBMC_ADAPT_WEIGHT && CONFIG_MOTION_VAR
#if CONFIG_NCOBMC_ADAPT_WEIGHT
typedef enum ATTRIBUTE_PACKED {
NO_OVERLAP,
NCOBMC_MODE_0,
NCOBMC_MODE_1,
NCOBMC_MODE_2,
NCOBMC_MODE_3,
......@@ -206,11 +211,24 @@ typedef enum ATTRIBUTE_PACKED {
NCOBMC_MODE_5,
NCOBMC_MODE_6,
NCOBMC_MODE_7,
NCOBMC_MODE_8,
MAX_NCOBMC_MODES
} NCOBMC_MODE;
// #define MAX_INTRPL_MODES 9
ALL_NCOBMC_MODES,
#ifdef TWO_MODE
MAX_NCOBMC_MODES = NCOBMC_MODE_1 + 1,
#else
MAX_NCOBMC_MODES = ALL_NCOBMC_MODES,
#endif
NO_OVERLAP = MAX_NCOBMC_MODES + 1
} NCOBMC_MODE;
typedef enum {
ADAPT_OVERLAP_BLOCK_8X8,
ADAPT_OVERLAP_BLOCK_16X16,
ADAPT_OVERLAP_BLOCK_32X32,
ADAPT_OVERLAP_BLOCK_64X64,
ADAPT_OVERLAP_BLOCKS,
ADAPT_OVERLAP_BLOCK_INVALID = 255
} ADAPT_OVERLAP_BLOCK;
#endif // CONFIG_NCOBMC_ADAPT_WEIGHT
// frame transform mode
typedef enum {
......@@ -486,17 +504,6 @@ typedef enum {
MOTION_MODES
} MOTION_MODE;
#if CONFIG_NCOBMC_ADAPT_WEIGHT
typedef enum {
ADAPT_OVERLAP_BLOCK_8X8,
ADAPT_OVERLAP_BLOCK_16X16,
ADAPT_OVERLAP_BLOCK_32X32,
ADAPT_OVERLAP_BLOCK_64X64,
ADAPT_OVERLAP_BLOCKS,
ADAPT_OVERLAP_BLOCK_INVALID = 255
} ADAPT_OVERLAP_BLOCK;
#endif
#if CONFIG_EXT_INTER
#if CONFIG_INTERINTRA
typedef enum {
......
......@@ -454,6 +454,9 @@ typedef struct AV1Common {
#if CONFIG_ANS && ANS_MAX_SYMBOLS
int ans_window_size_log2;
#endif
#if CONFIG_NCOBMC_ADAPT_WEIGHT
NCOBMC_KERNELS ncobmc_kernels[ADAPT_OVERLAP_BLOCKS][ALL_NCOBMC_MODES];
#endif
} AV1_COMMON;
#if CONFIG_REFERENCE_BUFFER
......
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