Commit f12cc4a4 authored by Angie Chiang's avatar Angie Chiang
Browse files

Customize coding scheme for 1D transform

Observe 0.1% gain on lowres wo optimize_b before rebase

Change-Id: I0cb5b5e4be2563093efb2f6dfbefdce9b554e910
parent 2d3d0cd2
......@@ -2220,6 +2220,11 @@ void av1_average_tile_coef_cdfs(FRAME_CONTEXT *fc, FRAME_CONTEXT *ec_ctxs[],
#if BR_NODE
AVERAGE_TILE_CDFS(coeff_br_cdf)
#endif
#if CONFIG_CTX1D
AVERAGE_TILE_CDFS(eob_mode_cdf)
AVERAGE_TILE_CDFS(empty_line_cdf)
AVERAGE_TILE_CDFS(hv_eob_cdf)
#endif
#else
AVERAGE_TILE_CDFS(coef_head_cdfs)
AVERAGE_TILE_CDFS(coef_tail_cdfs)
......
......@@ -60,16 +60,25 @@ extern "C" {
#if CONFIG_LV_MAP
#define TXB_SKIP_CONTEXTS 13
#if CONFIG_CTX1D
#define EOB_COEF_CONTEXTS_2D 25
#define EOB_COEF_CONTEXTS_1D 25
#define EOB_COEF_CONTEXTS \
(EOB_COEF_CONTEXTS_2D + EOB_COEF_CONTEXTS_1D + EOB_COEF_CONTEXTS_1D)
#else // CONFIG_CTX1D
#define EOB_COEF_CONTEXTS 25
#endif // CONFIG_CTX1D
#if CONFIG_EXT_TX
#define SIG_COEF_CONTEXTS_2D 16
#define SIG_COEF_CONTEXTS_1D 16
#define SIG_COEF_CONTEXTS \
(SIG_COEF_CONTEXTS_2D + SIG_COEF_CONTEXTS_1D + SIG_COEF_CONTEXTS_1D)
#else
#else // CONFIG_EXT_TX
#define SIG_COEF_CONTEXTS_2D 16
#define SIG_COEF_CONTEXTS 16
#endif
#define EOB_COEF_CONTEXTS 25
#endif // CONFIG_EXT_TX
#define COEFF_BASE_CONTEXTS 42
#define DC_SIGN_CONTEXTS 3
......@@ -86,6 +95,11 @@ extern "C" {
#define BASE_CONTEXT_POSITION_NUM 12
#if CONFIG_CTX1D
#define EMPTY_LINE_CONTEXTS 5
#define HV_EOB_CONTEXTS 24
#endif // CONFIG_CTX1D
typedef enum TX_CLASS {
TX_CLASS_2D = 0,
TX_CLASS_HORIZ = 1,
......
......@@ -318,6 +318,114 @@ const aom_prob default_nz_map[TX_SIZES][PLANE_TYPES][SIG_COEF_CONTEXTS] = {
#endif // CONFIG_EXT_TX
};
#if CONFIG_CTX1D
const aom_prob default_eob_flag[TX_SIZES][PLANE_TYPES][EOB_COEF_CONTEXTS] = {
#if CONFIG_CHROMA_2X2
{ { 220, 225, 220, 216, 233, 225, 189, 178, 222, 199, 164, 112, 207,
171, 115, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
147, 125, 104, 36, 117, 107, 26, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
156, 124, 128, 128, 146, 68, 128, 128, 131, 17, 128, 128, 64,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
{ 146, 150, 142, 144, 178, 167, 131, 116, 150, 123, 107, 63, 119,
89, 74, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
117, 127, 105, 69, 53, 56, 30, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 86, 128, 128, 140, 72, 128, 128, 120, 44, 128, 128, 80,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 } },
{ { 237, 242, 242, 219, 192, 246, 246, 243, 233, 184, 155, 234, 217,
188, 152, 195, 167, 114, 89, 128, 128, 128, 128, 128, 128,
180, 173, 154, 133, 112, 147, 145, 142, 102, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
198, 173, 130, 200, 128, 208, 182, 160, 106, 171, 128, 144, 128,
128, 128, 124, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
{ 140, 170, 162, 111, 94, 182, 195, 165, 153, 110, 81, 178, 169,
158, 83, 133, 85, 85, 38, 128, 128, 128, 128, 128, 128,
112, 127, 107, 87, 31, 57, 49, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
160, 143, 99, 126, 128, 164, 133, 126, 59, 71, 128, 138, 128,
128, 128, 99, 128, 128, 128, 128, 128, 128, 128, 128, 128 } },
#endif
{ { 220, 225, 220, 216, 233, 225, 189, 178, 222, 199, 164, 112, 207,
171, 115, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
147, 125, 104, 36, 117, 107, 26, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
156, 124, 128, 128, 146, 68, 128, 128, 131, 17, 128, 128, 64,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
{ 146, 150, 142, 144, 178, 167, 131, 116, 150, 123, 107, 63, 119,
89, 74, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
117, 127, 105, 69, 53, 56, 30, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 86, 128, 128, 140, 72, 128, 128, 120, 44, 128, 128, 80,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 } },
{ { 237, 242, 242, 219, 192, 246, 246, 243, 233, 184, 155, 234, 217,
188, 152, 195, 167, 114, 89, 128, 128, 128, 128, 128, 128,
180, 173, 154, 133, 112, 147, 145, 142, 102, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
198, 173, 130, 200, 128, 208, 182, 160, 106, 171, 128, 144, 128,
128, 128, 124, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
{ 140, 170, 162, 111, 94, 182, 195, 165, 153, 110, 81, 178, 169,
158, 83, 133, 85, 85, 38, 128, 128, 128, 128, 128, 128,
112, 127, 107, 87, 31, 57, 49, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
160, 143, 99, 126, 128, 164, 133, 126, 59, 71, 128, 138, 128,
128, 128, 99, 128, 128, 128, 128, 128, 128, 128, 128, 128 } },
{ { 229, 241, 243, 245, 247, 247, 251, 248, 235, 210, 247, 235, 208,
166, 245, 247, 244, 182, 236, 229, 180, 136, 128, 128, 128,
191, 197, 96, 70, 199, 128, 128, 191, 174, 117, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
211, 183, 215, 188, 138, 209, 136, 128, 170, 128, 191, 128, 161,
128, 182, 128, 128, 128, 164, 128, 128, 128, 128, 128, 128 },
{ 106, 153, 182, 191, 186, 202, 211, 203, 166, 147, 205, 205, 195,
128, 206, 212, 182, 109, 192, 154, 139, 79, 128, 128, 128,
112, 133, 128, 255, 128, 128, 128, 130, 154, 98, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
144, 185, 169, 199, 85, 183, 128, 128, 64, 128, 146, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 } },
{ { 169, 203, 224, 222, 220, 228, 229, 223, 234, 247, 242, 230, 222,
238, 246, 234, 196, 245, 249, 245, 192, 240, 235, 199, 161,
176, 148, 158, 77, 178, 128, 128, 158, 128, 128, 196, 208, 155,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
232, 187, 191, 221, 116, 217, 154, 128, 203, 128, 128, 192, 128,
201, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
{ 133, 182, 215, 204, 176, 220, 182, 168, 187, 197, 181, 145, 75,
164, 136, 51, 57, 156, 128, 128, 128, 85, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 } },
};
#else // CONFIG_CTX1D
const aom_prob default_eob_flag[TX_SIZES][PLANE_TYPES][EOB_COEF_CONTEXTS] = {
#if CONFIG_CHROMA_2X2
{
......@@ -352,6 +460,7 @@ const aom_prob default_eob_flag[TX_SIZES][PLANE_TYPES][EOB_COEF_CONTEXTS] = {
236, 186, 182, 57, 209, 140, 128, 85, 184, 110, 128, 128 },
},
};
#endif // CONFIG_CTX1D
const aom_prob default_coeff_lps[TX_SIZES][PLANE_TYPES][LEVEL_CONTEXTS] = {
#if CONFIG_CHROMA_2X2
......@@ -524,6 +633,117 @@ const aom_prob
125, 159, 128, 173, 212, 128, 85, 189, 128, 128, 255, 171 } } }
};
#endif // BR_NODE
#if CONFIG_CTX1D
static const aom_prob default_eob_mode[TX_SIZES][PLANE_TYPES][TX_CLASSES] = {
#if CONFIG_CHROMA_2X2
{ { 128, 176, 157 }, { 128, 222, 198 } },
#endif
{ { 128, 176, 157 }, { 128, 222, 198 } },
{ { 128, 35, 56 }, { 128, 203, 225 } },
{ { 128, 55, 136 }, { 128, 230, 253 } },
{ { 128, 101, 188 }, { 128, 128, 128 } }
};
static const aom_prob default_empty_line[TX_SIZES][PLANE_TYPES][TX_CLASSES]
[EMPTY_LINE_CONTEXTS] = {
#if CONFIG_CHROMA_2X2
{ { { 128, 128, 128, 128, 128 },
{ 142, 153, 211, 205, 128 },
{ 162, 142, 203, 197, 128 } },
{ { 128, 128, 128, 128, 128 },
{ 133, 116, 178, 123, 128 },
{ 139, 109, 159, 115, 128 } } },
#endif
{ { { 128, 128, 128, 128, 128 },
{ 142, 153, 211, 205, 128 },
{ 162, 142, 203, 197, 128 } },
{ { 128, 128, 128, 128, 128 },
{ 133, 116, 178, 123, 128 },
{ 139, 109, 159, 115, 128 } } },
{ { { 128, 128, 128, 128, 128 },
{ 185, 130, 183, 204, 227 },
{ 171, 81, 177, 200, 221 } },
{ { 128, 128, 128, 128, 128 },
{ 180, 127, 175, 189, 213 },
{ 120, 74, 129, 134, 156 } } },
{ { { 128, 128, 128, 128, 128 },
{ 202, 82, 183, 214, 248 },
{ 144, 41, 163, 185, 203 } },
{ { 128, 128, 128, 128, 128 },
{ 151, 93, 171, 224, 160 },
{ 128, 51, 171, 128, 1 } } },
{ { { 128, 128, 128, 128, 128 },
{ 154, 48, 174, 210, 233 },
{ 123, 16, 148, 189, 197 } },
{ { 128, 128, 128, 128, 128 },
{ 128, 128, 128, 128, 128 },
{ 128, 128, 128, 128, 128 } } }
};
static const aom_prob
default_hv_eob[TX_SIZES][PLANE_TYPES][TX_CLASSES][HV_EOB_CONTEXTS] = {
#if CONFIG_CHROMA_2X2
{ { { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
{ 151, 173, 114, 128, 128, 128, 128, 128, 128, 162, 198, 128,
128, 128, 128, 128, 182, 198, 109, 128, 128, 128, 128, 128 },
{ 152, 173, 119, 128, 128, 128, 128, 128, 128, 164, 193, 128,
128, 128, 128, 128, 198, 209, 121, 128, 128, 128, 128, 128 } },
{ { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
{ 123, 143, 70, 128, 128, 128, 128, 128, 128, 127, 154, 128,
128, 128, 128, 128, 176, 148, 36, 128, 128, 128, 128, 128 },
{ 132, 152, 73, 128, 128, 128, 128, 128, 128, 127, 159, 128,
128, 128, 128, 128, 186, 181, 48, 128, 128, 128, 128, 128 } } },
#endif
{ { { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
{ 151, 173, 114, 128, 128, 128, 128, 128, 128, 162, 198, 128,
128, 128, 128, 128, 182, 198, 109, 128, 128, 128, 128, 128 },
{ 152, 173, 119, 128, 128, 128, 128, 128, 128, 164, 193, 128,
128, 128, 128, 128, 198, 209, 121, 128, 128, 128, 128, 128 } },
{ { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
{ 123, 143, 70, 128, 128, 128, 128, 128, 128, 127, 154, 128,
128, 128, 128, 128, 176, 148, 36, 128, 128, 128, 128, 128 },
{ 132, 152, 73, 128, 128, 128, 128, 128, 128, 127, 159, 128,
128, 128, 128, 128, 186, 181, 48, 128, 128, 128, 128, 128 } } },
{ { { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
{ 109, 105, 78, 44, 128, 128, 128, 128, 128, 146, 185, 221,
128, 128, 128, 128, 199, 188, 134, 69, 128, 128, 128, 128 },
{ 124, 127, 115, 82, 128, 128, 128, 128, 128, 162, 198, 224,
128, 128, 128, 128, 206, 214, 177, 135, 128, 128, 128, 128 } },
{ { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
{ 95, 102, 65, 14, 128, 128, 128, 128, 128, 132, 164, 199,
128, 128, 128, 128, 162, 163, 66, 27, 128, 128, 128, 128 },
{ 83, 141, 97, 38, 128, 128, 128, 128, 128, 154, 132, 184,
128, 128, 128, 128, 194, 218, 112, 63, 128, 128, 128, 128 } } },
{ { { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
{ 117, 107, 86, 61, 51, 104, 128, 128, 128, 160, 198, 238,
252, 251, 128, 128, 221, 223, 209, 186, 99, 81, 128, 128 },
{ 118, 122, 121, 100, 91, 97, 128, 128, 128, 168, 190, 214,
233, 235, 128, 128, 197, 216, 177, 165, 147, 126, 128, 128 } },
{ { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
{ 109, 102, 63, 51, 255, 85, 128, 128, 128, 163, 131, 175,
128, 128, 128, 128, 183, 102, 40, 1, 128, 128, 128, 128 },
{ 255, 255, 1, 1, 128, 1, 128, 128, 128, 1, 128, 128,
128, 128, 128, 128, 255, 1, 128, 128, 128, 128, 128, 128 } } },
{ { { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
{ 114, 108, 83, 61, 53, 28, 77, 177, 128, 161, 187, 218,
240, 237, 228, 234, 200, 207, 167, 136, 98, 78, 183, 128 },
{ 117, 138, 116, 77, 75, 85, 26, 1, 128, 197, 162, 200,
184, 212, 225, 236, 189, 225, 168, 124, 144, 171, 128, 128 } },
{ { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
{ 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
{ 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 } } }
};
#endif // CONFIG_CTX1D
#endif // CONFIG_LV_MAP
#if CONFIG_EXT_PARTITION_TYPES
......@@ -4712,6 +4932,11 @@ static void init_mode_probs(FRAME_CONTEXT *fc) {
#if BR_NODE
av1_copy(fc->coeff_br, default_coeff_br);
#endif
#if CONFIG_CTX1D
av1_copy(fc->eob_mode, default_eob_mode);
av1_copy(fc->empty_line, default_empty_line);
av1_copy(fc->hv_eob, default_hv_eob);
#endif // CONFIG_CTX1D
#if LV_MAP_PROB
av1_init_txb_probs(fc);
......
......@@ -172,6 +172,11 @@ typedef struct frame_contexts {
#if BR_NODE
aom_prob coeff_br[TX_SIZES][PLANE_TYPES][BASE_RANGE_SETS][LEVEL_CONTEXTS];
#endif
#if CONFIG_CTX1D
aom_prob eob_mode[TX_SIZES][PLANE_TYPES][TX_CLASSES];
aom_prob empty_line[TX_SIZES][PLANE_TYPES][TX_CLASSES][EMPTY_LINE_CONTEXTS];
aom_prob hv_eob[TX_SIZES][PLANE_TYPES][TX_CLASSES][HV_EOB_CONTEXTS];
#endif // CONFIG_CTX1D
#if LV_MAP_PROB
aom_cdf_prob txb_skip_cdf[TX_SIZES][TXB_SKIP_CONTEXTS][CDF_SIZE(2)];
......@@ -188,6 +193,13 @@ typedef struct frame_contexts {
aom_cdf_prob coeff_br_cdf[TX_SIZES][PLANE_TYPES][BASE_RANGE_SETS]
[LEVEL_CONTEXTS][CDF_SIZE(2)];
#endif
#if CONFIG_CTX1D
aom_cdf_prob eob_mode_cdf[TX_SIZES][PLANE_TYPES][TX_CLASSES][CDF_SIZE(2)];
aom_cdf_prob empty_line_cdf[TX_SIZES][PLANE_TYPES][TX_CLASSES]
[EMPTY_LINE_CONTEXTS][CDF_SIZE(2)];
aom_cdf_prob hv_eob_cdf[TX_SIZES][PLANE_TYPES][TX_CLASSES][HV_EOB_CONTEXTS]
[CDF_SIZE(2)];
#endif // CONFIG_CTX1D
#endif // LV_MAP_PROB
#endif
......@@ -430,6 +442,12 @@ typedef struct FRAME_COUNTS {
unsigned int coeff_lps[TX_SIZES][PLANE_TYPES][LEVEL_CONTEXTS][2];
unsigned int coeff_br[TX_SIZES][PLANE_TYPES][BASE_RANGE_SETS][LEVEL_CONTEXTS]
[2];
#if CONFIG_CTX1D
unsigned int eob_mode[TX_SIZES][PLANE_TYPES][TX_CLASSES][2];
unsigned int empty_line[TX_SIZES][PLANE_TYPES][TX_CLASSES]
[EMPTY_LINE_CONTEXTS][2];
unsigned int hv_eob[TX_SIZES][PLANE_TYPES][TX_CLASSES][HV_EOB_CONTEXTS][2];
#endif // CONFIG_CTX1D
#endif // CONFIG_LV_MAP
av1_blockz_count_model blockz_count[TX_SIZES][PLANE_TYPES];
......
......@@ -210,6 +210,10 @@ typedef enum ATTRIBUTE_PACKED {
#define MAX_TX_DEPTH (TX_SIZES - TX_SIZE_CTX_MIN)
#if CONFIG_CTX1D
#define MAX_HVTX_SIZE (1 << 5)
#endif // CONFIG_CTX1D
#define MAX_TX_SIZE_LOG2 (5 + CONFIG_TX64X64)
#define MAX_TX_SIZE (1 << MAX_TX_SIZE_LOG2)
#define MIN_TX_SIZE_LOG2 2
......
......@@ -172,6 +172,44 @@ void av1_init_txb_probs(FRAME_CONTEXT *fc) {
#endif // BR_NODE
}
}
#if CONFIG_CTX1D
for (tx_size = 0; tx_size < TX_SIZES; ++tx_size) {
for (plane = 0; plane < PLANE_TYPES; ++plane) {
for (int tx_class = 0; tx_class < TX_CLASSES; ++tx_class) {
fc->eob_mode_cdf[tx_size][plane][tx_class][0] = AOM_ICDF(
128 * (aom_cdf_prob)fc->eob_mode[tx_size][plane][tx_class]);
fc->eob_mode_cdf[tx_size][plane][tx_class][1] = AOM_ICDF(32768);
fc->eob_mode_cdf[tx_size][plane][tx_class][2] = AOM_ICDF(0);
}
}
}
for (tx_size = 0; tx_size < TX_SIZES; ++tx_size) {
for (plane = 0; plane < PLANE_TYPES; ++plane) {
for (int tx_class = 0; tx_class < TX_CLASSES; ++tx_class) {
for (ctx = 0; ctx < EMPTY_LINE_CONTEXTS; ++ctx) {
fc->empty_line_cdf[tx_size][plane][tx_class][ctx][0] = AOM_ICDF(
128 *
(aom_cdf_prob)fc->empty_line[tx_size][plane][tx_class][ctx]);
fc->empty_line_cdf[tx_size][plane][tx_class][ctx][1] =
AOM_ICDF(32768);
fc->empty_line_cdf[tx_size][plane][tx_class][ctx][2] = AOM_ICDF(0);
}
}
}
}
for (tx_size = 0; tx_size < TX_SIZES; ++tx_size) {
for (plane = 0; plane < PLANE_TYPES; ++plane) {
for (int tx_class = 0; tx_class < TX_CLASSES; ++tx_class) {
for (ctx = 0; ctx < HV_EOB_CONTEXTS; ++ctx) {
fc->hv_eob_cdf[tx_size][plane][tx_class][ctx][0] = AOM_ICDF(
128 * (aom_cdf_prob)fc->hv_eob[tx_size][plane][tx_class][ctx]);
fc->hv_eob_cdf[tx_size][plane][tx_class][ctx][1] = AOM_ICDF(32768);
fc->hv_eob_cdf[tx_size][plane][tx_class][ctx][2] = AOM_ICDF(0);
}
}
}
}
#endif // CONFIG_CTX1D
}
#endif // LV_MAP_PROB
......@@ -239,6 +277,34 @@ void av1_adapt_txb_probs(AV1_COMMON *cm, unsigned int count_sat,
#endif // BR_NODE
}
}
#if CONFIG_CTX1D
for (tx_size = 0; tx_size < TX_SIZES; ++tx_size) {
for (plane = 0; plane < PLANE_TYPES; ++plane)
for (int tx_class = 0; tx_class < TX_CLASSES; ++tx_class)
fc->eob_mode[tx_size][plane][tx_class] =
merge_probs(pre_fc->eob_mode[tx_size][plane][tx_class],
counts->eob_mode[tx_size][plane][tx_class], count_sat,
update_factor);
}
for (tx_size = 0; tx_size < TX_SIZES; ++tx_size) {
for (plane = 0; plane < PLANE_TYPES; ++plane)
for (int tx_class = 0; tx_class < TX_CLASSES; ++tx_class)
for (ctx = 0; ctx < EMPTY_LINE_CONTEXTS; ++ctx)
fc->empty_line[tx_size][plane][tx_class][ctx] =
merge_probs(pre_fc->empty_line[tx_size][plane][tx_class][ctx],
counts->empty_line[tx_size][plane][tx_class][ctx],
count_sat, update_factor);
}
for (tx_size = 0; tx_size < TX_SIZES; ++tx_size) {
for (plane = 0; plane < PLANE_TYPES; ++plane)
for (int tx_class = 0; tx_class < TX_CLASSES; ++tx_class)
for (ctx = 0; ctx < HV_EOB_CONTEXTS; ++ctx)
fc->hv_eob[tx_size][plane][tx_class][ctx] =
merge_probs(pre_fc->hv_eob[tx_size][plane][tx_class][ctx],
counts->hv_eob[tx_size][plane][tx_class][ctx],
count_sat, update_factor);
}
#endif
}
void av1_init_lv_map(AV1_COMMON *cm) {
......
......@@ -367,11 +367,21 @@ static INLINE int get_eob_ctx(const tran_low_t *tcoeffs,
const int coeff_idx, // raster order
const TX_SIZE txs_ctx, TX_TYPE tx_type) {
(void)tcoeffs;
int offset = 0;
#if CONFIG_CTX1D
TX_CLASS tx_class = get_tx_class(tx_type);
if (tx_class == TX_CLASS_VERT)
offset = EOB_COEF_CONTEXTS_2D;
else if (tx_class == TX_CLASS_HORIZ)
offset = EOB_COEF_CONTEXTS_2D + EOB_COEF_CONTEXTS_1D;
#else
(void)tx_type;
if (txs_ctx == TX_4X4) return av1_coeff_band_4x4[coeff_idx];
if (txs_ctx == TX_8X8) return av1_coeff_band_8x8[coeff_idx];
if (txs_ctx == TX_16X16) return av1_coeff_band_16x16[coeff_idx];
if (txs_ctx == TX_32X32) return av1_coeff_band_32x32[coeff_idx];
#endif
if (txs_ctx == TX_4X4) return offset + av1_coeff_band_4x4[coeff_idx];
if (txs_ctx == TX_8X8) return offset + av1_coeff_band_8x8[coeff_idx];
if (txs_ctx == TX_16X16) return offset + av1_coeff_band_16x16[coeff_idx];
if (txs_ctx == TX_32X32) return offset + av1_coeff_band_32x32[coeff_idx];
assert(0);
return 0;
......@@ -467,4 +477,78 @@ void av1_adapt_txb_probs(AV1_COMMON *cm, unsigned int count_sat,
unsigned int update_factor);
void av1_init_lv_map(AV1_COMMON *cm);
#if CONFIG_CTX1D
static INLINE void get_eob_vert(int16_t *eob_ls, const tran_low_t *tcoeff,
int w, int h) {
for (int c = 0; c < w; ++c) {
eob_ls[c] = 0;
for (int r = h - 1; r >= 0; --r) {
int coeff_idx = r * w + c;
if (tcoeff[coeff_idx] != 0) {
eob_ls[c] = r + 1;
break;
}
}
}
}
static INLINE void get_eob_horiz(int16_t *eob_ls, const tran_low_t *tcoeff,
int w, int h) {
for (int r = 0; r < h; ++r) {
eob_ls[r] = 0;
for (int c = w - 1; c >= 0; --c) {
int coeff_idx = r * w + c;
if (tcoeff[coeff_idx] != 0) {
eob_ls[r] = c + 1;
break;
}
}
}
}
static INLINE int get_empty_line_ctx(int line_idx, int16_t *eob_ls) {
if (line_idx > 0) {
int prev_eob = eob_ls[line_idx - 1];
if (prev_eob == 0) {
return 1;
} else if (prev_eob < 3) {
return 2;
} else if (prev_eob < 6) {
return 3;
} else {
return 4;
}
} else {
return 0;
}
}
#define MAX_POS_CTX 8
static int pos_ctx[MAX_HVTX_SIZE] = {
0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5,
6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7,
};
static INLINE int get_hv_eob_ctx(int line_idx, int pos, int16_t *eob_ls) {
if (line_idx > 0) {
int prev_eob = eob_ls[line_idx - 1];
int diff = pos + 1 - prev_eob;
int abs_diff = abs(diff);
int ctx_idx = pos_ctx[abs_diff];
assert(ctx_idx < MAX_POS_CTX);
if (diff < 0) {
ctx_idx += MAX_POS_CTX;
assert(ctx_idx >= MAX_POS_CTX);
assert(ctx_idx < 2 * MAX_POS_CTX);
}
return ctx_idx;
} else {
int ctx_idx = MAX_POS_CTX + MAX_POS_CTX + pos_ctx[pos];
assert(ctx_idx < HV_EOB_CONTEXTS);
assert(HV_EOB_CONTEXTS == MAX_POS_CTX * 3);
return ctx_idx;
}
}
#endif // CONFIG_CTX1D
#endif // AV1_COMMON_TXB_COMMON_H_
......@@ -41,6 +41,217 @@ static int read_golomb(MACROBLOCKD *xd, aom_reader *r) {
return x - 1;
}
static INLINE int read_nz_map(aom_reader *r, tran_low_t *tcoeffs, int plane,
const int16_t *scan, TX_SIZE tx_size,
TX_TYPE tx_type, FRAME_CONTEXT *fc,
FRAME_COUNTS *counts) {
TX_SIZE txs_ctx = get_txsize_context(tx_size);
const int bwl = b_width_log2_lookup[txsize_to_bsize[tx_size]] + 2;
const int height = tx_size_high[tx_size];
#if CONFIG_CTX1D
const int width = tx_size_wide[tx_size];
const int eob_offset = width + height;
const TX_CLASS tx_class = get_tx_class(tx_type);
const int seg_eob =
(tx_class == TX_CLASS_2D) ? tx_size_2d[tx_size] : eob_offset;
#else