Removes the code_nonzerocount experiment

This patch does not seem to give any benefits.

Change-Id: I9d2b4091d6af3dfc0875f24db86c01e2de57f8db
This commit is contained in:
Deb Mukherjee 2013-04-22 10:58:49 -07:00
Родитель 70d9f116fd
Коммит 0aa79be7d5
20 изменённых файлов: 37 добавлений и 3581 удалений

1
configure поставляемый
Просмотреть файл

@ -243,7 +243,6 @@ EXPERIMENT_LIST="
newbintramodes
comp_interintra_pred
enable_6tap
code_nonzerocount
modelcoefprob
loop_dering
implicit_compoundinter_weight

Просмотреть файл

@ -282,9 +282,6 @@ typedef struct {
INTERPOLATIONFILTERTYPE interp_filter;
BLOCK_SIZE_TYPE sb_type;
#if CONFIG_CODE_NONZEROCOUNT
uint16_t nzcs[256+64*2];
#endif
} MB_MODE_INFO;
typedef struct {
@ -363,9 +360,6 @@ struct mb_plane {
BLOCK_OFFSET((x)->plane[2].field, ((i) - 20), 16))
typedef struct macroblockd {
#if CONFIG_CODE_NONZEROCOUNT
DECLARE_ALIGNED(16, uint16_t, nzcs[256+64*2]);
#endif
struct mb_plane plane[MAX_MB_PLANE];
/* 16 Y blocks, 4 U, 4 V, each with 16 entries. */
@ -753,12 +747,6 @@ static TX_SIZE get_uv_tx_size(const MACROBLOCKD *xd) {
return size;
}
#if CONFIG_CODE_NONZEROCOUNT
static int get_nzc_used(TX_SIZE tx_size) {
return (tx_size >= TX_16X16);
}
#endif
struct plane_block_idx {
int plane;
int block;

Просмотреть файл

@ -18,14 +18,6 @@ static const vp9_prob vp9_coef_update_prob[ENTROPY_NODES] = {
252, 252, 252, 252, 252, 252, 252, 252, 252, 252, 252
};
#if CONFIG_CODE_NONZEROCOUNT
#define NZC_UPDATE_PROB_4X4 252
#define NZC_UPDATE_PROB_8X8 252
#define NZC_UPDATE_PROB_16X16 252
#define NZC_UPDATE_PROB_32X32 252
#define NZC_UPDATE_PROB_PCAT 252
#endif
#if CONFIG_CODE_ZEROGROUP
#define ZPC_UPDATE_PROB 248
#endif

Просмотреть файл

@ -700,302 +700,6 @@ static const vp9_coeff_probs default_coef_probs_32x32[BLOCK_TYPES] = {
}
};
#if CONFIG_CODE_NONZEROCOUNT
// TODO(debargha): Remove the macro and count tables after experimentation
#define NZC_DEFAULT_COUNTS /* Uncomment to use counts as defaults */
#ifdef NZC_DEFAULT_COUNTS
static const unsigned int default_nzc_counts_4x4[MAX_NZC_CONTEXTS]
[REF_TYPES]
[BLOCK_TYPES]
[NZC4X4_TOKENS] = {
{
{
{ 967652, 29023, 15039, 6952, 1568, 116 },
{ 289116, 22938, 4522, 1935, 520, 47 }
}, {
{ 967652, 29023, 15039, 6952, 1568, 116 },
{ 689116, 22938, 4522, 1935, 520, 47 }
},
}, {
{
{ 124684, 37167, 15270, 8483, 1777, 102 },
{ 10405, 12395, 3401, 3574, 2461, 771 }
}, {
{ 124684, 37167, 15270, 8483, 1777, 102 },
{ 20405, 12395, 3401, 3574, 2461, 771 }
}
}, {
{
{ 4100, 22976, 15627, 16137, 7982, 1793 },
{ 4249, 3084, 2131, 4081, 6439, 1653 }
}, {
{ 21100, 22976, 15627, 16137, 7982, 1793 },
{ 4249, 3084, 2131, 4081, 2439, 1653 }
}
}
};
static const unsigned int default_nzc_counts_8x8[MAX_NZC_CONTEXTS]
[REF_TYPES]
[BLOCK_TYPES]
[NZC8X8_TOKENS] = {
{
{
{ 372988, 62777, 19440, 11812, 5145, 1917, 439, 10 },
{ 72052, 30468, 6973, 3250, 1500, 750, 375, 5 },
}, {
{ 372988, 62777, 19440, 11812, 5145, 1917, 439, 10 },
{ 192052, 30468, 6973, 3250, 1500, 750, 375, 5 },
}
}, {
{
{ 121533, 33527, 15655, 11920, 5723, 2009, 315, 7 },
{ 23772, 23120, 13127, 8115, 4000, 2000, 200, 6 },
}, {
{ 121533, 33527, 15655, 11920, 5723, 2009, 315, 7 },
{ 23772, 23120, 13127, 8115, 4000, 2000, 200, 6 },
}
}, {
{
{ 29408, 11758, 8023, 10123, 6705, 2468, 369, 17 },
{ 11612, 13874, 13329, 13022, 6500, 3250, 300, 12 },
}, {
{ 29408, 11758, 8023, 10123, 6705, 2468, 369, 17 },
{ 11612, 13874, 13329, 13022, 6500, 3250, 300, 12 },
}
}
};
static const unsigned int default_nzc_counts_16x16[MAX_NZC_CONTEXTS]
[REF_TYPES]
[BLOCK_TYPES]
[NZC16X16_TOKENS] = {
{
{
{ 372988, 62777, 19440, 11812, 5145, 1917, 439, 10, 5, 2 },
{ 72052, 30468, 6973, 3250, 1500, 750, 375, 50, 8, 1 },
}, {
{ 32988, 62777, 19440, 11812, 5145, 1917, 439, 10, 5, 2 },
{ 92052, 30468, 6973, 3250, 1500, 750, 375, 50, 8, 1 },
}
}, {
{
{ 21533, 33527, 15655, 11920, 5723, 2009, 315, 7, 4, 2 },
{ 47772, 23120, 13127, 8115, 4000, 2000, 200, 6, 4, 2 },
}, {
{ 21533, 33527, 15655, 11920, 5723, 2009, 315, 7, 4, 2 },
{ 27772, 23120, 13127, 8115, 4000, 2000, 200, 6, 4, 2 },
}
}, {
{
{ 19408, 31758, 16023, 10123, 6705, 2468, 369, 17, 10, 5 },
{ 9612, 13874, 13329, 13022, 6500, 3250, 300, 12, 6, 3 },
}, {
{ 22408, 11758, 8023, 10123, 6705, 2468, 369, 17, 10, 5 },
{ 9612, 13874, 13329, 13022, 6500, 3250, 300, 12, 6, 3 },
}
}
};
static const unsigned int default_nzc_counts_32x32[MAX_NZC_CONTEXTS]
[REF_TYPES]
[BLOCK_TYPES]
[NZC32X32_TOKENS] = {
{
{
{ 72988, 62777, 19440, 11812, 5145, 1917, 439, 10, 5, 2, 1, 0 },
{ 52052, 30468, 6973, 3250, 1500, 750, 375, 50, 8, 1, 0, 0 },
}, {
{ 72988, 62777, 19440, 11812, 5145, 1917, 439, 10, 5, 2, 1, 0 },
{ 72052, 30468, 6973, 3250, 1500, 750, 375, 50, 8, 1, 0, 0 },
}
}, {
{
{ 21533, 33527, 15655, 11920, 5723, 2009, 315, 7, 4, 2, 1, 0 },
{ 27772, 23120, 13127, 8115, 4000, 2000, 200, 6, 4, 2, 1, 0 },
}, {
{ 21533, 33527, 15655, 11920, 5723, 2009, 315, 7, 4, 2, 1, 0 },
{ 27772, 23120, 13127, 8115, 4000, 2000, 200, 6, 4, 2, 1, 0 },
}
}, {
{
{ 19408, 11758, 8023, 10123, 6705, 2468, 369, 17, 10, 5, 2, 1 },
{ 9612, 13874, 13329, 13022, 6500, 3250, 300, 12, 6, 3, 2, 1 },
}, {
{ 29408, 11758, 8023, 10123, 6705, 2468, 369, 17, 10, 5, 2, 1 },
{ 9612, 13874, 13329, 13022, 6500, 3250, 300, 12, 6, 3, 2, 1 },
}
}
};
#else
static const vp9_prob default_nzc_probs_4x4[MAX_NZC_CONTEXTS]
[REF_TYPES]
[BLOCK_TYPES]
[NZC4X4_TOKENS] = {
{
{
{ 219, 162, 179, 142, 242, },
{ 214, 253, 228, 246, 255, },
}, {
{ 225, 236, 190, 229, 253, },
{ 251, 253, 240, 248, 255, },
},
}, {
{
{ 106, 126, 158, 126, 244, },
{ 118, 241, 201, 240, 255, },
}, {
{ 165, 179, 143, 189, 242, },
{ 173, 239, 192, 255, 128, },
},
}, {
{
{ 42 , 78 , 153, 92 , 223, },
{ 128, 128, 128, 128, 128, },
}, {
{ 76 , 68 , 126, 110, 216, },
{ 128, 128, 128, 128, 128, },
},
},
};
static const vp9_prob default_nzc_probs_8x8[MAX_NZC_CONTEXTS]
[REF_TYPES]
[BLOCK_TYPES]
[NZC8X8_TOKENS] = {
{
{
{ 134, 139, 170, 178, 142, 197, 255, },
{ 167, 224, 199, 252, 205, 255, 128, },
}, {
{ 181, 210, 180, 241, 190, 235, 255, },
{ 234, 251, 235, 252, 219, 255, 128, },
},
}, {
{
{ 33 , 64 , 155, 143, 86 , 216, 255, },
{ 73 , 160, 167, 251, 153, 255, 128, },
}, {
{ 79 , 104, 153, 195, 119, 246, 255, },
{ 149, 183, 186, 249, 203, 255, 128, },
},
}, {
{
{ 10 , 25 , 156, 61 , 69 , 156, 254, },
{ 32 , 1 , 128, 146, 64 , 255, 128, },
}, {
{ 37 , 48 , 143, 113, 81 , 202, 255, },
{ 1 , 255, 128, 128, 128, 128, 128, },
},
},
};
static const vp9_prob default_nzc_probs_16x16[MAX_NZC_CONTEXTS]
[REF_TYPES]
[BLOCK_TYPES]
[NZC16X16_TOKENS] = {
{
{
{ 11 , 188, 210, 167, 141, 143, 152, 255, 128, },
{ 171, 201, 203, 244, 207, 255, 255, 128, 128, },
}, {
{ 23 , 217, 207, 251, 198, 255, 219, 128, 128, },
{ 235, 249, 229, 255, 199, 128, 128, 128, 128, },
},
}, {
{
{ 9 , 45 , 168, 85 , 66 , 221, 139, 246, 255, },
{ 51 , 110, 163, 238, 94 , 255, 255, 128, 128, },
}, {
{ 4 , 149, 175, 240, 149, 255, 205, 128, 128, },
{ 141, 217, 186, 255, 128, 128, 128, 128, 128, },
},
}, {
{
{ 1 , 12 , 173, 6 , 68 , 145, 41 , 204, 255, },
{ 39 , 47 , 128, 199, 110, 255, 128, 128, 128, },
}, {
{ 1 , 121, 171, 149, 115, 242, 159, 255, 128, },
{ 1 , 255, 255, 128, 128, 128, 128, 128, 128, },
},
},
};
static const vp9_prob default_nzc_probs_32x32[MAX_NZC_CONTEXTS]
[REF_TYPES]
[BLOCK_TYPES]
[NZC32X32_TOKENS] = {
{
{
{ 11 , 216, 195, 201, 160, 247, 217, 255, 255, 128, 128, },
{ 177, 240, 239, 255, 192, 128, 128, 128, 128, 128, 128, },
}, {
{ 48 , 235, 213, 235, 199, 255, 255, 128, 128, 128, 128, },
{ 205, 255, 248, 128, 128, 128, 128, 128, 128, 128, 128, },
},
}, {
{
{ 6 , 96 , 138, 99 , 125, 248, 188, 255, 128, 128, 128, },
{ 17 , 53 , 43 , 189, 1 , 255, 171, 128, 128, 128, 128, },
}, {
{ 5 , 187, 235, 232, 117, 255, 219, 128, 128, 128, 128, },
{ 146, 255, 255, 128, 128, 128, 128, 128, 128, 128, 128, },
},
}, {
{
{ 1 , 7 , 93 , 14 , 100, 30 , 85 , 65 , 81 , 210, 255, },
{ 1 , 1 , 128, 26 , 1 , 218, 78 , 255, 255, 128, 128, },
}, {
{ 4 , 148, 206, 137, 160, 255, 255, 128, 128, 128, 128, },
{ 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, },
},
},
};
#endif
static const vp9_prob default_nzc_pcat_probs[MAX_NZC_CONTEXTS]
[NZC_TOKENS_EXTRA]
[NZC_BITS_EXTRA] = {
// Bit probabilities are in least to most significance order
{
{176, 128, 128, 128, 128, 128, 128, 128, 128}, // 3 - 4
{164, 192, 128, 128, 128, 128, 128, 128, 128}, // 5 - 8
{154, 184, 208, 128, 128, 128, 128, 128, 128}, // 9 - 16
{144, 176, 200, 216, 128, 128, 128, 128, 128}, // 17 - 32
{140, 172, 192, 208, 224, 128, 128, 128, 128}, // 33 - 64
{136, 168, 188, 200, 220, 232, 128, 128, 128}, // 65 - 128
{132, 164, 184, 196, 216, 228, 240, 128, 128}, // 129 - 256
{130, 162, 178, 194, 212, 226, 240, 248, 128}, // 257 - 512
{128, 160, 176, 192, 208, 224, 240, 248, 254}, // 513 - 1024
}, {
{168, 128, 128, 128, 128, 128, 128, 128, 128}, // 3 - 4
{152, 184, 128, 128, 128, 128, 128, 128, 128}, // 5 - 8
{152, 184, 208, 128, 128, 128, 128, 128, 128}, // 9 - 16
{144, 176, 200, 216, 128, 128, 128, 128, 128}, // 17 - 32
{140, 172, 192, 208, 224, 128, 128, 128, 128}, // 33 - 64
{136, 168, 188, 200, 220, 232, 128, 128, 128}, // 65 - 128
{132, 164, 184, 196, 216, 228, 240, 128, 128}, // 129 - 256
{130, 162, 178, 194, 212, 226, 240, 248, 128}, // 257 - 512
{128, 160, 176, 192, 208, 224, 240, 248, 254}, // 513 - 1024
}, {
{160, 128, 128, 128, 128, 128, 128, 128, 128}, // 3 - 4
{152, 176, 128, 128, 128, 128, 128, 128, 128}, // 5 - 8
{150, 184, 208, 128, 128, 128, 128, 128, 128}, // 9 - 16
{144, 176, 200, 216, 128, 128, 128, 128, 128}, // 17 - 32
{140, 172, 192, 208, 224, 128, 128, 128, 128}, // 33 - 64
{136, 168, 188, 200, 220, 232, 128, 128, 128}, // 65 - 128
{132, 164, 184, 196, 216, 228, 240, 128, 128}, // 129 - 256
{130, 162, 178, 194, 212, 226, 240, 248, 128}, // 257 - 512
{128, 160, 176, 192, 208, 224, 240, 248, 254}, // 513 - 1024
},
};
#endif // CONFIG_CODE_NONZEROCOUNT
#if CONFIG_CODE_ZEROGROUP
// There are two probs: the first is the prob(0) of the isolated zero bit,

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -167,89 +167,6 @@ void vp9_get_model_distribution(vp9_prob model, vp9_prob *tree_probs,
int b, int r);
#endif // CONFIG_MODELCOEFPROB
#if CONFIG_CODE_NONZEROCOUNT
/* Alphabet for number of non-zero symbols in block */
#define NZC_0 0 /* Used for all blocks */
#define NZC_1 1 /* Used for all blocks */
#define NZC_2 2 /* Used for all blocks */
#define NZC_3TO4 3 /* Used for all blocks */
#define NZC_5TO8 4 /* Used for all blocks */
#define NZC_9TO16 5 /* Used for all blocks */
#define NZC_17TO32 6 /* Used for 8x8 and larger blocks */
#define NZC_33TO64 7 /* Used for 8x8 and larger blocks */
#define NZC_65TO128 8 /* Used for 16x16 and larger blocks */
#define NZC_129TO256 9 /* Used for 16x16 and larger blocks */
#define NZC_257TO512 10 /* Used for 32x32 and larger blocks */
#define NZC_513TO1024 11 /* Used for 32x32 and larger blocks */
/* Number of tokens for each block size */
#define NZC4X4_TOKENS 6
#define NZC8X8_TOKENS 8
#define NZC16X16_TOKENS 10
#define NZC32X32_TOKENS 12
/* Number of nodes for each block size */
#define NZC4X4_NODES 5
#define NZC8X8_NODES 7
#define NZC16X16_NODES 9
#define NZC32X32_NODES 11
/* Max number of tokens with extra bits */
#define NZC_TOKENS_EXTRA 9
/* Max number of extra bits */
#define NZC_BITS_EXTRA 9
/* Tokens without extra bits */
#define NZC_TOKENS_NOEXTRA (NZC32X32_TOKENS - NZC_TOKENS_EXTRA)
#define MAX_NZC_CONTEXTS 3
/* whether to update extra bit probabilities */
#define NZC_PCAT_UPDATE
/* nzc trees */
extern const vp9_tree_index vp9_nzc4x4_tree[];
extern const vp9_tree_index vp9_nzc8x8_tree[];
extern const vp9_tree_index vp9_nzc16x16_tree[];
extern const vp9_tree_index vp9_nzc32x32_tree[];
/* nzc encodings */
extern struct vp9_token vp9_nzc4x4_encodings[NZC4X4_TOKENS];
extern struct vp9_token vp9_nzc8x8_encodings[NZC8X8_TOKENS];
extern struct vp9_token vp9_nzc16x16_encodings[NZC16X16_TOKENS];
extern struct vp9_token vp9_nzc32x32_encodings[NZC32X32_TOKENS];
#define codenzc(x) (\
(x) <= 3 ? (x) : (x) <= 4 ? 3 : (x) <= 8 ? 4 : \
(x) <= 16 ? 5 : (x) <= 32 ? 6 : (x) <= 64 ? 7 :\
(x) <= 128 ? 8 : (x) <= 256 ? 9 : (x) <= 512 ? 10 : 11)
int vp9_get_nzc_context_y_sb64(struct VP9Common *cm, MODE_INFO *cur,
int mb_row, int mb_col, int block);
int vp9_get_nzc_context_y_sb32(struct VP9Common *cm, MODE_INFO *cur,
int mb_row, int mb_col, int block);
int vp9_get_nzc_context_y_mb16(struct VP9Common *cm, MODE_INFO *cur,
int mb_row, int mb_col, int block);
int vp9_get_nzc_context_uv_sb64(struct VP9Common *cm, MODE_INFO *cur,
int mb_row, int mb_col, int block);
int vp9_get_nzc_context_uv_sb32(struct VP9Common *cm, MODE_INFO *cur,
int mb_row, int mb_col, int block);
int vp9_get_nzc_context_uv_mb16(struct VP9Common *cm, MODE_INFO *cur,
int mb_row, int mb_col, int block);
int vp9_get_nzc_context(struct VP9Common *cm, MACROBLOCKD *xd, int block);
void vp9_update_nzc_counts(struct VP9Common *cm, MACROBLOCKD *xd,
int mb_row, int mb_col);
void vp9_adapt_nzc_probs(struct VP9Common *cm);
/* Extra bits array */
extern const int vp9_extranzcbits[NZC32X32_TOKENS];
/* Base nzc values */
extern const int vp9_basenzcvalue[NZC32X32_TOKENS];
#endif // CONFIG_CODE_NONZEROCOUNT
#if CONFIG_CODE_ZEROGROUP
#define ZPC_STATS

Просмотреть файл

@ -74,18 +74,6 @@ typedef struct frame_contexts {
vp9_coeff_probs coef_probs_8x8[BLOCK_TYPES];
vp9_coeff_probs coef_probs_16x16[BLOCK_TYPES];
vp9_coeff_probs coef_probs_32x32[BLOCK_TYPES];
#if CONFIG_CODE_NONZEROCOUNT
vp9_prob nzc_probs_4x4[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES]
[NZC4X4_NODES];
vp9_prob nzc_probs_8x8[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES]
[NZC8X8_NODES];
vp9_prob nzc_probs_16x16[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES]
[NZC16X16_NODES];
vp9_prob nzc_probs_32x32[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES]
[NZC32X32_NODES];
vp9_prob nzc_pcat_probs[MAX_NZC_CONTEXTS]
[NZC_TOKENS_EXTRA][NZC_BITS_EXTRA];
#endif
#if CONFIG_CODE_ZEROGROUP
vp9_zpc_probs zpc_probs_4x4;
vp9_zpc_probs zpc_probs_8x8;
@ -116,18 +104,6 @@ typedef struct frame_contexts {
vp9_coeff_probs pre_coef_probs_8x8[BLOCK_TYPES];
vp9_coeff_probs pre_coef_probs_16x16[BLOCK_TYPES];
vp9_coeff_probs pre_coef_probs_32x32[BLOCK_TYPES];
#if CONFIG_CODE_NONZEROCOUNT
vp9_prob pre_nzc_probs_4x4[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES]
[NZC4X4_NODES];
vp9_prob pre_nzc_probs_8x8[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES]
[NZC8X8_NODES];
vp9_prob pre_nzc_probs_16x16[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES]
[NZC16X16_NODES];
vp9_prob pre_nzc_probs_32x32[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES]
[NZC32X32_NODES];
vp9_prob pre_nzc_pcat_probs[MAX_NZC_CONTEXTS]
[NZC_TOKENS_EXTRA][NZC_BITS_EXTRA];
#endif
#if CONFIG_CODE_ZEROGROUP
vp9_zpc_probs pre_zpc_probs_4x4;
vp9_zpc_probs pre_zpc_probs_8x8;
@ -142,18 +118,6 @@ typedef struct frame_contexts {
unsigned int eob_branch_counts[TX_SIZE_MAX_SB][BLOCK_TYPES][REF_TYPES]
[COEF_BANDS][PREV_COEF_CONTEXTS];
#if CONFIG_CODE_NONZEROCOUNT
unsigned int nzc_counts_4x4[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES]
[NZC4X4_TOKENS];
unsigned int nzc_counts_8x8[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES]
[NZC8X8_TOKENS];
unsigned int nzc_counts_16x16[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES]
[NZC16X16_TOKENS];
unsigned int nzc_counts_32x32[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES]
[NZC32X32_TOKENS];
unsigned int nzc_pcat_counts[MAX_NZC_CONTEXTS]
[NZC_TOKENS_EXTRA][NZC_BITS_EXTRA][2];
#endif
#if CONFIG_CODE_ZEROGROUP
vp9_zpc_count zpc_counts_4x4;
vp9_zpc_count zpc_counts_8x8;

Просмотреть файл

@ -1018,258 +1018,6 @@ void vp9_decode_mode_mvs_init(VP9D_COMP* const pbi, vp9_reader *r) {
mb_mode_mv_init(pbi, r);
}
#if CONFIG_CODE_NONZEROCOUNT
static uint16_t read_nzc(VP9_COMMON *const cm,
int nzc_context,
TX_SIZE tx_size,
int ref,
int type,
vp9_reader *r) {
int c, e;
uint16_t nzc;
if (!get_nzc_used(tx_size)) return 0;
if (tx_size == TX_32X32) {
c = treed_read(r, vp9_nzc32x32_tree,
cm->fc.nzc_probs_32x32[nzc_context][ref][type]);
cm->fc.nzc_counts_32x32[nzc_context][ref][type][c]++;
} else if (tx_size == TX_16X16) {
c = treed_read(r, vp9_nzc16x16_tree,
cm->fc.nzc_probs_16x16[nzc_context][ref][type]);
cm->fc.nzc_counts_16x16[nzc_context][ref][type][c]++;
} else if (tx_size == TX_8X8) {
c = treed_read(r, vp9_nzc8x8_tree,
cm->fc.nzc_probs_8x8[nzc_context][ref][type]);
cm->fc.nzc_counts_8x8[nzc_context][ref][type][c]++;
} else if (tx_size == TX_4X4) {
c = treed_read(r, vp9_nzc4x4_tree,
cm->fc.nzc_probs_4x4[nzc_context][ref][type]);
cm->fc.nzc_counts_4x4[nzc_context][ref][type][c]++;
} else {
assert(0);
}
nzc = vp9_basenzcvalue[c];
if ((e = vp9_extranzcbits[c])) {
int x = 0;
while (e--) {
int b = vp9_read(
r, cm->fc.nzc_pcat_probs[nzc_context][c - NZC_TOKENS_NOEXTRA][e]);
x |= (b << e);
cm->fc.nzc_pcat_counts[nzc_context][c - NZC_TOKENS_NOEXTRA][e][b]++;
}
nzc += x;
}
if (tx_size == TX_32X32)
assert(nzc <= 1024);
else if (tx_size == TX_16X16)
assert(nzc <= 256);
else if (tx_size == TX_8X8)
assert(nzc <= 64);
else if (tx_size == TX_4X4)
assert(nzc <= 16);
return nzc;
}
static void read_nzcs_sb64(VP9_COMMON *const cm,
MACROBLOCKD* xd,
int mb_row,
int mb_col,
vp9_reader *r) {
MODE_INFO *m = xd->mode_info_context;
MB_MODE_INFO *const mi = &m->mbmi;
int j, nzc_context;
const int ref = m->mbmi.ref_frame != INTRA_FRAME;
assert(mb_col == get_mb_col(xd));
assert(mb_row == get_mb_row(xd));
vpx_memset(m->mbmi.nzcs, 0, 384 * sizeof(m->mbmi.nzcs[0]));
if (mi->mb_skip_coeff)
return;
switch (mi->txfm_size) {
case TX_32X32:
for (j = 0; j < 256; j += 64) {
nzc_context = vp9_get_nzc_context_y_sb64(cm, m, mb_row, mb_col, j);
m->mbmi.nzcs[j] = read_nzc(cm, nzc_context, TX_32X32, ref, 0, r);
}
for (j = 256; j < 384; j += 64) {
nzc_context = vp9_get_nzc_context_uv_sb64(cm, m, mb_row, mb_col, j);
m->mbmi.nzcs[j] = read_nzc(cm, nzc_context, TX_32X32, ref, 1, r);
}
break;
case TX_16X16:
for (j = 0; j < 256; j += 16) {
nzc_context = vp9_get_nzc_context_y_sb64(cm, m, mb_row, mb_col, j);
m->mbmi.nzcs[j] = read_nzc(cm, nzc_context, TX_16X16, ref, 0, r);
}
for (j = 256; j < 384; j += 16) {
nzc_context = vp9_get_nzc_context_uv_sb64(cm, m, mb_row, mb_col, j);
m->mbmi.nzcs[j] = read_nzc(cm, nzc_context, TX_16X16, ref, 1, r);
}
break;
case TX_8X8:
for (j = 0; j < 256; j += 4) {
nzc_context = vp9_get_nzc_context_y_sb64(cm, m, mb_row, mb_col, j);
m->mbmi.nzcs[j] = read_nzc(cm, nzc_context, TX_8X8, ref, 0, r);
}
for (j = 256; j < 384; j += 4) {
nzc_context = vp9_get_nzc_context_uv_sb64(cm, m, mb_row, mb_col, j);
m->mbmi.nzcs[j] = read_nzc(cm, nzc_context, TX_8X8, ref, 1, r);
}
break;
case TX_4X4:
for (j = 0; j < 256; ++j) {
nzc_context = vp9_get_nzc_context_y_sb64(cm, m, mb_row, mb_col, j);
m->mbmi.nzcs[j] = read_nzc(cm, nzc_context, TX_4X4, ref, 0, r);
}
for (j = 256; j < 384; ++j) {
nzc_context = vp9_get_nzc_context_uv_sb64(cm, m, mb_row, mb_col, j);
m->mbmi.nzcs[j] = read_nzc(cm, nzc_context, TX_4X4, ref, 1, r);
}
break;
default:
break;
}
}
static void read_nzcs_sb32(VP9_COMMON *const cm,
MACROBLOCKD* xd,
int mb_row,
int mb_col,
vp9_reader *r) {
MODE_INFO *m = xd->mode_info_context;
MB_MODE_INFO *const mi = &m->mbmi;
int j, nzc_context;
const int ref = m->mbmi.ref_frame != INTRA_FRAME;
assert(mb_col == get_mb_col(xd));
assert(mb_row == get_mb_row(xd));
vpx_memset(m->mbmi.nzcs, 0, 384 * sizeof(m->mbmi.nzcs[0]));
if (mi->mb_skip_coeff)
return;
switch (mi->txfm_size) {
case TX_32X32:
for (j = 0; j < 64; j += 64) {
nzc_context = vp9_get_nzc_context_y_sb32(cm, m, mb_row, mb_col, j);
m->mbmi.nzcs[j] = read_nzc(cm, nzc_context, TX_32X32, ref, 0, r);
}
for (j = 64; j < 96; j += 16) {
nzc_context = vp9_get_nzc_context_uv_sb32(cm, m, mb_row, mb_col, j);
m->mbmi.nzcs[j] = read_nzc(cm, nzc_context, TX_16X16, ref, 1, r);
}
break;
case TX_16X16:
for (j = 0; j < 64; j += 16) {
nzc_context = vp9_get_nzc_context_y_sb32(cm, m, mb_row, mb_col, j);
m->mbmi.nzcs[j] = read_nzc(cm, nzc_context, TX_16X16, ref, 0, r);
}
for (j = 64; j < 96; j += 16) {
nzc_context = vp9_get_nzc_context_uv_sb32(cm, m, mb_row, mb_col, j);
m->mbmi.nzcs[j] = read_nzc(cm, nzc_context, TX_16X16, ref, 1, r);
}
break;
case TX_8X8:
for (j = 0; j < 64; j += 4) {
nzc_context = vp9_get_nzc_context_y_sb32(cm, m, mb_row, mb_col, j);
m->mbmi.nzcs[j] = read_nzc(cm, nzc_context, TX_8X8, ref, 0, r);
}
for (j = 64; j < 96; j += 4) {
nzc_context = vp9_get_nzc_context_uv_sb32(cm, m, mb_row, mb_col, j);
m->mbmi.nzcs[j] = read_nzc(cm, nzc_context, TX_8X8, ref, 1, r);
}
break;
case TX_4X4:
for (j = 0; j < 64; ++j) {
nzc_context = vp9_get_nzc_context_y_sb32(cm, m, mb_row, mb_col, j);
m->mbmi.nzcs[j] = read_nzc(cm, nzc_context, TX_4X4, ref, 0, r);
}
for (j = 64; j < 96; ++j) {
nzc_context = vp9_get_nzc_context_uv_sb32(cm, m, mb_row, mb_col, j);
m->mbmi.nzcs[j] = read_nzc(cm, nzc_context, TX_4X4, ref, 1, r);
}
break;
default:
break;
}
}
static void read_nzcs_mb16(VP9_COMMON *const cm,
MACROBLOCKD* xd,
int mb_row,
int mb_col,
vp9_reader *r) {
MODE_INFO *m = xd->mode_info_context;
MB_MODE_INFO *const mi = &m->mbmi;
int j, nzc_context;
const int ref = m->mbmi.ref_frame != INTRA_FRAME;
assert(mb_col == get_mb_col(xd));
assert(mb_row == get_mb_row(xd));
vpx_memset(m->mbmi.nzcs, 0, 384 * sizeof(m->mbmi.nzcs[0]));
if (mi->mb_skip_coeff)
return;
switch (mi->txfm_size) {
case TX_16X16:
for (j = 0; j < 16; j += 16) {
nzc_context = vp9_get_nzc_context_y_mb16(cm, m, mb_row, mb_col, j);
m->mbmi.nzcs[j] = read_nzc(cm, nzc_context, TX_16X16, ref, 0, r);
}
for (j = 16; j < 24; j += 4) {
nzc_context = vp9_get_nzc_context_uv_mb16(cm, m, mb_row, mb_col, j);
m->mbmi.nzcs[j] = read_nzc(cm, nzc_context, TX_8X8, ref, 1, r);
}
break;
case TX_8X8:
for (j = 0; j < 16; j += 4) {
nzc_context = vp9_get_nzc_context_y_mb16(cm, m, mb_row, mb_col, j);
m->mbmi.nzcs[j] = read_nzc(cm, nzc_context, TX_8X8, ref, 0, r);
}
if (mi->mode == I8X8_PRED || mi->mode == SPLITMV) {
for (j = 16; j < 24; ++j) {
nzc_context = vp9_get_nzc_context_uv_mb16(cm, m, mb_row, mb_col, j);
m->mbmi.nzcs[j] = read_nzc(cm, nzc_context, TX_4X4, ref, 1, r);
}
} else {
for (j = 16; j < 24; j += 4) {
nzc_context = vp9_get_nzc_context_uv_mb16(cm, m, mb_row, mb_col, j);
m->mbmi.nzcs[j] = read_nzc(cm, nzc_context, TX_8X8, ref, 1, r);
}
}
break;
case TX_4X4:
for (j = 0; j < 16; ++j) {
nzc_context = vp9_get_nzc_context_y_mb16(cm, m, mb_row, mb_col, j);
m->mbmi.nzcs[j] = read_nzc(cm, nzc_context, TX_4X4, ref, 0, r);
}
for (j = 16; j < 24; ++j) {
nzc_context = vp9_get_nzc_context_uv_mb16(cm, m, mb_row, mb_col, j);
m->mbmi.nzcs[j] = read_nzc(cm, nzc_context, TX_4X4, ref, 1, r);
}
break;
default:
break;
}
}
#endif // CONFIG_CODE_NONZEROCOUNT
void vp9_decode_mb_mode_mv(VP9D_COMP* const pbi,
MACROBLOCKD* const xd,
int mb_row,
@ -1288,14 +1036,6 @@ void vp9_decode_mb_mode_mv(VP9D_COMP* const pbi,
mi->mbmi.ref_frame - 1, mi->mbmi.second_ref_frame - 1,
cm->active_ref_scale);
}
#if CONFIG_CODE_NONZEROCOUNT
if (mbmi->sb_type == BLOCK_SIZE_SB64X64)
read_nzcs_sb64(cm, xd, mb_row, mb_col, r);
else if (mbmi->sb_type == BLOCK_SIZE_SB32X32)
read_nzcs_sb32(cm, xd, mb_row, mb_col, r);
else
read_nzcs_mb16(cm, xd, mb_row, mb_col, r);
#endif // CONFIG_CODE_NONZEROCOUNT
if (mbmi->sb_type) {
const int bw = 1 << mb_width_log2(mbmi->sb_type);

Просмотреть файл

@ -220,32 +220,6 @@ static void mb_init_dequantizer(VP9D_COMP *pbi, MACROBLOCKD *mb) {
}
}
#if CONFIG_CODE_NONZEROCOUNT
static void propagate_nzcs(VP9_COMMON *cm, MACROBLOCKD *xd) {
MODE_INFO *m = xd->mode_info_context;
BLOCK_SIZE_TYPE sb_type = m->mbmi.sb_type;
const int mis = cm->mode_info_stride;
int n;
if (sb_type == BLOCK_SIZE_SB64X64) {
for (n = 0; n < 16; ++n) {
int i = n >> 2;
int j = n & 3;
if (i == 0 && j == 0) continue;
vpx_memcpy((m + j + mis * i)->mbmi.nzcs, m->mbmi.nzcs,
384 * sizeof(m->mbmi.nzcs[0]));
}
} else if (sb_type == BLOCK_SIZE_SB32X32) {
for (n = 0; n < 4; ++n) {
int i = n >> 1;
int j = n & 1;
if (i == 0 && j == 0) continue;
vpx_memcpy((m + j + mis * i)->mbmi.nzcs, m->mbmi.nzcs,
384 * sizeof(m->mbmi.nzcs[0]));
}
}
}
#endif
static void decode_16x16(MACROBLOCKD *xd) {
const TX_TYPE tx_type = get_tx_type_16x16(xd, 0);
@ -644,9 +618,6 @@ static void decode_sb(VP9D_COMP *pbi, MACROBLOCKD *xd, int mb_row, int mb_col,
if (mi->mbmi.mb_skip_coeff) {
vp9_reset_sb_tokens_context(xd, bsize);
#if CONFIG_CODE_NONZEROCOUNT
vpx_memset(mi->mbmi.nzcs, 0, 384 * sizeof(mi->mbmi.nzcs[0]));
#endif
} else {
// re-initialize macroblock dequantizer before detokenization
if (xd->segmentation_enabled)
@ -681,10 +652,6 @@ static void decode_sb(VP9D_COMP *pbi, MACROBLOCKD *xd, int mb_row, int mb_col,
}
}
}
#if CONFIG_CODE_NONZEROCOUNT
propagate_nzcs(&pbi->common, xd);
#endif
}
// TODO(jingning): Need to merge SB and MB decoding. The MB decoding currently
@ -1043,88 +1010,6 @@ static void read_zpc_probs(VP9_COMMON *cm,
}
#endif // CONFIG_CODE_ZEROGROUP
#if CONFIG_CODE_NONZEROCOUNT
static void read_nzc_probs_common(VP9_COMMON *cm,
vp9_reader *rd,
TX_SIZE tx_size) {
int c, r, b, t;
int tokens, nodes;
vp9_prob *nzc_probs;
vp9_prob upd;
if (!get_nzc_used(tx_size)) return;
if (!vp9_read_bit(rd)) return;
if (tx_size == TX_32X32) {
tokens = NZC32X32_TOKENS;
nzc_probs = cm->fc.nzc_probs_32x32[0][0][0];
upd = NZC_UPDATE_PROB_32X32;
} else if (tx_size == TX_16X16) {
tokens = NZC16X16_TOKENS;
nzc_probs = cm->fc.nzc_probs_16x16[0][0][0];
upd = NZC_UPDATE_PROB_16X16;
} else if (tx_size == TX_8X8) {
tokens = NZC8X8_TOKENS;
nzc_probs = cm->fc.nzc_probs_8x8[0][0][0];
upd = NZC_UPDATE_PROB_8X8;
} else {
tokens = NZC4X4_TOKENS;
nzc_probs = cm->fc.nzc_probs_4x4[0][0][0];
upd = NZC_UPDATE_PROB_4X4;
}
nodes = tokens - 1;
for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
for (r = 0; r < REF_TYPES; ++r) {
for (b = 0; b < BLOCK_TYPES; ++b) {
int offset = c * REF_TYPES * BLOCK_TYPES + r * BLOCK_TYPES + b;
int offset_nodes = offset * nodes;
for (t = 0; t < nodes; ++t) {
vp9_prob *p = &nzc_probs[offset_nodes + t];
if (vp9_read(rd, upd)) {
*p = read_prob_diff_update(rd, *p);
}
}
}
}
}
}
static void read_nzc_pcat_probs(VP9_COMMON *cm, vp9_reader *r) {
int c, t, b;
vp9_prob upd = NZC_UPDATE_PROB_PCAT;
if (!(get_nzc_used(TX_4X4) || get_nzc_used(TX_8X8) ||
get_nzc_used(TX_16X16) || get_nzc_used(TX_32X32)))
return;
if (!vp9_read_bit(r)) {
return;
}
for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
for (t = 0; t < NZC_TOKENS_EXTRA; ++t) {
int bits = vp9_extranzcbits[t + NZC_TOKENS_NOEXTRA];
for (b = 0; b < bits; ++b) {
vp9_prob *p = &cm->fc.nzc_pcat_probs[c][t][b];
if (vp9_read(r, upd)) {
*p = read_prob_diff_update(r, *p);
}
}
}
}
}
static void read_nzc_probs(VP9_COMMON *cm, vp9_reader *r) {
read_nzc_probs_common(cm, r, TX_4X4);
if (cm->txfm_mode != ONLY_4X4)
read_nzc_probs_common(cm, r, TX_8X8);
if (cm->txfm_mode > ALLOW_8X8)
read_nzc_probs_common(cm, r, TX_16X16);
if (cm->txfm_mode > ALLOW_16X16)
read_nzc_probs_common(cm, r, TX_32X32);
#ifdef NZC_PCAT_UPDATE
read_nzc_pcat_probs(cm, r);
#endif
}
#endif // CONFIG_CODE_NONZEROCOUNT
static void read_coef_probs_common(VP9D_COMP *pbi,
vp9_reader *r,
vp9_coeff_probs *coef_probs,
@ -1142,11 +1027,7 @@ static void read_coef_probs_common(VP9D_COMP *pbi,
for (j = 0; j < REF_TYPES; j++) {
for (k = 0; k < COEF_BANDS; k++) {
for (l = 0; l < PREV_COEF_CONTEXTS; l++) {
#if CONFIG_CODE_NONZEROCOUNT
const int mstart = get_nzc_used(tx_size);
#else
const int mstart = 0;
#endif
if (l >= 3 && k == 0)
continue;
@ -1439,19 +1320,6 @@ static void update_frame_context(VP9D_COMP *pbi) {
vp9_zero(fc->interintra_counts);
#endif
#if CONFIG_CODE_NONZEROCOUNT
vp9_copy(fc->pre_nzc_probs_4x4, fc->nzc_probs_4x4);
vp9_copy(fc->pre_nzc_probs_8x8, fc->nzc_probs_8x8);
vp9_copy(fc->pre_nzc_probs_16x16, fc->nzc_probs_16x16);
vp9_copy(fc->pre_nzc_probs_32x32, fc->nzc_probs_32x32);
vp9_copy(fc->pre_nzc_pcat_probs, fc->nzc_pcat_probs);
vp9_zero(fc->nzc_counts_4x4);
vp9_zero(fc->nzc_counts_8x8);
vp9_zero(fc->nzc_counts_16x16);
vp9_zero(fc->nzc_counts_32x32);
vp9_zero(fc->nzc_pcat_counts);
#endif
#if CONFIG_CODE_ZEROGROUP
vp9_copy(fc->pre_zpc_probs_4x4, fc->zpc_probs_4x4);
vp9_copy(fc->pre_zpc_probs_8x8, fc->zpc_probs_8x8);
@ -1716,9 +1584,6 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
update_frame_context(pbi);
read_coef_probs(pbi, &header_bc);
#if CONFIG_CODE_NONZEROCOUNT
read_nzc_probs(&pbi->common, &header_bc);
#endif
#if CONFIG_CODE_ZEROGROUP
read_zpc_probs(&pbi->common, &header_bc);
#endif
@ -1771,9 +1636,6 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
if (!pc->error_resilient_mode && !pc->frame_parallel_decoding_mode) {
vp9_adapt_coef_probs(pc);
#if CONFIG_CODE_NONZEROCOUNT
vp9_adapt_nzc_probs(pc);
#endif
#if CONFIG_CODE_ZEROGROUP
vp9_adapt_zpc_probs(pc);
#endif

Просмотреть файл

@ -83,16 +83,6 @@ DECLARE_ALIGNED(16, extern const uint8_t, vp9_norm[256]);
} while (0)
#endif
#if CONFIG_CODE_NONZEROCOUNT
#define WRITE_COEF_CONTINUE(val, token) \
{ \
qcoeff_ptr[scan[c]] = vp9_read_and_apply_sign(r, val); \
INCREMENT_COUNT(token); \
c++; \
nzc++; \
continue; \
}
#else
#define WRITE_COEF_CONTINUE(val, token) \
{ \
qcoeff_ptr[scan[c]] = vp9_read_and_apply_sign(r, val); \
@ -100,7 +90,6 @@ DECLARE_ALIGNED(16, extern const uint8_t, vp9_norm[256]);
c++; \
continue; \
}
#endif // CONFIG_CODE_NONZEROCOUNT
#define WRITE_COEF_ONE() \
{ \
@ -137,12 +126,6 @@ static int decode_coefs(VP9D_COMP *dx, const MACROBLOCKD *xd,
vp9_zpc_count *zpc_count;
vp9_prob *zprobs;
int eoo = 0, use_eoo;
#endif
#if CONFIG_CODE_NONZEROCOUNT
const int nzc_used = get_nzc_used(txfm_size);
uint16_t nzc = 0;
uint16_t nzc_expected =
nzc_used ? xd->mode_info_context->mbmi.nzcs[block_idx] : 0;
#endif
const int *scan, *nb;
uint8_t token_cache[1024];
@ -309,41 +292,27 @@ static int decode_coefs(VP9D_COMP *dx, const MACROBLOCKD *xd,
const uint8_t *cat6 = cat6_prob;
if (c >= seg_eob)
break;
#if CONFIG_CODE_NONZEROCOUNT
if (nzc_used && nzc == nzc_expected)
break;
#endif
if (c)
pt = vp9_get_coef_context(scan, nb, pad, token_cache,
c, default_eob);
band = get_coef_band(scan, txfm_size, c);
prob = coef_probs[type][ref][band][pt];
fc->eob_branch_counts[txfm_size][type][ref][band][pt]++;
#if CONFIG_CODE_NONZEROCOUNT
if (!nzc_used) {
#endif
if (!vp9_read(r, prob[EOB_CONTEXT_NODE]))
break;
if (!vp9_read(r, prob[EOB_CONTEXT_NODE]))
break;
#if CONFIG_CODE_ZEROGROUP
rc = scan[c];
o = vp9_get_orientation(rc, txfm_size);
if (token_cache[rc] == ZERO_TOKEN || is_eoo[o]) {
coef_counts[type][ref][band][pt][ZERO_TOKEN]++;
ZEROGROUP_ADVANCE();
goto SKIP_START;
}
#endif
#if CONFIG_CODE_NONZEROCOUNT
rc = scan[c];
o = vp9_get_orientation(rc, txfm_size);
if (token_cache[rc] == ZERO_TOKEN || is_eoo[o]) {
coef_counts[type][ref][band][pt][ZERO_TOKEN]++;
ZEROGROUP_ADVANCE();
goto SKIP_START;
}
#endif
SKIP_START:
if (c >= seg_eob)
break;
#if CONFIG_CODE_NONZEROCOUNT
if (nzc_used && nzc == nzc_expected)
break;
#endif
if (c)
pt = vp9_get_coef_context(scan, nb, pad, token_cache,
c, default_eob);
@ -359,10 +328,6 @@ SKIP_START:
zprobs = (*zpc_probs)[ref]
[coef_to_zpc_band(band)]
[coef_to_zpc_ptok(pt)];
#endif
#if CONFIG_CODE_NONZEROCOUNT
// decode zero node only if there are zeros left
if (!nzc_used || seg_eob - nzc_expected - c + nzc > 0)
#endif
if (!vp9_read(r, prob[ZERO_CONTEXT_NODE])) {
#if CONFIG_CODE_ZEROGROUP
@ -446,18 +411,9 @@ SKIP_START:
WRITE_COEF_CONTINUE(val, DCT_VAL_CATEGORY6);
}
#if CONFIG_CODE_NONZEROCOUNT
if (!nzc_used)
#endif
if (c < seg_eob)
coef_counts[type][ref][get_coef_band(scan, txfm_size, c)]
[pt][DCT_EOB_TOKEN]++;
#if CONFIG_CODE_NONZEROCOUNT
if (!nzc_used)
xd->mode_info_context->mbmi.nzcs[block_idx] = nzc;
else
assert(nzc == nzc_expected);
#endif
if (c < seg_eob)
coef_counts[type][ref][get_coef_band(scan, txfm_size, c)]
[pt][DCT_EOB_TOKEN]++;
A0[aidx] = L0[lidx] = c > 0;
if (txfm_size >= TX_8X8) {

Просмотреть файл

@ -50,23 +50,6 @@ vp9_coeff_stats tree_update_hist_32x32[BLOCK_TYPES];
extern unsigned int active_section;
#endif
#if CONFIG_CODE_NONZEROCOUNT
#ifdef NZC_STATS
unsigned int nzc_stats_4x4[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES]
[NZC4X4_TOKENS];
unsigned int nzc_stats_8x8[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES]
[NZC8X8_TOKENS];
unsigned int nzc_stats_16x16[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES]
[NZC16X16_TOKENS];
unsigned int nzc_stats_32x32[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES]
[NZC32X32_TOKENS];
unsigned int nzc_pcat_stats[MAX_NZC_CONTEXTS][NZC_TOKENS_EXTRA]
[NZC_BITS_EXTRA][2];
void init_nzcstats();
void update_nzcstats(VP9_COMMON *const cm);
void print_nzcstats();
#endif
#endif
#if CONFIG_CODE_ZEROGROUP
#ifdef ZPC_STATS
vp9_zpc_count zpc_stats_4x4;
@ -1014,562 +997,6 @@ static void write_mb_modes_kf(const VP9_COMP *cpi,
}
}
#if CONFIG_CODE_NONZEROCOUNT
static void write_nzc(VP9_COMP *const cpi,
uint16_t nzc,
int nzc_context,
TX_SIZE tx_size,
int ref,
int type,
vp9_writer* const bc) {
VP9_COMMON *const cm = &cpi->common;
int c, e;
// if (!cpi->dummy_packing && cm->current_video_frame == 27)
// printf("nzc: %d, tx_size: %d\n", nzc, tx_size);
if (!get_nzc_used(tx_size)) return;
c = codenzc(nzc);
if (tx_size == TX_32X32) {
write_token(bc, vp9_nzc32x32_tree,
cm->fc.nzc_probs_32x32[nzc_context][ref][type],
vp9_nzc32x32_encodings + c);
// cm->fc.nzc_counts_32x32[nzc_context][ref][type][c]++;
} else if (tx_size == TX_16X16) {
write_token(bc, vp9_nzc16x16_tree,
cm->fc.nzc_probs_16x16[nzc_context][ref][type],
vp9_nzc16x16_encodings + c);
// cm->fc.nzc_counts_16x16[nzc_context][ref][type][c]++;
} else if (tx_size == TX_8X8) {
write_token(bc, vp9_nzc8x8_tree,
cm->fc.nzc_probs_8x8[nzc_context][ref][type],
vp9_nzc8x8_encodings + c);
// cm->fc.nzc_counts_8x8[nzc_context][ref][type][c]++;
} else if (tx_size == TX_4X4) {
write_token(bc, vp9_nzc4x4_tree,
cm->fc.nzc_probs_4x4[nzc_context][ref][type],
vp9_nzc4x4_encodings + c);
// cm->fc.nzc_counts_4x4[nzc_context][ref][type][c]++;
} else {
assert(0);
}
if ((e = vp9_extranzcbits[c])) {
int x = nzc - vp9_basenzcvalue[c];
while (e--) {
int b = (x >> e) & 1;
vp9_write(bc, b,
cm->fc.nzc_pcat_probs[nzc_context][c - NZC_TOKENS_NOEXTRA][e]);
// cm->fc.nzc_pcat_counts[nzc_context][c - NZC_TOKENS_NOEXTRA][e][b]++;
}
}
}
static void write_nzcs_sb64(VP9_COMP *cpi,
MACROBLOCKD *xd,
int mb_row,
int mb_col,
vp9_writer* const bc) {
VP9_COMMON *const cm = &cpi->common;
MODE_INFO *m = xd->mode_info_context;
MB_MODE_INFO *const mi = &m->mbmi;
int j, nzc_context;
const int ref = m->mbmi.ref_frame != INTRA_FRAME;
assert(mb_col == get_mb_col(xd));
assert(mb_row == get_mb_row(xd));
if (mi->mb_skip_coeff)
return;
switch (mi->txfm_size) {
case TX_32X32:
for (j = 0; j < 256; j += 64) {
nzc_context = vp9_get_nzc_context_y_sb64(cm, m, mb_row, mb_col, j);
write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_32X32, ref, 0, bc);
}
for (j = 256; j < 384; j += 64) {
nzc_context = vp9_get_nzc_context_uv_sb64(cm, m, mb_row, mb_col, j);
write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_32X32, ref, 1, bc);
}
break;
case TX_16X16:
for (j = 0; j < 256; j += 16) {
nzc_context = vp9_get_nzc_context_y_sb64(cm, m, mb_row, mb_col, j);
write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_16X16, ref, 0, bc);
}
for (j = 256; j < 384; j += 16) {
nzc_context = vp9_get_nzc_context_uv_sb64(cm, m, mb_row, mb_col, j);
write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_16X16, ref, 1, bc);
}
break;
case TX_8X8:
for (j = 0; j < 256; j += 4) {
nzc_context = vp9_get_nzc_context_y_sb64(cm, m, mb_row, mb_col, j);
write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_8X8, ref, 0, bc);
}
for (j = 256; j < 384; j += 4) {
nzc_context = vp9_get_nzc_context_uv_sb64(cm, m, mb_row, mb_col, j);
write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_8X8, ref, 1, bc);
}
break;
case TX_4X4:
for (j = 0; j < 256; ++j) {
nzc_context = vp9_get_nzc_context_y_sb64(cm, m, mb_row, mb_col, j);
write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_4X4, ref, 0, bc);
}
for (j = 256; j < 384; ++j) {
nzc_context = vp9_get_nzc_context_uv_sb64(cm, m, mb_row, mb_col, j);
write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_4X4, ref, 1, bc);
}
break;
default:
break;
}
}
static void write_nzcs_sb32(VP9_COMP *cpi,
MACROBLOCKD *xd,
int mb_row,
int mb_col,
vp9_writer* const bc) {
VP9_COMMON *const cm = &cpi->common;
MODE_INFO *m = xd->mode_info_context;
MB_MODE_INFO *const mi = &m->mbmi;
int j, nzc_context;
const int ref = m->mbmi.ref_frame != INTRA_FRAME;
assert(mb_col == get_mb_col(xd));
assert(mb_row == get_mb_row(xd));
if (mi->mb_skip_coeff)
return;
switch (mi->txfm_size) {
case TX_32X32:
for (j = 0; j < 64; j += 64) {
nzc_context = vp9_get_nzc_context_y_sb32(cm, m, mb_row, mb_col, j);
write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_32X32, ref, 0, bc);
}
for (j = 64; j < 96; j += 16) {
nzc_context = vp9_get_nzc_context_uv_sb32(cm, m, mb_row, mb_col, j);
write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_16X16, ref, 1, bc);
}
break;
case TX_16X16:
for (j = 0; j < 64; j += 16) {
nzc_context = vp9_get_nzc_context_y_sb32(cm, m, mb_row, mb_col, j);
write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_16X16, ref, 0, bc);
}
for (j = 64; j < 96; j += 16) {
nzc_context = vp9_get_nzc_context_uv_sb32(cm, m, mb_row, mb_col, j);
write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_16X16, ref, 1, bc);
}
break;
case TX_8X8:
for (j = 0; j < 64; j += 4) {
nzc_context = vp9_get_nzc_context_y_sb32(cm, m, mb_row, mb_col, j);
write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_8X8, ref, 0, bc);
}
for (j = 64; j < 96; j += 4) {
nzc_context = vp9_get_nzc_context_uv_sb32(cm, m, mb_row, mb_col, j);
write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_8X8, ref, 1, bc);
}
break;
case TX_4X4:
for (j = 0; j < 64; ++j) {
nzc_context = vp9_get_nzc_context_y_sb32(cm, m, mb_row, mb_col, j);
write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_4X4, ref, 0, bc);
}
for (j = 64; j < 96; ++j) {
nzc_context = vp9_get_nzc_context_uv_sb32(cm, m, mb_row, mb_col, j);
write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_4X4, ref, 1, bc);
}
break;
default:
break;
}
}
static void write_nzcs_mb16(VP9_COMP *cpi,
MACROBLOCKD *xd,
int mb_row,
int mb_col,
vp9_writer* const bc) {
VP9_COMMON *const cm = &cpi->common;
MODE_INFO *m = xd->mode_info_context;
MB_MODE_INFO *const mi = &m->mbmi;
int j, nzc_context;
const int ref = m->mbmi.ref_frame != INTRA_FRAME;
assert(mb_col == get_mb_col(xd));
assert(mb_row == get_mb_row(xd));
if (mi->mb_skip_coeff)
return;
switch (mi->txfm_size) {
case TX_16X16:
for (j = 0; j < 16; j += 16) {
nzc_context = vp9_get_nzc_context_y_mb16(cm, m, mb_row, mb_col, j);
write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_16X16, ref, 0, bc);
}
for (j = 16; j < 24; j += 4) {
nzc_context = vp9_get_nzc_context_uv_mb16(cm, m, mb_row, mb_col, j);
write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_8X8, ref, 1, bc);
}
break;
case TX_8X8:
for (j = 0; j < 16; j += 4) {
nzc_context = vp9_get_nzc_context_y_mb16(cm, m, mb_row, mb_col, j);
write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_8X8, ref, 0, bc);
}
if (mi->mode == I8X8_PRED || mi->mode == SPLITMV) {
for (j = 16; j < 24; ++j) {
nzc_context = vp9_get_nzc_context_uv_mb16(cm, m, mb_row, mb_col, j);
write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_4X4, ref, 1, bc);
}
} else {
for (j = 16; j < 24; j += 4) {
nzc_context = vp9_get_nzc_context_uv_mb16(cm, m, mb_row, mb_col, j);
write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_8X8, ref, 1, bc);
}
}
break;
case TX_4X4:
for (j = 0; j < 16; ++j) {
nzc_context = vp9_get_nzc_context_y_mb16(cm, m, mb_row, mb_col, j);
write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_4X4, ref, 0, bc);
}
for (j = 16; j < 24; ++j) {
nzc_context = vp9_get_nzc_context_uv_mb16(cm, m, mb_row, mb_col, j);
write_nzc(cpi, m->mbmi.nzcs[j], nzc_context, TX_4X4, ref, 1, bc);
}
break;
default:
break;
}
}
#ifdef NZC_STATS
void init_nzcstats() {
vp9_zero(nzc_stats_4x4);
vp9_zero(nzc_stats_8x8);
vp9_zero(nzc_stats_16x16);
vp9_zero(nzc_stats_32x32);
vp9_zero(nzc_pcat_stats);
}
void update_nzcstats(VP9_COMMON *const cm) {
int c, r, b, t;
for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
for (r = 0; r < REF_TYPES; ++r) {
for (b = 0; b < BLOCK_TYPES; ++b) {
for (t = 0; t < NZC4X4_TOKENS; ++t) {
nzc_stats_4x4[c][r][b][t] += cm->fc.nzc_counts_4x4[c][r][b][t];
}
}
}
}
for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
for (r = 0; r < REF_TYPES; ++r) {
for (b = 0; b < BLOCK_TYPES; ++b) {
for (t = 0; t < NZC8X8_TOKENS; ++t) {
nzc_stats_8x8[c][r][b][t] += cm->fc.nzc_counts_8x8[c][r][b][t];
}
}
}
}
for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
for (r = 0; r < REF_TYPES; ++r) {
for (b = 0; b < BLOCK_TYPES; ++b) {
for (t = 0; t < NZC16X16_TOKENS; ++t) {
nzc_stats_16x16[c][r][b][t] += cm->fc.nzc_counts_16x16[c][r][b][t];
}
}
}
}
for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
for (r = 0; r < REF_TYPES; ++r) {
for (b = 0; b < BLOCK_TYPES; ++b) {
for (t = 0; t < NZC32X32_TOKENS; ++t) {
nzc_stats_32x32[c][r][b][t] += cm->fc.nzc_counts_32x32[c][r][b][t];
}
}
}
}
for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
for (t = 0; t < NZC_TOKENS_EXTRA; ++t) {
int bits = vp9_extranzcbits[t + NZC_TOKENS_NOEXTRA];
for (b = 0; b < bits; ++b) {
nzc_pcat_stats[c][t][b][0] += cm->fc.nzc_pcat_counts[c][t][b][0];
nzc_pcat_stats[c][t][b][1] += cm->fc.nzc_pcat_counts[c][t][b][1];
}
}
}
}
void print_nzcstats() {
int c, r, b, t;
FILE *f;
printf(
"static const unsigned int default_nzc_counts_4x4[MAX_NZC_CONTEXTS]\n"
" [REF_TYPES]\n"
" [BLOCK_TYPES]\n"
" [NZC4X4_TOKENS] = {\n");
for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
printf(" {\n");
for (r = 0; r < REF_TYPES; ++r) {
printf(" {\n");
for (b = 0; b < BLOCK_TYPES; ++b) {
printf(" {");
for (t = 0; t < NZC4X4_TOKENS; ++t) {
printf(" %-3d,", nzc_stats_4x4[c][r][b][t]);
}
printf(" },\n");
}
printf(" },\n");
}
printf(" },\n");
}
printf("};\n");
printf(
"static const unsigned int default_nzc_counts_8x8[MAX_NZC_CONTEXTS]\n"
" [REF_TYPES]\n"
" [BLOCK_TYPES]\n"
" [NZC8X8_TOKENS] = {\n");
for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
printf(" {\n");
for (r = 0; r < REF_TYPES; ++r) {
printf(" {\n");
for (b = 0; b < BLOCK_TYPES; ++b) {
printf(" {");
for (t = 0; t < NZC8X8_TOKENS; ++t) {
printf(" %-3d,", nzc_stats_8x8[c][r][b][t]);
}
printf(" },\n");
}
printf(" },\n");
}
printf(" },\n");
}
printf("};\n");
printf(
"static const unsigned int default_nzc_counts_16x16[MAX_NZC_CONTEXTS]\n"
" [REF_TYPES]\n"
" [BLOCK_TYPES]\n"
" [NZC16X16_TOKENS] = {"
"\n");
for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
printf(" {\n");
for (r = 0; r < REF_TYPES; ++r) {
printf(" {\n");
for (b = 0; b < BLOCK_TYPES; ++b) {
printf(" {");
for (t = 0; t < NZC16X16_TOKENS; ++t) {
printf(" %-3d,", nzc_stats_16x16[c][r][b][t]);
}
printf(" },\n");
}
printf(" },\n");
}
printf(" },\n");
}
printf("};\n");
printf(
"static const unsigned int default_nzc_counts_32x32[MAX_NZC_CONTEXTS]\n"
" [REF_TYPES]\n"
" [BLOCK_TYPES]\n"
" [NZC32X32_TOKENS] = {"
"\n");
for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
printf(" {\n");
for (r = 0; r < REF_TYPES; ++r) {
printf(" {\n");
for (b = 0; b < BLOCK_TYPES; ++b) {
printf(" {");
for (t = 0; t < NZC32X32_TOKENS; ++t) {
printf(" %-3d,", nzc_stats_32x32[c][r][b][t]);
}
printf(" },\n");
}
printf(" },\n");
}
printf(" },\n");
}
printf("};\n");
printf(
"static const vp9_prob default_nzc_pcat_counts[MAX_NZC_CONTEXTS]\n"
" [NZC_TOKENS_EXTRA]\n"
" [NZC_BITS_EXTRA] = {\n");
for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
printf(" {\n");
for (t = 0; t < NZC_TOKENS_EXTRA; ++t) {
printf(" {");
for (b = 0; b < NZC_BITS_EXTRA; ++b) {
printf(" %d/%d,",
nzc_pcat_stats[c][t][b][0], nzc_pcat_stats[c][t][b][1]);
}
printf(" },\n");
}
printf(" },\n");
}
printf("};\n");
printf(
"static const vp9_prob default_nzc_probs_4x4[MAX_NZC_CONTEXTS]\n"
" [REF_TYPES]\n"
" [BLOCK_TYPES]\n"
" [NZC4X4_TOKENS] = {\n");
for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
printf(" {\n");
for (r = 0; r < REF_TYPES; ++r) {
printf(" {\n");
for (b = 0; b < BLOCK_TYPES; ++b) {
vp9_prob probs[NZC4X4_NODES];
unsigned int branch_ct[NZC4X4_NODES][2];
vp9_tree_probs_from_distribution(vp9_nzc4x4_tree,
probs, branch_ct,
nzc_stats_4x4[c][r][b], 0);
printf(" {");
for (t = 0; t < NZC4X4_NODES; ++t) {
printf(" %-3d,", probs[t]);
}
printf(" },\n");
}
printf(" },\n");
}
printf(" },\n");
}
printf("};\n");
printf(
"static const vp9_prob default_nzc_probs_8x8[MAX_NZC_CONTEXTS]\n"
" [REF_TYPES]\n"
" [BLOCK_TYPES]\n"
" [NZC8X8_TOKENS] = {\n");
for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
printf(" {\n");
for (r = 0; r < REF_TYPES; ++r) {
printf(" {\n");
for (b = 0; b < BLOCK_TYPES; ++b) {
vp9_prob probs[NZC8X8_NODES];
unsigned int branch_ct[NZC8X8_NODES][2];
vp9_tree_probs_from_distribution(vp9_nzc8x8_tree,
probs, branch_ct,
nzc_stats_8x8[c][r][b], 0);
printf(" {");
for (t = 0; t < NZC8X8_NODES; ++t) {
printf(" %-3d,", probs[t]);
}
printf(" },\n");
}
printf(" },\n");
}
printf(" },\n");
}
printf("};\n");
printf(
"static const vp9_prob default_nzc_probs_16x16[MAX_NZC_CONTEXTS]\n"
" [REF_TYPES]\n"
" [BLOCK_TYPES]\n"
" [NZC16X16_TOKENS] = {\n");
for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
printf(" {\n");
for (r = 0; r < REF_TYPES; ++r) {
printf(" {\n");
for (b = 0; b < BLOCK_TYPES; ++b) {
vp9_prob probs[NZC16X16_NODES];
unsigned int branch_ct[NZC16X16_NODES][2];
vp9_tree_probs_from_distribution(vp9_nzc16x16_tree,
probs, branch_ct,
nzc_stats_16x16[c][r][b], 0);
printf(" {");
for (t = 0; t < NZC16X16_NODES; ++t) {
printf(" %-3d,", probs[t]);
}
printf(" },\n");
}
printf(" },\n");
}
printf(" },\n");
}
printf("};\n");
printf(
"static const vp9_prob default_nzc_probs_32x32[MAX_NZC_CONTEXTS]\n"
" [REF_TYPES]\n"
" [BLOCK_TYPES]\n"
" [NZC32X32_TOKENS] = {\n");
for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
printf(" {\n");
for (r = 0; r < REF_TYPES; ++r) {
printf(" {\n");
for (b = 0; b < BLOCK_TYPES; ++b) {
vp9_prob probs[NZC32X32_NODES];
unsigned int branch_ct[NZC32X32_NODES][2];
vp9_tree_probs_from_distribution(vp9_nzc32x32_tree,
probs, branch_ct,
nzc_stats_32x32[c][r][b], 0);
printf(" {");
for (t = 0; t < NZC32X32_NODES; ++t) {
printf(" %-3d,", probs[t]);
}
printf(" },\n");
}
printf(" },\n");
}
printf(" },\n");
}
printf("};\n");
printf(
"static const vp9_prob default_nzc_pcat_probs[MAX_NZC_CONTEXTS]\n"
" [NZC_TOKENS_EXTRA]\n"
" [NZC_BITS_EXTRA] = {\n");
for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
printf(" {\n");
for (t = 0; t < NZC_TOKENS_EXTRA; ++t) {
printf(" {");
for (b = 0; b < NZC_BITS_EXTRA; ++b) {
vp9_prob prob = get_binary_prob(nzc_pcat_stats[c][t][b][0],
nzc_pcat_stats[c][t][b][1]);
printf(" %-3d,", prob);
}
printf(" },\n");
}
printf(" },\n");
}
printf("};\n");
f = fopen("nzcstats.bin", "wb");
fwrite(nzc_stats_4x4, sizeof(nzc_stats_4x4), 1, f);
fwrite(nzc_stats_8x8, sizeof(nzc_stats_8x8), 1, f);
fwrite(nzc_stats_16x16, sizeof(nzc_stats_16x16), 1, f);
fwrite(nzc_stats_32x32, sizeof(nzc_stats_32x32), 1, f);
fwrite(nzc_pcat_stats, sizeof(nzc_pcat_stats), 1, f);
fclose(f);
}
#endif
#endif // CONFIG_CODE_NONZEROCOUNT
#if CONFIG_CODE_ZEROGROUP
#ifdef ZPC_STATS
void init_zpcstats() {
@ -1736,14 +1163,6 @@ static void write_modes_b(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc,
active_section = 1;
#endif
}
#if CONFIG_CODE_NONZEROCOUNT
if (m->mbmi.sb_type == BLOCK_SIZE_SB64X64)
write_nzcs_sb64(cpi, xd, mb_row, mb_col, bc);
else if (m->mbmi.sb_type == BLOCK_SIZE_SB32X32)
write_nzcs_sb32(cpi, xd, mb_row, mb_col, bc);
else
write_nzcs_mb16(cpi, xd, mb_row, mb_col, bc);
#endif
assert(*tok < tok_end);
pack_mb_tokens(bc, tok, tok_end);
@ -2075,232 +1494,6 @@ static void update_zpc_probs(VP9_COMP* cpi,
}
#endif // CONFIG_CODE_ZEROGROUP
#if CONFIG_CODE_NONZEROCOUNT
static void update_nzc_probs_common(VP9_COMP* cpi,
vp9_writer* const bc,
TX_SIZE tx_size) {
VP9_COMMON *cm = &cpi->common;
int c, r, b, t;
int update[2] = {0, 0};
int savings = 0;
int tokens, nodes;
const vp9_tree_index *nzc_tree;
vp9_prob *new_nzc_probs;
vp9_prob *old_nzc_probs;
unsigned int *nzc_counts;
unsigned int (*nzc_branch_ct)[2];
vp9_prob upd;
if (!get_nzc_used(tx_size)) return;
if (tx_size == TX_32X32) {
tokens = NZC32X32_TOKENS;
nzc_tree = vp9_nzc32x32_tree;
old_nzc_probs = cm->fc.nzc_probs_32x32[0][0][0];
new_nzc_probs = cpi->frame_nzc_probs_32x32[0][0][0];
nzc_counts = cm->fc.nzc_counts_32x32[0][0][0];
nzc_branch_ct = cpi->frame_nzc_branch_ct_32x32[0][0][0];
upd = NZC_UPDATE_PROB_32X32;
} else if (tx_size == TX_16X16) {
tokens = NZC16X16_TOKENS;
nzc_tree = vp9_nzc16x16_tree;
old_nzc_probs = cm->fc.nzc_probs_16x16[0][0][0];
new_nzc_probs = cpi->frame_nzc_probs_16x16[0][0][0];
nzc_counts = cm->fc.nzc_counts_16x16[0][0][0];
nzc_branch_ct = cpi->frame_nzc_branch_ct_16x16[0][0][0];
upd = NZC_UPDATE_PROB_16X16;
} else if (tx_size == TX_8X8) {
tokens = NZC8X8_TOKENS;
nzc_tree = vp9_nzc8x8_tree;
old_nzc_probs = cm->fc.nzc_probs_8x8[0][0][0];
new_nzc_probs = cpi->frame_nzc_probs_8x8[0][0][0];
nzc_counts = cm->fc.nzc_counts_8x8[0][0][0];
nzc_branch_ct = cpi->frame_nzc_branch_ct_8x8[0][0][0];
upd = NZC_UPDATE_PROB_8X8;
} else {
nzc_tree = vp9_nzc4x4_tree;
tokens = NZC4X4_TOKENS;
old_nzc_probs = cm->fc.nzc_probs_4x4[0][0][0];
new_nzc_probs = cpi->frame_nzc_probs_4x4[0][0][0];
nzc_counts = cm->fc.nzc_counts_4x4[0][0][0];
nzc_branch_ct = cpi->frame_nzc_branch_ct_4x4[0][0][0];
upd = NZC_UPDATE_PROB_4X4;
}
nodes = tokens - 1;
// Get the new probabilities and the branch counts
for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
for (r = 0; r < REF_TYPES; ++r) {
for (b = 0; b < BLOCK_TYPES; ++b) {
int offset = c * REF_TYPES * BLOCK_TYPES + r * BLOCK_TYPES + b;
int offset_nodes = offset * nodes;
int offset_tokens = offset * tokens;
vp9_tree_probs_from_distribution(nzc_tree,
new_nzc_probs + offset_nodes,
nzc_branch_ct + offset_nodes,
nzc_counts + offset_tokens, 0);
}
}
}
for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
for (r = 0; r < REF_TYPES; ++r) {
for (b = 0; b < BLOCK_TYPES; ++b) {
int offset = c * REF_TYPES * BLOCK_TYPES + r * BLOCK_TYPES + b;
int offset_nodes = offset * nodes;
for (t = 0; t < nodes; ++t) {
vp9_prob newp = new_nzc_probs[offset_nodes + t];
vp9_prob oldp = old_nzc_probs[offset_nodes + t];
int s, u = 0;
#if defined(SEARCH_NEWP)
s = prob_diff_update_savings_search(nzc_branch_ct[offset_nodes],
oldp, &newp, upd);
if (s > 0 && newp != oldp)
u = 1;
if (u)
savings += s - (int)(vp9_cost_zero(upd));
else
savings -= (int)(vp9_cost_zero(upd));
#else
s = prob_update_savings(nzc_branch_ct[offset_nodes],
oldp, newp, upd);
if (s > 0)
u = 1;
if (u)
savings += s;
#endif
update[u]++;
}
}
}
}
if (update[1] == 0 || savings < 0) {
vp9_write_bit(bc, 0);
} else {
vp9_write_bit(bc, 1);
for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
for (r = 0; r < REF_TYPES; ++r) {
for (b = 0; b < BLOCK_TYPES; ++b) {
int offset = c * REF_TYPES * BLOCK_TYPES + r * BLOCK_TYPES + b;
int offset_nodes = offset * nodes;
for (t = 0; t < nodes; ++t) {
vp9_prob newp = new_nzc_probs[offset_nodes + t];
vp9_prob *oldp = &old_nzc_probs[offset_nodes + t];
int s, u = 0;
#if defined(SEARCH_NEWP)
s = prob_diff_update_savings_search(nzc_branch_ct[offset_nodes],
*oldp, &newp, upd);
if (s > 0 && newp != *oldp)
u = 1;
#else
s = prob_update_savings(nzc_branch_ct[offset_nodes],
*oldp, newp, upd);
if (s > 0)
u = 1;
#endif
vp9_write(bc, u, upd);
if (u) {
/* send/use new probability */
write_prob_diff_update(bc, newp, *oldp);
*oldp = newp;
}
}
}
}
}
}
}
static void update_nzc_pcat_probs(VP9_COMP *cpi, vp9_writer* const bc) {
VP9_COMMON *cm = &cpi->common;
int c, t, b;
int update[2] = {0, 0};
int savings = 0;
vp9_prob upd = NZC_UPDATE_PROB_PCAT;
if (!(get_nzc_used(TX_4X4) || get_nzc_used(TX_8X8) ||
get_nzc_used(TX_16X16) || get_nzc_used(TX_32X32)))
return;
for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
for (t = 0; t < NZC_TOKENS_EXTRA; ++t) {
int bits = vp9_extranzcbits[t + NZC_TOKENS_NOEXTRA];
for (b = 0; b < bits; ++b) {
vp9_prob newp = get_binary_prob(cm->fc.nzc_pcat_counts[c][t][b][0],
cm->fc.nzc_pcat_counts[c][t][b][1]);
vp9_prob oldp = cm->fc.nzc_pcat_probs[c][t][b];
int s, u = 0;
#if defined(SEARCH_NEWP)
s = prob_diff_update_savings_search(cm->fc.nzc_pcat_counts[c][t][b],
oldp, &newp, upd);
if (s > 0 && newp != oldp)
u = 1;
if (u)
savings += s - (int)(vp9_cost_zero(upd));
else
savings -= (int)(vp9_cost_zero(upd));
#else
s = prob_update_savings(cm->fc.nzc_pcat_counts[c][t][b],
oldp, newp, upd);
if (s > 0)
u = 1;
if (u)
savings += s;
#endif
update[u]++;
}
}
}
if (update[1] == 0 || savings < 0) {
vp9_write_bit(bc, 0);
} else {
vp9_write_bit(bc, 1);
for (c = 0; c < MAX_NZC_CONTEXTS; ++c) {
for (t = 0; t < NZC_TOKENS_EXTRA; ++t) {
int bits = vp9_extranzcbits[t + NZC_TOKENS_NOEXTRA];
for (b = 0; b < bits; ++b) {
vp9_prob newp = get_binary_prob(cm->fc.nzc_pcat_counts[c][t][b][0],
cm->fc.nzc_pcat_counts[c][t][b][1]);
vp9_prob *oldp = &cm->fc.nzc_pcat_probs[c][t][b];
int s, u = 0;
#if defined(SEARCH_NEWP)
s = prob_diff_update_savings_search(cm->fc.nzc_pcat_counts[c][t][b],
*oldp, &newp, upd);
if (s > 0 && newp != *oldp)
u = 1;
#else
s = prob_update_savings(cm->fc.nzc_pcat_counts[c][t][b],
*oldp, newp, upd);
if (s > 0)
u = 1;
#endif
vp9_write(bc, u, upd);
if (u) {
/* send/use new probability */
write_prob_diff_update(bc, newp, *oldp);
*oldp = newp;
}
}
}
}
}
}
static void update_nzc_probs(VP9_COMP* cpi,
vp9_writer* const bc) {
update_nzc_probs_common(cpi, bc, TX_4X4);
if (cpi->common.txfm_mode != ONLY_4X4)
update_nzc_probs_common(cpi, bc, TX_8X8);
if (cpi->common.txfm_mode > ALLOW_8X8)
update_nzc_probs_common(cpi, bc, TX_16X16);
if (cpi->common.txfm_mode > ALLOW_16X16)
update_nzc_probs_common(cpi, bc, TX_32X32);
#ifdef NZC_PCAT_UPDATE
update_nzc_pcat_probs(cpi, bc);
#endif
#ifdef NZC_STATS
if (!cpi->dummy_packing)
update_nzcstats(&cpi->common);
#endif
}
#endif // CONFIG_CODE_NONZEROCOUNT
static void update_coef_probs_common(vp9_writer* const bc,
VP9_COMP *cpi,
#ifdef ENTROPY_STATS
@ -2320,11 +1513,7 @@ static void update_coef_probs_common(vp9_writer* const bc,
#endif
// vp9_prob bestupd = find_coef_update_prob(cpi);
#if CONFIG_CODE_NONZEROCOUNT
const int tstart = get_nzc_used(tx_size);
#else
const int tstart = 0;
#endif
/* dry run to see if there is any udpate at all needed */
savings = 0;
for (i = 0; i < BLOCK_TYPES; ++i) {
@ -2966,27 +2155,6 @@ void vp9_pack_bitstream(VP9_COMP *cpi, unsigned char *dest,
cpi->common.fc.coef_probs_16x16);
vp9_copy(cpi->common.fc.pre_coef_probs_32x32,
cpi->common.fc.coef_probs_32x32);
#if CONFIG_CODE_NONZEROCOUNT
vp9_copy(cpi->common.fc.pre_nzc_probs_4x4,
cpi->common.fc.nzc_probs_4x4);
vp9_copy(cpi->common.fc.pre_nzc_probs_8x8,
cpi->common.fc.nzc_probs_8x8);
vp9_copy(cpi->common.fc.pre_nzc_probs_16x16,
cpi->common.fc.nzc_probs_16x16);
vp9_copy(cpi->common.fc.pre_nzc_probs_32x32,
cpi->common.fc.nzc_probs_32x32);
vp9_copy(cpi->common.fc.pre_nzc_pcat_probs,
cpi->common.fc.nzc_pcat_probs);
// NOTE that if the counts are reset, we also need to uncomment
// the count updates in the write_nzc function
/*
vp9_zero(cpi->common.fc.nzc_counts_4x4);
vp9_zero(cpi->common.fc.nzc_counts_8x8);
vp9_zero(cpi->common.fc.nzc_counts_16x16);
vp9_zero(cpi->common.fc.nzc_counts_32x32);
vp9_zero(cpi->common.fc.nzc_pcat_counts);
*/
#endif
#if CONFIG_CODE_ZEROGROUP
vp9_copy(cpi->common.fc.pre_zpc_probs_4x4,
cpi->common.fc.zpc_probs_4x4);
@ -3014,9 +2182,6 @@ void vp9_pack_bitstream(VP9_COMP *cpi, unsigned char *dest,
vp9_zero(cpi->common.fc.mv_ref_ct);
update_coef_probs(cpi, &header_bc);
#if CONFIG_CODE_NONZEROCOUNT
update_nzc_probs(cpi, &header_bc);
#endif
#if CONFIG_CODE_ZEROGROUP
update_zpc_probs(cpi, &header_bc);
#endif

Просмотреть файл

@ -151,12 +151,6 @@ struct macroblock {
unsigned char *active_ptr;
vp9_coeff_count token_costs[TX_SIZE_MAX_SB][BLOCK_TYPES];
#if CONFIG_CODE_NONZEROCOUNT
unsigned int nzc_costs_4x4[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES][17];
unsigned int nzc_costs_8x8[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES][65];
unsigned int nzc_costs_16x16[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES][257];
unsigned int nzc_costs_32x32[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES][1025];
#endif
int optimize;

Просмотреть файл

@ -738,9 +738,6 @@ static void update_stats(VP9_COMP *cpi, int mb_row, int mb_col) {
if ((mbmi->mode == ZEROMV) && (mbmi->ref_frame == LAST_FRAME))
cpi->inter_zz_count++;
}
#if CONFIG_CODE_NONZEROCOUNT
vp9_update_nzc_counts(&cpi->common, xd, mb_row, mb_col);
#endif
}
static void encode_sb(VP9_COMP *cpi,
@ -1338,13 +1335,6 @@ static void encode_frame_internal(VP9_COMP *cpi) {
vp9_zero(cpi->coef_counts_16x16);
vp9_zero(cpi->coef_counts_32x32);
vp9_zero(cm->fc.eob_branch_counts);
#if CONFIG_CODE_NONZEROCOUNT
vp9_zero(cm->fc.nzc_counts_4x4);
vp9_zero(cm->fc.nzc_counts_8x8);
vp9_zero(cm->fc.nzc_counts_16x16);
vp9_zero(cm->fc.nzc_counts_32x32);
vp9_zero(cm->fc.nzc_pcat_counts);
#endif
#if CONFIG_CODE_ZEROGROUP
vp9_zero(cm->fc.zpc_counts_4x4);
vp9_zero(cm->fc.zpc_counts_8x8);
@ -1881,137 +1871,6 @@ static void adjust_act_zbin(VP9_COMP *cpi, MACROBLOCK *x) {
#endif
}
#if CONFIG_CODE_NONZEROCOUNT
static void gather_nzcs_mb16(VP9_COMMON *const cm,
MACROBLOCKD *xd) {
int i;
vpx_memset(xd->mode_info_context->mbmi.nzcs, 0,
384 * sizeof(xd->mode_info_context->mbmi.nzcs[0]));
switch (xd->mode_info_context->mbmi.txfm_size) {
case TX_4X4:
for (i = 0; i < 24; ++i) {
xd->mode_info_context->mbmi.nzcs[i] = xd->nzcs[i];
}
break;
case TX_8X8:
for (i = 0; i < 16; i += 4) {
xd->mode_info_context->mbmi.nzcs[i] = xd->nzcs[i];
}
if (xd->mode_info_context->mbmi.mode == I8X8_PRED ||
xd->mode_info_context->mbmi.mode == SPLITMV) {
for (i = 16; i < 24; ++i) {
xd->mode_info_context->mbmi.nzcs[i] = xd->nzcs[i];
}
} else {
for (i = 16; i < 24; i += 4) {
xd->mode_info_context->mbmi.nzcs[i] = xd->nzcs[i];
}
}
break;
case TX_16X16:
xd->mode_info_context->mbmi.nzcs[0] = xd->nzcs[0];
for (i = 16; i < 24; i += 4) {
xd->mode_info_context->mbmi.nzcs[i] = xd->nzcs[i];
}
break;
default:
break;
}
}
static void gather_nzcs_sb32(VP9_COMMON *const cm,
MACROBLOCKD *xd) {
MODE_INFO *m = xd->mode_info_context;
int mis = cm->mode_info_stride;
int i, j;
vpx_memset(m->mbmi.nzcs, 0,
384 * sizeof(xd->mode_info_context->mbmi.nzcs[0]));
switch (xd->mode_info_context->mbmi.txfm_size) {
case TX_4X4:
for (i = 0; i < 96; ++i) {
xd->mode_info_context->mbmi.nzcs[i] = xd->nzcs[i];
}
break;
case TX_8X8:
for (i = 0; i < 96; i += 4) {
xd->mode_info_context->mbmi.nzcs[i] = xd->nzcs[i];
}
break;
case TX_16X16:
for (i = 0; i < 96; i += 16) {
xd->mode_info_context->mbmi.nzcs[i] = xd->nzcs[i];
}
break;
case TX_32X32:
xd->mode_info_context->mbmi.nzcs[0] = xd->nzcs[0];
for (i = 64; i < 96; i += 16) {
xd->mode_info_context->mbmi.nzcs[i] = xd->nzcs[i];
}
break;
default:
break;
}
for (i = 0; i < 2; ++i)
for (j = 0; j < 2; ++j) {
if (i == 0 && j == 0) continue;
vpx_memcpy((m + j + mis * i)->mbmi.nzcs, m->mbmi.nzcs,
384 * sizeof(m->mbmi.nzcs[0]));
}
}
static void gather_nzcs_sb64(VP9_COMMON *const cm,
MACROBLOCKD *xd) {
MODE_INFO *m = xd->mode_info_context;
int mis = cm->mode_info_stride;
int i, j;
vpx_memset(xd->mode_info_context->mbmi.nzcs, 0,
384 * sizeof(xd->mode_info_context->mbmi.nzcs[0]));
switch (xd->mode_info_context->mbmi.txfm_size) {
case TX_4X4:
for (i = 0; i < 384; ++i) {
xd->mode_info_context->mbmi.nzcs[i] = xd->nzcs[i];
}
break;
case TX_8X8:
for (i = 0; i < 384; i += 4) {
xd->mode_info_context->mbmi.nzcs[i] = xd->nzcs[i];
}
break;
case TX_16X16:
for (i = 0; i < 384; i += 16) {
xd->mode_info_context->mbmi.nzcs[i] = xd->nzcs[i];
}
break;
case TX_32X32:
for (i = 0; i < 384; i += 64) {
xd->mode_info_context->mbmi.nzcs[i] = xd->nzcs[i];
}
break;
default:
break;
}
for (i = 0; i < 4; ++i)
for (j = 0; j < 4; ++j) {
if (i == 0 && j == 0) continue;
vpx_memcpy((m + j + mis * i)->mbmi.nzcs, m->mbmi.nzcs,
384 * sizeof(m->mbmi.nzcs[0]));
}
}
#endif
static void encode_macroblock(VP9_COMP *cpi, TOKENEXTRA **t,
int output_enabled,
int mb_row, int mb_col) {
@ -2197,9 +2056,6 @@ static void encode_macroblock(VP9_COMP *cpi, TOKENEXTRA **t,
}
#endif
#if CONFIG_CODE_NONZEROCOUNT
gather_nzcs_mb16(cm, xd);
#endif
vp9_tokenize_mb(cpi, xd, t, !output_enabled);
} else {
@ -2419,13 +2275,6 @@ static void encode_superblock(VP9_COMP *cpi, TOKENEXTRA **t,
default: assert(0);
}
vp9_recon_sb_c(xd, bsize);
#if CONFIG_CODE_NONZEROCOUNT
if (bsize == BLOCK_SIZE_SB32X32) {
gather_nzcs_sb32(cm, &x->e_mbd);
} else {
gather_nzcs_sb64(cm, &x->e_mbd);
}
#endif
vp9_tokenize_sb(cpi, &x->e_mbd, t, !output_enabled, bsize);
} else {
// FIXME(rbultje): not tile-aware (mi - 1)

Просмотреть файл

@ -326,24 +326,6 @@ static void optimize_b(VP9_COMMON *const cm,
int const *scan, *nb;
const int mul = 1 + (tx_size == TX_32X32);
uint8_t token_cache[1024];
#if CONFIG_CODE_NONZEROCOUNT
// TODO(debargha): the dynamic programming approach used in this function
// is not compatible with the true rate cost when nzcs are used. Note
// the total rate is the sum of the nzc rate and the indicvidual token
// rates. The latter part can be optimized in this function, but because
// the nzc rate is a function of all the other tokens without a Markov
// relationship this rate cannot be considered correctly.
// The current implementation uses a suboptimal approach to account for
// the nzc rates somewhat, but in reality the optimization approach needs
// to change substantially.
const int nzc_used = get_nzc_used(tx_size);
uint16_t nzc = xd->nzcs[ib];
uint16_t nzc0, nzc1;
uint16_t final_nzc = 0, final_nzc_exp;
int nzc_context = vp9_get_nzc_context(cm, xd, ib);
unsigned int *nzc_cost;
nzc0 = nzc1 = nzc;
#endif
assert((!type && !pb_idx.plane) || (type && pb_idx.plane));
dqcoeff_ptr = BLOCK_OFFSET(xd->plane[pb_idx.plane].dqcoeff, pb_idx.block, 16);
@ -353,9 +335,6 @@ static void optimize_b(VP9_COMMON *const cm,
case TX_4X4: {
const TX_TYPE tx_type = get_tx_type_4x4(xd, ib);
default_eob = 16;
#if CONFIG_CODE_NONZEROCOUNT
nzc_cost = mb->nzc_costs_4x4[nzc_context][ref][type];
#endif
if (tx_type == DCT_ADST) {
scan = vp9_col_scan_4x4;
} else if (tx_type == ADST_DCT) {
@ -378,9 +357,6 @@ static void optimize_b(VP9_COMMON *const cm,
scan = vp9_default_zig_zag1d_8x8;
}
default_eob = 64;
#if CONFIG_CODE_NONZEROCOUNT
nzc_cost = mb->nzc_costs_8x8[nzc_context][ref][type];
#endif
break;
}
case TX_16X16: {
@ -396,17 +372,11 @@ static void optimize_b(VP9_COMMON *const cm,
scan = vp9_default_zig_zag1d_16x16;
}
default_eob = 256;
#if CONFIG_CODE_NONZEROCOUNT
nzc_cost = mb->nzc_costs_16x16[nzc_context][ref][type];
#endif
break;
}
case TX_32X32:
scan = vp9_default_zig_zag1d_32x32;
default_eob = 1024;
#if CONFIG_CODE_NONZEROCOUNT
nzc_cost = mb->nzc_costs_32x32[nzc_context][ref][type];
#endif
break;
}
assert(eob <= default_eob);
@ -418,11 +388,7 @@ static void optimize_b(VP9_COMMON *const cm,
rddiv = mb->rddiv;
memset(best_index, 0, sizeof(best_index));
/* Initialize the sentinel node of the trellis. */
#if CONFIG_CODE_NONZEROCOUNT
tokens[eob][0].rate = nzc_used ? nzc_cost[nzc] : 0;
#else
tokens[eob][0].rate = 0;
#endif
tokens[eob][0].error = 0;
tokens[eob][0].next = default_eob;
tokens[eob][0].token = DCT_EOB_TOKEN;
@ -435,9 +401,6 @@ static void optimize_b(VP9_COMMON *const cm,
for (i = eob; i-- > i0;) {
int base_bits, d2, dx;
#if CONFIG_CODE_NONZEROCOUNT
int new_nzc0, new_nzc1;
#endif
rc = scan[i];
x = qcoeff_ptr[rc];
@ -472,9 +435,6 @@ static void optimize_b(VP9_COMMON *const cm,
tokens[i][0].token = t0;
tokens[i][0].qc = x;
best_index[i][0] = best;
#if CONFIG_CODE_NONZEROCOUNT
new_nzc0 = (best ? nzc1 : nzc0);
#endif
/* Evaluate the second possibility for this state. */
rate0 = tokens[next][0].rate;
@ -501,14 +461,6 @@ static void optimize_b(VP9_COMMON *const cm,
DCT_EOB_TOKEN : ZERO_TOKEN;
t1 = tokens[next][1].token == DCT_EOB_TOKEN ?
DCT_EOB_TOKEN : ZERO_TOKEN;
#if CONFIG_CODE_NONZEROCOUNT
// Account for rate drop because of the nzc change.
// TODO(debargha): Find a better solution
if (nzc_used) {
rate0 -= nzc_cost[nzc0] - nzc_cost[nzc0 - 1];
rate1 -= nzc_cost[nzc1] - nzc_cost[nzc1 - 1];
}
#endif
} else {
t0 = t1 = (vp9_dct_value_tokens_ptr + x)->token;
}
@ -543,11 +495,6 @@ static void optimize_b(VP9_COMMON *const cm,
tokens[i][1].token = best ? t1 : t0;
tokens[i][1].qc = x;
best_index[i][1] = best;
#if CONFIG_CODE_NONZEROCOUNT
new_nzc1 = (best ? nzc1 : nzc0) - (!x);
nzc0 = new_nzc0;
nzc1 = new_nzc1;
#endif
/* Finally, make this the new head of the trellis. */
next = i;
}
@ -586,9 +533,6 @@ static void optimize_b(VP9_COMMON *const cm,
rate1 += mb->token_costs[tx_size][type][ref][band][pt][t1];
UPDATE_RD_COST();
best = rd_cost1 < rd_cost0;
#if CONFIG_CODE_NONZEROCOUNT
final_nzc_exp = (best ? nzc1 : nzc0);
#endif
final_eob = i0 - 1;
vpx_memset(qcoeff_ptr, 0, sizeof(*qcoeff_ptr) * (16 << (tx_size * 2)));
vpx_memset(dqcoeff_ptr, 0, sizeof(*dqcoeff_ptr) * (16 << (tx_size * 2)));
@ -596,9 +540,6 @@ static void optimize_b(VP9_COMMON *const cm,
x = tokens[i][best].qc;
if (x) {
final_eob = i;
#if CONFIG_CODE_NONZEROCOUNT
++final_nzc;
#endif
}
rc = scan[i];
qcoeff_ptr[rc] = x;
@ -611,10 +552,6 @@ static void optimize_b(VP9_COMMON *const cm,
xd->plane[pb_idx.plane].eobs[pb_idx.block] = final_eob;
*a = *l = (final_eob > 0);
#if CONFIG_CODE_NONZEROCOUNT
assert(final_nzc == final_nzc_exp);
xd->nzcs[ib] = final_nzc;
#endif
}
void vp9_optimize_sby_32x32(VP9_COMMON *const cm, MACROBLOCK *x,

Просмотреть файл

@ -114,12 +114,6 @@ extern void init_nmvstats();
extern void print_nmvstats();
#endif
#if CONFIG_CODE_NONZEROCOUNT
#ifdef NZC_STATS
extern void init_nzcstats();
extern void print_nzcstats();
#endif
#endif
#if CONFIG_CODE_ZEROGROUP
#ifdef ZPC_STATS
extern void init_zpcstats();
@ -1439,11 +1433,6 @@ VP9_PTR vp9_create_compressor(VP9_CONFIG *oxcf) {
#ifdef NMV_STATS
init_nmvstats();
#endif
#if CONFIG_CODE_NONZEROCOUNT
#ifdef NZC_STATS
init_nzcstats();
#endif
#endif
#if CONFIG_CODE_ZEROGROUP
#ifdef ZPC_STATS
init_zpcstats();
@ -1654,13 +1643,6 @@ VP9_PTR vp9_create_compressor(VP9_CONFIG *oxcf) {
cpi->common.error.setjmp = 0;
vp9_zero(cpi->y_uv_mode_count)
#if CONFIG_CODE_NONZEROCOUNT
vp9_zero(cm->fc.nzc_counts_4x4);
vp9_zero(cm->fc.nzc_counts_8x8);
vp9_zero(cm->fc.nzc_counts_16x16);
vp9_zero(cm->fc.nzc_counts_32x32);
vp9_zero(cm->fc.nzc_pcat_counts);
#endif
#if CONFIG_CODE_ZEROGROUP
vp9_zero(cm->fc.zpc_counts_4x4);
vp9_zero(cm->fc.zpc_counts_8x8);
@ -1694,12 +1676,6 @@ void vp9_remove_compressor(VP9_PTR *ptr) {
if (cpi->pass != 1)
print_nmvstats();
#endif
#if CONFIG_CODE_NONZEROCOUNT
#ifdef NZC_STATS
if (cpi->pass != 1)
print_nzcstats();
#endif
#endif
#if CONFIG_CODE_ZEROGROUP
#ifdef ZPC_STATS
if (cpi->pass != 1)
@ -3324,9 +3300,6 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
if (!cpi->common.error_resilient_mode &&
!cpi->common.frame_parallel_decoding_mode) {
vp9_adapt_coef_probs(&cpi->common);
#if CONFIG_CODE_NONZEROCOUNT
vp9_adapt_nzc_probs(&cpi->common);
#endif
#if CONFIG_CODE_ZEROGROUP
vp9_adapt_zpc_probs(&cpi->common);
#endif

Просмотреть файл

@ -114,18 +114,6 @@ typedef struct {
int mv_ref_ct[INTER_MODE_CONTEXTS][4][2];
int vp9_mode_contexts[INTER_MODE_CONTEXTS][4];
#if CONFIG_CODE_NONZEROCOUNT
vp9_prob nzc_probs_4x4
[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES][NZC4X4_NODES];
vp9_prob nzc_probs_8x8
[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES][NZC8X8_NODES];
vp9_prob nzc_probs_16x16
[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES][NZC16X16_NODES];
vp9_prob nzc_probs_32x32
[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES][NZC32X32_NODES];
vp9_prob nzc_pcat_probs[MAX_NZC_CONTEXTS]
[NZC_TOKENS_EXTRA][NZC_BITS_EXTRA];
#endif
#if CONFIG_CODE_ZEROGROUP
vp9_zpc_probs zpc_probs_4x4;
vp9_zpc_probs zpc_probs_8x8;
@ -493,25 +481,6 @@ typedef struct VP9_COMP {
vp9_coeff_probs frame_coef_probs_32x32[BLOCK_TYPES];
vp9_coeff_stats frame_branch_ct_32x32[BLOCK_TYPES];
#if CONFIG_CODE_NONZEROCOUNT
vp9_prob frame_nzc_probs_4x4
[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES][NZC4X4_NODES];
unsigned int frame_nzc_branch_ct_4x4
[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES][NZC4X4_NODES][2];
vp9_prob frame_nzc_probs_8x8
[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES][NZC8X8_NODES];
unsigned int frame_nzc_branch_ct_8x8
[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES][NZC8X8_NODES][2];
vp9_prob frame_nzc_probs_16x16
[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES][NZC16X16_NODES];
unsigned int frame_nzc_branch_ct_16x16
[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES][NZC16X16_NODES][2];
vp9_prob frame_nzc_probs_32x32
[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES][NZC32X32_NODES];
unsigned int frame_nzc_branch_ct_32x32
[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES][NZC32X32_NODES][2];
#endif
int gfu_boost;
int last_boost;
int kf_boost;

Просмотреть файл

@ -45,9 +45,6 @@ void vp9_ht_quantize_b_4x4(MACROBLOCK *mb, int b_idx, TX_TYPE tx_type) {
int16_t *dequant_ptr = d->dequant;
int zbin_oq_value = b->zbin_extra;
const int *pt_scan;
#if CONFIG_CODE_NONZEROCOUNT
int nzc = 0;
#endif
switch (tx_type) {
case ADST_DCT:
@ -87,9 +84,6 @@ void vp9_ht_quantize_b_4x4(MACROBLOCK *mb, int b_idx, TX_TYPE tx_type) {
if (y) {
eob = i; // last nonzero coeffs
#if CONFIG_CODE_NONZEROCOUNT
++nzc; // number of nonzero coeffs
#endif
zbin_boost_ptr = b->zrun_zbin_boost; // reset zero runlength
}
}
@ -97,9 +91,6 @@ void vp9_ht_quantize_b_4x4(MACROBLOCK *mb, int b_idx, TX_TYPE tx_type) {
}
xd->plane[0].eobs[b_idx] = eob + 1;
#if CONFIG_CODE_NONZEROCOUNT
xd->nzcs[b_idx] = nzc;
#endif
}
void vp9_regular_quantize_b_4x4(MACROBLOCK *mb, int b_idx, int y_blocks) {
@ -123,9 +114,6 @@ void vp9_regular_quantize_b_4x4(MACROBLOCK *mb, int b_idx, int y_blocks) {
uint8_t *quant_shift_ptr = b->quant_shift;
int16_t *dequant_ptr = d->dequant;
int zbin_oq_value = b->zbin_extra;
#if CONFIG_CODE_NONZEROCOUNT
int nzc = 0;
#endif
if (c_idx == 0) assert(pb_idx.plane == 0);
if (c_idx == 16) assert(pb_idx.plane == 1);
@ -157,9 +145,6 @@ void vp9_regular_quantize_b_4x4(MACROBLOCK *mb, int b_idx, int y_blocks) {
if (y) {
eob = i; // last nonzero coeffs
#if CONFIG_CODE_NONZEROCOUNT
++nzc; // number of nonzero coeffs
#endif
zbin_boost_ptr = b->zrun_zbin_boost; // reset zero runlength
}
}
@ -167,9 +152,6 @@ void vp9_regular_quantize_b_4x4(MACROBLOCK *mb, int b_idx, int y_blocks) {
}
xd->plane[pb_idx.plane].eobs[pb_idx.block] = eob + 1;
#if CONFIG_CODE_NONZEROCOUNT
xd->nzcs[b_idx] = nzc;
#endif
}
void vp9_regular_quantize_b_8x8(MACROBLOCK *mb, int b_idx, TX_TYPE tx_type,
@ -216,9 +198,6 @@ void vp9_regular_quantize_b_8x8(MACROBLOCK *mb, int b_idx, TX_TYPE tx_type,
uint8_t *quant_shift_ptr = b->quant_shift;
int16_t *dequant_ptr = d->dequant;
int zbin_oq_value = b->zbin_extra;
#if CONFIG_CODE_NONZEROCOUNT
int nzc = 0;
#endif
eob = -1;
@ -242,9 +221,6 @@ void vp9_regular_quantize_b_8x8(MACROBLOCK *mb, int b_idx, TX_TYPE tx_type,
if (y) {
eob = 0; // last nonzero coeffs
#if CONFIG_CODE_NONZEROCOUNT
++nzc; // number of nonzero coeffs
#endif
zero_run = 0;
}
}
@ -271,22 +247,13 @@ void vp9_regular_quantize_b_8x8(MACROBLOCK *mb, int b_idx, TX_TYPE tx_type,
if (y) {
eob = i; // last nonzero coeffs
#if CONFIG_CODE_NONZEROCOUNT
++nzc; // number of nonzero coeffs
#endif
zero_run = 0;
}
}
}
xd->plane[pb_idx.plane].eobs[pb_idx.block] = eob + 1;
#if CONFIG_CODE_NONZEROCOUNT
xd->nzcs[b_idx] = nzc;
#endif
} else {
xd->plane[pb_idx.plane].eobs[pb_idx.block] = 0;
#if CONFIG_CODE_NONZEROCOUNT
xd->nzcs[b_idx] = 0;
#endif
}
}
@ -297,18 +264,12 @@ static void quantize(int16_t *zbin_boost_orig_ptr,
int16_t *qcoeff_ptr, int16_t *dqcoeff_ptr,
int16_t *dequant_ptr, int zbin_oq_value,
uint16_t *eob_ptr,
#if CONFIG_CODE_NONZEROCOUNT
uint16_t *nzc_ptr,
#endif
const int *scan, int mul) {
int i, rc, eob;
int zbin;
int x, y, z, sz;
int zero_run = 0;
int16_t *zbin_boost_ptr = zbin_boost_orig_ptr;
#if CONFIG_CODE_NONZEROCOUNT
int nzc = 0;
#endif
vpx_memset(qcoeff_ptr, 0, n_coeffs*sizeof(int16_t));
vpx_memset(dqcoeff_ptr, 0, n_coeffs*sizeof(int16_t));
@ -337,18 +298,12 @@ static void quantize(int16_t *zbin_boost_orig_ptr,
if (y) {
eob = i; // last nonzero coeffs
zero_run = 0;
#if CONFIG_CODE_NONZEROCOUNT
++nzc; // number of nonzero coeffs
#endif
}
}
}
}
*eob_ptr = eob + 1;
#if CONFIG_CODE_NONZEROCOUNT
*nzc_ptr = nzc;
#endif
}
void vp9_regular_quantize_b_16x16(MACROBLOCK *mb, int b_idx, TX_TYPE tx_type,
@ -384,9 +339,6 @@ void vp9_regular_quantize_b_16x16(MACROBLOCK *mb, int b_idx, TX_TYPE tx_type,
d->dequant,
b->zbin_extra,
&xd->plane[pb_idx.plane].eobs[pb_idx.block],
#if CONFIG_CODE_NONZEROCOUNT
&xd->nzcs[b_idx],
#endif
pt_scan, 1);
}
@ -410,9 +362,6 @@ void vp9_regular_quantize_b_32x32(MACROBLOCK *mb, int b_idx, int y_blocks) {
d->dequant,
b->zbin_extra,
&xd->plane[pb_idx.plane].eobs[pb_idx.block],
#if CONFIG_CODE_NONZEROCOUNT
&xd->nzcs[b_idx],
#endif
vp9_default_zig_zag1d_32x32, 2);
}

Просмотреть файл

@ -172,13 +172,6 @@ void vp9_save_coding_context(VP9_COMP *cpi) {
#if CONFIG_COMP_INTERINTRA_PRED
cc->interintra_prob = cm->fc.interintra_prob;
#endif
#if CONFIG_CODE_NONZEROCOUNT
vp9_copy(cc->nzc_probs_4x4, cm->fc.nzc_probs_4x4);
vp9_copy(cc->nzc_probs_8x8, cm->fc.nzc_probs_8x8);
vp9_copy(cc->nzc_probs_16x16, cm->fc.nzc_probs_16x16);
vp9_copy(cc->nzc_probs_32x32, cm->fc.nzc_probs_32x32);
vp9_copy(cc->nzc_pcat_probs, cm->fc.nzc_pcat_probs);
#endif
#if CONFIG_CODE_ZEROGROUP
vp9_copy(cc->zpc_probs_4x4, cm->fc.zpc_probs_4x4);
vp9_copy(cc->zpc_probs_8x8, cm->fc.zpc_probs_8x8);
@ -241,13 +234,6 @@ void vp9_restore_coding_context(VP9_COMP *cpi) {
#if CONFIG_COMP_INTERINTRA_PRED
cm->fc.interintra_prob = cc->interintra_prob;
#endif
#if CONFIG_CODE_NONZEROCOUNT
vp9_copy(cm->fc.nzc_probs_4x4, cc->nzc_probs_4x4);
vp9_copy(cm->fc.nzc_probs_8x8, cc->nzc_probs_8x8);
vp9_copy(cm->fc.nzc_probs_16x16, cc->nzc_probs_16x16);
vp9_copy(cm->fc.nzc_probs_32x32, cc->nzc_probs_32x32);
vp9_copy(cm->fc.nzc_pcat_probs, cc->nzc_pcat_probs);
#endif
#if CONFIG_CODE_ZEROGROUP
vp9_copy(cm->fc.zpc_probs_4x4, cc->zpc_probs_4x4);
vp9_copy(cm->fc.zpc_probs_8x8, cc->zpc_probs_8x8);

Просмотреть файл

@ -162,60 +162,6 @@ static void fill_token_costs(vp9_coeff_count *c,
}
}
#if CONFIG_CODE_NONZEROCOUNT
static void fill_nzc_costs(VP9_COMP *cpi, TX_SIZE tx_size) {
int nzc_context, r, b, nzc, values;
int cost[16];
values = (16 << (2 * tx_size)) + 1;
for (nzc_context = 0; nzc_context < MAX_NZC_CONTEXTS; ++nzc_context) {
for (r = 0; r < REF_TYPES; ++r) {
for (b = 0; b < BLOCK_TYPES; ++b) {
unsigned int *nzc_costs;
if (tx_size == TX_4X4) {
vp9_cost_tokens(cost,
cpi->common.fc.nzc_probs_4x4[nzc_context][r][b],
vp9_nzc4x4_tree);
nzc_costs = cpi->mb.nzc_costs_4x4[nzc_context][r][b];
} else if (tx_size == TX_8X8) {
vp9_cost_tokens(cost,
cpi->common.fc.nzc_probs_8x8[nzc_context][r][b],
vp9_nzc8x8_tree);
nzc_costs = cpi->mb.nzc_costs_8x8[nzc_context][r][b];
} else if (tx_size == TX_16X16) {
vp9_cost_tokens(cost,
cpi->common.fc.nzc_probs_16x16[nzc_context][r][b],
vp9_nzc16x16_tree);
nzc_costs = cpi->mb.nzc_costs_16x16[nzc_context][r][b];
} else {
vp9_cost_tokens(cost,
cpi->common.fc.nzc_probs_32x32[nzc_context][r][b],
vp9_nzc32x32_tree);
nzc_costs = cpi->mb.nzc_costs_32x32[nzc_context][r][b];
}
for (nzc = 0; nzc < values; ++nzc) {
int e, c, totalcost = 0;
c = codenzc(nzc);
totalcost = cost[c];
if ((e = vp9_extranzcbits[c])) {
int x = nzc - vp9_basenzcvalue[c];
while (e--) {
totalcost += vp9_cost_bit(
cpi->common.fc.nzc_pcat_probs[nzc_context]
[c - NZC_TOKENS_NOEXTRA][e],
((x >> e) & 1));
}
}
nzc_costs[nzc] = totalcost;
}
}
}
}
}
#endif
static int rd_iifactor[32] = { 4, 4, 3, 2, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
@ -313,12 +259,6 @@ void vp9_initialize_rd_consts(VP9_COMP *cpi, int qindex) {
cpi->common.fc.coef_probs_16x16, TX_16X16);
fill_token_costs(cpi->mb.token_costs[TX_32X32],
cpi->common.fc.coef_probs_32x32, TX_32X32);
#if CONFIG_CODE_NONZEROCOUNT
fill_nzc_costs(cpi, TX_4X4);
fill_nzc_costs(cpi, TX_8X8);
fill_nzc_costs(cpi, TX_16X16);
fill_nzc_costs(cpi, TX_32X32);
#endif
for (i = 0; i < 2; i++)
vp9_cost_tokens(cpi->mb.partition_cost[i],
@ -376,11 +316,6 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
sizeof(ENTROPY_CONTEXT_PLANES)/sizeof(ENTROPY_CONTEXT);
TX_TYPE tx_type = DCT_DCT;
#if CONFIG_CODE_NONZEROCOUNT
const int nzc_used = get_nzc_used(tx_size);
int nzc_context = vp9_get_nzc_context(cm, xd, ib);
unsigned int *nzc_cost;
#endif
#if CONFIG_CODE_ZEROGROUP
int last_nz_pos[3] = {-1, -1, -1}; // Encoder only
int is_eoo_list[3] = {0, 0, 0};
@ -415,9 +350,6 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
get_tx_type_4x4(xd, ib) : DCT_DCT;
a_ec = *a;
l_ec = *l;
#if CONFIG_CODE_NONZEROCOUNT
nzc_cost = mb->nzc_costs_4x4[nzc_context][ref][type];
#endif
coef_probs = cm->fc.coef_probs_4x4;
seg_eob = 16;
if (tx_type == ADST_DCT) {
@ -447,9 +379,6 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
} else {
scan = vp9_default_zig_zag1d_8x8;
}
#if CONFIG_CODE_NONZEROCOUNT
nzc_cost = mb->nzc_costs_8x8[nzc_context][ref][type];
#endif
coef_probs = cm->fc.coef_probs_8x8;
seg_eob = 64;
#if CONFIG_CODE_ZEROGROUP
@ -470,9 +399,6 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
} else {
scan = vp9_default_zig_zag1d_16x16;
}
#if CONFIG_CODE_NONZEROCOUNT
nzc_cost = mb->nzc_costs_16x16[nzc_context][ref][type];
#endif
coef_probs = cm->fc.coef_probs_16x16;
seg_eob = 256;
if (type == PLANE_TYPE_UV) {
@ -489,9 +415,6 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
}
case TX_32X32:
scan = vp9_default_zig_zag1d_32x32;
#if CONFIG_CODE_NONZEROCOUNT
nzc_cost = mb->nzc_costs_32x32[nzc_context][ref][type];
#endif
coef_probs = cm->fc.coef_probs_32x32;
seg_eob = 1024;
if (type == PLANE_TYPE_UV) {
@ -524,11 +447,8 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
nb = vp9_get_coef_neighbors_handle(scan, &pad);
default_eob = seg_eob;
#if CONFIG_CODE_NONZEROCOUNT
if (!nzc_used)
#endif
if (vp9_segfeature_active(xd, segment_id, SEG_LVL_SKIP))
seg_eob = 0;
if (vp9_segfeature_active(xd, segment_id, SEG_LVL_SKIP))
seg_eob = 0;
/* sanity check to ensure that we do not have spurious non-zero q values */
if (eob < seg_eob)
@ -545,16 +465,10 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
}
#endif
{
#if CONFIG_CODE_NONZEROCOUNT
int nzc = 0;
#endif
for (c = 0; c < eob; c++) {
int v = qcoeff_ptr[scan[c]];
int t = vp9_dct_value_tokens_ptr[v].token;
int band = get_coef_band(scan, tx_size, c);
#if CONFIG_CODE_NONZEROCOUNT
nzc += (v != 0);
#endif
if (c)
pt = vp9_get_coef_context(scan, nb, pad, token_cache, c, default_eob);
#if CONFIG_CODE_ZEROGROUP
@ -569,11 +483,8 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
#else
cost += token_costs[band][pt][t] + vp9_dct_value_cost_ptr[v];
#endif
#if CONFIG_CODE_NONZEROCOUNT
if (!nzc_used)
#endif
if (!c || token_cache[scan[c - 1]])
cost += vp9_cost_bit(coef_probs[type][ref][band][pt][0], 1);
if (!c || token_cache[scan[c - 1]])
cost += vp9_cost_bit(coef_probs[type][ref][band][pt][0], 1);
token_cache[scan[c]] = t;
#if CONFIG_CODE_ZEROGROUP
if (t == ZERO_TOKEN && !skip_coef_val) {
@ -632,22 +543,17 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
is_last_zero[o] = (t == ZERO_TOKEN);
#endif
}
#if CONFIG_CODE_NONZEROCOUNT
if (nzc_used)
cost += nzc_cost[nzc];
else
#endif
if (c < seg_eob) {
if (c)
pt = vp9_get_coef_context(scan, nb, pad, token_cache, c, default_eob);
cost += mb->token_costs[tx_size][type][ref]
[get_coef_band(scan, tx_size, c)]
[pt][DCT_EOB_TOKEN];
}
if (c < seg_eob) {
if (c)
pt = vp9_get_coef_context(scan, nb, pad, token_cache, c, default_eob);
cost += mb->token_costs[tx_size][type][ref]
[get_coef_band(scan, tx_size, c)]
[pt][DCT_EOB_TOKEN];
}
}
// is eob first coefficient;
pt = (c > 0);
// is eob first coefficient;
pt = (c > 0);
*a = *l = pt;
if (tx_size >= TX_8X8) {
a[1] = l[1] = pt;

Просмотреть файл

@ -36,21 +36,6 @@ extern vp9_coeff_stats tree_update_hist_16x16[BLOCK_TYPES];
extern vp9_coeff_stats tree_update_hist_32x32[BLOCK_TYPES];
#endif /* ENTROPY_STATS */
#if CONFIG_CODE_NONZEROCOUNT
#ifdef NZC_STATS
unsigned int nzc_counts_4x4[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES]
[NZC4X4_TOKENS];
unsigned int nzc_counts_8x8[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES]
[NZC8X8_TOKENS];
unsigned int nzc_counts_16x16[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES]
[NZC16X16_TOKENS];
unsigned int nzc_counts_32x32[MAX_NZC_CONTEXTS][REF_TYPES][BLOCK_TYPES]
[NZC32X32_TOKENS];
unsigned int nzc_pcat_counts[MAX_NZC_CONTEXTS][NZC_TOKENS_EXTRA]
[NZC_BITS_EXTRA][2];
#endif
#endif
static TOKENVALUE dct_value_tokens[DCT_MAX_VALUE * 2];
const TOKENVALUE *vp9_dct_value_tokens_ptr;
static int dct_value_cost[DCT_MAX_VALUE * 2];
@ -147,12 +132,6 @@ static void tokenize_b(VP9_COMP *cpi,
vp9_zpc_count *zpc_count;
uint8_t token_cache_full[1024];
#endif
#if CONFIG_CODE_NONZEROCOUNT
const int nzc_used = get_nzc_used(tx_size);
int zerosleft = 0, nzc = 0;
if (eob == 0)
assert(xd->nzcs[ib] == 0);
#endif
#if CONFIG_CODE_ZEROGROUP
vpx_memset(token_cache, UNKNOWN_TOKEN, sizeof(token_cache));
#endif
@ -343,10 +322,6 @@ static void tokenize_b(VP9_COMP *cpi,
rc = scan[c];
if (c)
pt = vp9_get_coef_context(scan, nb, pad, token_cache, c, default_eob);
#if CONFIG_CODE_NONZEROCOUNT
if (nzc_used)
zerosleft = seg_eob - xd->nzcs[ib] - c + nzc;
#endif
if (c < eob) {
v = qcoeff_ptr[rc];
assert(-DCT_MAX_VALUE <= v && v < DCT_MAX_VALUE);
@ -354,22 +329,11 @@ static void tokenize_b(VP9_COMP *cpi,
t->extra = vp9_dct_value_tokens_ptr[v].extra;
token = vp9_dct_value_tokens_ptr[v].token;
} else {
#if CONFIG_CODE_NONZEROCOUNT
if (nzc_used)
break;
else
#endif
token = DCT_EOB_TOKEN;
token = DCT_EOB_TOKEN;
}
t->token = token;
t->context_tree = coef_probs[type][ref][band][pt];
#if CONFIG_CODE_NONZEROCOUNT
// Skip zero node if there are no zeros left
if (nzc_used)
t->skip_eob_node = 1 + (zerosleft == 0);
else
#endif
t->skip_eob_node = (c > 0) && (token_cache[scan[c - 1]] == 0);
assert(vp9_coef_encodings[t->token].len - t->skip_eob_node > 0);
#if CONFIG_CODE_ZEROGROUP
@ -391,9 +355,6 @@ static void tokenize_b(VP9_COMP *cpi,
if (!t->skip_eob_node)
++cpi->common.fc.eob_branch_counts[tx_size][type][ref][band][pt];
}
#if CONFIG_CODE_NONZEROCOUNT
nzc += (v != 0);
#endif
token_cache[scan[c]] = token;
#if CONFIG_CODE_ZEROGROUP
if (token == ZERO_TOKEN && !t->skip_coef_val) {
@ -464,10 +425,7 @@ static void tokenize_b(VP9_COMP *cpi,
is_last_zero[o] = (token == ZERO_TOKEN);
#endif
++t;
} while (c < eob && ++c < seg_eob);
#if CONFIG_CODE_NONZEROCOUNT
assert(nzc == xd->nzcs[ib]);
#endif
} while (c < eob && ++c < seg_eob);
*tp = t;
a_ec = l_ec = (c > 0); /* 0 <-> all coeff data is zero */
@ -860,9 +818,6 @@ static void stuff_b(VP9_COMP *cpi,
TOKENEXTRA *t = *tp;
const int ref = mbmi->ref_frame != INTRA_FRAME;
ENTROPY_CONTEXT *a, *l, *a1, *l1, *a2, *l2, *a3, *l3, a_ec, l_ec;
#if CONFIG_CODE_NONZEROCOUNT
const int nzc_used = get_nzc_used(tx_size);
#endif
if (sb_type == BLOCK_SIZE_SB64X64) {
a = (ENTROPY_CONTEXT *)xd->above_context +
@ -928,26 +883,20 @@ static void stuff_b(VP9_COMP *cpi,
break;
}
#if CONFIG_CODE_NONZEROCOUNT
if (!nzc_used) {
#endif
pt = combine_entropy_contexts(a_ec, l_ec);
band = 0;
t->token = DCT_EOB_TOKEN;
t->context_tree = probs[type][ref][band][pt];
t->skip_eob_node = 0;
pt = combine_entropy_contexts(a_ec, l_ec);
band = 0;
t->token = DCT_EOB_TOKEN;
t->context_tree = probs[type][ref][band][pt];
t->skip_eob_node = 0;
#if CONFIG_CODE_ZEROGROUP
t->skip_coef_val = 0;
t->skip_coef_val = 0;
#endif
++t;
*tp = t;
if (!dry_run) {
++counts[type][ref][band][pt][DCT_EOB_TOKEN];
}
#if CONFIG_CODE_NONZEROCOUNT
++t;
*tp = t;
if (!dry_run) {
++counts[type][ref][band][pt][DCT_EOB_TOKEN];
}
#endif
*a = *l = 0;
*a = *l = 0;
if (tx_size == TX_8X8) {
a[1] = 0;
l[1] = 0;