Merge "Bugfix from reordering frame probs patch" into experimental
diff --git a/configure b/configure
index 1479019..37eb9cf 100755
--- a/configure
+++ b/configure
@@ -243,7 +243,6 @@
newbintramodes
comp_interintra_pred
enable_6tap
- code_nonzerocount
modelcoefprob
loop_dering
implicit_compoundinter_weight
diff --git a/vp9/common/vp9_blockd.h b/vp9/common/vp9_blockd.h
index b1915d1..715df98 100644
--- a/vp9/common/vp9_blockd.h
+++ b/vp9/common/vp9_blockd.h
@@ -282,9 +282,6 @@
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,16 +360,11 @@
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. */
BLOCKD block[24];
- YV12_BUFFER_CONFIG pre; /* Filtered copy of previous frame reconstruction */
- YV12_BUFFER_CONFIG second_pre;
struct scale_factors scale_factor[2];
struct scale_factors scale_factor_uv[2];
@@ -753,12 +745,6 @@
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;
diff --git a/vp9/common/vp9_coefupdateprobs.h b/vp9/common/vp9_coefupdateprobs.h
index a13f9b2..e49935c 100644
--- a/vp9/common/vp9_coefupdateprobs.h
+++ b/vp9/common/vp9_coefupdateprobs.h
@@ -18,14 +18,6 @@
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
diff --git a/vp9/common/vp9_default_coef_probs.h b/vp9/common/vp9_default_coef_probs.h
index 9e105bd..453b4a2 100644
--- a/vp9/common/vp9_default_coef_probs.h
+++ b/vp9/common/vp9_default_coef_probs.h
@@ -700,302 +700,6 @@
}
};
-#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,
diff --git a/vp9/common/vp9_entropy.c b/vp9/common/vp9_entropy.c
index cfd6a3c..a5437d8 100644
--- a/vp9/common/vp9_entropy.c
+++ b/vp9/common/vp9_entropy.c
@@ -400,65 +400,6 @@
254, 254, 254, 252, 249, 243, 230, 196, 177, 153, 140, 133, 130, 129
};
-#if CONFIG_CODE_NONZEROCOUNT
-const vp9_tree_index vp9_nzc4x4_tree[2 * NZC4X4_NODES] = {
- -NZC_0, 2,
- 4, 6,
- -NZC_1, -NZC_2,
- -NZC_3TO4, 8,
- -NZC_5TO8, -NZC_9TO16,
-};
-struct vp9_token vp9_nzc4x4_encodings[NZC4X4_TOKENS];
-
-const vp9_tree_index vp9_nzc8x8_tree[2 * NZC8X8_NODES] = {
- -NZC_0, 2,
- 4, 6,
- -NZC_1, -NZC_2,
- 8, 10,
- -NZC_3TO4, -NZC_5TO8,
- -NZC_9TO16, 12,
- -NZC_17TO32, -NZC_33TO64,
-};
-struct vp9_token vp9_nzc8x8_encodings[NZC8X8_TOKENS];
-
-const vp9_tree_index vp9_nzc16x16_tree[2 * NZC16X16_NODES] = {
- -NZC_0, 2,
- 4, 6,
- -NZC_1, -NZC_2,
- 8, 10,
- -NZC_3TO4, -NZC_5TO8,
- 12, 14,
- -NZC_9TO16, -NZC_17TO32,
- -NZC_33TO64, 16,
- -NZC_65TO128, -NZC_129TO256,
-};
-struct vp9_token vp9_nzc16x16_encodings[NZC16X16_TOKENS];
-
-const vp9_tree_index vp9_nzc32x32_tree[2 * NZC32X32_NODES] = {
- -NZC_0, 2,
- 4, 6,
- -NZC_1, -NZC_2,
- 8, 10,
- -NZC_3TO4, -NZC_5TO8,
- 12, 14,
- -NZC_9TO16, -NZC_17TO32,
- 16, 18,
- -NZC_33TO64, -NZC_65TO128,
- -NZC_129TO256, 20,
- -NZC_257TO512, -NZC_513TO1024,
-};
-struct vp9_token vp9_nzc32x32_encodings[NZC32X32_TOKENS];
-
-const int vp9_extranzcbits[NZC32X32_TOKENS] = {
- 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
-};
-
-const int vp9_basenzcvalue[NZC32X32_TOKENS] = {
- 0, 1, 2, 3, 5, 9, 17, 33, 65, 129, 257, 513
-};
-
-#endif // CONFIG_CODE_NONZEROCOUNT
-
#if CONFIG_MODELCOEFPROB
#if UNCONSTRAINED_NODES == 2
@@ -1357,55 +1298,6 @@
#if CONFIG_MODELCOEFPROB
int b, r, c, p;
#endif
-#if CONFIG_CODE_NONZEROCOUNT
-#ifdef NZC_DEFAULT_COUNTS
- int h, g;
- for (h = 0; h < MAX_NZC_CONTEXTS; ++h) {
- for (g = 0; g < REF_TYPES; ++g) {
- int i;
- unsigned int branch_ct4x4[NZC4X4_NODES][2];
- unsigned int branch_ct8x8[NZC8X8_NODES][2];
- unsigned int branch_ct16x16[NZC16X16_NODES][2];
- unsigned int branch_ct32x32[NZC32X32_NODES][2];
- for (i = 0; i < BLOCK_TYPES; ++i) {
- vp9_tree_probs_from_distribution(
- vp9_nzc4x4_tree,
- pc->fc.nzc_probs_4x4[h][g][i], branch_ct4x4,
- default_nzc_counts_4x4[h][g][i], 0);
- }
- for (i = 0; i < BLOCK_TYPES; ++i) {
- vp9_tree_probs_from_distribution(
- vp9_nzc8x8_tree,
- pc->fc.nzc_probs_8x8[h][g][i], branch_ct8x8,
- default_nzc_counts_8x8[h][g][i], 0);
- }
- for (i = 0; i < BLOCK_TYPES; ++i) {
- vp9_tree_probs_from_distribution(
- vp9_nzc16x16_tree,
- pc->fc.nzc_probs_16x16[h][g][i], branch_ct16x16,
- default_nzc_counts_16x16[h][g][i], 0);
- }
- for (i = 0; i < BLOCK_TYPES; ++i) {
- vp9_tree_probs_from_distribution(
- vp9_nzc32x32_tree,
- pc->fc.nzc_probs_32x32[h][g][i], branch_ct32x32,
- default_nzc_counts_32x32[h][g][i], 0);
- }
- }
- }
-#else
- vpx_memcpy(pc->fc.nzc_probs_4x4, default_nzc_probs_4x4,
- sizeof(pc->fc.nzc_probs_4x4));
- vpx_memcpy(pc->fc.nzc_probs_8x8, default_nzc_probs_8x8,
- sizeof(pc->fc.nzc_probs_8x8));
- vpx_memcpy(pc->fc.nzc_probs_16x16, default_nzc_probs_16x16,
- sizeof(pc->fc.nzc_probs_16x16));
- vpx_memcpy(pc->fc.nzc_probs_32x32, default_nzc_probs_32x32,
- sizeof(pc->fc.nzc_probs_32x32));
-#endif
- vpx_memcpy(pc->fc.nzc_pcat_probs, default_nzc_pcat_probs,
- sizeof(pc->fc.nzc_pcat_probs));
-#endif // CONFIG_CODE_NONZEROCOUNT
#if CONFIG_MODELCOEFPROB
for (b = 0; b < BLOCK_TYPES; ++b)
for (r = 0; r < REF_TYPES; ++r)
@@ -1607,1099 +1499,8 @@
vp9_init_neighbors();
init_bit_trees();
vp9_tokens_from_tree(vp9_coef_encodings, vp9_coef_tree);
-#if CONFIG_CODE_NONZEROCOUNT
- vp9_tokens_from_tree(vp9_nzc4x4_encodings, vp9_nzc4x4_tree);
- vp9_tokens_from_tree(vp9_nzc8x8_encodings, vp9_nzc8x8_tree);
- vp9_tokens_from_tree(vp9_nzc16x16_encodings, vp9_nzc16x16_tree);
- vp9_tokens_from_tree(vp9_nzc32x32_encodings, vp9_nzc32x32_tree);
-#endif
}
-#if CONFIG_CODE_NONZEROCOUNT
-
-#define mb_in_cur_tile(cm, mb_row, mb_col) \
- ((mb_col) >= (cm)->cur_tile_mb_col_start && \
- (mb_col) <= (cm)->cur_tile_mb_col_end && \
- (mb_row) >= 0)
-
-#define choose_nzc_context(nzc_exp, t2, t1) \
- ((nzc_exp) >= (t2) ? 2 : (nzc_exp) >= (t1) ? 1 : 0)
-
-#define NZC_T2_32X32 (16 << 6)
-#define NZC_T1_32X32 (4 << 6)
-
-#define NZC_T2_16X16 (12 << 6)
-#define NZC_T1_16X16 (3 << 6)
-
-#define NZC_T2_8X8 (8 << 6)
-#define NZC_T1_8X8 (2 << 6)
-
-#define NZC_T2_4X4 (4 << 6)
-#define NZC_T1_4X4 (1 << 6)
-
-// Transforms a mb16 block index to a sb64 block index
-static inline int mb16_to_sb64_index(int mb_row, int mb_col, int block) {
- int r = (mb_row & 3);
- int c = (mb_col & 3);
- int b;
- if (block < 16) { // Y
- int ib = block >> 2;
- int jb = block & 3;
- ib += r * 4;
- jb += c * 4;
- b = ib * 16 + jb;
- assert(b < 256);
- return b;
- } else { // UV
- int base = block - (block & 3);
- int ib = (block - base) >> 1;
- int jb = (block - base) & 1;
- ib += r * 2;
- jb += c * 2;
- b = base * 16 + ib * 8 + jb;
- assert(b >= 256 && b < 384);
- return b;
- }
-}
-
-// Transforms a mb16 block index to a sb32 block index
-static inline int mb16_to_sb32_index(int mb_row, int mb_col, int block) {
- int r = (mb_row & 1);
- int c = (mb_col & 1);
- int b;
- if (block < 16) { // Y
- int ib = block >> 2;
- int jb = block & 3;
- ib += r * 4;
- jb += c * 4;
- b = ib * 8 + jb;
- assert(b < 64);
- return b;
- } else { // UV
- int base = block - (block & 3);
- int ib = (block - base) >> 1;
- int jb = (block - base) & 1;
- ib += r * 2;
- jb += c * 2;
- b = base * 4 + ib * 4 + jb;
- assert(b >= 64 && b < 96);
- return b;
- }
-}
-
-static inline int block_to_txfm_index(int block, TX_SIZE tx_size, int s) {
- // s is the log of the number of 4x4 blocks in each row/col of larger block
- int b, ib, jb, nb;
- ib = block >> s;
- jb = block - (ib << s);
- ib >>= tx_size;
- jb >>= tx_size;
- nb = 1 << (s - tx_size);
- b = (ib * nb + jb) << (2 * tx_size);
- return b;
-}
-
-/* BEGIN - Helper functions to get the y nzcs */
-static unsigned int get_nzc_4x4_y_sb64(MB_MODE_INFO *mi, int block) {
- int b;
- assert(block < 256);
- b = block_to_txfm_index(block, mi->txfm_size, 4);
- assert(b < 256);
- return mi->nzcs[b] << (6 - 2 * mi->txfm_size);
-}
-
-static unsigned int get_nzc_4x4_y_sb32(MB_MODE_INFO *mi, int block) {
- int b;
- assert(block < 64);
- b = block_to_txfm_index(block, mi->txfm_size, 3);
- assert(b < 64);
- return mi->nzcs[b] << (6 - 2 * mi->txfm_size);
-}
-
-static unsigned int get_nzc_4x4_y_mb16(MB_MODE_INFO *mi, int block) {
- int b;
- assert(block < 16);
- b = block_to_txfm_index(block, mi->txfm_size, 2);
- assert(b < 16);
- return mi->nzcs[b] << (6 - 2 * mi->txfm_size);
-}
-/* END - Helper functions to get the y nzcs */
-
-/* Function to get y nzc where block index is in mb16 terms */
-static unsigned int get_nzc_4x4_y(VP9_COMMON *cm, MODE_INFO *m,
- int mb_row, int mb_col, int block) {
- // NOTE: All values returned are at 64 times the true value at 4x4 scale
- MB_MODE_INFO *const mi = &m->mbmi;
- const int mis = cm->mode_info_stride;
- if (mi->mb_skip_coeff || !mb_in_cur_tile(cm, mb_row, mb_col))
- return 0;
- if (mi->sb_type == BLOCK_SIZE_SB64X64) {
- int r = mb_row & 3;
- int c = mb_col & 3;
- m -= c + r * mis;
- if (m->mbmi.mb_skip_coeff || !mb_in_cur_tile(cm, mb_row - r, mb_col - c))
- return 0;
- else
- return get_nzc_4x4_y_sb64(
- &m->mbmi, mb16_to_sb64_index(mb_row, mb_col, block));
- } else if (mi->sb_type == BLOCK_SIZE_SB32X32) {
- int r = mb_row & 1;
- int c = mb_col & 1;
- m -= c + r * mis;
- if (m->mbmi.mb_skip_coeff || !mb_in_cur_tile(cm, mb_row - r, mb_col - c))
- return 0;
- else
- return get_nzc_4x4_y_sb32(
- &m->mbmi, mb16_to_sb32_index(mb_row, mb_col, block));
- } else {
- if (m->mbmi.mb_skip_coeff || !mb_in_cur_tile(cm, mb_row, mb_col))
- return 0;
- return get_nzc_4x4_y_mb16(mi, block);
- }
-}
-
-/* BEGIN - Helper functions to get the uv nzcs */
-static unsigned int get_nzc_4x4_uv_sb64(MB_MODE_INFO *mi, int block) {
- int b;
- int base, uvtxfm_size;
- assert(block >= 256 && block < 384);
- uvtxfm_size = mi->txfm_size;
- base = 256 + (block & 64);
- block -= base;
- b = base + block_to_txfm_index(block, uvtxfm_size, 3);
- assert(b >= 256 && b < 384);
- return mi->nzcs[b] << (6 - 2 * uvtxfm_size);
-}
-
-static unsigned int get_nzc_4x4_uv_sb32(MB_MODE_INFO *mi, int block) {
- int b;
- int base, uvtxfm_size;
- assert(block >= 64 && block < 96);
- if (mi->txfm_size == TX_32X32)
- uvtxfm_size = TX_16X16;
- else
- uvtxfm_size = mi->txfm_size;
- base = 64 + (block & 16);
- block -= base;
- b = base + block_to_txfm_index(block, uvtxfm_size, 2);
- assert(b >= 64 && b < 96);
- return mi->nzcs[b] << (6 - 2 * uvtxfm_size);
-}
-
-static unsigned int get_nzc_4x4_uv_mb16(MB_MODE_INFO *mi, int block) {
- int b;
- int base, uvtxfm_size;
- assert(block >= 16 && block < 24);
- if (mi->txfm_size == TX_8X8 &&
- (mi->mode == SPLITMV || mi->mode == I8X8_PRED))
- uvtxfm_size = TX_4X4;
- else if (mi->txfm_size == TX_16X16)
- uvtxfm_size = TX_8X8;
- else
- uvtxfm_size = mi->txfm_size;
- base = 16 + (block & 4);
- block -= base;
- b = base + block_to_txfm_index(block, uvtxfm_size, 1);
- assert(b >= 16 && b < 24);
- return mi->nzcs[b] << (6 - 2 * uvtxfm_size);
-}
-/* END - Helper functions to get the uv nzcs */
-
-/* Function to get uv nzc where block index is in mb16 terms */
-static unsigned int get_nzc_4x4_uv(VP9_COMMON *cm, MODE_INFO *m,
- int mb_row, int mb_col, int block) {
- // NOTE: All values returned are at 64 times the true value at 4x4 scale
- MB_MODE_INFO *const mi = &m->mbmi;
- const int mis = cm->mode_info_stride;
- if (mi->mb_skip_coeff || !mb_in_cur_tile(cm, mb_row, mb_col))
- return 0;
- if (mi->sb_type == BLOCK_SIZE_SB64X64) {
- int r = mb_row & 3;
- int c = mb_col & 3;
- m -= c + r * mis;
- if (m->mbmi.mb_skip_coeff || !mb_in_cur_tile(cm, mb_row - r, mb_col - c))
- return 0;
- else
- return get_nzc_4x4_uv_sb64(
- &m->mbmi, mb16_to_sb64_index(mb_row, mb_col, block));
- } else if (mi->sb_type == BLOCK_SIZE_SB32X32) {
- int r = mb_row & 1;
- int c = mb_col & 1;
- m -= c + r * mis;
- if (m->mbmi.mb_skip_coeff || !mb_in_cur_tile(cm, mb_row - r, mb_col - c))
- return 0;
- else
- return get_nzc_4x4_uv_sb32(
- &m->mbmi, mb16_to_sb32_index(mb_row, mb_col, block));
- } else {
- return get_nzc_4x4_uv_mb16(mi, block);
- }
-}
-
-int vp9_get_nzc_context_y_sb64(VP9_COMMON *cm, MODE_INFO *cur,
- int mb_row, int mb_col, int block) {
- // returns an index in [0, MAX_NZC_CONTEXTS - 1] to reflect how busy
- // neighboring blocks are
- int mis = cm->mode_info_stride;
- int nzc_exp = 0;
- TX_SIZE txfm_size = cur->mbmi.txfm_size;
- assert(block < 256);
- switch (txfm_size) {
- case TX_32X32:
- assert((block & 63) == 0);
- if (block < 128) {
- int o = (block >> 6) * 2;
- nzc_exp =
- get_nzc_4x4_y(cm, cur - mis + o, mb_row - 1, mb_col + o, 12) +
- get_nzc_4x4_y(cm, cur - mis + o, mb_row - 1, mb_col + o, 13) +
- get_nzc_4x4_y(cm, cur - mis + o, mb_row - 1, mb_col + o, 14) +
- get_nzc_4x4_y(cm, cur - mis + o, mb_row - 1, mb_col + o, 15) +
- get_nzc_4x4_y(cm, cur - mis + o + 1,
- mb_row - 1, mb_col + o + 1, 12) +
- get_nzc_4x4_y(cm, cur - mis + o + 1,
- mb_row - 1, mb_col + o + 1, 13) +
- get_nzc_4x4_y(cm, cur - mis + o + 1,
- mb_row - 1, mb_col + o + 1, 14) +
- get_nzc_4x4_y(cm, cur - mis + o + 1,
- mb_row - 1, mb_col + o + 1, 15);
- } else {
- nzc_exp = cur->mbmi.nzcs[block - 128] << 3;
- }
- if ((block & 127) == 0) {
- int o = (block >> 7) * 2;
- nzc_exp +=
- get_nzc_4x4_y(cm, cur - 1 + o * mis, mb_row + o, mb_col - 1, 3) +
- get_nzc_4x4_y(cm, cur - 1 + o * mis, mb_row + o, mb_col - 1, 7) +
- get_nzc_4x4_y(cm, cur - 1 + o * mis, mb_row + o, mb_col - 1, 11) +
- get_nzc_4x4_y(cm, cur - 1 + o * mis, mb_row + o, mb_col - 1, 15) +
- get_nzc_4x4_y(cm, cur - 1 + o * mis + mis,
- mb_row + o + 1, mb_col - 1, 3) +
- get_nzc_4x4_y(cm, cur - 1 + o * mis + mis,
- mb_row + o + 1, mb_col - 1, 7) +
- get_nzc_4x4_y(cm, cur - 1 + o * mis + mis,
- mb_row + o + 1, mb_col - 1, 11) +
- get_nzc_4x4_y(cm, cur - 1 + o * mis + mis,
- mb_row + o + 1, mb_col - 1, 15);
- } else {
- nzc_exp += cur->mbmi.nzcs[block - 64] << 3;
- }
- nzc_exp <<= 2;
- // Note nzc_exp is 64 times the average value expected at 32x32 scale
- return choose_nzc_context(nzc_exp, NZC_T2_32X32, NZC_T1_32X32);
- break;
-
- case TX_16X16:
- assert((block & 15) == 0);
- if (block < 64) {
- int o = block >> 4;
- nzc_exp =
- get_nzc_4x4_y(cm, cur - mis + o, mb_row - 1, mb_col + o, 12) +
- get_nzc_4x4_y(cm, cur - mis + o, mb_row - 1, mb_col + o, 13) +
- get_nzc_4x4_y(cm, cur - mis + o, mb_row - 1, mb_col + o, 14) +
- get_nzc_4x4_y(cm, cur - mis + o, mb_row - 1, mb_col + o, 15);
- } else {
- nzc_exp = cur->mbmi.nzcs[block - 64] << 4;
- }
- if ((block & 63) == 0) {
- int o = block >> 6;
- nzc_exp +=
- get_nzc_4x4_y(cm, cur - 1 + o * mis, mb_row + o, mb_col - 1, 3) +
- get_nzc_4x4_y(cm, cur - 1 + o * mis, mb_row + o, mb_col - 1, 7) +
- get_nzc_4x4_y(cm, cur - 1 + o * mis, mb_row + o, mb_col - 1, 11) +
- get_nzc_4x4_y(cm, cur - 1 + o * mis, mb_row + o, mb_col - 1, 15);
- } else {
- nzc_exp += cur->mbmi.nzcs[block - 16] << 4;
- }
- nzc_exp <<= 1;
- // Note nzc_exp is 64 times the average value expected at 16x16 scale
- return choose_nzc_context(nzc_exp, NZC_T2_16X16, NZC_T1_16X16);
- break;
-
- case TX_8X8:
- assert((block & 3) == 0);
- if (block < 32) {
- int o = block >> 3;
- int p = ((block >> 2) & 1) ? 14 : 12;
- nzc_exp =
- get_nzc_4x4_y(cm, cur - mis + o, mb_row - 1, mb_col + o, p) +
- get_nzc_4x4_y(cm, cur - mis + o, mb_row - 1, mb_col + o, p + 1);
- } else {
- nzc_exp = cur->mbmi.nzcs[block - 32] << 5;
- }
- if ((block & 31) == 0) {
- int o = block >> 6;
- int p = ((block >> 5) & 1) ? 11 : 3;
- nzc_exp +=
- get_nzc_4x4_y(cm, cur - 1 + o * mis, mb_row + o, mb_col - 1, p) +
- get_nzc_4x4_y(cm, cur - 1 + o * mis, mb_row + o, mb_col - 1, p + 4);
- } else {
- nzc_exp += cur->mbmi.nzcs[block - 4] << 5;
- }
- // Note nzc_exp is 64 times the average value expected at 8x8 scale
- return choose_nzc_context(nzc_exp, NZC_T2_8X8, NZC_T1_8X8);
- break;
-
- case TX_4X4:
- if (block < 16) {
- int o = block >> 2;
- int p = block & 3;
- nzc_exp = get_nzc_4x4_y(cm, cur - mis + o, mb_row - 1, mb_col + o,
- 12 + p);
- } else {
- nzc_exp = (cur->mbmi.nzcs[block - 16] << 6);
- }
- if ((block & 15) == 0) {
- int o = block >> 6;
- int p = (block >> 4) & 3;
- nzc_exp += get_nzc_4x4_y(cm, cur - 1 + o * mis, mb_row + o, mb_col - 1,
- 3 + 4 * p);
- } else {
- nzc_exp += (cur->mbmi.nzcs[block - 1] << 6);
- }
- nzc_exp >>= 1;
- // Note nzc_exp is 64 times the average value expected at 4x4 scale
- return choose_nzc_context(nzc_exp, NZC_T2_4X4, NZC_T1_4X4);
- break;
-
- default:
- return 0;
- }
-}
-
-int vp9_get_nzc_context_y_sb32(VP9_COMMON *cm, MODE_INFO *cur,
- int mb_row, int mb_col, int block) {
- // returns an index in [0, MAX_NZC_CONTEXTS - 1] to reflect how busy
- // neighboring blocks are
- int mis = cm->mode_info_stride;
- int nzc_exp = 0;
- TX_SIZE txfm_size = cur->mbmi.txfm_size;
- assert(block < 64);
- switch (txfm_size) {
- case TX_32X32:
- assert(block == 0);
- nzc_exp =
- (get_nzc_4x4_y(cm, cur - mis, mb_row - 1, mb_col, 12) +
- get_nzc_4x4_y(cm, cur - mis, mb_row - 1, mb_col, 13) +
- get_nzc_4x4_y(cm, cur - mis, mb_row - 1, mb_col, 14) +
- get_nzc_4x4_y(cm, cur - mis, mb_row - 1, mb_col, 15) +
- get_nzc_4x4_y(cm, cur - mis + 1, mb_row - 1, mb_col + 1, 12) +
- get_nzc_4x4_y(cm, cur - mis + 1, mb_row - 1, mb_col + 1, 13) +
- get_nzc_4x4_y(cm, cur - mis + 1, mb_row - 1, mb_col + 1, 14) +
- get_nzc_4x4_y(cm, cur - mis + 1, mb_row - 1, mb_col + 1, 15) +
- get_nzc_4x4_y(cm, cur - 1, mb_row, mb_col - 1, 3) +
- get_nzc_4x4_y(cm, cur - 1, mb_row, mb_col - 1, 7) +
- get_nzc_4x4_y(cm, cur - 1, mb_row, mb_col - 1, 11) +
- get_nzc_4x4_y(cm, cur - 1, mb_row, mb_col - 1, 15) +
- get_nzc_4x4_y(cm, cur - 1 + mis, mb_row + 1, mb_col - 1, 3) +
- get_nzc_4x4_y(cm, cur - 1 + mis, mb_row + 1, mb_col - 1, 7) +
- get_nzc_4x4_y(cm, cur - 1 + mis, mb_row + 1, mb_col - 1, 11) +
- get_nzc_4x4_y(cm, cur - 1 + mis, mb_row + 1, mb_col - 1, 15)) << 2;
- // Note nzc_exp is 64 times the average value expected at 32x32 scale
- return choose_nzc_context(nzc_exp, NZC_T2_32X32, NZC_T1_32X32);
- break;
-
- case TX_16X16:
- assert((block & 15) == 0);
- if (block < 32) {
- int o = (block >> 4) & 1;
- nzc_exp =
- get_nzc_4x4_y(cm, cur - mis + o, mb_row - 1, mb_col + o, 12) +
- get_nzc_4x4_y(cm, cur - mis + o, mb_row - 1, mb_col + o, 13) +
- get_nzc_4x4_y(cm, cur - mis + o, mb_row - 1, mb_col + o, 14) +
- get_nzc_4x4_y(cm, cur - mis + o, mb_row - 1, mb_col + o, 15);
- } else {
- nzc_exp = cur->mbmi.nzcs[block - 32] << 4;
- }
- if ((block & 31) == 0) {
- int o = block >> 5;
- nzc_exp +=
- get_nzc_4x4_y(cm, cur - 1 + o * mis, mb_row + o, mb_col - 1, 3) +
- get_nzc_4x4_y(cm, cur - 1 + o * mis, mb_row + o, mb_col - 1, 7) +
- get_nzc_4x4_y(cm, cur - 1 + o * mis, mb_row + o, mb_col - 1, 11) +
- get_nzc_4x4_y(cm, cur - 1 + o * mis, mb_row + o, mb_col - 1, 15);
- } else {
- nzc_exp += cur->mbmi.nzcs[block - 16] << 4;
- }
- nzc_exp <<= 1;
- // Note nzc_exp is 64 times the average value expected at 16x16 scale
- return choose_nzc_context(nzc_exp, NZC_T2_16X16, NZC_T1_16X16);
- break;
-
- case TX_8X8:
- assert((block & 3) == 0);
- if (block < 16) {
- int o = block >> 3;
- int p = ((block >> 2) & 1) ? 14 : 12;
- nzc_exp =
- get_nzc_4x4_y(cm, cur - mis + o, mb_row - 1, mb_col + o, p) +
- get_nzc_4x4_y(cm, cur - mis + o, mb_row - 1, mb_col + o, p + 1);
- } else {
- nzc_exp = cur->mbmi.nzcs[block - 16] << 5;
- }
- if ((block & 15) == 0) {
- int o = block >> 5;
- int p = ((block >> 4) & 1) ? 11 : 3;
- nzc_exp +=
- get_nzc_4x4_y(cm, cur - 1 + o * mis, mb_row + o, mb_col - 1, p) +
- get_nzc_4x4_y(cm, cur - 1 + o * mis, mb_row + o, mb_col - 1, p + 4);
- } else {
- nzc_exp += cur->mbmi.nzcs[block - 4] << 5;
- }
- // Note nzc_exp is 64 times the average value expected at 8x8 scale
- return choose_nzc_context(nzc_exp, NZC_T2_8X8, NZC_T1_8X8);
- break;
-
- case TX_4X4:
- if (block < 8) {
- int o = block >> 2;
- int p = block & 3;
- nzc_exp = get_nzc_4x4_y(cm, cur - mis + o, mb_row - 1, mb_col + o,
- 12 + p);
- } else {
- nzc_exp = (cur->mbmi.nzcs[block - 8] << 6);
- }
- if ((block & 7) == 0) {
- int o = block >> 5;
- int p = (block >> 3) & 3;
- nzc_exp += get_nzc_4x4_y(cm, cur - 1 + o * mis, mb_row + o, mb_col - 1,
- 3 + 4 * p);
- } else {
- nzc_exp += (cur->mbmi.nzcs[block - 1] << 6);
- }
- nzc_exp >>= 1;
- // Note nzc_exp is 64 times the average value expected at 4x4 scale
- return choose_nzc_context(nzc_exp, NZC_T2_4X4, NZC_T1_4X4);
- break;
-
- default:
- return 0;
- break;
- }
-}
-
-int vp9_get_nzc_context_y_mb16(VP9_COMMON *cm, MODE_INFO *cur,
- int mb_row, int mb_col, int block) {
- // returns an index in [0, MAX_NZC_CONTEXTS - 1] to reflect how busy
- // neighboring blocks are
- int mis = cm->mode_info_stride;
- int nzc_exp = 0;
- TX_SIZE txfm_size = cur->mbmi.txfm_size;
- assert(block < 16);
- switch (txfm_size) {
- case TX_16X16:
- assert(block == 0);
- nzc_exp =
- get_nzc_4x4_y(cm, cur - mis, mb_row - 1, mb_col, 12) +
- get_nzc_4x4_y(cm, cur - mis, mb_row - 1, mb_col, 13) +
- get_nzc_4x4_y(cm, cur - mis, mb_row - 1, mb_col, 14) +
- get_nzc_4x4_y(cm, cur - mis, mb_row - 1, mb_col, 15) +
- get_nzc_4x4_y(cm, cur - 1, mb_row, mb_col - 1, 3) +
- get_nzc_4x4_y(cm, cur - 1, mb_row, mb_col - 1, 7) +
- get_nzc_4x4_y(cm, cur - 1, mb_row, mb_col - 1, 11) +
- get_nzc_4x4_y(cm, cur - 1, mb_row, mb_col - 1, 15);
- nzc_exp <<= 1;
- // Note nzc_exp is 64 times the average value expected at 16x16 scale
- return choose_nzc_context(nzc_exp, NZC_T2_16X16, NZC_T1_16X16);
-
- case TX_8X8:
- assert((block & 3) == 0);
- if (block < 8) {
- int p = ((block >> 2) & 1) ? 14 : 12;
- nzc_exp =
- get_nzc_4x4_y(cm, cur - mis, mb_row - 1, mb_col, p) +
- get_nzc_4x4_y(cm, cur - mis, mb_row - 1, mb_col, p + 1);
- } else {
- nzc_exp = cur->mbmi.nzcs[block - 8] << 5;
- }
- if ((block & 7) == 0) {
- int p = ((block >> 3) & 1) ? 11 : 3;
- nzc_exp +=
- get_nzc_4x4_y(cm, cur - 1, mb_row, mb_col - 1, p) +
- get_nzc_4x4_y(cm, cur - 1, mb_row, mb_col - 1, p + 4);
- } else {
- nzc_exp += cur->mbmi.nzcs[block - 4] << 5;
- }
- // Note nzc_exp is 64 times the average value expected at 8x8 scale
- return choose_nzc_context(nzc_exp, NZC_T2_8X8, NZC_T1_8X8);
-
- case TX_4X4:
- if (block < 4) {
- int p = block & 3;
- nzc_exp = get_nzc_4x4_y(cm, cur - mis, mb_row - 1, mb_col,
- 12 + p);
- } else {
- nzc_exp = (cur->mbmi.nzcs[block - 4] << 6);
- }
- if ((block & 3) == 0) {
- int p = (block >> 2) & 3;
- nzc_exp += get_nzc_4x4_y(cm, cur - 1, mb_row, mb_col - 1,
- 3 + 4 * p);
- } else {
- nzc_exp += (cur->mbmi.nzcs[block - 1] << 6);
- }
- nzc_exp >>= 1;
- // Note nzc_exp is 64 times the average value expected at 4x4 scale
- return choose_nzc_context(nzc_exp, NZC_T2_4X4, NZC_T1_4X4);
-
- default:
- return 0;
- break;
- }
-}
-
-int vp9_get_nzc_context_uv_sb64(VP9_COMMON *cm, MODE_INFO *cur,
- int mb_row, int mb_col, int block) {
- // returns an index in [0, MAX_NZC_CONTEXTS - 1] to reflect how busy
- // neighboring blocks are
- int mis = cm->mode_info_stride;
- int nzc_exp = 0;
- const int base = block - (block & 63);
- const int boff = (block & 63);
- const int base_mb16 = base >> 4;
- TX_SIZE txfm_size = cur->mbmi.txfm_size;
- TX_SIZE txfm_size_uv;
-
- assert(block >= 256 && block < 384);
- txfm_size_uv = txfm_size;
-
- switch (txfm_size_uv) {
- case TX_32X32:
- assert(block == 256 || block == 320);
- nzc_exp =
- get_nzc_4x4_uv(cm, cur - mis, mb_row - 1, mb_col,
- base_mb16 + 2) +
- get_nzc_4x4_uv(cm, cur - mis, mb_row - 1, mb_col,
- base_mb16 + 3) +
- get_nzc_4x4_uv(cm, cur - mis + 1, mb_row - 1, mb_col + 1,
- base_mb16 + 2) +
- get_nzc_4x4_uv(cm, cur - mis + 1, mb_row - 1, mb_col + 1,
- base_mb16 + 3) +
- get_nzc_4x4_uv(cm, cur - mis + 2, mb_row - 1, mb_col + 2,
- base_mb16 + 2) +
- get_nzc_4x4_uv(cm, cur - mis + 2, mb_row - 1, mb_col + 2,
- base_mb16 + 3) +
- get_nzc_4x4_uv(cm, cur - mis + 3, mb_row - 1, mb_col + 3,
- base_mb16 + 2) +
- get_nzc_4x4_uv(cm, cur - mis + 3, mb_row - 1, mb_col + 3,
- base_mb16 + 3) +
- get_nzc_4x4_uv(cm, cur - 1, mb_row, mb_col - 1,
- base_mb16 + 1) +
- get_nzc_4x4_uv(cm, cur - 1, mb_row, mb_col - 1,
- base_mb16 + 3) +
- get_nzc_4x4_uv(cm, cur - 1 + mis, mb_row + 1, mb_col - 1,
- base_mb16 + 1) +
- get_nzc_4x4_uv(cm, cur - 1 + mis, mb_row + 1, mb_col - 1,
- base_mb16 + 3) +
- get_nzc_4x4_uv(cm, cur - 1 + 2 * mis, mb_row + 2, mb_col - 1,
- base_mb16 + 1) +
- get_nzc_4x4_uv(cm, cur - 1 + 2 * mis, mb_row + 2, mb_col - 1,
- base_mb16 + 3) +
- get_nzc_4x4_uv(cm, cur - 1 + 3 * mis, mb_row + 3, mb_col - 1,
- base_mb16 + 1) +
- get_nzc_4x4_uv(cm, cur - 1 + 3 * mis, mb_row + 3, mb_col - 1,
- base_mb16 + 3);
- nzc_exp <<= 2;
- // Note nzc_exp is 64 times the average value expected at 32x32 scale
- return choose_nzc_context(nzc_exp, NZC_T2_32X32, NZC_T1_32X32);
-
- case TX_16X16:
- // uv txfm_size 16x16
- assert((block & 15) == 0);
- if (boff < 32) {
- int o = (boff >> 4) & 1;
- nzc_exp =
- get_nzc_4x4_uv(cm, cur - mis + o, mb_row - 1, mb_col + o,
- base_mb16 + 2) +
- get_nzc_4x4_uv(cm, cur - mis + o, mb_row - 1, mb_col + o,
- base_mb16 + 3) +
- get_nzc_4x4_uv(cm, cur - mis + o + 1, mb_row - 1, mb_col + o + 1,
- base_mb16 + 2) +
- get_nzc_4x4_uv(cm, cur - mis + o + 1, mb_row - 1, mb_col + o + 1,
- base_mb16 + 3);
- } else {
- nzc_exp = cur->mbmi.nzcs[block - 32] << 4;
- }
- if ((boff & 31) == 0) {
- int o = boff >> 5;
- nzc_exp +=
- get_nzc_4x4_uv(cm, cur - 1 + o * mis,
- mb_row + o, mb_col - 1, base_mb16 + 1) +
- get_nzc_4x4_uv(cm, cur - 1 + o * mis,
- mb_row + o, mb_col - 1, base_mb16 + 3) +
- get_nzc_4x4_uv(cm, cur - 1 + o * mis + mis,
- mb_row + o + 1, mb_col - 1, base_mb16 + 1) +
- get_nzc_4x4_uv(cm, cur - 1 + o * mis + mis,
- mb_row + o + 1, mb_col - 1, base_mb16 + 3);
- } else {
- nzc_exp += cur->mbmi.nzcs[block - 16] << 4;
- }
- nzc_exp <<= 1;
- // Note nzc_exp is 64 times the average value expected at 16x16 scale
- return choose_nzc_context(nzc_exp, NZC_T2_16X16, NZC_T1_16X16);
-
- case TX_8X8:
- assert((block & 3) == 0);
- if (boff < 16) {
- int o = boff >> 2;
- nzc_exp =
- get_nzc_4x4_uv(cm, cur - mis + o, mb_row - 1, mb_col + o,
- base_mb16 + 2) +
- get_nzc_4x4_uv(cm, cur - mis + o, mb_row - 1, mb_col + o,
- base_mb16 + 3);
- } else {
- nzc_exp = cur->mbmi.nzcs[block - 16] << 5;
- }
- if ((boff & 15) == 0) {
- int o = boff >> 4;
- nzc_exp +=
- get_nzc_4x4_uv(cm, cur - 1 + o * mis, mb_row + o, mb_col - 1,
- base_mb16 + 1) +
- get_nzc_4x4_uv(cm, cur - 1 + o * mis, mb_row + o, mb_col - 1,
- base_mb16 + 3);
- } else {
- nzc_exp += cur->mbmi.nzcs[block - 4] << 5;
- }
- // Note nzc_exp is 64 times the average value expected at 8x8 scale
- return choose_nzc_context(nzc_exp, NZC_T2_8X8, NZC_T1_8X8);
-
- case TX_4X4:
- if (boff < 8) {
- int o = boff >> 1;
- int p = boff & 1;
- nzc_exp = get_nzc_4x4_uv(cm, cur - mis + o, mb_row - 1, mb_col + o,
- base_mb16 + 2 + p);
- } else {
- nzc_exp = (cur->mbmi.nzcs[block - 8] << 6);
- }
- if ((boff & 7) == 0) {
- int o = boff >> 4;
- int p = (boff >> 3) & 1;
- nzc_exp += get_nzc_4x4_uv(cm, cur - 1 + o * mis, mb_row + o, mb_col - 1,
- base_mb16 + 1 + 2 * p);
- } else {
- nzc_exp += (cur->mbmi.nzcs[block - 1] << 6);
- }
- nzc_exp >>= 1;
- // Note nzc_exp is 64 times the average value expected at 4x4 scale
- return choose_nzc_context(nzc_exp, NZC_T2_4X4, NZC_T1_4X4);
-
- default:
- return 0;
- }
-}
-
-int vp9_get_nzc_context_uv_sb32(VP9_COMMON *cm, MODE_INFO *cur,
- int mb_row, int mb_col, int block) {
- // returns an index in [0, MAX_NZC_CONTEXTS - 1] to reflect how busy
- // neighboring blocks are
- int mis = cm->mode_info_stride;
- int nzc_exp = 0;
- const int base = block - (block & 15);
- const int boff = (block & 15);
- const int base_mb16 = base >> 2;
- TX_SIZE txfm_size = cur->mbmi.txfm_size;
- TX_SIZE txfm_size_uv;
-
- assert(block >= 64 && block < 96);
- if (txfm_size == TX_32X32)
- txfm_size_uv = TX_16X16;
- else
- txfm_size_uv = txfm_size;
-
- switch (txfm_size_uv) {
- case TX_16X16:
- // uv txfm_size 16x16
- assert(block == 64 || block == 80);
- nzc_exp =
- get_nzc_4x4_uv(cm, cur - mis, mb_row - 1, mb_col,
- base_mb16 + 2) +
- get_nzc_4x4_uv(cm, cur - mis, mb_row - 1, mb_col,
- base_mb16 + 3) +
- get_nzc_4x4_uv(cm, cur - mis + 1, mb_row - 1, mb_col + 1,
- base_mb16 + 2) +
- get_nzc_4x4_uv(cm, cur - mis + 1, mb_row - 1, mb_col + 1,
- base_mb16 + 3) +
- get_nzc_4x4_uv(cm, cur - 1 + mis, mb_row, mb_col - 1,
- base_mb16 + 1) +
- get_nzc_4x4_uv(cm, cur - 1 + mis, mb_row, mb_col - 1,
- base_mb16 + 3) +
- get_nzc_4x4_uv(cm, cur - 1 + mis, mb_row + 1, mb_col - 1,
- base_mb16 + 1) +
- get_nzc_4x4_uv(cm, cur - 1 + mis, mb_row + 1, mb_col - 1,
- base_mb16 + 3);
- nzc_exp <<= 1;
- // Note nzc_exp is 64 times the average value expected at 16x16 scale
- return choose_nzc_context(nzc_exp, NZC_T2_16X16, NZC_T1_16X16);
- break;
-
- case TX_8X8:
- assert((block & 3) == 0);
- if (boff < 8) {
- int o = boff >> 2;
- nzc_exp =
- get_nzc_4x4_uv(cm, cur - mis + o, mb_row - 1, mb_col + o,
- base_mb16 + 2) +
- get_nzc_4x4_uv(cm, cur - mis + o, mb_row - 1, mb_col + o,
- base_mb16 + 3);
- } else {
- nzc_exp = cur->mbmi.nzcs[block - 8] << 5;
- }
- if ((boff & 7) == 0) {
- int o = boff >> 3;
- nzc_exp +=
- get_nzc_4x4_uv(cm, cur - 1 + o * mis, mb_row + o, mb_col - 1,
- base_mb16 + 1) +
- get_nzc_4x4_uv(cm, cur - 1 + o * mis, mb_row + o, mb_col - 1,
- base_mb16 + 3);
- } else {
- nzc_exp += cur->mbmi.nzcs[block - 4] << 5;
- }
- // Note nzc_exp is 64 times the average value expected at 8x8 scale
- return choose_nzc_context(nzc_exp, NZC_T2_8X8, NZC_T1_8X8);
-
- case TX_4X4:
- if (boff < 4) {
- int o = boff >> 1;
- int p = boff & 1;
- nzc_exp = get_nzc_4x4_uv(cm, cur - mis + o, mb_row - 1, mb_col + o,
- base_mb16 + 2 + p);
- } else {
- nzc_exp = (cur->mbmi.nzcs[block - 4] << 6);
- }
- if ((boff & 3) == 0) {
- int o = boff >> 3;
- int p = (boff >> 2) & 1;
- nzc_exp += get_nzc_4x4_uv(cm, cur - 1 + o * mis, mb_row + o, mb_col - 1,
- base_mb16 + 1 + 2 * p);
- } else {
- nzc_exp += (cur->mbmi.nzcs[block - 1] << 6);
- }
- nzc_exp >>= 1;
- // Note nzc_exp is 64 times the average value expected at 4x4 scale
- return choose_nzc_context(nzc_exp, NZC_T2_4X4, NZC_T1_4X4);
-
- default:
- return 0;
- }
-}
-
-int vp9_get_nzc_context_uv_mb16(VP9_COMMON *cm, MODE_INFO *cur,
- int mb_row, int mb_col, int block) {
- // returns an index in [0, MAX_NZC_CONTEXTS - 1] to reflect how busy
- // neighboring blocks are
- int mis = cm->mode_info_stride;
- int nzc_exp = 0;
- const int base = block - (block & 3);
- const int boff = (block & 3);
- const int base_mb16 = base;
- TX_SIZE txfm_size = cur->mbmi.txfm_size;
- TX_SIZE txfm_size_uv;
-
- assert(block >= 16 && block < 24);
- if (txfm_size == TX_16X16)
- txfm_size_uv = TX_8X8;
- else if (txfm_size == TX_8X8 &&
- (cur->mbmi.mode == I8X8_PRED || cur->mbmi.mode == SPLITMV))
- txfm_size_uv = TX_4X4;
- else
- txfm_size_uv = txfm_size;
-
- switch (txfm_size_uv) {
- case TX_8X8:
- assert((block & 3) == 0);
- nzc_exp =
- get_nzc_4x4_uv(cm, cur - mis, mb_row - 1, mb_col, base_mb16 + 2) +
- get_nzc_4x4_uv(cm, cur - mis, mb_row - 1, mb_col, base_mb16 + 3) +
- get_nzc_4x4_uv(cm, cur - 1, mb_row, mb_col - 1, base_mb16 + 1) +
- get_nzc_4x4_uv(cm, cur - 1, mb_row, mb_col - 1, base_mb16 + 3);
- // Note nzc_exp is 64 times the average value expected at 8x8 scale
- return choose_nzc_context(nzc_exp, NZC_T2_8X8, NZC_T1_8X8);
-
- case TX_4X4:
- if (boff < 2) {
- int p = boff & 1;
- nzc_exp = get_nzc_4x4_uv(cm, cur - mis, mb_row - 1, mb_col,
- base_mb16 + 2 + p);
- } else {
- nzc_exp = (cur->mbmi.nzcs[block - 2] << 6);
- }
- if ((boff & 1) == 0) {
- int p = (boff >> 1) & 1;
- nzc_exp += get_nzc_4x4_uv(cm, cur - 1, mb_row, mb_col - 1,
- base_mb16 + 1 + 2 * p);
- } else {
- nzc_exp += (cur->mbmi.nzcs[block - 1] << 6);
- }
- nzc_exp >>= 1;
- // Note nzc_exp is 64 times the average value expected at 4x4 scale
- return choose_nzc_context(nzc_exp, NZC_T2_4X4, NZC_T1_4X4);
-
- default:
- return 0;
- }
-}
-
-int vp9_get_nzc_context(VP9_COMMON *cm, MACROBLOCKD *xd, int block) {
- if (xd->mode_info_context->mbmi.sb_type == BLOCK_SIZE_SB64X64) {
- assert(block < 384);
- if (block < 256)
- return vp9_get_nzc_context_y_sb64(cm, xd->mode_info_context,
- get_mb_row(xd), get_mb_col(xd), block);
- else
- return vp9_get_nzc_context_uv_sb64(cm, xd->mode_info_context,
- get_mb_row(xd), get_mb_col(xd), block);
- } else if (xd->mode_info_context->mbmi.sb_type == BLOCK_SIZE_SB32X32) {
- assert(block < 96);
- if (block < 64)
- return vp9_get_nzc_context_y_sb32(cm, xd->mode_info_context,
- get_mb_row(xd), get_mb_col(xd), block);
- else
- return vp9_get_nzc_context_uv_sb32(cm, xd->mode_info_context,
- get_mb_row(xd), get_mb_col(xd), block);
- } else {
- assert(block < 64);
- if (block < 16)
- return vp9_get_nzc_context_y_mb16(cm, xd->mode_info_context,
- get_mb_row(xd), get_mb_col(xd), block);
- else
- return vp9_get_nzc_context_uv_mb16(cm, xd->mode_info_context,
- get_mb_row(xd), get_mb_col(xd), block);
- }
-}
-
-static void update_nzc(VP9_COMMON *cm,
- uint16_t nzc,
- int nzc_context,
- TX_SIZE tx_size,
- int ref,
- int type) {
- int e, c;
- if (!get_nzc_used(tx_size)) return;
- c = codenzc(nzc);
- if (tx_size == TX_32X32)
- cm->fc.nzc_counts_32x32[nzc_context][ref][type][c]++;
- else if (tx_size == TX_16X16)
- cm->fc.nzc_counts_16x16[nzc_context][ref][type][c]++;
- else if (tx_size == TX_8X8)
- cm->fc.nzc_counts_8x8[nzc_context][ref][type][c]++;
- else if (tx_size == TX_4X4)
- 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;
- cm->fc.nzc_pcat_counts[nzc_context][c - NZC_TOKENS_NOEXTRA][e][b]++;
- }
- }
-}
-
-static void update_nzcs_sb64(VP9_COMMON *cm,
- MACROBLOCKD *xd,
- int mb_row,
- int mb_col) {
- 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);
- update_nzc(cm, m->mbmi.nzcs[j], nzc_context, TX_32X32, ref, 0);
- }
- for (j = 256; j < 384; j += 64) {
- nzc_context = vp9_get_nzc_context_uv_sb64(cm, m, mb_row, mb_col, j);
- update_nzc(cm, m->mbmi.nzcs[j], nzc_context, TX_32X32, ref, 1);
- }
- 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);
- update_nzc(cm, m->mbmi.nzcs[j], nzc_context, TX_16X16, ref, 0);
- }
- for (j = 256; j < 384; j += 16) {
- nzc_context = vp9_get_nzc_context_uv_sb64(cm, m, mb_row, mb_col, j);
- update_nzc(cm, m->mbmi.nzcs[j], nzc_context, TX_16X16, ref, 1);
- }
- 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);
- update_nzc(cm, m->mbmi.nzcs[j], nzc_context, TX_8X8, ref, 0);
- }
- for (j = 256; j < 384; j += 4) {
- nzc_context = vp9_get_nzc_context_uv_sb64(cm, m, mb_row, mb_col, j);
- update_nzc(cm, m->mbmi.nzcs[j], nzc_context, TX_8X8, ref, 1);
- }
- 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);
- update_nzc(cm, m->mbmi.nzcs[j], nzc_context, TX_4X4, ref, 0);
- }
- for (j = 256; j < 384; ++j) {
- nzc_context = vp9_get_nzc_context_uv_sb64(cm, m, mb_row, mb_col, j);
- update_nzc(cm, m->mbmi.nzcs[j], nzc_context, TX_4X4, ref, 1);
- }
- break;
-
- default:
- break;
- }
-}
-
-static void update_nzcs_sb32(VP9_COMMON *cm,
- MACROBLOCKD *xd,
- int mb_row,
- int mb_col) {
- 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);
- update_nzc(cm, m->mbmi.nzcs[j], nzc_context, TX_32X32, ref, 0);
- }
- for (j = 64; j < 96; j += 16) {
- nzc_context = vp9_get_nzc_context_uv_sb32(cm, m, mb_row, mb_col, j);
- update_nzc(cm, m->mbmi.nzcs[j], nzc_context, TX_16X16, ref, 1);
- }
- 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);
- update_nzc(cm, m->mbmi.nzcs[j], nzc_context, TX_16X16, ref, 0);
- }
- for (j = 64; j < 96; j += 16) {
- nzc_context = vp9_get_nzc_context_uv_sb32(cm, m, mb_row, mb_col, j);
- update_nzc(cm, m->mbmi.nzcs[j], nzc_context, TX_16X16, ref, 1);
- }
- 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);
- update_nzc(cm, m->mbmi.nzcs[j], nzc_context, TX_8X8, ref, 0);
- }
- for (j = 64; j < 96; j += 4) {
- nzc_context = vp9_get_nzc_context_uv_sb32(cm, m, mb_row, mb_col, j);
- update_nzc(cm, m->mbmi.nzcs[j], nzc_context, TX_8X8, ref, 1);
- }
- 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);
- update_nzc(cm, m->mbmi.nzcs[j], nzc_context, TX_4X4, ref, 0);
- }
- for (j = 64; j < 96; ++j) {
- nzc_context = vp9_get_nzc_context_uv_sb32(cm, m, mb_row, mb_col, j);
- update_nzc(cm, m->mbmi.nzcs[j], nzc_context, TX_4X4, ref, 1);
- }
- break;
-
- default:
- break;
- }
-}
-
-static void update_nzcs_mb16(VP9_COMMON *cm,
- MACROBLOCKD *xd,
- int mb_row,
- int mb_col) {
- 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);
- update_nzc(cm, m->mbmi.nzcs[j], nzc_context, TX_16X16, ref, 0);
- }
- for (j = 16; j < 24; j += 4) {
- nzc_context = vp9_get_nzc_context_uv_mb16(cm, m, mb_row, mb_col, j);
- update_nzc(cm, m->mbmi.nzcs[j], nzc_context, TX_8X8, ref, 1);
- }
- 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);
- update_nzc(cm, m->mbmi.nzcs[j], nzc_context, TX_8X8, ref, 0);
- }
- 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);
- update_nzc(cm, m->mbmi.nzcs[j], nzc_context, TX_4X4, ref, 1);
- }
- } else {
- for (j = 16; j < 24; j += 4) {
- nzc_context = vp9_get_nzc_context_uv_mb16(cm, m, mb_row, mb_col, j);
- update_nzc(cm, m->mbmi.nzcs[j], nzc_context, TX_8X8, ref, 1);
- }
- }
- 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);
- update_nzc(cm, m->mbmi.nzcs[j], nzc_context, TX_4X4, ref, 0);
- }
- for (j = 16; j < 24; ++j) {
- nzc_context = vp9_get_nzc_context_uv_mb16(cm, m, mb_row, mb_col, j);
- update_nzc(cm, m->mbmi.nzcs[j], nzc_context, TX_4X4, ref, 1);
- }
- break;
-
- default:
- break;
- }
-}
-
-void vp9_update_nzc_counts(VP9_COMMON *cm,
- MACROBLOCKD *xd,
- int mb_row,
- int mb_col) {
- if (xd->mode_info_context->mbmi.sb_type == BLOCK_SIZE_SB64X64)
- update_nzcs_sb64(cm, xd, mb_row, mb_col);
- else if (xd->mode_info_context->mbmi.sb_type == BLOCK_SIZE_SB32X32)
- update_nzcs_sb32(cm, xd, mb_row, mb_col);
- else
- update_nzcs_mb16(cm, xd, mb_row, mb_col);
-}
-#endif // CONFIG_CODE_NONZEROCOUNT
-
// #define COEF_COUNT_TESTING
#define COEF_COUNT_SAT 24
@@ -2787,131 +1588,6 @@
count_sat, update_factor);
}
-#if CONFIG_CODE_NONZEROCOUNT
-static void adapt_nzc_probs_common(VP9_COMMON *cm,
- TX_SIZE tx_size,
- int count_sat,
- int update_factor) {
- int c, r, b, n;
- int count, factor;
- unsigned int nzc_branch_ct[NZC32X32_NODES][2];
- vp9_prob nzc_probs[NZC32X32_NODES];
- int tokens, nodes;
- const vp9_tree_index *nzc_tree;
- vp9_prob *dst_nzc_probs;
- vp9_prob *pre_nzc_probs;
- unsigned int *nzc_counts;
-
- if (!get_nzc_used(tx_size)) return;
- if (tx_size == TX_32X32) {
- tokens = NZC32X32_TOKENS;
- nzc_tree = vp9_nzc32x32_tree;
- dst_nzc_probs = cm->fc.nzc_probs_32x32[0][0][0];
- pre_nzc_probs = cm->fc.pre_nzc_probs_32x32[0][0][0];
- nzc_counts = cm->fc.nzc_counts_32x32[0][0][0];
- } else if (tx_size == TX_16X16) {
- tokens = NZC16X16_TOKENS;
- nzc_tree = vp9_nzc16x16_tree;
- dst_nzc_probs = cm->fc.nzc_probs_16x16[0][0][0];
- pre_nzc_probs = cm->fc.pre_nzc_probs_16x16[0][0][0];
- nzc_counts = cm->fc.nzc_counts_16x16[0][0][0];
- } else if (tx_size == TX_8X8) {
- tokens = NZC8X8_TOKENS;
- nzc_tree = vp9_nzc8x8_tree;
- dst_nzc_probs = cm->fc.nzc_probs_8x8[0][0][0];
- pre_nzc_probs = cm->fc.pre_nzc_probs_8x8[0][0][0];
- nzc_counts = cm->fc.nzc_counts_8x8[0][0][0];
- } else {
- nzc_tree = vp9_nzc4x4_tree;
- tokens = NZC4X4_TOKENS;
- dst_nzc_probs = cm->fc.nzc_probs_4x4[0][0][0];
- pre_nzc_probs = cm->fc.pre_nzc_probs_4x4[0][0][0];
- nzc_counts = cm->fc.nzc_counts_4x4[0][0][0];
- }
- 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;
- int offset_tokens = offset * tokens;
- vp9_tree_probs_from_distribution(nzc_tree,
- nzc_probs, nzc_branch_ct,
- nzc_counts + offset_tokens, 0);
- for (n = 0; n < nodes; ++n) {
- count = nzc_branch_ct[n][0] + nzc_branch_ct[n][1];
- count = count > count_sat ? count_sat : count;
- factor = (update_factor * count / count_sat);
- dst_nzc_probs[offset_nodes + n] =
- weighted_prob(pre_nzc_probs[offset_nodes + n],
- nzc_probs[n], factor);
- }
- }
-}
-
-static void adapt_nzc_pcat(VP9_COMMON *cm, int count_sat, int update_factor) {
- int c, t;
- int count, factor;
- 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];
- int b;
- for (b = 0; b < bits; ++b) {
- vp9_prob prob = get_binary_prob(cm->fc.nzc_pcat_counts[c][t][b][0],
- cm->fc.nzc_pcat_counts[c][t][b][1]);
- count = cm->fc.nzc_pcat_counts[c][t][b][0] +
- cm->fc.nzc_pcat_counts[c][t][b][1];
- count = count > count_sat ? count_sat : count;
- factor = (update_factor * count / count_sat);
- cm->fc.nzc_pcat_probs[c][t][b] = weighted_prob(
- cm->fc.pre_nzc_pcat_probs[c][t][b], prob, factor);
- }
- }
- }
-}
-
-// #define NZC_COUNT_TESTING
-void vp9_adapt_nzc_probs(VP9_COMMON *cm) {
- int count_sat;
- int update_factor; /* denominator 256 */
-#ifdef NZC_COUNT_TESTING
- int c, r, b, t;
- printf("\n");
- for (c = 0; c < MAX_NZC_CONTEXTS; ++c)
- for (r = 0; r < REF_TYPES; ++r) {
- for (b = 0; b < BLOCK_TYPES; ++b) {
- printf(" {");
- for (t = 0; t < NZC4X4_TOKENS; ++t) {
- printf(" %d,", cm->fc.nzc_counts_4x4[c][r][b][t]);
- }
- printf("}\n");
- }
- printf("\n");
- }
-#endif
-
- if (cm->frame_type == KEY_FRAME) {
- update_factor = COEF_MAX_UPDATE_FACTOR_KEY;
- count_sat = COEF_COUNT_SAT_KEY;
- } else if (cm->last_frame_type == KEY_FRAME) {
- update_factor = COEF_MAX_UPDATE_FACTOR_AFTER_KEY; /* adapt quickly */
- count_sat = COEF_COUNT_SAT_AFTER_KEY;
- } else {
- update_factor = COEF_MAX_UPDATE_FACTOR;
- count_sat = COEF_COUNT_SAT;
- }
-
- adapt_nzc_probs_common(cm, TX_4X4, count_sat, update_factor);
- adapt_nzc_probs_common(cm, TX_8X8, count_sat, update_factor);
- adapt_nzc_probs_common(cm, TX_16X16, count_sat, update_factor);
- adapt_nzc_probs_common(cm, TX_32X32, count_sat, update_factor);
- adapt_nzc_pcat(cm, count_sat, update_factor);
-}
-#endif // CONFIG_CODE_NONZEROCOUNT
-
#if CONFIG_CODE_ZEROGROUP
OrientationType vp9_get_orientation(int rc, TX_SIZE tx_size) {
int i = rc >> (tx_size + 2);
@@ -3011,25 +1687,6 @@
void vp9_adapt_zpc_probs(VP9_COMMON *cm) {
int count_sat;
int update_factor; /* denominator 256 */
-#ifdef NZC_COUNT_TESTING
- int r, b, p, n;
- printf("\n");
- for (r = 0; r < REF_TYPES; ++r) {
- printf("{");
- for (b = 0; b < ZPC_BANDS; ++b) {
- printf(" {");
- for (p = 0; p < ZPC_PTOKS; ++p) {
- printf(" {");
- for (n = 0; n < ZPC_NODES; ++n) {
- printf(" %d,", cm->fc.zpc_counts_16x16[r][b][p][n]);
- }
- printf("},\n");
- }
- printf(" },\n");
- }
- printf("},\n");
- }
-#endif
if (cm->frame_type == KEY_FRAME) {
update_factor = COEF_MAX_UPDATE_FACTOR_KEY;
diff --git a/vp9/common/vp9_entropy.h b/vp9/common/vp9_entropy.h
index 6b24ffc..123b5e2 100644
--- a/vp9/common/vp9_entropy.h
+++ b/vp9/common/vp9_entropy.h
@@ -167,89 +167,6 @@
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
diff --git a/vp9/common/vp9_mbpitch.c b/vp9/common/vp9_mbpitch.c
index 957068f..d5f104d 100644
--- a/vp9/common/vp9_mbpitch.c
+++ b/vp9/common/vp9_mbpitch.c
@@ -44,13 +44,13 @@
u2 = NULL;
v2 = NULL;
} else {
- y = &mb->pre.y_buffer;
- u = &mb->pre.u_buffer;
- v = &mb->pre.v_buffer;
+ y = &mb->plane[0].pre[0].buf;
+ u = &mb->plane[1].pre[0].buf;
+ v = &mb->plane[2].pre[0].buf;
- y2 = &mb->second_pre.y_buffer;
- u2 = &mb->second_pre.u_buffer;
- v2 = &mb->second_pre.v_buffer;
+ y2 = &mb->plane[0].pre[1].buf;
+ u2 = &mb->plane[1].pre[1].buf;
+ v2 = &mb->plane[2].pre[1].buf;
}
// luma
diff --git a/vp9/common/vp9_onyxc_int.h b/vp9/common/vp9_onyxc_int.h
index eb2a2c6..8f95734 100644
--- a/vp9/common/vp9_onyxc_int.h
+++ b/vp9/common/vp9_onyxc_int.h
@@ -74,18 +74,6 @@
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 @@
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 @@
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;
diff --git a/vp9/common/vp9_recon.c b/vp9/common/vp9_recon.c
index cc44afe..4119450 100644
--- a/vp9/common/vp9_recon.c
+++ b/vp9/common/vp9_recon.c
@@ -14,79 +14,61 @@
#include "vp9/common/vp9_blockd.h"
static INLINE void recon(int rows, int cols,
- const uint8_t *pred_ptr, int pred_stride,
const int16_t *diff_ptr, int diff_stride,
uint8_t *dst_ptr, int dst_stride) {
int r, c;
for (r = 0; r < rows; r++) {
for (c = 0; c < cols; c++)
- dst_ptr[c] = clip_pixel(diff_ptr[c] + pred_ptr[c]);
+ dst_ptr[c] = clip_pixel(diff_ptr[c] + dst_ptr[c]);
dst_ptr += dst_stride;
diff_ptr += diff_stride;
- pred_ptr += pred_stride;
}
}
void vp9_recon_b_c(uint8_t *pred_ptr, int16_t *diff_ptr, uint8_t *dst_ptr,
int stride) {
- recon(4, 4, pred_ptr, stride, diff_ptr, 16, dst_ptr, stride);
+ assert(pred_ptr == dst_ptr);
+ recon(4, 4, diff_ptr, 16, dst_ptr, stride);
}
void vp9_recon_uv_b_c(uint8_t *pred_ptr, int16_t *diff_ptr, uint8_t *dst_ptr,
int stride) {
- recon(4, 4, pred_ptr, stride, diff_ptr, 8, dst_ptr, stride);
+ assert(pred_ptr == dst_ptr);
+ recon(4, 4, diff_ptr, 8, dst_ptr, stride);
}
void vp9_recon4b_c(uint8_t *pred_ptr, int16_t *diff_ptr, uint8_t *dst_ptr,
int stride) {
- recon(4, 16, pred_ptr, stride, diff_ptr, 16, dst_ptr, stride);
+ assert(pred_ptr == dst_ptr);
+ recon(4, 16, diff_ptr, 16, dst_ptr, stride);
}
void vp9_recon2b_c(uint8_t *pred_ptr, int16_t *diff_ptr, uint8_t *dst_ptr,
int stride) {
- recon(4, 8, pred_ptr, stride, diff_ptr, 8, dst_ptr, stride);
+ assert(pred_ptr == dst_ptr);
+ recon(4, 8, diff_ptr, 8, dst_ptr, stride);
+}
+
+static void recon_plane(MACROBLOCKD *xd, BLOCK_SIZE_TYPE bsize, int plane) {
+ const int bw = 4 << (b_width_log2(bsize) - xd->plane[plane].subsampling_x);
+ const int bh = 4 << (b_height_log2(bsize) - xd->plane[plane].subsampling_y);
+ recon(bh, bw,
+ xd->plane[plane].diff, bw,
+ xd->plane[plane].dst.buf, xd->plane[plane].dst.stride);
}
void vp9_recon_sby_c(MACROBLOCKD *mb, BLOCK_SIZE_TYPE bsize) {
- const int bw = 16 << mb_width_log2(bsize), bh = 16 << mb_height_log2(bsize);
- int x, y;
- const int stride = mb->plane[0].dst.stride;
- uint8_t *dst = mb->plane[0].dst.buf;
- const int16_t *diff = mb->plane[0].diff;
-
- for (y = 0; y < bh; y++) {
- for (x = 0; x < bw; x++)
- dst[x] = clip_pixel(dst[x] + diff[x]);
-
- dst += stride;
- diff += bw;
- }
+ recon_plane(mb, bsize, 0);
}
void vp9_recon_sbuv_c(MACROBLOCKD *mb, BLOCK_SIZE_TYPE bsize) {
- const int bwl = mb_width_log2(bsize), bhl = mb_height_log2(bsize);
- const int bw = 8 << bwl, bh = 8 << bhl;
- int x, y;
- const int stride = mb->plane[1].dst.stride;
- uint8_t *u_dst = mb->plane[1].dst.buf;
- uint8_t *v_dst = mb->plane[2].dst.buf;
- const int16_t *u_diff = mb->plane[1].diff;
- const int16_t *v_diff = mb->plane[2].diff;
+ int i;
- for (y = 0; y < bh; y++) {
- for (x = 0; x < bw; x++) {
- u_dst[x] = clip_pixel(u_dst[x] + u_diff[x]);
- v_dst[x] = clip_pixel(v_dst[x] + v_diff[x]);
- }
-
- u_dst += stride;
- v_dst += stride;
- u_diff += bw;
- v_diff += bw;
- }
+ for (i = 1; i < MAX_MB_PLANE; i++)
+ recon_plane(mb, bsize, i);
}
void vp9_recon_sb_c(MACROBLOCKD *xd, BLOCK_SIZE_TYPE bsize) {
diff --git a/vp9/common/vp9_reconinter.c b/vp9/common/vp9_reconinter.c
index 362fb3b..2697bd2 100644
--- a/vp9/common/vp9_reconinter.c
+++ b/vp9/common/vp9_reconinter.c
@@ -581,8 +581,9 @@
struct build_inter_predictors_args args = {
xd, mb_col * 16, mb_row * 16,
{xd->plane[0].dst.buf, NULL, NULL}, {xd->plane[0].dst.stride, 0, 0},
- {{xd->pre.y_buffer, NULL, NULL}, {xd->second_pre.y_buffer, NULL, NULL}},
- {{xd->pre.y_stride, 0, 0}, {xd->second_pre.y_stride, 0, 0}},
+ {{xd->plane[0].pre[0].buf, NULL, NULL},
+ {xd->plane[0].pre[1].buf, NULL, NULL}},
+ {{xd->plane[0].pre[0].stride, 0, 0}, {xd->plane[0].pre[1].stride, 0, 0}},
};
// TODO(jkoleszar): This is a hack no matter where you put it, but does it
@@ -600,10 +601,10 @@
xd, mb_col * 16, mb_row * 16,
{NULL, xd->plane[1].dst.buf, xd->plane[2].dst.buf},
{0, xd->plane[1].dst.stride, xd->plane[1].dst.stride},
- {{NULL, xd->pre.u_buffer, xd->pre.v_buffer},
- {NULL, xd->second_pre.u_buffer, xd->second_pre.v_buffer}},
- {{0, xd->pre.uv_stride, xd->pre.uv_stride},
- {0, xd->second_pre.uv_stride, xd->second_pre.uv_stride}},
+ {{NULL, xd->plane[1].pre[0].buf, xd->plane[2].pre[0].buf},
+ {NULL, xd->plane[1].pre[1].buf, xd->plane[2].pre[1].buf}},
+ {{0, xd->plane[1].pre[0].stride, xd->plane[1].pre[0].stride},
+ {0, xd->plane[1].pre[1].stride, xd->plane[1].pre[1].stride}},
};
foreach_predicted_block_uv(xd, bsize, build_inter_predictors, &args);
}
@@ -889,8 +890,8 @@
edge[3] = xd->mb_to_right_edge;
clamp_mvs = xd->mode_info_context->mbmi.need_to_clamp_secondmv;
- base_pre = xd->second_pre.y_buffer;
- pre_stride = xd->second_pre.y_stride;
+ base_pre = xd->plane[0].pre[1].buf;
+ pre_stride = xd->plane[0].pre[1].stride;
ymv.as_int = xd->mode_info_context->mbmi.mv[1].as_int;
// First generate the second predictor
scale = &xd->scale_factor[1];
@@ -925,8 +926,8 @@
metric_2 = get_consistency_metric(xd, tmp_y, tmp_ystride);
clamp_mvs = xd->mode_info_context->mbmi.need_to_clamp_mvs;
- base_pre = xd->pre.y_buffer;
- pre_stride = xd->pre.y_stride;
+ base_pre = xd->plane[0].pre[0].buf;
+ pre_stride = xd->plane[0].pre[0].stride;
ymv.as_int = xd->mode_info_context->mbmi.mv[0].as_int;
// Now generate the first predictor
scale = &xd->scale_factor[0];
@@ -978,8 +979,8 @@
xd->mode_info_context->mbmi.need_to_clamp_secondmv :
xd->mode_info_context->mbmi.need_to_clamp_mvs;
- uint8_t *base_pre = which_mv ? xd->second_pre.y_buffer : xd->pre.y_buffer;
- int pre_stride = which_mv ? xd->second_pre.y_stride : xd->pre.y_stride;
+ uint8_t *base_pre = xd->plane[0].pre[which_mv].buf;
+ int pre_stride = xd->plane[0].pre[which_mv].stride;
int_mv ymv;
struct scale_factors *scale = &xd->scale_factor[which_mv];
@@ -1011,8 +1012,8 @@
which_mv ? xd->mode_info_context->mbmi.need_to_clamp_secondmv
: xd->mode_info_context->mbmi.need_to_clamp_mvs;
uint8_t *uptr, *vptr;
- int pre_stride = which_mv ? xd->second_pre.uv_stride
- : xd->pre.uv_stride;
+ int pre_stride = which_mv ? xd->plane[1].pre[1].stride
+ : xd->plane[1].pre[0].stride;
int_mv mv;
struct scale_factors *scale = &xd->scale_factor_uv[which_mv];
@@ -1022,8 +1023,8 @@
if (clamp_mvs)
clamp_mv_to_umv_border(&mv.as_mv, xd);
- uptr = (which_mv ? xd->second_pre.u_buffer : xd->pre.u_buffer);
- vptr = (which_mv ? xd->second_pre.v_buffer : xd->pre.v_buffer);
+ uptr = (which_mv ? xd->plane[1].pre[1].buf : xd->plane[1].pre[0].buf);
+ vptr = (which_mv ? xd->plane[2].pre[1].buf : xd->plane[2].pre[0].buf);
scale->set_scaled_offsets(scale, mb_row * 16, mb_col * 16);
@@ -1045,8 +1046,8 @@
BLOCK_SIZE_TYPE bsize) {
const int bwl = mb_width_log2(bsize), bw = 1 << bwl;
const int bhl = mb_height_log2(bsize), bh = 1 << bhl;
- uint8_t *y1 = x->pre.y_buffer;
- uint8_t *y2 = x->second_pre.y_buffer;
+ uint8_t *y1 = x->plane[0].pre[0].buf;
+ uint8_t *y2 = x->plane[0].pre[1].buf;
int edge[4], n;
edge[0] = x->mb_to_top_edge;
@@ -1062,15 +1063,15 @@
x->mb_to_left_edge = edge[2] - ((x_idx * 16) << 3);
x->mb_to_right_edge = edge[3] + (((bw - 1 - x_idx) * 16) << 3);
- x->pre.y_buffer = y1 + scaled_buffer_offset(x_idx * 16,
+ x->plane[0].pre[0].buf = y1 + scaled_buffer_offset(x_idx * 16,
y_idx * 16,
- x->pre.y_stride,
+ x->plane[0].pre[0].stride,
&x->scale_factor[0]);
if (x->mode_info_context->mbmi.second_ref_frame > 0) {
- x->second_pre.y_buffer = y2 +
+ x->plane[0].pre[1].buf = y2 +
scaled_buffer_offset(x_idx * 16,
y_idx * 16,
- x->second_pre.y_stride,
+ x->plane[0].pre[1].stride,
&x->scale_factor[1]);
}
build_inter16x16_predictors_mby_w(x,
@@ -1082,9 +1083,9 @@
x->mb_to_left_edge = edge[2];
x->mb_to_right_edge = edge[3];
- x->pre.y_buffer = y1;
+ x->plane[0].pre[0].buf = y1;
if (x->mode_info_context->mbmi.second_ref_frame > 0) {
- x->second_pre.y_buffer = y2;
+ x->plane[0].pre[1].buf = y2;
}
}
@@ -1110,8 +1111,8 @@
BLOCK_SIZE_TYPE bsize) {
const int bwl = mb_width_log2(bsize), bw = 1 << bwl;
const int bhl = mb_height_log2(bsize), bh = 1 << bhl;
- uint8_t *u1 = x->pre.u_buffer, *v1 = x->pre.v_buffer;
- uint8_t *u2 = x->second_pre.u_buffer, *v2 = x->second_pre.v_buffer;
+ uint8_t *u1 = x->plane[1].pre[0].buf, *v1 = x->plane[2].pre[0].buf;
+ uint8_t *u2 = x->plane[1].pre[1].buf, *v2 = x->plane[2].pre[1].buf;
int edge[4], n;
edge[0] = x->mb_to_top_edge;
@@ -1130,18 +1131,18 @@
scaled_uv_offset = scaled_buffer_offset(x_idx * 8,
y_idx * 8,
- x->pre.uv_stride,
+ x->plane[1].pre[0].stride,
&x->scale_factor_uv[0]);
- x->pre.u_buffer = u1 + scaled_uv_offset;
- x->pre.v_buffer = v1 + scaled_uv_offset;
+ x->plane[1].pre[0].buf = u1 + scaled_uv_offset;
+ x->plane[2].pre[0].buf = v1 + scaled_uv_offset;
if (x->mode_info_context->mbmi.second_ref_frame > 0) {
scaled_uv_offset = scaled_buffer_offset(x_idx * 8,
y_idx * 8,
- x->second_pre.uv_stride,
+ x->plane[1].pre[1].stride,
&x->scale_factor_uv[1]);
- x->second_pre.u_buffer = u2 + scaled_uv_offset;
- x->second_pre.v_buffer = v2 + scaled_uv_offset;
+ x->plane[1].pre[1].buf = u2 + scaled_uv_offset;
+ x->plane[2].pre[1].buf = v2 + scaled_uv_offset;
}
build_inter16x16_predictors_mbuv_w(x,
@@ -1154,12 +1155,12 @@
x->mb_to_left_edge = edge[2];
x->mb_to_right_edge = edge[3];
- x->pre.u_buffer = u1;
- x->pre.v_buffer = v1;
+ x->plane[1].pre[0].buf = u1;
+ x->plane[2].pre[0].buf = v1;
if (x->mode_info_context->mbmi.second_ref_frame > 0) {
- x->second_pre.u_buffer = u2;
- x->second_pre.v_buffer = v2;
+ x->plane[1].pre[1].buf = u2;
+ x->plane[2].pre[1].buf = v2;
}
}
diff --git a/vp9/common/vp9_reconinter.h b/vp9/common/vp9_reconinter.h
index 052fe29..51b705f 100644
--- a/vp9/common/vp9_reconinter.h
+++ b/vp9/common/vp9_reconinter.h
@@ -106,6 +106,35 @@
xd->plane[2].subsampling_x, xd->plane[2].subsampling_y);
}
+static void setup_pre_planes(MACROBLOCKD *xd,
+ const YV12_BUFFER_CONFIG *src0,
+ const YV12_BUFFER_CONFIG *src1,
+ int mb_row, int mb_col,
+ const struct scale_factors *scale,
+ const struct scale_factors *scale_uv) {
+ int i;
+
+ for (i = 0; i < 2; i++) {
+ const YV12_BUFFER_CONFIG *src = i ? src1 : src0;
+
+ if (!src)
+ continue;
+
+ setup_pred_plane(&xd->plane[0].pre[i],
+ src->y_buffer, src->y_stride,
+ mb_row, mb_col, scale ? scale + i : NULL,
+ xd->plane[0].subsampling_x, xd->plane[0].subsampling_y);
+ setup_pred_plane(&xd->plane[1].pre[i],
+ src->u_buffer, src->uv_stride,
+ mb_row, mb_col, scale_uv ? scale_uv + i : NULL,
+ xd->plane[1].subsampling_x, xd->plane[1].subsampling_y);
+ setup_pred_plane(&xd->plane[2].pre[i],
+ src->v_buffer, src->uv_stride,
+ mb_row, mb_col, scale_uv ? scale_uv + i : NULL,
+ xd->plane[2].subsampling_x, xd->plane[2].subsampling_y);
+ }
+}
+
static void setup_pred_block(YV12_BUFFER_CONFIG *dst,
const YV12_BUFFER_CONFIG *src,
int mb_row, int mb_col,
diff --git a/vp9/common/vp9_reconintra.c b/vp9/common/vp9_reconintra.c
index 1031be7..6caebd7 100644
--- a/vp9/common/vp9_reconintra.c
+++ b/vp9/common/vp9_reconintra.c
@@ -269,15 +269,6 @@
}
}
-void vp9_recon_intra_mbuv(MACROBLOCKD *xd) {
- int i;
- for (i = 16; i < 24; i += 2) {
- BLOCKD *b = &xd->block[i];
- vp9_recon2b(*(b->base_dst) + b->dst, b->diff,
- *(b->base_dst) + b->dst, b->dst_stride);
- }
-}
-
static INLINE int log2_minus_1(int n) {
switch (n) {
case 4: return 1;
diff --git a/vp9/common/vp9_reconintra.h b/vp9/common/vp9_reconintra.h
index b97b608..1e0cfa4 100644
--- a/vp9/common/vp9_reconintra.h
+++ b/vp9/common/vp9_reconintra.h
@@ -14,8 +14,6 @@
#include "vpx/vpx_integer.h"
#include "vp9/common/vp9_blockd.h"
-void vp9_recon_intra_mbuv(MACROBLOCKD *xd);
-
B_PREDICTION_MODE vp9_find_dominant_direction(uint8_t *ptr,
int stride, int n,
int tx, int ty);
diff --git a/vp9/decoder/vp9_decodemv.c b/vp9/decoder/vp9_decodemv.c
index 7135ea1..0df2e07 100644
--- a/vp9/decoder/vp9_decodemv.c
+++ b/vp9/decoder/vp9_decodemv.c
@@ -644,15 +644,14 @@
const MV_REFERENCE_FRAME ref_frame = mbmi->ref_frame;
struct scale_factors *sf0 = &xd->scale_factor[0];
- struct scale_factors *sf_uv0 = &xd->scale_factor_uv[0];
*sf0 = cm->active_ref_scale[mbmi->ref_frame - 1];
{
// Select the appropriate reference frame for this MB
const int ref_fb_idx = cm->active_ref_idx[ref_frame - 1];
- setup_pred_block(&xd->pre, &cm->yv12_fb[ref_fb_idx],
- mb_row, mb_col, sf0, sf_uv0);
+ setup_pre_planes(xd, &cm->yv12_fb[ref_fb_idx], NULL,
+ mb_row, mb_col, xd->scale_factor, xd->scale_factor_uv);
#ifdef DEC_DEBUG
if (dec_debug)
@@ -712,12 +711,11 @@
if (mbmi->second_ref_frame > 0) {
const MV_REFERENCE_FRAME second_ref_frame = mbmi->second_ref_frame;
struct scale_factors *sf1 = &xd->scale_factor[1];
- struct scale_factors *sf_uv1 = &xd->scale_factor_uv[1];
const int second_ref_fb_idx = cm->active_ref_idx[second_ref_frame - 1];
*sf1 = cm->active_ref_scale[second_ref_frame - 1];
- setup_pred_block(&xd->second_pre, &cm->yv12_fb[second_ref_fb_idx],
- mb_row, mb_col, sf1, sf_uv1);
+ setup_pre_planes(xd, NULL, &cm->yv12_fb[second_ref_fb_idx],
+ mb_row, mb_col, xd->scale_factor, xd->scale_factor_uv);
vp9_find_mv_refs(cm, xd, mi,
use_prev_in_find_mv_refs ? prev_mi : NULL,
@@ -1018,258 +1016,6 @@
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 +1034,6 @@
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);
diff --git a/vp9/decoder/vp9_decodframe.c b/vp9/decoder/vp9_decodframe.c
index da01597..a16b610 100644
--- a/vp9/decoder/vp9_decodframe.c
+++ b/vp9/decoder/vp9_decodframe.c
@@ -220,32 +220,6 @@
}
}
-#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 @@
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 @@
}
}
}
-
-#if CONFIG_CODE_NONZEROCOUNT
- propagate_nzcs(&pbi->common, xd);
-#endif
}
// TODO(jingning): Need to merge SB and MB decoding. The MB decoding currently
@@ -848,8 +815,8 @@
const YV12_BUFFER_CONFIG *cfg = &cm->yv12_fb[fb_idx];
xd->scale_factor[0] = cm->active_ref_scale[mbmi->ref_frame - 1];
xd->scale_factor_uv[0] = cm->active_ref_scale[mbmi->ref_frame - 1];
- setup_pred_block(&xd->pre, cfg, mb_row, mb_col,
- &xd->scale_factor[0], &xd->scale_factor_uv[0]);
+ setup_pre_planes(xd, cfg, NULL, mb_row, mb_col,
+ xd->scale_factor, xd->scale_factor_uv);
xd->corrupted |= cfg->corrupted;
if (mbmi->second_ref_frame > INTRA_FRAME) {
@@ -858,8 +825,8 @@
const YV12_BUFFER_CONFIG *second_cfg = &cm->yv12_fb[second_fb_idx];
xd->scale_factor[1] = cm->active_ref_scale[mbmi->second_ref_frame - 1];
xd->scale_factor_uv[1] = cm->active_ref_scale[mbmi->second_ref_frame - 1];
- setup_pred_block(&xd->second_pre, second_cfg, mb_row, mb_col,
- &xd->scale_factor[1], &xd->scale_factor_uv[1]);
+ setup_pre_planes(xd, NULL, second_cfg, mb_row, mb_col,
+ xd->scale_factor, xd->scale_factor_uv);
xd->corrupted |= second_cfg->corrupted;
}
}
@@ -1043,88 +1010,6 @@
}
#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 @@
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 @@
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);
@@ -1717,16 +1585,13 @@
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
// Initialize xd pointers. Any reference should do for xd->pre, so use 0.
- vpx_memcpy(&xd->pre, &pc->yv12_fb[pc->active_ref_idx[0]],
- sizeof(YV12_BUFFER_CONFIG));
+ setup_pre_planes(xd, &pc->yv12_fb[pc->active_ref_idx[0]], NULL,
+ 0, 0, NULL, NULL);
setup_dst_planes(xd, &pc->yv12_fb[pc->new_fb_idx], 0, 0);
// Create the segmentation map structure and set to 0
@@ -1772,9 +1637,6 @@
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
diff --git a/vp9/decoder/vp9_detokenize.c b/vp9/decoder/vp9_detokenize.c
index 7cfc7dc..18ef51a 100644
--- a/vp9/decoder/vp9_detokenize.c
+++ b/vp9/decoder/vp9_detokenize.c
@@ -83,16 +83,6 @@
} 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 @@
c++; \
continue; \
}
-#endif // CONFIG_CODE_NONZEROCOUNT
#define WRITE_COEF_ONE() \
{ \
@@ -138,12 +127,6 @@
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];
#if CONFIG_CODE_ZEROGROUP
@@ -309,41 +292,27 @@
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);
@@ -360,10 +329,6 @@
[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
eoo = 0;
@@ -446,18 +411,9 @@
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) {
diff --git a/vp9/encoder/vp9_bitstream.c b/vp9/encoder/vp9_bitstream.c
index 1f419c3..e94f616 100644
--- a/vp9/encoder/vp9_bitstream.c
+++ b/vp9/encoder/vp9_bitstream.c
@@ -50,23 +50,6 @@
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 @@
}
}
-#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 @@
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 @@
}
#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 @@
#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) {
@@ -2968,27 +2157,6 @@
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);
@@ -3016,9 +2184,6 @@
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
diff --git a/vp9/encoder/vp9_block.h b/vp9/encoder/vp9_block.h
index f4e3c2e..e511be8 100644
--- a/vp9/encoder/vp9_block.h
+++ b/vp9/encoder/vp9_block.h
@@ -151,12 +151,6 @@
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;
diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c
index dbd06a0..1f20d5e 100644
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -738,9 +738,6 @@
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,
@@ -1238,7 +1235,10 @@
// Copy data over into macro block data structures.
x->src = *cpi->Source;
- xd->pre = cm->yv12_fb[cm->ref_frame_map[cpi->lst_fb_idx]];
+
+ // TODO(jkoleszar): are these initializations required?
+ setup_pre_planes(xd, &cm->yv12_fb[cm->ref_frame_map[cpi->lst_fb_idx]], NULL,
+ 0, 0, NULL, NULL);
setup_dst_planes(xd, &cm->yv12_fb[cm->new_fb_idx], 0, 0);
// set up frame for intra coded blocks
@@ -1338,13 +1338,6 @@
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 +1874,6 @@
#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) {
@@ -2087,7 +1949,7 @@
if (output_enabled)
sum_intra_stats(cpi, x);
} else {
- int ref_fb_idx;
+ int ref_fb_idx, second_ref_fb_idx;
#ifdef ENC_DEBUG
if (enc_debug)
printf("Mode %d skip %d tx_size %d ref %d ref2 %d mv %d %d interp %d\n",
@@ -2106,27 +1968,21 @@
else
ref_fb_idx = cpi->common.ref_frame_map[cpi->alt_fb_idx];
- setup_pred_block(&xd->pre,
- &cpi->common.yv12_fb[ref_fb_idx],
- mb_row, mb_col,
- &xd->scale_factor[0], &xd->scale_factor_uv[0]);
-
if (mbmi->second_ref_frame > 0) {
- int second_ref_fb_idx;
-
if (mbmi->second_ref_frame == LAST_FRAME)
second_ref_fb_idx = cpi->common.ref_frame_map[cpi->lst_fb_idx];
else if (mbmi->second_ref_frame == GOLDEN_FRAME)
second_ref_fb_idx = cpi->common.ref_frame_map[cpi->gld_fb_idx];
else
second_ref_fb_idx = cpi->common.ref_frame_map[cpi->alt_fb_idx];
-
- setup_pred_block(&xd->second_pre,
- &cpi->common.yv12_fb[second_ref_fb_idx],
- mb_row, mb_col,
- &xd->scale_factor[1], &xd->scale_factor_uv[1]);
}
+ setup_pre_planes(xd,
+ &cpi->common.yv12_fb[ref_fb_idx],
+ mbmi->second_ref_frame > 0 ? &cpi->common.yv12_fb[second_ref_fb_idx]
+ : NULL,
+ mb_row, mb_col, xd->scale_factor, xd->scale_factor_uv);
+
if (!x->skip) {
vp9_encode_inter16x16(cm, x, mb_row, mb_col);
} else {
@@ -2197,9 +2053,6 @@
}
#endif
-#if CONFIG_CODE_NONZEROCOUNT
- gather_nzcs_mb16(cm, xd);
-#endif
vp9_tokenize_mb(cpi, xd, t, !output_enabled);
} else {
@@ -2304,7 +2157,7 @@
if (output_enabled)
sum_intra_stats(cpi, x);
} else {
- int ref_fb_idx;
+ int ref_fb_idx, second_ref_fb_idx;
assert(cm->frame_type != KEY_FRAME);
@@ -2315,27 +2168,21 @@
else
ref_fb_idx = cpi->common.ref_frame_map[cpi->alt_fb_idx];
- setup_pred_block(&xd->pre,
- &cpi->common.yv12_fb[ref_fb_idx],
- mb_row, mb_col,
- &xd->scale_factor[0], &xd->scale_factor_uv[0]);
-
if (xd->mode_info_context->mbmi.second_ref_frame > 0) {
- int second_ref_fb_idx;
-
if (xd->mode_info_context->mbmi.second_ref_frame == LAST_FRAME)
second_ref_fb_idx = cpi->common.ref_frame_map[cpi->lst_fb_idx];
else if (xd->mode_info_context->mbmi.second_ref_frame == GOLDEN_FRAME)
second_ref_fb_idx = cpi->common.ref_frame_map[cpi->gld_fb_idx];
else
second_ref_fb_idx = cpi->common.ref_frame_map[cpi->alt_fb_idx];
-
- setup_pred_block(&xd->second_pre,
- &cpi->common.yv12_fb[second_ref_fb_idx],
- mb_row, mb_col,
- &xd->scale_factor[1], &xd->scale_factor_uv[1]);
}
+ setup_pre_planes(xd,
+ &cpi->common.yv12_fb[ref_fb_idx],
+ xd->mode_info_context->mbmi.second_ref_frame > 0
+ ? &cpi->common.yv12_fb[second_ref_fb_idx] : NULL,
+ mb_row, mb_col, xd->scale_factor, xd->scale_factor_uv);
+
vp9_build_inter_predictors_sb(xd, mb_row, mb_col, bsize);
}
@@ -2419,13 +2266,6 @@
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)
diff --git a/vp9/encoder/vp9_encodeintra.c b/vp9/encoder/vp9_encodeintra.c
index 95befb7..5c6559b 100644
--- a/vp9/encoder/vp9_encodeintra.c
+++ b/vp9/encoder/vp9_encodeintra.c
@@ -146,7 +146,7 @@
break;
}
- vp9_recon_intra_mbuv(xd);
+ vp9_recon_sbuv(xd, BLOCK_SIZE_MB16X16);
}
void vp9_encode_intra8x8(MACROBLOCK *x, int ib) {
diff --git a/vp9/encoder/vp9_encodemb.c b/vp9/encoder/vp9_encodemb.c
index c67207b..c841c28 100644
--- a/vp9/encoder/vp9_encodemb.c
+++ b/vp9/encoder/vp9_encodemb.c
@@ -326,24 +326,6 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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,
diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c
index 91d7f05..b18dce4 100644
--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -358,7 +358,7 @@
int ref_stride = d->pre_stride;
// Set up pointers for this macro block recon buffer
- xd->pre.y_buffer = recon_buffer->y_buffer + recon_yoffset;
+ xd->plane[0].pre[0].buf = recon_buffer->y_buffer + recon_yoffset;
ref_ptr = (uint8_t *)(*(d->base_pre) + d->pre);
@@ -402,7 +402,7 @@
v_fn_ptr.vf = vp9_mse16x16;
// Set up pointers for this macro block recon buffer
- xd->pre.y_buffer = recon_buffer->y_buffer + recon_yoffset;
+ xd->plane[0].pre[0].buf = recon_buffer->y_buffer + recon_yoffset;
// Initial step/diamond search centred on best mv
tmp_mv.as_int = 0;
@@ -485,7 +485,7 @@
vp9_clear_system_state(); // __asm emms;
x->src = * cpi->Source;
- xd->pre = *lst_yv12;
+ setup_pre_planes(xd, lst_yv12, NULL, 0, 0, NULL, NULL);
setup_dst_planes(xd, new_yv12, 0, 0);
x->partition_info = x->pi;
@@ -601,9 +601,9 @@
}
// Reset to last frame as reference buffer
- xd->pre.y_buffer = lst_yv12->y_buffer + recon_yoffset;
- xd->pre.u_buffer = lst_yv12->u_buffer + recon_uvoffset;
- xd->pre.v_buffer = lst_yv12->v_buffer + recon_uvoffset;
+ xd->plane[0].pre[0].buf = lst_yv12->y_buffer + recon_yoffset;
+ xd->plane[1].pre[0].buf = lst_yv12->u_buffer + recon_uvoffset;
+ xd->plane[2].pre[0].buf = lst_yv12->v_buffer + recon_uvoffset;
// In accumulating a score for the older reference frame
// take the best of the motion predicted score and
diff --git a/vp9/encoder/vp9_mbgraph.c b/vp9/encoder/vp9_mbgraph.c
index 9a72af4..924d9fd 100644
--- a/vp9/encoder/vp9_mbgraph.c
+++ b/vp9/encoder/vp9_mbgraph.c
@@ -110,15 +110,16 @@
b->src_stride = x->src.y_stride;
b->src = x->src.y_stride * (n & 12) + (n & 3) * 4;
- d->base_pre = &xd->pre.y_buffer;
- d->pre_stride = xd->pre.y_stride;
- d->pre = xd->pre.y_stride * (n & 12) + (n & 3) * 4;
+ d->base_pre = &xd->plane[0].pre[0].buf;
+ d->pre_stride = xd->plane[0].pre[0].stride;
+ d->pre = xd->plane[0].pre[0].stride * (n & 12) + (n & 3) * 4;
}
// Try zero MV first
// FIXME should really use something like near/nearest MV and/or MV prediction
err = vp9_sad16x16(x->src.y_buffer, x->src.y_stride,
- xd->pre.y_buffer, xd->pre.y_stride, INT_MAX);
+ xd->plane[0].pre[0].buf, xd->plane[0].pre[0].stride,
+ INT_MAX);
dst_mv->as_int = 0;
// Test last reference frame using the previous best mv as the
@@ -162,7 +163,8 @@
// Try zero MV first
// FIXME should really use something like near/nearest MV and/or MV prediction
err = vp9_sad16x16(x->src.y_buffer, x->src.y_stride,
- xd->pre.y_buffer, xd->pre.y_stride, INT_MAX);
+ xd->plane[0].pre[0].buf, xd->plane[0].pre[0].stride,
+ INT_MAX);
dst_mv->as_int = 0;
@@ -247,8 +249,8 @@
// Golden frame MV search, if it exists and is different than last frame
if (golden_ref) {
int g_motion_error;
- xd->pre.y_buffer = golden_ref->y_buffer + mb_y_offset;
- xd->pre.y_stride = golden_ref->y_stride;
+ xd->plane[0].pre[0].buf = golden_ref->y_buffer + mb_y_offset;
+ xd->plane[0].pre[0].stride = golden_ref->y_stride;
g_motion_error = do_16x16_motion_search(cpi, prev_golden_ref_mv,
&stats->ref[GOLDEN_FRAME].m.mv,
buf, mb_y_offset,
@@ -263,8 +265,8 @@
// Alt-ref frame MV search, if it exists and is different than last/golden frame
if (alt_ref) {
int a_motion_error;
- xd->pre.y_buffer = alt_ref->y_buffer + mb_y_offset;
- xd->pre.y_stride = alt_ref->y_stride;
+ xd->plane[0].pre[0].buf = alt_ref->y_buffer + mb_y_offset;
+ xd->plane[0].pre[0].stride = alt_ref->y_stride;
a_motion_error = do_16x16_zerozero_search(cpi,
&stats->ref[ALTREF_FRAME].m.mv,
buf, mb_y_offset,
@@ -304,7 +306,7 @@
- 16 - VP9_INTERP_EXTEND;
xd->up_available = 0;
xd->plane[0].dst.stride = buf->y_stride;
- xd->pre.y_stride = buf->y_stride;
+ xd->plane[0].pre[0].stride = buf->y_stride;
xd->plane[1].dst.stride = buf->uv_stride;
xd->mode_info_context = &mi_local;
diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c
index 1c308af..b294870 100644
--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -114,12 +114,6 @@
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 @@
#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 @@
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 @@
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 @@
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
diff --git a/vp9/encoder/vp9_onyx_int.h b/vp9/encoder/vp9_onyx_int.h
index a6cfe93..e6a2a31 100644
--- a/vp9/encoder/vp9_onyx_int.h
+++ b/vp9/encoder/vp9_onyx_int.h
@@ -114,18 +114,6 @@
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 @@
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;
diff --git a/vp9/encoder/vp9_quantize.c b/vp9/encoder/vp9_quantize.c
index 80d9849..18f0f4f 100644
--- a/vp9/encoder/vp9_quantize.c
+++ b/vp9/encoder/vp9_quantize.c
@@ -45,9 +45,6 @@
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 @@
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 @@
}
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 @@
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 @@
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 @@
}
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 @@
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 @@
if (y) {
eob = 0; // last nonzero coeffs
-#if CONFIG_CODE_NONZEROCOUNT
- ++nzc; // number of nonzero coeffs
-#endif
zero_run = 0;
}
}
@@ -271,22 +247,13 @@
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 @@
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 @@
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 @@
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 @@
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);
}
diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c
index 30889d3..7a419fb 100644
--- a/vp9/encoder/vp9_ratectrl.c
+++ b/vp9/encoder/vp9_ratectrl.c
@@ -172,13 +172,6 @@
#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 @@
#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);
diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c
index 87a6b6f..18ad10b 100644
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -162,60 +162,6 @@
}
}
-#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 @@
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 @@
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 @@
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 @@
} 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 @@
} 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 @@
}
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 @@
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 @@
}
#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 @@
#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 @@
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;
@@ -2979,7 +2885,7 @@
x->nmvjointcost, x->mvcost, 96,
x->e_mbd.allow_high_precision_mv);
} else {
- YV12_BUFFER_CONFIG backup_yv12 = xd->pre;
+ struct buf_2d backup_yv12[MAX_MB_PLANE] = {{0}};
int bestsme = INT_MAX;
int further_steps, step_param = cpi->sf.first_step;
int sadpb = x->sadperbit16;
@@ -2992,13 +2898,16 @@
int tmp_row_max = x->mv_row_max;
if (scaled_ref_frame) {
+ int i;
+
// Swap out the reference frame for a version that's been scaled to
// match the resolution of the current frame, allowing the existing
// motion search code to be used without additional modifications.
- xd->pre = *scaled_ref_frame;
- xd->pre.y_buffer += mb_row * 16 * xd->pre.y_stride + mb_col * 16;
- xd->pre.u_buffer += mb_row * 8 * xd->pre.uv_stride + mb_col * 8;
- xd->pre.v_buffer += mb_row * 8 * xd->pre.uv_stride + mb_col * 8;
+ for (i = 0; i < MAX_MB_PLANE; i++)
+ backup_yv12[i] = xd->plane[i].pre[0];
+
+ setup_pre_planes(xd, scaled_ref_frame, NULL, mb_row, mb_col,
+ NULL, NULL);
}
vp9_clamp_mv_min_max(x, &ref_mv[0]);
@@ -3048,7 +2957,10 @@
// restore the predictor, if required
if (scaled_ref_frame) {
- xd->pre = backup_yv12;
+ int i;
+
+ for (i = 0; i < MAX_MB_PLANE; i++)
+ xd->plane[i].pre[0] = backup_yv12[i];
}
}
break;
@@ -3627,7 +3539,6 @@
int ref = mbmi->ref_frame;
int fb;
- xd->pre = yv12_mb[ref];
best_ref_mv = mbmi->ref_mvs[ref][0];
vpx_memcpy(mdcounts, frame_mdcounts[ref], sizeof(mdcounts));
@@ -3646,10 +3557,15 @@
if (mbmi->second_ref_frame > 0) {
int ref = mbmi->second_ref_frame;
- xd->second_pre = yv12_mb[ref];
second_best_ref_mv = mbmi->ref_mvs[ref][0];
}
+ // TODO(jkoleszar) scaling/translation handled during creation of yv12_mb
+ // currently.
+ setup_pre_planes(xd, &yv12_mb[mbmi->ref_frame],
+ mbmi->second_ref_frame > 0 ? &yv12_mb[mbmi->second_ref_frame] : NULL,
+ 0, 0, NULL, NULL);
+
// Experimental code. Special case for gf and arf zeromv modes.
// Increase zbin size to suppress noise
if (cpi->zbin_mode_boost_enabled) {
@@ -4406,7 +4322,7 @@
MB_MODE_INFO *mbmi = &xd->mode_info_context->mbmi;
MB_PREDICTION_MODE this_mode;
MB_PREDICTION_MODE best_mode = DC_PRED;
- MV_REFERENCE_FRAME ref_frame;
+ MV_REFERENCE_FRAME ref_frame, second_ref;
unsigned char segment_id = xd->mode_info_context->mbmi.segment_id;
int comp_pred, i;
int_mv frame_mv[MB_MODE_COUNT][MAX_REF_FRAMES];
@@ -4572,8 +4488,6 @@
// continue;
if (comp_pred) {
- int second_ref;
-
if (ref_frame == ALTREF_FRAME) {
second_ref = LAST_FRAME;
} else {
@@ -4585,7 +4499,6 @@
set_scale_factors(xd, mbmi->ref_frame, mbmi->second_ref_frame,
scale_factor);
- xd->second_pre = yv12_mb[second_ref];
mode_excluded =
mode_excluded ?
mode_excluded : cm->comp_pred_mode == SINGLE_PREDICTION_ONLY;
@@ -4603,7 +4516,9 @@
}
}
- xd->pre = yv12_mb[ref_frame];
+ setup_pre_planes(xd, &yv12_mb[ref_frame],
+ comp_pred ? &yv12_mb[second_ref] : NULL, 0, 0, NULL, NULL);
+
vpx_memcpy(mdcounts, frame_mdcounts[ref_frame], sizeof(mdcounts));
// If the segment reference frame feature is enabled....
diff --git a/vp9/encoder/vp9_temporal_filter.c b/vp9/encoder/vp9_temporal_filter.c
index 6149518..be3875a 100644
--- a/vp9/encoder/vp9_temporal_filter.c
+++ b/vp9/encoder/vp9_temporal_filter.c
@@ -221,9 +221,9 @@
DECLARE_ALIGNED_ARRAY(16, uint8_t, predictor, 16 * 16 + 8 * 8 + 8 * 8);
// Save input state
- uint8_t *y_buffer = mbd->pre.y_buffer;
- uint8_t *u_buffer = mbd->pre.u_buffer;
- uint8_t *v_buffer = mbd->pre.v_buffer;
+ uint8_t *y_buffer = mbd->plane[0].pre[0].buf;
+ uint8_t *u_buffer = mbd->plane[1].pre[0].buf;
+ uint8_t *v_buffer = mbd->plane[2].pre[0].buf;
for (mb_row = 0; mb_row < mb_rows; mb_row++) {
#if ALT_REF_MC_ENABLED
@@ -368,9 +368,9 @@
}
// Restore input state
- mbd->pre.y_buffer = y_buffer;
- mbd->pre.u_buffer = u_buffer;
- mbd->pre.v_buffer = v_buffer;
+ mbd->plane[0].pre[0].buf = y_buffer;
+ mbd->plane[1].pre[0].buf = u_buffer;
+ mbd->plane[2].pre[0].buf = v_buffer;
}
void vp9_temporal_filter_prepare(VP9_COMP *cpi, int distance) {
diff --git a/vp9/encoder/vp9_tokenize.c b/vp9/encoder/vp9_tokenize.c
index dd9efe6..f6a7206 100644
--- a/vp9/encoder/vp9_tokenize.c
+++ b/vp9/encoder/vp9_tokenize.c
@@ -36,21 +36,6 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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;