summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vp8/encoder/onyx_if.c2
-rw-r--r--vp9/common/vp9_alloccommon.c12
-rw-r--r--vp9/common/vp9_blockd.h15
-rw-r--r--vp9/common/vp9_common.h4
-rw-r--r--vp9/common/vp9_entropymode.c70
-rw-r--r--vp9/common/vp9_entropymode.h7
-rw-r--r--vp9/common/vp9_loopfilter.c38
-rw-r--r--vp9/common/vp9_mvref_common.c76
-rw-r--r--vp9/common/vp9_onyxc_int.h8
-rw-r--r--vp9/common/vp9_reconintra.c91
-rw-r--r--vp9/common/vp9_seg_common.c2
-rw-r--r--vp9/decoder/vp9_decodemv.c28
-rw-r--r--vp9/decoder/vp9_decodframe.c21
-rw-r--r--vp9/decoder/vp9_detokenize.c2
-rw-r--r--vp9/encoder/vp9_bitstream.c70
-rw-r--r--vp9/encoder/vp9_encodeframe.c55
-rw-r--r--vp9/encoder/vp9_onyx_if.c10
-rw-r--r--vp9/encoder/vp9_onyx_int.h7
-rw-r--r--vp9/encoder/vp9_ratectrl.c2
-rw-r--r--vp9/encoder/vp9_rdopt.c12
-rw-r--r--vp9/vp9_iface_common.h2
21 files changed, 272 insertions, 262 deletions
diff --git a/vp8/encoder/onyx_if.c b/vp8/encoder/onyx_if.c
index 930d93f87..aec7bffa4 100644
--- a/vp8/encoder/onyx_if.c
+++ b/vp8/encoder/onyx_if.c
@@ -5179,7 +5179,7 @@ int vp8_get_compressed_data(VP8_COMP *cpi, unsigned int *frame_flags, unsigned l
if (cm->show_frame)
{
-
+ cpi->common.show_frame_mi = cpi->common.mi;
cpi->count ++;
if (cpi->b_calculate_psnr)
diff --git a/vp9/common/vp9_alloccommon.c b/vp9/common/vp9_alloccommon.c
index ce552678d..496096373 100644
--- a/vp9/common/vp9_alloccommon.c
+++ b/vp9/common/vp9_alloccommon.c
@@ -68,8 +68,8 @@ void vp9_free_frame_buffers(VP9_COMMON *oci) {
}
static void set_mb_mi(VP9_COMMON *cm, int aligned_width, int aligned_height) {
- cm->mb_cols = (aligned_width + 8) >> 4;
- cm->mb_rows = (aligned_height + 8) >> 4;
+ cm->mb_cols = aligned_width >> 4;
+ cm->mb_rows = aligned_height >> 4;
cm->MBs = cm->mb_rows * cm->mb_cols;
cm->mi_cols = aligned_width >> LOG2_MI_SIZE;
@@ -95,8 +95,8 @@ int vp9_alloc_frame_buffers(VP9_COMMON *oci, int width, int height) {
int i, mi_cols;
// Our internal buffers are always multiples of 16
- const int aligned_width = multiple8(width);
- const int aligned_height = multiple8(height);
+ const int aligned_width = multiple16(width);
+ const int aligned_height = multiple16(height);
const int ss_x = oci->subsampling_x;
const int ss_y = oci->subsampling_y;
@@ -223,8 +223,8 @@ void vp9_initialize_common() {
}
void vp9_update_frame_size(VP9_COMMON *cm) {
- const int aligned_width = multiple8(cm->width);
- const int aligned_height = multiple8(cm->height);
+ const int aligned_width = multiple16(cm->width);
+ const int aligned_height = multiple16(cm->height);
set_mb_mi(cm, aligned_width, aligned_height);
setup_mi(cm);
diff --git a/vp9/common/vp9_blockd.h b/vp9/common/vp9_blockd.h
index b8822a614..4b06a61bd 100644
--- a/vp9/common/vp9_blockd.h
+++ b/vp9/common/vp9_blockd.h
@@ -30,7 +30,7 @@
#define MBSKIP_CONTEXTS 3
#define MAX_REF_LF_DELTAS 4
-#define MAX_MODE_LF_DELTAS 4
+#define MAX_MODE_LF_DELTAS 2
/* Segment Feature Masks */
#define SEGMENT_DELTADATA 0
@@ -122,6 +122,15 @@ typedef enum {
#define WHT_UPSCALE_FACTOR 2
+#define TX_SIZE_PROBS 6 // (TX_SIZE_MAX_SB * (TX_SIZE_MAX_SB - 1) / 2)
+
+#if TX_SIZE_PROBS == 6
+#define get_tx_probs_offset(b) ((b) < BLOCK_SIZE_MB16X16 ? 0 : \
+ (b) < BLOCK_SIZE_SB32X32 ? 1 : 3)
+#else
+#define get_tx_probs_offset(b) 0
+#endif
+
/* For keyframes, intra block modes are predicted by the (already decoded)
modes for the Y blocks to the left and above us; for interframes, there
is a single probability table. */
@@ -330,9 +339,9 @@ typedef struct macroblockd {
signed char last_ref_lf_deltas[MAX_REF_LF_DELTAS];
/* 0 = Intra, Last, GF, ARF */
signed char ref_lf_deltas[MAX_REF_LF_DELTAS];
- /* 0 = I4X4_PRED, ZERO_MV, MV, SPLIT */
+ /* 0 = ZERO_MV, MV */
signed char last_mode_lf_deltas[MAX_MODE_LF_DELTAS];
- /* 0 = I4X4_PRED, ZERO_MV, MV, SPLIT */
+ /* 0 = ZERO_MV, MV */
signed char mode_lf_deltas[MAX_MODE_LF_DELTAS];
/* Distance of MB away from frame edges */
diff --git a/vp9/common/vp9_common.h b/vp9/common/vp9_common.h
index 0d7babf97..5c97f9863 100644
--- a/vp9/common/vp9_common.h
+++ b/vp9/common/vp9_common.h
@@ -56,8 +56,8 @@ static INLINE double fclamp(double value, double low, double high) {
return value < low ? low : (value > high ? high : value);
}
-static INLINE int multiple8(int value) {
- return (value + 7) & ~7;
+static INLINE int multiple16(int value) {
+ return (value + 15) & ~15;
}
#define SYNC_CODE_0 0x49
diff --git a/vp9/common/vp9_entropymode.c b/vp9/common/vp9_entropymode.c
index bed4edf97..bf57e7ecc 100644
--- a/vp9/common/vp9_entropymode.c
+++ b/vp9/common/vp9_entropymode.c
@@ -149,6 +149,54 @@ static const vp9_prob default_single_ref_p[REF_CONTEXTS][2] = {
{ 235, 248 },
};
+void tx_counts_to_branch_counts(unsigned int *tx_count_32x32p,
+ unsigned int *tx_count_16x16p,
+ unsigned int *tx_count_8x8p,
+ unsigned int (*ct)[2]) {
+#if TX_SIZE_PROBS == 6
+ ct[0][0] = tx_count_8x8p[TX_4X4];
+ ct[0][1] = tx_count_8x8p[TX_8X8];
+ ct[1][0] = tx_count_16x16p[TX_4X4];
+ ct[1][1] = tx_count_16x16p[TX_8X8] + tx_count_16x16p[TX_16X16];
+ ct[2][0] = tx_count_16x16p[TX_8X8];
+ ct[2][1] = tx_count_16x16p[TX_16X16];
+ ct[3][0] = tx_count_32x32p[TX_4X4];
+ ct[3][1] = tx_count_32x32p[TX_8X8] + tx_count_32x32p[TX_16X16] +
+ tx_count_32x32p[TX_32X32];
+ ct[4][0] = tx_count_32x32p[TX_8X8];
+ ct[4][1] = tx_count_32x32p[TX_16X16] + tx_count_32x32p[TX_32X32];
+ ct[5][0] = tx_count_32x32p[TX_16X16];
+ ct[5][1] = tx_count_32x32p[TX_32X32];
+#else
+ ct[0][0] = tx_count_32x32p[TX_4X4] +
+ tx_count_16x16p[TX_4X4] +
+ tx_count_8x8p[TX_4X4];
+ ct[0][1] = tx_count_32x32p[TX_8X8] +
+ tx_count_32x32p[TX_16X16] +
+ tx_count_32x32p[TX_32X32] +
+ tx_count_16x16p[TX_8X8] +
+ tx_count_16x16p[TX_16X16] +
+ tx_count_8x8p[TX_8X8];
+ ct[1][0] = tx_count_32x32p[TX_8X8] +
+ tx_count_16x16p[TX_8X8];
+ ct[1][1] = tx_count_32x32p[TX_16X16] +
+ tx_count_32x32p[TX_32X32] +
+ tx_count_16x16p[TX_16X16];
+ ct[2][0] = tx_count_32x32p[TX_16X16];
+ ct[2][1] = tx_count_32x32p[TX_32X32];
+#endif
+}
+
+#if TX_SIZE_PROBS == 6
+const vp9_prob vp9_default_tx_probs[TX_SIZE_PROBS] = {
+ 96, 96, 96, 96, 96, 96
+};
+#else
+const vp9_prob vp9_default_tx_probs[TX_SIZE_PROBS] = {
+ 96, 96, 96
+};
+#endif
+
void vp9_init_mbmode_probs(VP9_COMMON *x) {
vpx_memcpy(x->fc.uv_mode_prob, default_if_uv_probs,
sizeof(default_if_uv_probs));
@@ -171,6 +219,8 @@ void vp9_init_mbmode_probs(VP9_COMMON *x) {
sizeof(default_comp_ref_p));
vpx_memcpy(x->fc.single_ref_prob, default_single_ref_p,
sizeof(default_single_ref_p));
+ vpx_memcpy(x->fc.tx_probs, vp9_default_tx_probs,
+ sizeof(vp9_default_tx_probs));
}
#if VP9_SWITCHABLE_FILTERS == 3
@@ -374,6 +424,20 @@ void vp9_adapt_mode_probs(VP9_COMMON *cm) {
fc->switchable_interp_prob[i], 0);
}
}
+ if (cm->txfm_mode == TX_MODE_SELECT) {
+ unsigned int branch_ct[TX_SIZE_PROBS][2];
+ tx_counts_to_branch_counts(cm->fc.tx_count_32x32p,
+ cm->fc.tx_count_16x16p,
+ cm->fc.tx_count_8x8p, branch_ct);
+ for (i = 0; i < TX_SIZE_PROBS; ++i) {
+ int factor;
+ int count = branch_ct[i][0] + branch_ct[i][1];
+ vp9_prob prob = get_binary_prob(branch_ct[i][0], branch_ct[i][1]);
+ count = count > MODE_COUNT_SAT ? MODE_COUNT_SAT : count;
+ factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_COUNT_SAT);
+ cm->fc.tx_probs[i] = weighted_prob(cm->fc.pre_tx_probs[i], prob, factor);
+ }
+ }
}
static void set_default_lf_deltas(MACROBLOCKD *xd) {
@@ -385,10 +449,8 @@ static void set_default_lf_deltas(MACROBLOCKD *xd) {
xd->ref_lf_deltas[GOLDEN_FRAME] = -1;
xd->ref_lf_deltas[ALTREF_FRAME] = -1;
- xd->mode_lf_deltas[0] = 2; // I4X4_PRED
- xd->mode_lf_deltas[1] = -1; // Zero
- xd->mode_lf_deltas[2] = 1; // New mv
- xd->mode_lf_deltas[3] = 2; // Split mv
+ xd->mode_lf_deltas[0] = 0; // Zero
+ xd->mode_lf_deltas[1] = 0; // New mv
}
void vp9_setup_past_independence(VP9_COMMON *cm, MACROBLOCKD *xd) {
diff --git a/vp9/common/vp9_entropymode.h b/vp9/common/vp9_entropymode.h
index 32a40adc7..ce13a4cb1 100644
--- a/vp9/common/vp9_entropymode.h
+++ b/vp9/common/vp9_entropymode.h
@@ -75,4 +75,11 @@ extern struct vp9_token vp9_switchable_interp_encodings[VP9_SWITCHABLE_FILTERS];
extern const vp9_prob vp9_switchable_interp_prob[VP9_SWITCHABLE_FILTERS + 1]
[VP9_SWITCHABLE_FILTERS - 1];
+extern const vp9_prob vp9_default_tx_probs[TX_SIZE_PROBS];
+
+extern void tx_counts_to_branch_counts(unsigned int *tx_count_32x32p,
+ unsigned int *tx_count_16x16p,
+ unsigned int *tx_count_8x8p,
+ unsigned int (*ct)[2]);
+
#endif // VP9_COMMON_VP9_ENTROPYMODE_H_
diff --git a/vp9/common/vp9_loopfilter.c b/vp9/common/vp9_loopfilter.c
index e3d8e858d..0347630fa 100644
--- a/vp9/common/vp9_loopfilter.c
+++ b/vp9/common/vp9_loopfilter.c
@@ -17,20 +17,20 @@
#include "vp9/common/vp9_seg_common.h"
static void lf_init_lut(loop_filter_info_n *lfi) {
- lfi->mode_lf_lut[DC_PRED] = 1;
- lfi->mode_lf_lut[D45_PRED] = 1;
- lfi->mode_lf_lut[D135_PRED] = 1;
- lfi->mode_lf_lut[D117_PRED] = 1;
- lfi->mode_lf_lut[D153_PRED] = 1;
- lfi->mode_lf_lut[D27_PRED] = 1;
- lfi->mode_lf_lut[D63_PRED] = 1;
- lfi->mode_lf_lut[V_PRED] = 1;
- lfi->mode_lf_lut[H_PRED] = 1;
- lfi->mode_lf_lut[TM_PRED] = 1;
- lfi->mode_lf_lut[ZEROMV] = 1;
- lfi->mode_lf_lut[NEARESTMV] = 2;
- lfi->mode_lf_lut[NEARMV] = 2;
- lfi->mode_lf_lut[NEWMV] = 2;
+ lfi->mode_lf_lut[DC_PRED] = 0;
+ lfi->mode_lf_lut[D45_PRED] = 0;
+ lfi->mode_lf_lut[D135_PRED] = 0;
+ lfi->mode_lf_lut[D117_PRED] = 0;
+ lfi->mode_lf_lut[D153_PRED] = 0;
+ lfi->mode_lf_lut[D27_PRED] = 0;
+ lfi->mode_lf_lut[D63_PRED] = 0;
+ lfi->mode_lf_lut[V_PRED] = 0;
+ lfi->mode_lf_lut[H_PRED] = 0;
+ lfi->mode_lf_lut[TM_PRED] = 0;
+ lfi->mode_lf_lut[ZEROMV] = 0;
+ lfi->mode_lf_lut[NEARESTMV] = 1;
+ lfi->mode_lf_lut[NEARMV] = 1;
+ lfi->mode_lf_lut[NEWMV] = 1;
}
void vp9_loop_filter_update_sharpness(loop_filter_info_n *lfi,
@@ -132,13 +132,7 @@ void vp9_loop_filter_frame_init(VP9_COMMON *cm,
/* Apply delta for reference frame */
lvl_ref += xd->ref_lf_deltas[ref] << n_shift;
- /* Apply delta for Intra modes */
- mode = 0; /* I4X4_PRED */
- /* Only the split mode I4X4_PRED has a further special case */
- lvl_mode = lvl_ref + (xd->mode_lf_deltas[mode] << n_shift);
- lfi->lvl[seg][ref][mode] = clamp(lvl_mode, 0, 63);
-
- mode = 1; /* all the rest of Intra modes */
+ mode = 0; /* all the rest of Intra modes */
lvl_mode = lvl_ref;
lfi->lvl[seg][ref][mode] = clamp(lvl_mode, 0, 63);
@@ -150,7 +144,7 @@ void vp9_loop_filter_frame_init(VP9_COMMON *cm,
lvl_ref += xd->ref_lf_deltas[ref] << n_shift;
/* Apply delta for Inter modes */
- for (mode = 1; mode < 4; mode++) {
+ for (mode = 0; mode < MAX_MODE_LF_DELTAS; mode++) {
lvl_mode = lvl_ref + (xd->mode_lf_deltas[mode] << n_shift);
lfi->lvl[seg][ref][mode] = clamp(lvl_mode, 0, 63);
}
diff --git a/vp9/common/vp9_mvref_common.c b/vp9/common/vp9_mvref_common.c
index f225c0236..0a829d250 100644
--- a/vp9/common/vp9_mvref_common.c
+++ b/vp9/common/vp9_mvref_common.c
@@ -11,27 +11,34 @@
#include "vp9/common/vp9_mvref_common.h"
#define MVREF_NEIGHBOURS 8
-
-static int b_mv_ref_search[MVREF_NEIGHBOURS][2] = {
- {0, -1}, {-1, 0}, {-1, -1}, {0, -2},
- {-2, 0}, {-1, -2}, {-2, -1}, {-2, -2}
-};
-
-static int mb_mv_ref_search[MVREF_NEIGHBOURS][2] = {
- {0, -1}, {-1, 0}, {-1, -1}, {0, -3},
- {-3, 0}, {-1, -3}, {-3, -1}, {-3, -3}
-};
-
-static int sb_mv_ref_search[MVREF_NEIGHBOURS][2] = {
- {0, -1}, {-1, 0}, {2, -1}, {-1, 2},
- {-1, -1}, {0, -3}, {-3, 0}, {-1, -3}
-};
-
-static int sb64_mv_ref_search[MVREF_NEIGHBOURS][2] = {
- {0, -1}, {-1, 0}, {2, -1}, {-1, 2},
- {4, -1}, {-1, 4}, {6, -1}, {-1, -1}
+static int mv_ref_blocks[BLOCK_SIZE_TYPES][MVREF_NEIGHBOURS][2] = {
+ // SB4X4
+ {{0, -1}, {-1, 0}, {-1, -1}, {0, -2}, {-2, 0}, {-1, -2}, {-2, -1}, {-2, -2}},
+ // SB4X8
+ {{0, -1}, {-1, 0}, {-1, -1}, {0, -2}, {-2, 0}, {-1, -2}, {-2, -1}, {-2, -2}},
+ // SB8X4
+ {{0, -1}, {-1, 0}, {-1, -1}, {0, -2}, {-2, 0}, {-1, -2}, {-2, -1}, {-2, -2}},
+ // SB8X8
+ {{0, -1}, {-1, 0}, {-1, -1}, {0, -2}, {-2, 0}, {-1, -2}, {-2, -1}, {-2, -2}},
+ // SB8X16
+ {{-1, 0}, {0, -1}, {-1, 1}, {-1, -1}, {-2, 0}, {0, -2}, {-1, -2}, {-2, -1}},
+ // SB16X8
+ {{0, -1}, {-1, 0}, {1, -1}, {-1, -1}, {0, -2}, {-2, 0}, {-2, -1}, {-1, -2}},
+ // SB16X16
+ {{0, -1}, {-1, 0}, {1, -1}, {-1, 1}, {-1, -1}, {0, -3}, {-3, 0}, {-3, -3}},
+ // SB16X32
+ {{-1, 0}, {0, -1}, {-1, 2}, {-1, -1}, {1, -1}, {-3, 0}, {0, -3}, {-3, -3}},
+ // SB32X16
+ {{0, -1}, {-1, 0}, {2, -1}, {-1, -1}, {-1, 1}, {0, -3}, {-3, 0}, {-3, -3}},
+ // SB32X32
+ {{1, -1}, {-1, 1}, {2, -1}, {-1, 2}, {-1, -1}, {0, -3}, {-3, 0}, {-3, -3}},
+ // SB32X64
+ {{-1, 0}, {0, -1}, {-1, 4}, {2, -1}, {-1, -1}, {-3, 0}, {0, -3}, {-1, 2}},
+ // SB64X32
+ {{0, -1}, {-1, 0}, {4, -1}, {-1, 2}, {-1, -1}, {0, -3}, {-3, 0}, {2, -1}},
+ // SB64X64
+ {{3, -1}, {-1, 3}, {4, -1}, {-1, 4}, {-1, -1}, {0, -1}, {-1, 0}, {6, -1}}
};
-
// clamp_mv_ref
#define MV_BORDER (16 << 3) // Allow 16 pels in 1/8th pel units
@@ -42,7 +49,7 @@ static void clamp_mv_ref(const MACROBLOCKD *xd, int_mv *mv) {
xd->mb_to_bottom_edge + MV_BORDER);
}
-// Gets a candidate refenence motion vector from the given mode info
+// Gets a candidate reference motion vector from the given mode info
// structure if one exists that matches the given reference frame.
static int get_matching_candidate(const MODE_INFO *candidate_mi,
MV_REFERENCE_FRAME ref_frame,
@@ -64,7 +71,7 @@ static int get_matching_candidate(const MODE_INFO *candidate_mi,
return 1;
}
-// Gets candidate refenence motion vector(s) from the given mode info
+// Gets candidate reference motion vector(s) from the given mode info
// structure if they exists and do NOT match the given reference frame.
static void get_non_matching_candidates(const MODE_INFO *candidate_mi,
MV_REFERENCE_FRAME ref_frame,
@@ -171,13 +178,13 @@ void vp9_find_mv_refs_idx(VP9_COMMON *cm, MACROBLOCKD *xd, MODE_INFO *here,
pixels_square = pixels_high;
if (pixels_square == 64) {
- mv_ref_search = sb64_mv_ref_search;
+ mv_ref_search = mv_ref_blocks[BLOCK_SIZE_SB64X64];
} else if (pixels_square == 32) {
- mv_ref_search = sb_mv_ref_search;
+ mv_ref_search = mv_ref_blocks[BLOCK_SIZE_SB32X32];
} else if (pixels_square == 16) {
- mv_ref_search = mb_mv_ref_search;
+ mv_ref_search = mv_ref_blocks[BLOCK_SIZE_MB16X16];
} else {
- mv_ref_search = b_mv_ref_search;
+ mv_ref_search = mv_ref_blocks[BLOCK_SIZE_SB8X8];
if (mbmi->sb_type < BLOCK_SIZE_SB8X8) {
x_idx = block_idx & 1;
y_idx = block_idx >> 1;
@@ -185,26 +192,17 @@ void vp9_find_mv_refs_idx(VP9_COMMON *cm, MACROBLOCKD *xd, MODE_INFO *here,
}
}
else {
- if (mbmi->sb_type == BLOCK_SIZE_SB64X64) {
- mv_ref_search = sb64_mv_ref_search;
- } else if (mbmi->sb_type >= BLOCK_SIZE_SB32X32) {
- mv_ref_search = sb_mv_ref_search;
- } else if (mbmi->sb_type >= BLOCK_SIZE_MB16X16) {
- mv_ref_search = mb_mv_ref_search;
- } else {
- mv_ref_search = b_mv_ref_search;
- if (mbmi->sb_type < BLOCK_SIZE_SB8X8) {
- x_idx = block_idx & 1;
- y_idx = block_idx >> 1;
+ mv_ref_search = mv_ref_blocks[mbmi->sb_type];
+ if (mbmi->sb_type < BLOCK_SIZE_SB8X8) {
+ x_idx = block_idx & 1;
+ y_idx = block_idx >> 1;
}
- }
}
// We first scan for candidate vectors that match the current reference frame
// Look at nearest neigbours
for (i = 0; i < 2; ++i) {
const int mi_search_col = mi_col + mv_ref_search[i][0];
-
if ((mi_search_col >= cm->cur_tile_mi_col_start) &&
(mi_search_col < cm->cur_tile_mi_col_end) &&
((mv_ref_search[i][1] << 6) >= xd->mb_to_top_edge)) {
diff --git a/vp9/common/vp9_onyxc_int.h b/vp9/common/vp9_onyxc_int.h
index e73d88c26..dedda2069 100644
--- a/vp9/common/vp9_onyxc_int.h
+++ b/vp9/common/vp9_onyxc_int.h
@@ -89,6 +89,11 @@ typedef struct frame_contexts {
unsigned int comp_inter_count[COMP_INTER_CONTEXTS][2];
unsigned int single_ref_count[REF_CONTEXTS][2][2];
unsigned int comp_ref_count[REF_CONTEXTS][2];
+ vp9_prob tx_probs[TX_SIZE_PROBS];
+ vp9_prob pre_tx_probs[TX_SIZE_PROBS];
+ unsigned int tx_count_32x32p[TX_SIZE_MAX_SB];
+ unsigned int tx_count_16x16p[TX_SIZE_MAX_SB - 1];
+ unsigned int tx_count_8x8p[TX_SIZE_MAX_SB - 2];
} FRAME_CONTEXT;
typedef enum {
@@ -239,9 +244,6 @@ typedef struct VP9Common {
MV_REFERENCE_FRAME comp_var_ref[2];
COMPPREDMODE_TYPE comp_pred_mode;
- // FIXME contextualize
- vp9_prob prob_tx[TX_SIZE_MAX_SB - 1];
-
vp9_prob mbskip_pred_probs[MBSKIP_CONTEXTS];
FRAME_CONTEXT fc; /* this frame entropy */
diff --git a/vp9/common/vp9_reconintra.c b/vp9/common/vp9_reconintra.c
index 4a4634b63..85dfe5137 100644
--- a/vp9/common/vp9_reconintra.c
+++ b/vp9/common/vp9_reconintra.c
@@ -204,6 +204,8 @@ void vp9_build_intra_predictors(uint8_t *src, int src_stride,
// 129 G H .. S T T T T T
// ..
+ assert(bw == bh);
+
if (left_available) {
for (i = 0; i < bh; i++)
yleft_col[i] = src[i * src_stride - 1];
@@ -271,89 +273,22 @@ void vp9_build_intra_predictors(uint8_t *src, int src_stride,
}
break;
case D45_PRED:
+ d45_predictor(ypred_ptr, y_stride, bw, bh, yabove_row, yleft_col);
+ break;
case D135_PRED:
+ d135_predictor(ypred_ptr, y_stride, bw, bh, yabove_row, yleft_col);
+ break;
case D117_PRED:
+ d117_predictor(ypred_ptr, y_stride, bw, bh, yabove_row, yleft_col);
+ break;
case D153_PRED:
+ d153_predictor(ypred_ptr, y_stride, bw, bh, yabove_row, yleft_col);
+ break;
case D27_PRED:
+ d27_predictor(ypred_ptr, y_stride, bw, bh, yabove_row, yleft_col);
+ break;
case D63_PRED:
- if (bw == bh) {
- switch (mode) {
- case D45_PRED:
- d45_predictor(ypred_ptr, y_stride, bw, bh, yabove_row, yleft_col);
- break;
- case D135_PRED:
- d135_predictor(ypred_ptr, y_stride, bw, bh, yabove_row, yleft_col);
- break;
- case D117_PRED:
- d117_predictor(ypred_ptr, y_stride, bw, bh, yabove_row, yleft_col);
- break;
- case D153_PRED:
- d153_predictor(ypred_ptr, y_stride, bw, bh, yabove_row, yleft_col);
- break;
- case D27_PRED:
- d27_predictor(ypred_ptr, y_stride, bw, bh, yabove_row, yleft_col);
- break;
- case D63_PRED:
- d63_predictor(ypred_ptr, y_stride, bw, bh, yabove_row, yleft_col);
- break;
- default:
- assert(0);
- }
- } else if (bw > bh) {
- uint8_t pred[64*64];
- vpx_memset(yleft_col + bh, yleft_col[bh - 1], bw - bh);
- switch (mode) {
- case D45_PRED:
- d45_predictor(pred, 64, bw, bw, yabove_row, yleft_col);
- break;
- case D135_PRED:
- d135_predictor(pred, 64, bw, bw, yabove_row, yleft_col);
- break;
- case D117_PRED:
- d117_predictor(pred, 64, bw, bw, yabove_row, yleft_col);
- break;
- case D153_PRED:
- d153_predictor(pred, 64, bw, bw, yabove_row, yleft_col);
- break;
- case D27_PRED:
- d27_predictor(pred, 64, bw, bw, yabove_row, yleft_col);
- break;
- case D63_PRED:
- d63_predictor(pred, 64, bw, bw, yabove_row, yleft_col);
- break;
- default:
- assert(0);
- }
- for (i = 0; i < bh; i++)
- vpx_memcpy(ypred_ptr + y_stride * i, pred + i * 64, bw);
- } else {
- uint8_t pred[64 * 64];
- vpx_memset(yabove_row + bw * 2, yabove_row[bw * 2 - 1], (bh - bw) * 2);
- switch (mode) {
- case D45_PRED:
- d45_predictor(pred, 64, bh, bh, yabove_row, yleft_col);
- break;
- case D135_PRED:
- d135_predictor(pred, 64, bh, bh, yabove_row, yleft_col);
- break;
- case D117_PRED:
- d117_predictor(pred, 64, bh, bh, yabove_row, yleft_col);
- break;
- case D153_PRED:
- d153_predictor(pred, 64, bh, bh, yabove_row, yleft_col);
- break;
- case D27_PRED:
- d27_predictor(pred, 64, bh, bh, yabove_row, yleft_col);
- break;
- case D63_PRED:
- d63_predictor(pred, 64, bh, bh, yabove_row, yleft_col);
- break;
- default:
- assert(0);
- }
- for (i = 0; i < bh; i++)
- vpx_memcpy(ypred_ptr + y_stride * i, pred + i * 64, bw);
- }
+ d63_predictor(ypred_ptr, y_stride, bw, bh, yabove_row, yleft_col);
break;
default:
break;
diff --git a/vp9/common/vp9_seg_common.c b/vp9/common/vp9_seg_common.c
index 67dfeaed6..890dcce37 100644
--- a/vp9/common/vp9_seg_common.c
+++ b/vp9/common/vp9_seg_common.c
@@ -13,7 +13,7 @@
#include "vp9/common/vp9_seg_common.h"
static const int seg_feature_data_signed[SEG_LVL_MAX] = { 1, 1, 0, 0 };
-static const int seg_feature_data_max[SEG_LVL_MAX] = { MAXQ, 63, 15, 15 };
+static const int seg_feature_data_max[SEG_LVL_MAX] = { MAXQ, 63, 15, 0 };
// These functions provide access to new segment level features.
// Eventually these function may be "optimized out" but for the moment,
diff --git a/vp9/decoder/vp9_decodemv.c b/vp9/decoder/vp9_decodemv.c
index 69adb8caf..cb16ccdf3 100644
--- a/vp9/decoder/vp9_decodemv.c
+++ b/vp9/decoder/vp9_decodemv.c
@@ -64,12 +64,20 @@ static void set_segment_id(VP9_COMMON *cm, MB_MODE_INFO *mbmi,
}
static TX_SIZE select_txfm_size(VP9_COMMON *cm, vp9_reader *r,
- int allow_16x16, int allow_32x32) {
- TX_SIZE txfm_size = vp9_read(r, cm->prob_tx[0]); // TX_4X4 or >TX_4X4
- if (txfm_size != TX_4X4 && allow_16x16) {
- txfm_size += vp9_read(r, cm->prob_tx[1]); // TX_8X8 or >TX_8X8
- if (txfm_size != TX_8X8 && allow_32x32)
- txfm_size += vp9_read(r, cm->prob_tx[2]); // TX_16X16 or >TX_16X16
+ BLOCK_SIZE_TYPE bsize) {
+ int tx_probs_offset = get_tx_probs_offset(bsize);
+ TX_SIZE txfm_size = vp9_read(r, cm->fc.tx_probs[tx_probs_offset]);
+ if (txfm_size != TX_4X4 && bsize >= BLOCK_SIZE_MB16X16) {
+ txfm_size += vp9_read(r, cm->fc.tx_probs[tx_probs_offset + 1]);
+ if (txfm_size != TX_8X8 && bsize >= BLOCK_SIZE_SB32X32)
+ txfm_size += vp9_read(r, cm->fc.tx_probs[tx_probs_offset + 2]);
+ }
+ if (bsize >= BLOCK_SIZE_SB32X32) {
+ cm->fc.tx_count_32x32p[txfm_size]++;
+ } else if (bsize >= BLOCK_SIZE_MB16X16) {
+ cm->fc.tx_count_16x16p[txfm_size]++;
+ } else {
+ cm->fc.tx_count_8x8p[txfm_size]++;
}
return txfm_size;
}
@@ -96,9 +104,7 @@ static void kfread_modes(VP9D_COMP *pbi, MODE_INFO *m,
if (cm->txfm_mode == TX_MODE_SELECT &&
m->mbmi.sb_type >= BLOCK_SIZE_SB8X8) {
- const int allow_16x16 = m->mbmi.sb_type >= BLOCK_SIZE_MB16X16;
- const int allow_32x32 = m->mbmi.sb_type >= BLOCK_SIZE_SB32X32;
- m->mbmi.txfm_size = select_txfm_size(cm, r, allow_16x16, allow_32x32);
+ m->mbmi.txfm_size = select_txfm_size(cm, r, m->mbmi.sb_type);
} else if (cm->txfm_mode >= ALLOW_32X32 &&
m->mbmi.sb_type >= BLOCK_SIZE_SB32X32) {
m->mbmi.txfm_size = TX_32X32;
@@ -537,9 +543,7 @@ static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
if (cm->txfm_mode == TX_MODE_SELECT &&
(mbmi->mb_skip_coeff == 0 || mbmi->ref_frame[0] == INTRA_FRAME) &&
bsize >= BLOCK_SIZE_SB8X8) {
- const int allow_16x16 = bsize >= BLOCK_SIZE_MB16X16;
- const int allow_32x32 = bsize >= BLOCK_SIZE_SB32X32;
- mbmi->txfm_size = select_txfm_size(cm, r, allow_16x16, allow_32x32);
+ mbmi->txfm_size = select_txfm_size(cm, r, bsize);
} else if (bsize >= BLOCK_SIZE_SB32X32 &&
cm->txfm_mode >= ALLOW_32X32) {
mbmi->txfm_size = TX_32X32;
diff --git a/vp9/decoder/vp9_decodframe.c b/vp9/decoder/vp9_decodframe.c
index 632560798..0d7ffaa80 100644
--- a/vp9/decoder/vp9_decodframe.c
+++ b/vp9/decoder/vp9_decodframe.c
@@ -57,11 +57,16 @@ static void setup_txfm_mode(VP9_COMMON *pc, int lossless, vp9_reader *r) {
pc->txfm_mode = vp9_read_literal(r, 2);
if (pc->txfm_mode == ALLOW_32X32)
pc->txfm_mode += vp9_read_bit(r);
-
if (pc->txfm_mode == TX_MODE_SELECT) {
- pc->prob_tx[0] = vp9_read_prob(r);
- pc->prob_tx[1] = vp9_read_prob(r);
- pc->prob_tx[2] = vp9_read_prob(r);
+ int i;
+ for (i = 0; i < TX_SIZE_PROBS; ++i) {
+ if (vp9_read(r, VP9_DEF_UPDATE_PROB))
+ pc->fc.tx_probs[i] =
+ vp9_read_prob_diff_update(r, pc->fc.tx_probs[i]);
+ }
+ } else {
+ vpx_memcpy(pc->fc.tx_probs, vp9_default_tx_probs,
+ sizeof(vp9_default_tx_probs));
}
}
}
@@ -779,6 +784,7 @@ static void update_frame_context(FRAME_CONTEXT *fc) {
fc->pre_nmvc = fc->nmvc;
vp9_copy(fc->pre_switchable_interp_prob, fc->switchable_interp_prob);
vp9_copy(fc->pre_inter_mode_probs, fc->inter_mode_probs);
+ vp9_copy(fc->pre_tx_probs, fc->tx_probs);
vp9_zero(fc->coef_counts);
vp9_zero(fc->eob_branch_counts);
@@ -792,6 +798,9 @@ static void update_frame_context(FRAME_CONTEXT *fc) {
vp9_zero(fc->comp_inter_count);
vp9_zero(fc->single_ref_count);
vp9_zero(fc->comp_ref_count);
+ vp9_zero(fc->tx_count_8x8p);
+ vp9_zero(fc->tx_count_16x16p);
+ vp9_zero(fc->tx_count_32x32p);
}
static void decode_tile(VP9D_COMP *pbi, vp9_reader *r) {
@@ -1068,10 +1077,10 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
pc->fc = pc->frame_contexts[pc->frame_context_idx];
- setup_txfm_mode(pc, xd->lossless, &header_bc);
-
update_frame_context(&pc->fc);
+ setup_txfm_mode(pc, xd->lossless, &header_bc);
+
read_coef_probs(pbi, &header_bc);
// Initialize xd pointers. Any reference should do for xd->pre, so use 0.
diff --git a/vp9/decoder/vp9_detokenize.c b/vp9/decoder/vp9_detokenize.c
index 655c358eb..d06c9b000 100644
--- a/vp9/decoder/vp9_detokenize.c
+++ b/vp9/decoder/vp9_detokenize.c
@@ -293,7 +293,7 @@ SKIP_START:
}
static int get_eob(MACROBLOCKD* const xd, int segment_id, int eob_max) {
- return vp9_get_segdata(xd, segment_id, SEG_LVL_SKIP) ? 0 : eob_max;
+ return vp9_segfeature_active(xd, segment_id, SEG_LVL_SKIP) ? 0 : eob_max;
}
struct decode_block_args {
diff --git a/vp9/encoder/vp9_bitstream.c b/vp9/encoder/vp9_bitstream.c
index c0da212f4..aea9fb6b1 100644
--- a/vp9/encoder/vp9_bitstream.c
+++ b/vp9/encoder/vp9_bitstream.c
@@ -575,12 +575,12 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, MODE_INFO *m,
!(rf != INTRA_FRAME &&
(skip_coeff || vp9_segfeature_active(xd, segment_id, SEG_LVL_SKIP)))) {
TX_SIZE sz = mi->txfm_size;
- // FIXME(rbultje) code ternary symbol once all experiments are merged
- vp9_write(bc, sz != TX_4X4, pc->prob_tx[0]);
+ int tx_probs_offset = get_tx_probs_offset(mi->sb_type);
+ vp9_write(bc, sz != TX_4X4, pc->fc.tx_probs[tx_probs_offset]);
if (mi->sb_type >= BLOCK_SIZE_MB16X16 && sz != TX_4X4) {
- vp9_write(bc, sz != TX_8X8, pc->prob_tx[1]);
+ vp9_write(bc, sz != TX_8X8, pc->fc.tx_probs[tx_probs_offset + 1]);
if (mi->sb_type >= BLOCK_SIZE_SB32X32 && sz != TX_8X8)
- vp9_write(bc, sz != TX_16X16, pc->prob_tx[2]);
+ vp9_write(bc, sz != TX_16X16, pc->fc.tx_probs[tx_probs_offset + 2]);
}
}
@@ -706,12 +706,12 @@ static void write_mb_modes_kf(const VP9_COMP *cpi,
if (m->mbmi.sb_type >= BLOCK_SIZE_SB8X8 && c->txfm_mode == TX_MODE_SELECT) {
TX_SIZE sz = m->mbmi.txfm_size;
- // FIXME(rbultje) code ternary symbol once all experiments are merged
- vp9_write(bc, sz != TX_4X4, c->prob_tx[0]);
+ int tx_probs_offset = get_tx_probs_offset(m->mbmi.sb_type);
+ vp9_write(bc, sz != TX_4X4, c->fc.tx_probs[tx_probs_offset]);
if (m->mbmi.sb_type >= BLOCK_SIZE_MB16X16 && sz != TX_4X4) {
- vp9_write(bc, sz != TX_8X8, c->prob_tx[1]);
+ vp9_write(bc, sz != TX_8X8, c->fc.tx_probs[tx_probs_offset + 1]);
if (m->mbmi.sb_type >= BLOCK_SIZE_SB32X32 && sz != TX_8X8)
- vp9_write(bc, sz != TX_16X16, c->prob_tx[2]);
+ vp9_write(bc, sz != TX_16X16, c->fc.tx_probs[tx_probs_offset + 2]);
}
}
@@ -1217,7 +1217,7 @@ static void encode_segmentation(VP9_COMP *cpi,
}
-static void encode_txfm(VP9_COMP *cpi, vp9_writer *w) {
+static void encode_txfm_probs(VP9_COMP *cpi, vp9_writer *w) {
VP9_COMMON *const cm = &cpi->common;
// Mode
@@ -1227,35 +1227,19 @@ static void encode_txfm(VP9_COMP *cpi, vp9_writer *w) {
// Probabilities
if (cm->txfm_mode == TX_MODE_SELECT) {
- cm->prob_tx[0] = get_prob(cpi->txfm_count_32x32p[TX_4X4] +
- cpi->txfm_count_16x16p[TX_4X4] +
- cpi->txfm_count_8x8p[TX_4X4],
- cpi->txfm_count_32x32p[TX_4X4] +
- cpi->txfm_count_32x32p[TX_8X8] +
- cpi->txfm_count_32x32p[TX_16X16] +
- cpi->txfm_count_32x32p[TX_32X32] +
- cpi->txfm_count_16x16p[TX_4X4] +
- cpi->txfm_count_16x16p[TX_8X8] +
- cpi->txfm_count_16x16p[TX_16X16] +
- cpi->txfm_count_8x8p[TX_4X4] +
- cpi->txfm_count_8x8p[TX_8X8]);
- cm->prob_tx[1] = get_prob(cpi->txfm_count_32x32p[TX_8X8] +
- cpi->txfm_count_16x16p[TX_8X8],
- cpi->txfm_count_32x32p[TX_8X8] +
- cpi->txfm_count_32x32p[TX_16X16] +
- cpi->txfm_count_32x32p[TX_32X32] +
- cpi->txfm_count_16x16p[TX_8X8] +
- cpi->txfm_count_16x16p[TX_16X16]);
- cm->prob_tx[2] = get_prob(cpi->txfm_count_32x32p[TX_16X16],
- cpi->txfm_count_32x32p[TX_16X16] +
- cpi->txfm_count_32x32p[TX_32X32]);
- vp9_write_prob(w, cm->prob_tx[0]);
- vp9_write_prob(w, cm->prob_tx[1]);
- vp9_write_prob(w, cm->prob_tx[2]);
+ int i;
+ unsigned int ct[TX_SIZE_PROBS][2];
+ tx_counts_to_branch_counts(cm->fc.tx_count_32x32p,
+ cm->fc.tx_count_16x16p,
+ cm->fc.tx_count_8x8p, ct);
+
+ for (i = 0; i < TX_SIZE_PROBS; i++) {
+ vp9_cond_prob_diff_update(w, &cm->fc.tx_probs[i],
+ VP9_DEF_UPDATE_PROB, ct[i]);
+ }
} else {
- cm->prob_tx[0] = 128;
- cm->prob_tx[1] = 128;
- cm->prob_tx[2] = 128;
+ vpx_memcpy(cm->fc.tx_probs, vp9_default_tx_probs,
+ sizeof(vp9_default_tx_probs));
}
}
@@ -1460,11 +1444,6 @@ void vp9_pack_bitstream(VP9_COMP *cpi, uint8_t *dest, unsigned long *size) {
active_section = 7;
#endif
- if (xd->lossless)
- pc->txfm_mode = ONLY_4X4;
- else
- encode_txfm(cpi, &header_bc);
-
vp9_clear_system_state(); // __asm emms;
vp9_copy(pc->fc.pre_coef_probs, pc->fc.coef_probs);
@@ -1480,6 +1459,13 @@ void vp9_pack_bitstream(VP9_COMP *cpi, uint8_t *dest, unsigned long *size) {
vp9_copy(pc->fc.pre_comp_ref_prob, pc->fc.comp_ref_prob);
vp9_copy(pc->fc.pre_single_ref_prob, pc->fc.single_ref_prob);
cpi->common.fc.pre_nmvc = cpi->common.fc.nmvc;
+ vp9_copy(cpi->common.fc.pre_tx_probs, cpi->common.fc.tx_probs);
+
+ if (xd->lossless) {
+ pc->txfm_mode = ONLY_4X4;
+ } else {
+ encode_txfm_probs(cpi, &header_bc);
+ }
update_coef_probs(cpi, &header_bc);
diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c
index 26ec57ec2..898030604 100644
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -448,8 +448,8 @@ static void update_state(VP9_COMP *cpi,
int i, j;
for (j = 0; j < bh; ++j)
for (i = 0; i < bw; ++i)
- if ((xd->mb_to_right_edge >> (3 + LOG2_MI_SIZE)) + bw > j &&
- (xd->mb_to_bottom_edge >> (3 + LOG2_MI_SIZE)) + bh > i)
+ if ((xd->mb_to_right_edge >> (3 + LOG2_MI_SIZE)) + bw > i &&
+ (xd->mb_to_bottom_edge >> (3 + LOG2_MI_SIZE)) + bh > j)
xd->mode_info_context[mis * j + i].mbmi = *mbmi;
}
@@ -1464,12 +1464,15 @@ static void init_encode_frame_mb_context(VP9_COMP *cpi) {
vp9_zero(cpi->y_mode_count)
vp9_zero(cpi->y_uv_mode_count)
- vp9_zero(cpi->common.fc.inter_mode_counts)
+ vp9_zero(cm->fc.inter_mode_counts)
vp9_zero(cpi->partition_count);
vp9_zero(cpi->intra_inter_count);
vp9_zero(cpi->comp_inter_count);
vp9_zero(cpi->single_ref_count);
vp9_zero(cpi->comp_ref_count);
+ vp9_zero(cm->fc.tx_count_32x32p);
+ vp9_zero(cm->fc.tx_count_16x16p);
+ vp9_zero(cm->fc.tx_count_8x8p);
// Note: this memset assumes above_context[0], [1] and [2]
// are allocated as part of the same buffer.
@@ -1560,9 +1563,6 @@ static void encode_frame_internal(VP9_COMP *cpi) {
init_encode_frame_mb_context(cpi);
vpx_memset(cpi->rd_comp_pred_diff, 0, sizeof(cpi->rd_comp_pred_diff));
- vpx_memset(cpi->txfm_count_32x32p, 0, sizeof(cpi->txfm_count_32x32p));
- vpx_memset(cpi->txfm_count_16x16p, 0, sizeof(cpi->txfm_count_16x16p));
- vpx_memset(cpi->txfm_count_8x8p, 0, sizeof(cpi->txfm_count_8x8p));
vpx_memset(cpi->rd_tx_select_diff, 0, sizeof(cpi->rd_tx_select_diff));
vpx_memset(cpi->rd_tx_select_threshes, 0, sizeof(cpi->rd_tx_select_threshes));
@@ -1752,10 +1752,16 @@ static void reset_skip_txfm_size(VP9_COMP *cpi, TX_SIZE txfm_max) {
void vp9_encode_frame(VP9_COMP *cpi) {
VP9_COMMON *const cm = &cpi->common;
- if (cm->ref_frame_sign_bias[LAST_FRAME] ==
- cm->ref_frame_sign_bias[GOLDEN_FRAME] &&
- cm->ref_frame_sign_bias[LAST_FRAME] ==
- cm->ref_frame_sign_bias[ALTREF_FRAME]) {
+ // In the longer term the encoder should be generalized to match the
+ // decoder such that we allow compound where one of the 3 buffers has a
+ // differnt sign bias and that buffer is then the fixed ref. However, this
+ // requires further work in the rd loop. For now the only supported encoder
+ // side behaviour is where the ALT ref buffer has oppositie sign bias to
+ // the other two.
+ if ((cm->ref_frame_sign_bias[ALTREF_FRAME] ==
+ cm->ref_frame_sign_bias[GOLDEN_FRAME]) ||
+ (cm->ref_frame_sign_bias[ALTREF_FRAME] ==
+ cm->ref_frame_sign_bias[LAST_FRAME])) {
cm->allow_comp_inter_inter = 0;
} else {
cm->allow_comp_inter_inter = 1;
@@ -1841,11 +1847,6 @@ void vp9_encode_frame(VP9_COMP *cpi) {
ALLOW_32X32 : TX_MODE_SELECT;
#endif
cpi->common.txfm_mode = txfm_type;
- if (txfm_type != TX_MODE_SELECT) {
- cpi->common.prob_tx[0] = 128;
- cpi->common.prob_tx[1] = 128;
- cpi->common.prob_tx[2] = 128;
- }
cpi->common.comp_pred_mode = pred_type;
encode_frame_internal(cpi);
@@ -1885,15 +1886,15 @@ void vp9_encode_frame(VP9_COMP *cpi) {
}
if (cpi->common.txfm_mode == TX_MODE_SELECT) {
- const int count4x4 = cpi->txfm_count_16x16p[TX_4X4] +
- cpi->txfm_count_32x32p[TX_4X4] +
- cpi->txfm_count_8x8p[TX_4X4];
- const int count8x8_lp = cpi->txfm_count_32x32p[TX_8X8] +
- cpi->txfm_count_16x16p[TX_8X8];
- const int count8x8_8x8p = cpi->txfm_count_8x8p[TX_8X8];
- const int count16x16_16x16p = cpi->txfm_count_16x16p[TX_16X16];
- const int count16x16_lp = cpi->txfm_count_32x32p[TX_16X16];
- const int count32x32 = cpi->txfm_count_32x32p[TX_32X32];
+ const int count4x4 = cm->fc.tx_count_16x16p[TX_4X4] +
+ cm->fc.tx_count_32x32p[TX_4X4] +
+ cm->fc.tx_count_8x8p[TX_4X4];
+ const int count8x8_lp = cm->fc.tx_count_32x32p[TX_8X8] +
+ cm->fc.tx_count_16x16p[TX_8X8];
+ const int count8x8_8x8p = cm->fc.tx_count_8x8p[TX_8X8];
+ const int count16x16_16x16p = cm->fc.tx_count_16x16p[TX_16X16];
+ const int count16x16_lp = cm->fc.tx_count_32x32p[TX_16X16];
+ const int count32x32 = cm->fc.tx_count_32x32p[TX_32X32];
if (count4x4 == 0 && count16x16_lp == 0 && count16x16_16x16p == 0 &&
count32x32 == 0) {
@@ -2077,11 +2078,11 @@ static void encode_superblock(VP9_COMP *cpi, TOKENEXTRA **t,
!(mbmi->ref_frame[0] != INTRA_FRAME && (mbmi->mb_skip_coeff ||
vp9_segfeature_active(xd, segment_id, SEG_LVL_SKIP)))) {
if (bsize >= BLOCK_SIZE_SB32X32) {
- cpi->txfm_count_32x32p[mbmi->txfm_size]++;
+ cm->fc.tx_count_32x32p[mbmi->txfm_size]++;
} else if (bsize >= BLOCK_SIZE_MB16X16) {
- cpi->txfm_count_16x16p[mbmi->txfm_size]++;
+ cm->fc.tx_count_16x16p[mbmi->txfm_size]++;
} else {
- cpi->txfm_count_8x8p[mbmi->txfm_size]++;
+ cm->fc.tx_count_8x8p[mbmi->txfm_size]++;
}
} else {
int x, y;
diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c
index 4ca5ef3ec..73220dcd9 100644
--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -575,10 +575,8 @@ static void set_default_lf_deltas(VP9_COMP *cpi) {
cpi->mb.e_mbd.ref_lf_deltas[GOLDEN_FRAME] = -2;
cpi->mb.e_mbd.ref_lf_deltas[ALTREF_FRAME] = -2;
- cpi->mb.e_mbd.mode_lf_deltas[0] = 4; // I4X4_PRED
- cpi->mb.e_mbd.mode_lf_deltas[1] = -2; // Zero
- cpi->mb.e_mbd.mode_lf_deltas[2] = 2; // New mv
- cpi->mb.e_mbd.mode_lf_deltas[3] = 4; // Split mv
+ cpi->mb.e_mbd.mode_lf_deltas[0] = 0; // Zero
+ cpi->mb.e_mbd.mode_lf_deltas[1] = 0; // New mv
}
static void set_rd_speed_thresholds(VP9_COMP *cpi, int mode, int speed) {
@@ -746,7 +744,7 @@ void vp9_set_speed_features(VP9_COMP *cpi) {
// Switch segmentation off.
sf->static_segmentation = 0;
#else
- sf->static_segmentation = 0;
+ sf->static_segmentation = 0;
#endif
sf->comp_inter_joint_search_thresh = BLOCK_SIZE_SB8X8;
sf->adpative_rd_thresh = 1;
@@ -1298,8 +1296,6 @@ VP9_PTR vp9_create_compressor(VP9_CONFIG *oxcf) {
cpi->frames_till_gf_update_due = 0;
cpi->gf_overspend_bits = 0;
cpi->non_gf_bitrate_adjustment = 0;
- for (i = 0; i < TX_SIZE_MAX_SB - 1; i++)
- cm->prob_tx[i] = 128;
// Set reference frame sign bias for ALTREF frame to 1 (for now)
cpi->common.ref_frame_sign_bias[ALTREF_FRAME] = 1;
diff --git a/vp9/encoder/vp9_onyx_int.h b/vp9/encoder/vp9_onyx_int.h
index 79a57eeb6..b8a60d2f2 100644
--- a/vp9/encoder/vp9_onyx_int.h
+++ b/vp9/encoder/vp9_onyx_int.h
@@ -74,7 +74,7 @@ typedef struct {
// 0 = Intra, Last, GF, ARF
signed char last_ref_lf_deltas[MAX_REF_LF_DELTAS];
- // 0 = I4X4_PRED, ZERO_MV, MV, SPLIT
+ // 0 = ZERO_MV, MV
signed char last_mode_lf_deltas[MAX_MODE_LF_DELTAS];
vp9_coeff_probs_model coef_probs[TX_SIZE_MAX_SB][BLOCK_TYPES];
@@ -89,6 +89,7 @@ typedef struct {
int inter_mode_counts[INTER_MODE_CONTEXTS][VP9_INTER_MODES - 1][2];
vp9_prob inter_mode_probs[INTER_MODE_CONTEXTS][VP9_INTER_MODES - 1];
+ vp9_prob tx_probs[TX_SIZE_PROBS];
} CODING_CONTEXT;
typedef struct {
@@ -326,9 +327,7 @@ typedef struct VP9_COMP {
unsigned int comp_ref_count[REF_CONTEXTS][2];
// FIXME contextualize
- int txfm_count_32x32p[TX_SIZE_MAX_SB];
- int txfm_count_16x16p[TX_SIZE_MAX_SB - 1];
- int txfm_count_8x8p[TX_SIZE_MAX_SB - 2];
+
int64_t rd_tx_select_diff[NB_TXFM_MODES];
int rd_tx_select_threshes[4][NB_TXFM_MODES];
diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c
index 9515ea4a5..60ca355c5 100644
--- a/vp9/encoder/vp9_ratectrl.c
+++ b/vp9/encoder/vp9_ratectrl.c
@@ -143,6 +143,7 @@ void vp9_save_coding_context(VP9_COMP *cpi) {
vp9_copy(cc->coef_probs, cm->fc.coef_probs);
vp9_copy(cc->switchable_interp_prob, cm->fc.switchable_interp_prob);
+ vp9_copy(cc->tx_probs, cm->fc.tx_probs);
}
void vp9_restore_coding_context(VP9_COMP *cpi) {
@@ -180,6 +181,7 @@ void vp9_restore_coding_context(VP9_COMP *cpi) {
vp9_copy(cm->fc.coef_probs, cc->coef_probs);
vp9_copy(cm->fc.switchable_interp_prob, cc->switchable_interp_prob);
+ vp9_copy(cm->fc.tx_probs, cc->tx_probs);
}
void vp9_setup_key_frame(VP9_COMP *cpi) {
diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c
index 8eedfc13a..0fea2b931 100644
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -420,6 +420,7 @@ static void choose_txfm_size_from_rd(VP9_COMP *cpi, MACROBLOCK *x,
int *d, int *distortion,
int *s, int *skip,
int64_t txfm_cache[NB_TXFM_MODES],
+ BLOCK_SIZE_TYPE bs,
TX_SIZE max_txfm_size) {
VP9_COMMON *const cm = &cpi->common;
MACROBLOCKD *const xd = &x->e_mbd;
@@ -429,13 +430,15 @@ static void choose_txfm_size_from_rd(VP9_COMP *cpi, MACROBLOCK *x,
int n, m;
int s0, s1;
+ int tx_probs_offset = get_tx_probs_offset(bs);
+
for (n = TX_4X4; n <= max_txfm_size; n++) {
r[n][1] = r[n][0];
for (m = 0; m <= n - (n == max_txfm_size); m++) {
if (m == n)
- r[n][1] += vp9_cost_zero(cm->prob_tx[m]);
+ r[n][1] += vp9_cost_zero(cm->fc.tx_probs[tx_probs_offset + m]);
else
- r[n][1] += vp9_cost_one(cm->prob_tx[m]);
+ r[n][1] += vp9_cost_one(cm->fc.tx_probs[tx_probs_offset + m]);
}
}
@@ -608,6 +611,8 @@ static void super_block_yrd(VP9_COMP *cpi,
MACROBLOCKD *xd = &x->e_mbd;
MB_MODE_INFO *const mbmi = &xd->mode_info_context->mbmi;
+ assert(bs == mbmi->sb_type);
+
if (mbmi->ref_frame[0] > INTRA_FRAME)
vp9_subtract_sby(x, bs);
@@ -637,7 +642,8 @@ static void super_block_yrd(VP9_COMP *cpi,
super_block_yrd_for_txfm(cm, x, &r[TX_4X4][0], &d[TX_4X4], &s[TX_4X4], bs,
TX_4X4);
- choose_txfm_size_from_rd(cpi, x, r, rate, d, distortion, s, skip, txfm_cache,
+ choose_txfm_size_from_rd(cpi, x, r, rate, d, distortion, s,
+ skip, txfm_cache, bs,
TX_32X32 - (bs < BLOCK_SIZE_SB32X32)
- (bs < BLOCK_SIZE_MB16X16));
}
diff --git a/vp9/vp9_iface_common.h b/vp9/vp9_iface_common.h
index dc41d77d1..1c3cc62d2 100644
--- a/vp9/vp9_iface_common.h
+++ b/vp9/vp9_iface_common.h
@@ -29,7 +29,7 @@ static void yuvconfig2image(vpx_image_t *img, const YV12_BUFFER_CONFIG *yv12,
img->fmt = VPX_IMG_FMT_I420;
}
img->w = yv12->y_stride;
- img->h = multiple8(yv12->y_height + 2 * VP9BORDERINPIXELS);
+ img->h = multiple16(yv12->y_height + 2 * VP9BORDERINPIXELS);
img->d_w = yv12->y_crop_width;
img->d_h = yv12->y_crop_height;
img->x_chroma_shift = yv12->uv_width < yv12->y_width;