Commit cf85d5c8 authored by Angie Chiang's avatar Angie Chiang

Separate horiz/vert/2d txfm's nz ctx in lv_map

This give us 0.16% gain on lowres

Change-Id: Iaf1932dc54a3e6eeb2e2efa2872222df2a08257e
parent 8b53d315
......@@ -60,7 +60,15 @@ extern "C" {
#if CONFIG_LV_MAP
#define TXB_SKIP_CONTEXTS 13
#if CONFIG_EXT_TX
#define SIG_COEF_CONTEXTS_2D 20
#define SIG_COEF_CONTEXTS_1D 20
#define SIG_COEF_CONTEXTS \
(SIG_COEF_CONTEXTS_2D + SIG_COEF_CONTEXTS_1D + SIG_COEF_CONTEXTS_1D)
#else
#define SIG_COEF_CONTEXTS_2D 20
#define SIG_COEF_CONTEXTS 20
#endif
#define EOB_COEF_CONTEXTS 25
#define COEFF_BASE_CONTEXTS 42
#define DC_SIGN_CONTEXTS 3
......@@ -76,6 +84,14 @@ extern "C" {
#define COEFF_CONTEXT_MASK ((1 << COEFF_CONTEXT_BITS) - 1)
#define BASE_CONTEXT_POSITION_NUM 12
typedef enum TX_CLASS {
TX_CLASS_2D = 0,
TX_CLASS_HORIZ = 1,
TX_CLASS_VERT = 2,
TX_CLASSES = 3,
} TX_CLASS;
#endif
DECLARE_ALIGNED(16, extern const uint8_t, av1_pt_energy_class[ENTROPY_TOKENS]);
......
......@@ -172,38 +172,138 @@ const aom_prob default_coeff_base
};
const aom_prob default_nz_map[TX_SIZES][PLANE_TYPES][SIG_COEF_CONTEXTS] = {
#if CONFIG_EXT_TX
#if CONFIG_CHROMA_2X2
{
{ 34, 103, 61, 106, 62, 160, 112, 54, 173, 121,
75, 157, 92, 75, 157, 129, 94, 65, 52, 37,
34, 103, 61, 106, 62, 160, 112, 54, 173, 121,
75, 157, 92, 75, 157, 129, 94, 65, 52, 37,
34, 103, 61, 106, 62, 160, 112, 54, 173, 121,
75, 157, 92, 75, 157, 129, 94, 65, 52, 37 },
{ 52, 124, 84, 136, 107, 197, 161, 82, 183, 151,
109, 153, 140, 103, 152, 134, 109, 81, 69, 50,
52, 124, 84, 136, 107, 197, 161, 82, 183, 151,
109, 153, 140, 103, 152, 134, 109, 81, 69, 50,
52, 124, 84, 136, 107, 197, 161, 82, 183, 151,
109, 153, 140, 103, 152, 134, 109, 81, 69, 50 },
},
#endif
{
{ 34, 103, 61, 106, 62, 160, 112, 54, 173, 121,
75, 157, 92, 75, 157, 129, 94, 65, 52, 37,
34, 103, 61, 106, 62, 160, 112, 54, 173, 121,
75, 157, 92, 75, 157, 129, 94, 65, 52, 37,
34, 103, 61, 106, 62, 160, 112, 54, 173, 121,
75, 157, 92, 75, 157, 129, 94, 65, 52, 37 },
{ 52, 124, 84, 136, 107, 197, 161, 82, 183, 151,
109, 153, 140, 103, 152, 134, 109, 81, 69, 50,
52, 124, 84, 136, 107, 197, 161, 82, 183, 151,
109, 153, 140, 103, 152, 134, 109, 81, 69, 50,
52, 124, 84, 136, 107, 197, 161, 82, 183, 151,
109, 153, 140, 103, 152, 134, 109, 81, 69, 50 },
},
{
{ 34, 127, 74, 124, 74, 204, 153, 76, 226, 162,
92, 207, 126, 91, 227, 192, 149, 108, 85, 55,
34, 127, 74, 124, 74, 204, 153, 76, 226, 162,
92, 207, 126, 91, 227, 192, 149, 108, 85, 55,
34, 127, 74, 124, 74, 204, 153, 76, 226, 162,
92, 207, 126, 91, 227, 192, 149, 108, 85, 55 },
{ 43, 136, 115, 158, 130, 212, 187, 112, 231, 180,
130, 202, 164, 130, 236, 204, 168, 139, 112, 114,
43, 136, 115, 158, 130, 212, 187, 112, 231, 180,
130, 202, 164, 130, 236, 204, 168, 139, 112, 114,
43, 136, 115, 158, 130, 212, 187, 112, 231, 180,
130, 202, 164, 130, 236, 204, 168, 139, 112, 114 },
},
{
{ 25, 117, 70, 120, 77, 215, 171, 102, 234, 156,
105, 235, 155, 109, 247, 220, 176, 127, 92, 72,
25, 117, 70, 120, 77, 215, 171, 102, 234, 156,
105, 235, 155, 109, 247, 220, 176, 127, 92, 72,
25, 117, 70, 120, 77, 215, 171, 102, 234, 156,
105, 235, 155, 109, 247, 220, 176, 127, 92, 72 },
{ 24, 88, 49, 100, 62, 202, 148, 62, 237, 178,
102, 233, 168, 105, 244, 198, 162, 127, 103, 71,
24, 88, 49, 100, 62, 202, 148, 62, 237, 178,
102, 233, 168, 105, 244, 198, 162, 127, 103, 71,
24, 88, 49, 100, 62, 202, 148, 62, 237, 178,
102, 233, 168, 105, 244, 198, 162, 127, 103, 71 },
},
{
{ 11, 54, 17, 69, 26, 128, 125, 56, 232, 130,
60, 237, 121, 66, 250, 168, 134, 114, 93, 53,
11, 54, 17, 69, 26, 128, 125, 56, 232, 130,
60, 237, 121, 66, 250, 168, 134, 114, 93, 53,
11, 54, 17, 69, 26, 128, 125, 56, 232, 130,
60, 237, 121, 66, 250, 168, 134, 114, 93, 53 },
{ 21, 52, 32, 95, 64, 171, 152, 70, 247, 159,
81, 252, 177, 100, 252, 221, 192, 143, 195, 146,
21, 52, 32, 95, 64, 171, 152, 70, 247, 159,
81, 252, 177, 100, 252, 221, 192, 143, 195, 146,
21, 52, 32, 95, 64, 171, 152, 70, 247, 159,
81, 252, 177, 100, 252, 221, 192, 143, 195, 146 },
},
#else // CONFIG_EXT_TX
#if CONFIG_CHROMA_2X2
{
{ 34, 103, 61, 106, 62, 160, 112, 54, 173, 121,
75, 157, 92, 75, 157, 129, 94, 65, 52, 37 },
{ 52, 124, 84, 136, 107, 197, 161, 82, 183, 151,
109, 153, 140, 103, 152, 134, 109, 81, 69, 50 },
},
#endif
{
{ 34, 103, 61, 106, 62, 160, 112, 54, 173, 121,
75, 157, 92, 75, 157, 129, 94, 65, 52, 37 },
{ 52, 124, 84, 136, 107, 197, 161, 82, 183, 151,
109, 153, 140, 103, 152, 134, 109, 81, 69, 50 },
},
{
{ 34, 127, 74, 124, 74, 204, 153, 76, 226, 162,
92, 207, 126, 91, 227, 192, 149, 108, 85, 55 },
{ 43, 136, 115, 158, 130, 212, 187, 112, 231, 180,
130, 202, 164, 130, 236, 204, 168, 139, 112, 114 },
},
{
{ 25, 117, 70, 120, 77, 215, 171, 102, 234, 156,
105, 235, 155, 109, 247, 220, 176, 127, 92, 72 },
{ 24, 88, 49, 100, 62, 202, 148, 62, 237, 178,
102, 233, 168, 105, 244, 198, 162, 127, 103, 71 },
},
{
{ 11, 54, 17, 69, 26, 128, 125, 56, 232, 130,
60, 237, 121, 66, 250, 168, 134, 114, 93, 53 },
{ 21, 52, 32, 95, 64, 171, 152, 70, 247, 159,
81, 252, 177, 100, 252, 221, 192, 143, 195, 146 },
},
#endif // CONFIG_EXT_TX
};
const aom_prob default_eob_flag[TX_SIZES][PLANE_TYPES][EOB_COEF_CONTEXTS] = {
......
......@@ -271,6 +271,20 @@ static INLINE int get_nz_count(const tran_low_t *tcoeffs, int bwl, int height,
return count;
}
static INLINE TX_CLASS get_tx_class(TX_TYPE tx_type) {
switch (tx_type) {
#if CONFIG_EXT_TX
case V_DCT:
case V_ADST:
case V_FLIPADST: return TX_CLASS_VERT;
case H_DCT:
case H_ADST:
case H_FLIPADST: return TX_CLASS_HORIZ;
#endif
default: return TX_CLASS_2D;
}
}
// TODO(angiebird): optimize this function by generate a table that maps from
// count to ctx
static INLINE int get_nz_map_ctx_from_count(int count,
......@@ -282,12 +296,24 @@ static INLINE int get_nz_map_ctx_from_count(int count,
const int row = coeff_idx >> bwl;
const int col = coeff_idx - (row << bwl);
int ctx = 0;
#if CONFIG_EXT_TX
int tx_class = get_tx_class(tx_type);
int offset;
if (tx_class == TX_CLASS_2D)
offset = 0;
else if (tx_class == TX_CLASS_VERT)
offset = SIG_COEF_CONTEXTS_2D;
else
offset = SIG_COEF_CONTEXTS_2D + SIG_COEF_CONTEXTS_1D;
#else
int offset = 0;
#endif
if (row == 0 && col == 0) return 0;
if (row == 0 && col == 0) return offset + 0;
if (row == 0 && col == 1) return 1 + (tcoeffs[0] != 0);
if (row == 0 && col == 1) return offset + 1 + (tcoeffs[0] != 0);
if (row == 1 && col == 0) return 3 + (tcoeffs[0] != 0);
if (row == 1 && col == 0) return offset + 3 + (tcoeffs[0] != 0);
if (row == 1 && col == 1) {
int pos;
......@@ -301,28 +327,28 @@ static INLINE int get_nz_map_ctx_from_count(int count,
assert(5 + ctx <= 7);
return 5 + ctx;
return offset + 5 + ctx;
}
if (row == 0) {
ctx = (count + 1) >> 1;
assert(ctx < 3);
return 8 + ctx;
return offset + 8 + ctx;
}
if (col == 0) {
ctx = (count + 1) >> 1;
assert(ctx < 3);
return 11 + ctx;
return offset + 11 + ctx;
}
ctx = count >> 1;
assert(14 + ctx < 20);
return 14 + ctx;
return offset + 14 + ctx;
}
static INLINE int get_nz_map_ctx(const tran_low_t *tcoeffs,
......
......@@ -8447,7 +8447,7 @@ static int64_t motion_mode_rd(
(void)rate_mv;
(void)is_comp_pred;
(void)this_mode;
#if !CONFIG_WARPED_MOTION
#if !CONFIG_WARPED_MOTION && CONFIG_MOTION_VAR
(void)single_newmv;
#endif
......
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