Commit bdaa2576 authored by Debargha Mukherjee's avatar Debargha Mukherjee Committed by Gerrit Code Review

Merge "Refactoring tx-types to add more flexibility" into nextgenv2

parents fff67045 8a429244
...@@ -32,11 +32,6 @@ extern "C" { ...@@ -32,11 +32,6 @@ extern "C" {
#define MAX_MB_PLANE 3 #define MAX_MB_PLANE 3
#if CONFIG_EXT_TX
#define GET_TX_TYPES(tx_size) \
((tx_size) >= TX_32X32 ? 1 : TX_TYPES)
#endif // CONFIG_EXT_TX
typedef enum { typedef enum {
KEY_FRAME = 0, KEY_FRAME = 0,
INTER_FRAME = 1, INTER_FRAME = 1,
...@@ -250,6 +245,58 @@ static const TX_TYPE intra_mode_to_tx_type_lookup[INTRA_MODES] = { ...@@ -250,6 +245,58 @@ static const TX_TYPE intra_mode_to_tx_type_lookup[INTRA_MODES] = {
ADST_ADST, // TM ADST_ADST, // TM
}; };
#if CONFIG_EXT_TX
static const int num_ext_tx_set_inter[EXT_TX_SETS_INTER] = {
1, 17, 10, 2
};
static const int num_ext_tx_set_intra[EXT_TX_SETS_INTRA] = {
1, 17,
};
#define USE_IDTX_FOR_32X32 0
static INLINE int get_ext_tx_set(TX_SIZE tx_size, BLOCK_SIZE bs,
int is_inter) {
(void) is_inter;
if (tx_size > TX_32X32 || bs < BLOCK_8X8) return 0;
#if USE_IDTX_FOR_32X32
if (tx_size == TX_32X32) return is_inter ? 3 : 0;
#else
if (tx_size == TX_32X32) return 0;
#endif
return 1;
}
static INLINE int get_ext_tx_types(TX_SIZE tx_size, BLOCK_SIZE bs,
int is_inter) {
const int set = get_ext_tx_set(tx_size, bs, is_inter);
return is_inter ? num_ext_tx_set_inter[set] : num_ext_tx_set_intra[set];
}
static const int use_intra_ext_tx_for_tx[EXT_TX_SETS_INTRA][TX_SIZES] = {
{ 0, 0, 0, 0, }, // unused
{ 1, 1, 1, 0, },
};
static const int use_inter_ext_tx_for_tx[EXT_TX_SETS_INTER][TX_SIZES] = {
{ 0, 0, 0, 0, }, // unused
{ 1, 1, 1, 0, },
{ 0, 0, 0, 0, },
{ 0, 0, 0, USE_IDTX_FOR_32X32, },
};
static const int ext_tx_used_intra[EXT_TX_SETS_INTRA][TX_TYPES] = {
{ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, },
};
static const int ext_tx_used_inter[EXT_TX_SETS_INTER][TX_TYPES] = {
{ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, },
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, },
{ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, },
};
#endif // CONFIG_EXT_TX
static INLINE TX_TYPE get_tx_type(PLANE_TYPE plane_type, static INLINE TX_TYPE get_tx_type(PLANE_TYPE plane_type,
const MACROBLOCKD *xd, const MACROBLOCKD *xd,
int block_idx, TX_SIZE tx_size) { int block_idx, TX_SIZE tx_size) {
...@@ -257,16 +304,27 @@ static INLINE TX_TYPE get_tx_type(PLANE_TYPE plane_type, ...@@ -257,16 +304,27 @@ static INLINE TX_TYPE get_tx_type(PLANE_TYPE plane_type,
const MB_MODE_INFO *const mbmi = &mi->mbmi; const MB_MODE_INFO *const mbmi = &mi->mbmi;
#if CONFIG_EXT_TX #if CONFIG_EXT_TX
if ( xd->lossless[mbmi->segment_id] || tx_size >= TX_32X32) #if USE_IDTX_FOR_32X32
if (xd->lossless[mbmi->segment_id] || tx_size > TX_32X32 ||
(tx_size >= TX_32X32 && !is_inter_block(mbmi)))
#else
if (xd->lossless[mbmi->segment_id] || tx_size >= TX_32X32)
#endif
return DCT_DCT; return DCT_DCT;
if (mbmi->sb_type >= BLOCK_8X8) { if (mbmi->sb_type >= BLOCK_8X8) {
if (plane_type == PLANE_TYPE_Y || is_inter_block(mbmi)) if (plane_type == PLANE_TYPE_Y)
return mbmi->tx_type; return mbmi->tx_type;
if (is_inter_block(mbmi))
// UV Inter only
return (mbmi->tx_type == IDTX && tx_size == TX_32X32 ?
DCT_DCT : mbmi->tx_type);
// return mbmi->tx_type;
} }
if (is_inter_block(mbmi)) // Sub8x8-Inter/Intra OR UV-Intra
if (is_inter_block(mbmi)) // Sub8x8-Inter
return DCT_DCT; return DCT_DCT;
else else // Sub8x8 Intra OR UV-Intra
return intra_mode_to_tx_type_lookup[plane_type == PLANE_TYPE_Y ? return intra_mode_to_tx_type_lookup[plane_type == PLANE_TYPE_Y ?
get_y_mode(mi, block_idx) : mbmi->uv_mode]; get_y_mode(mi, block_idx) : mbmi->uv_mode];
#else #else
......
This diff is collapsed.
...@@ -70,8 +70,9 @@ typedef struct frame_contexts { ...@@ -70,8 +70,9 @@ typedef struct frame_contexts {
vpx_prob skip_probs[SKIP_CONTEXTS]; vpx_prob skip_probs[SKIP_CONTEXTS];
nmv_context nmvc; nmv_context nmvc;
#if CONFIG_EXT_TX #if CONFIG_EXT_TX
vpx_prob inter_tx_type_prob[EXT_TX_SIZES][TX_TYPES - 1]; vpx_prob inter_ext_tx_prob[EXT_TX_SETS_INTER][EXT_TX_SIZES][TX_TYPES - 1];
vpx_prob intra_tx_type_prob[EXT_TX_SIZES][INTRA_MODES][TX_TYPES - 1]; vpx_prob intra_ext_tx_prob[EXT_TX_SETS_INTRA][EXT_TX_SIZES][INTRA_MODES]
[TX_TYPES - 1];
#endif // CONFIG_EXT_TX #endif // CONFIG_EXT_TX
#if CONFIG_MISC_FIXES #if CONFIG_MISC_FIXES
struct segmentation_probs seg; struct segmentation_probs seg;
...@@ -98,8 +99,9 @@ typedef struct FRAME_COUNTS { ...@@ -98,8 +99,9 @@ typedef struct FRAME_COUNTS {
unsigned int skip[SKIP_CONTEXTS][2]; unsigned int skip[SKIP_CONTEXTS][2];
nmv_context_counts mv; nmv_context_counts mv;
#if CONFIG_EXT_TX #if CONFIG_EXT_TX
unsigned int inter_tx_type[EXT_TX_SIZES][TX_TYPES]; unsigned int inter_ext_tx[EXT_TX_SETS_INTER][EXT_TX_SIZES][TX_TYPES];
unsigned int intra_tx_type[EXT_TX_SIZES][INTRA_MODES][TX_TYPES]; unsigned int intra_ext_tx[EXT_TX_SETS_INTRA][EXT_TX_SIZES][INTRA_MODES]
[TX_TYPES];
#endif // CONFIG_EXT_TX #endif // CONFIG_EXT_TX
#if CONFIG_MISC_FIXES #if CONFIG_MISC_FIXES
struct seg_counts seg; struct seg_counts seg;
...@@ -147,7 +149,10 @@ void vp10_tx_counts_to_branch_counts_8x8(const unsigned int *tx_count_8x8p, ...@@ -147,7 +149,10 @@ void vp10_tx_counts_to_branch_counts_8x8(const unsigned int *tx_count_8x8p,
unsigned int (*ct_8x8p)[2]); unsigned int (*ct_8x8p)[2]);
#if CONFIG_EXT_TX #if CONFIG_EXT_TX
extern const vpx_tree_index vp10_tx_type_tree[TREE_SIZE(TX_TYPES)]; extern const vpx_tree_index
vp10_ext_tx_inter_tree[EXT_TX_SETS_INTER][TREE_SIZE(TX_TYPES)];
extern const vpx_tree_index
vp10_ext_tx_intra_tree[EXT_TX_SETS_INTRA][TREE_SIZE(TX_TYPES)];
#endif // CONFIG_EXT_TX #endif // CONFIG_EXT_TX
static INLINE int vp10_ceil_log2(int n) { static INLINE int vp10_ceil_log2(int n) {
......
...@@ -113,7 +113,12 @@ typedef enum { ...@@ -113,7 +113,12 @@ typedef enum {
} TX_TYPE; } TX_TYPE;
#if CONFIG_EXT_TX #if CONFIG_EXT_TX
#define EXT_TX_SIZES 3 // number of sizes that use extended transforms #define EXT_TX_SIZES 3 // number of sizes that use extended transforms
#define EXT_TX_SETS_INTER 4 // Sets of transform selections for INTER
#define EXT_TX_SETS_INTRA 2 // Sets of transform selections for INTRA
#define TX_TYPES_10 10
#define TX_TYPES_2 2
#endif // CONFIG_EXT_TX #endif // CONFIG_EXT_TX
typedef enum { typedef enum {
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "./vp10_rtcd.h" #include "./vp10_rtcd.h"
#include "./vpx_dsp_rtcd.h" #include "./vpx_dsp_rtcd.h"
#include "vp10/common/blockd.h" #include "vp10/common/blockd.h"
#include "vp10/common/enums.h"
#include "vp10/common/idct.h" #include "vp10/common/idct.h"
#include "vpx_dsp/inv_txfm.h" #include "vpx_dsp/inv_txfm.h"
#include "vpx_ports/mem.h" #include "vpx_ports/mem.h"
...@@ -864,6 +865,11 @@ void vp10_inv_txfm_add_32x32(const tran_low_t *input, uint8_t *dest, ...@@ -864,6 +865,11 @@ void vp10_inv_txfm_add_32x32(const tran_low_t *input, uint8_t *dest,
case DCT_DCT: case DCT_DCT:
vp10_idct32x32_add(input, dest, stride, eob); vp10_idct32x32_add(input, dest, stride, eob);
break; break;
#if CONFIG_EXT_TX
case IDTX:
inv_idtx_add_c(input, dest, stride, 32);
break;
#endif // CONFIG_EXT_TX
case ADST_DCT: case ADST_DCT:
case DCT_ADST: case DCT_ADST:
case ADST_ADST: case ADST_ADST:
...@@ -1295,6 +1301,11 @@ void vp10_highbd_inv_txfm_add_32x32(const tran_low_t *input, uint8_t *dest, ...@@ -1295,6 +1301,11 @@ void vp10_highbd_inv_txfm_add_32x32(const tran_low_t *input, uint8_t *dest,
case DCT_DCT: case DCT_DCT:
vp10_highbd_idct32x32_add(input, dest, stride, eob, bd); vp10_highbd_idct32x32_add(input, dest, stride, eob, bd);
break; break;
#if CONFIG_EXT_TX
case IDTX:
highbd_inv_idtx_add_c(input, dest, stride, 32, bd);
break;
#endif // CONFIG_EXT_TX
case ADST_DCT: case ADST_DCT:
case DCT_ADST: case DCT_ADST:
case ADST_ADST: case ADST_ADST:
......
...@@ -436,15 +436,25 @@ void vp10_accumulate_frame_counts(VP10_COMMON *cm, FRAME_COUNTS *counts, ...@@ -436,15 +436,25 @@ void vp10_accumulate_frame_counts(VP10_COMMON *cm, FRAME_COUNTS *counts,
} }
#if CONFIG_EXT_TX #if CONFIG_EXT_TX
for (i = 0; i < EXT_TX_SIZES; i++) for (i = 0; i < EXT_TX_SIZES; i++) {
for (j = 0; j < TX_TYPES; j++) int s, k;
cm->counts.inter_tx_type[i][j] += counts->inter_tx_type[i][j]; for (s = 1; s < EXT_TX_SETS_INTER; ++s) {
if (use_inter_ext_tx_for_tx[s][i]) {
for (i = 0; i < EXT_TX_SIZES; i++) for (k = 0; k < TX_TYPES; k++)
for (j = 0; j < INTRA_MODES; j++) cm->counts.inter_ext_tx[s][i][k] += counts->inter_ext_tx[s][i][k];
for (k = 0; k < TX_TYPES; k++) }
cm->counts.intra_tx_type[i][j][k] += counts->intra_tx_type[i][j][k]; }
#endif for (s = 1; s < EXT_TX_SETS_INTRA; ++s) {
if (use_intra_ext_tx_for_tx[s][i]) {
int j;
for (j = 0; j < INTRA_MODES; ++j)
for (k = 0; k < TX_TYPES; k++)
cm->counts.intra_ext_tx[s][i][j][k] +=
counts->intra_ext_tx[s][i][j][k];
}
}
}
#endif // CONFIG_EXT_TX
#if CONFIG_MISC_FIXES #if CONFIG_MISC_FIXES
for (i = 0; i < PREDICTION_PROBS; i++) for (i = 0; i < PREDICTION_PROBS; i++)
......
...@@ -2224,17 +2224,26 @@ static size_t read_uncompressed_header(VP10Decoder *pbi, ...@@ -2224,17 +2224,26 @@ static size_t read_uncompressed_header(VP10Decoder *pbi,
#if CONFIG_EXT_TX #if CONFIG_EXT_TX
static void read_ext_tx_probs(FRAME_CONTEXT *fc, vpx_reader *r) { static void read_ext_tx_probs(FRAME_CONTEXT *fc, vpx_reader *r) {
int i, j, k; int i, j, k;
if (vpx_read(r, GROUP_DIFF_UPDATE_PROB)) { int s;
for (i = TX_4X4; i <= TX_16X16; ++i) for (s = 1; s < EXT_TX_SETS_INTER; ++s) {
for (j = 0; j < TX_TYPES - 1; ++j) if (vpx_read(r, GROUP_DIFF_UPDATE_PROB)) {
vp10_diff_update_prob(r, &fc->inter_tx_type_prob[i][j]); for (i = TX_4X4; i < EXT_TX_SIZES; ++i) {
if (!use_inter_ext_tx_for_tx[s][i]) continue;
for (j = 0; j < num_ext_tx_set_inter[s] - 1; ++j)
vp10_diff_update_prob(r, &fc->inter_ext_tx_prob[s][i][j]);
}
}
} }
if (vpx_read(r, GROUP_DIFF_UPDATE_PROB)) { for (s = 1; s < EXT_TX_SETS_INTRA; ++s) {
for (i = TX_4X4; i <= TX_16X16; ++i) if (vpx_read(r, GROUP_DIFF_UPDATE_PROB)) {
for (j = 0; j < INTRA_MODES; ++j) for (i = TX_4X4; i < EXT_TX_SIZES; ++i) {
for (k = 0; k < TX_TYPES - 1; ++k) if (!use_intra_ext_tx_for_tx[s][i]) continue;
vp10_diff_update_prob(r, &fc->intra_tx_type_prob[i][j][k]); for (j = 0; j < INTRA_MODES; ++j)
for (k = 0; k < num_ext_tx_set_intra[s] - 1; ++k)
vp10_diff_update_prob(r, &fc->intra_ext_tx_prob[s][i][j][k]);
}
}
} }
} }
#endif // CONFIG_EXT_TX #endif // CONFIG_EXT_TX
...@@ -2365,11 +2374,11 @@ static void debug_check_frame_counts(const VP10_COMMON *const cm) { ...@@ -2365,11 +2374,11 @@ static void debug_check_frame_counts(const VP10_COMMON *const cm) {
assert(!memcmp(&cm->counts.mv, &zero_counts.mv, sizeof(cm->counts.mv))); assert(!memcmp(&cm->counts.mv, &zero_counts.mv, sizeof(cm->counts.mv)));
#if CONFIG_EXT_TX #if CONFIG_EXT_TX
assert(!memcmp(cm->counts.inter_tx_type, assert(!memcmp(cm->counts.inter_ext_tx, zero_counts.inter_ext_tx,
zero_counts.inter_tx_type, sizeof(cm->counts.inter_tx_type))); sizeof(cm->counts.inter_ext_tx)));
assert(!memcmp(cm->counts.intra_tx_type, assert(!memcmp(cm->counts.intra_ext_tx, zero_counts.intra_ext_tx,
zero_counts.intra_tx_type, sizeof(cm->counts.intra_tx_type))); sizeof(cm->counts.intra_ext_tx)));
#endif #endif // CONFIG_EXT_TX
} }
#endif // NDEBUG #endif // NDEBUG
......
...@@ -381,15 +381,19 @@ static void read_intra_frame_mode_info(VP10_COMMON *const cm, ...@@ -381,15 +381,19 @@ static void read_intra_frame_mode_info(VP10_COMMON *const cm,
read_palette_mode_info(cm, xd, r); read_palette_mode_info(cm, xd, r);
#if CONFIG_EXT_TX #if CONFIG_EXT_TX
if (mbmi->tx_size <= TX_16X16 && cm->base_qindex > 0 && if (get_ext_tx_types(mbmi->tx_size, mbmi->sb_type, 0) > 1 &&
mbmi->sb_type >= BLOCK_8X8 && !mbmi->skip && cm->base_qindex > 0 && !mbmi->skip &&
!segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) { !segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) {
FRAME_COUNTS *counts = xd->counts; FRAME_COUNTS *counts = xd->counts;
mbmi->tx_type = int eset = get_ext_tx_set(mbmi->tx_size, mbmi->sb_type, 0);
vpx_read_tree(r, vp10_tx_type_tree, if (eset > 0) {
cm->fc->intra_tx_type_prob[mbmi->tx_size][mbmi->mode]); mbmi->tx_type = vpx_read_tree(
if (counts) r, vp10_ext_tx_intra_tree[eset],
++counts->intra_tx_type[mbmi->tx_size][mbmi->mode][mbmi->tx_type]; cm->fc->intra_ext_tx_prob[eset][mbmi->tx_size][mbmi->mode]);
if (counts)
++counts->intra_ext_tx[eset][mbmi->tx_size][mbmi->mode]
[mbmi->tx_type];
}
} else { } else {
mbmi->tx_type = DCT_DCT; mbmi->tx_type = DCT_DCT;
} }
...@@ -790,25 +794,30 @@ static void read_inter_frame_mode_info(VP10Decoder *const pbi, ...@@ -790,25 +794,30 @@ static void read_inter_frame_mode_info(VP10Decoder *const pbi,
read_intra_block_mode_info(cm, xd, mi, r); read_intra_block_mode_info(cm, xd, mi, r);
#if CONFIG_EXT_TX #if CONFIG_EXT_TX
if (mbmi->tx_size <= TX_16X16 && cm->base_qindex > 0 && if (get_ext_tx_types(mbmi->tx_size, mbmi->sb_type, inter_block) > 1 &&
mbmi->sb_type >= BLOCK_8X8 && !mbmi->skip && cm->base_qindex > 0 && !mbmi->skip &&
!segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) { !segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) {
int eset = get_ext_tx_set(mbmi->tx_size, mbmi->sb_type,
inter_block);
FRAME_COUNTS *counts = xd->counts; FRAME_COUNTS *counts = xd->counts;
if (inter_block) if (inter_block) {
mbmi->tx_type = if (eset > 0) {
vpx_read_tree(r, vp10_tx_type_tree, mbmi->tx_type =
cm->fc->inter_tx_type_prob[mbmi->tx_size]); vpx_read_tree(r, vp10_ext_tx_inter_tree[eset],
else cm->fc->inter_ext_tx_prob[eset][mbmi->tx_size]);
mbmi->tx_type = vpx_read_tree(r, vp10_tx_type_tree, if (counts)
cm->fc->intra_tx_type_prob ++counts->inter_ext_tx[eset][mbmi->tx_size][mbmi->tx_type];
[mbmi->tx_size][mbmi->mode]); }
} else {
if (counts) { if (eset > 0) {
if (inter_block) mbmi->tx_type = vpx_read_tree(r, vp10_ext_tx_intra_tree[eset],
++counts->inter_tx_type[mbmi->tx_size][mbmi->tx_type]; cm->fc->intra_ext_tx_prob[eset]
else [mbmi->tx_size][mbmi->mode]);
++counts->intra_tx_type[mbmi->tx_size][mbmi->mode][mbmi->tx_type]; if (counts)
++counts->intra_ext_tx[eset][mbmi->tx_size]
[mbmi->mode][mbmi->tx_type];
}
} }
} else { } else {
mbmi->tx_type = DCT_DCT; mbmi->tx_type = DCT_DCT;
......
...@@ -73,12 +73,19 @@ static INLINE void write_uniform(vpx_writer *w, int n, int v) { ...@@ -73,12 +73,19 @@ static INLINE void write_uniform(vpx_writer *w, int n, int v) {
} }
#if CONFIG_EXT_TX #if CONFIG_EXT_TX
static struct vp10_token tx_type_encodings[TX_TYPES]; static struct vp10_token ext_tx_inter_encodings[EXT_TX_SETS_INTER][TX_TYPES];
static struct vp10_token ext_tx_intra_encodings[EXT_TX_SETS_INTRA][TX_TYPES];
#endif // CONFIG_EXT_TX #endif // CONFIG_EXT_TX
void vp10_encode_token_init() { void vp10_encode_token_init() {
#if CONFIG_EXT_TX #if CONFIG_EXT_TX
vp10_tokens_from_tree(tx_type_encodings, vp10_tx_type_tree); int s;
for (s = 1; s < EXT_TX_SETS_INTER; ++s) {
vp10_tokens_from_tree(ext_tx_inter_encodings[s], vp10_ext_tx_inter_tree[s]);
}
for (s = 1; s < EXT_TX_SETS_INTRA; ++s) {
vp10_tokens_from_tree(ext_tx_intra_encodings[s], vp10_ext_tx_intra_tree[s]);
}
#endif // CONFIG_EXT_TX #endif // CONFIG_EXT_TX
} }
...@@ -231,37 +238,51 @@ static void update_ext_tx_probs(VP10_COMMON *cm, vpx_writer *w) { ...@@ -231,37 +238,51 @@ static void update_ext_tx_probs(VP10_COMMON *cm, vpx_writer *w) {
const int savings_thresh = vp10_cost_one(GROUP_DIFF_UPDATE_PROB) - const int savings_thresh = vp10_cost_one(GROUP_DIFF_UPDATE_PROB) -
vp10_cost_zero(GROUP_DIFF_UPDATE_PROB); vp10_cost_zero(GROUP_DIFF_UPDATE_PROB);
int i, j; int i, j;
int savings = 0; int s;
int do_update = 0; for (s = 1; s < EXT_TX_SETS_INTER; ++s) {
for (i = TX_4X4; i <= TX_16X16; ++i) { int savings = 0;
savings += prob_diff_update_savings( int do_update = 0;
vp10_tx_type_tree, cm->fc->inter_tx_type_prob[i], for (i = TX_4X4; i < EXT_TX_SIZES; ++i) {
cm->counts.inter_tx_type[i], TX_TYPES); if (!use_inter_ext_tx_for_tx[s][i]) continue;
} savings += prob_diff_update_savings(
do_update = savings > savings_thresh; vp10_ext_tx_inter_tree[s], cm->fc->inter_ext_tx_prob[s][i],
vpx_write(w, do_update, GROUP_DIFF_UPDATE_PROB); cm->counts.inter_ext_tx[s][i], num_ext_tx_set_inter[s]);
if (do_update) { }
for (i = TX_4X4; i <= TX_16X16; ++i) { do_update = savings > savings_thresh;
prob_diff_update(vp10_tx_type_tree, cm->fc->inter_tx_type_prob[i], vpx_write(w, do_update, GROUP_DIFF_UPDATE_PROB);
cm->counts.inter_tx_type[i], TX_TYPES, w); if (do_update) {
for (i = TX_4X4; i < EXT_TX_SIZES; ++i) {
if (!use_inter_ext_tx_for_tx[s][i]) continue;
prob_diff_update(vp10_ext_tx_inter_tree[s],
cm->fc->inter_ext_tx_prob[s][i],
cm->counts.inter_ext_tx[s][i],
num_ext_tx_set_inter[s], w);
}
} }
} }
savings = 0; for (s = 1; s < EXT_TX_SETS_INTRA; ++s) {
do_update = 0; int savings = 0;
int do_update = 0;
for (i = TX_4X4; i <= TX_16X16; ++i) for (i = TX_4X4; i < EXT_TX_SIZES; ++i) {
for (j = 0; j < INTRA_MODES; ++j) if (!use_intra_ext_tx_for_tx[s][i]) continue;
savings += prob_diff_update_savings(
vp10_tx_type_tree, cm->fc->intra_tx_type_prob[i][j],
cm->counts.intra_tx_type[i][j], TX_TYPES);
do_update = savings > savings_thresh;
vpx_write(w, do_update, GROUP_DIFF_UPDATE_PROB);
if (do_update) {
for (i = TX_4X4; i <= TX_16X16; ++i)
for (j = 0; j < INTRA_MODES; ++j) for (j = 0; j < INTRA_MODES; ++j)
prob_diff_update(vp10_tx_type_tree, cm->fc->intra_tx_type_prob[i][j], savings += prob_diff_update_savings(
cm->counts.intra_tx_type[i][j], TX_TYPES, w); vp10_ext_tx_intra_tree[s], cm->fc->intra_ext_tx_prob[s][i][j],
cm->counts.intra_ext_tx[s][i][j], num_ext_tx_set_intra[s]);
}
do_update = savings > savings_thresh;
vpx_write(w, do_update, GROUP_DIFF_UPDATE_PROB);
if (do_update) {
for (i = TX_4X4; i < EXT_TX_SIZES; ++i) {
if (!use_intra_ext_tx_for_tx[s][i]) continue;
for (j = 0; j < INTRA_MODES; ++j)
prob_diff_update(vp10_ext_tx_intra_tree[s],
cm->fc->intra_ext_tx_prob[s][i][j],
cm->counts.intra_ext_tx[s][i][j],
num_ext_tx_set_intra[s], w);
}
}
} }
} }
#endif // CONFIG_EXT_TX #endif // CONFIG_EXT_TX
...@@ -598,17 +619,22 @@ static void pack_inter_mode_mvs(VP10_COMP *cpi, const MODE_INFO *mi, ...@@ -598,17 +619,22 @@ static void pack_inter_mode_mvs(VP10_COMP *cpi, const MODE_INFO *mi,
} }
#if CONFIG_EXT_TX #if CONFIG_EXT_TX
if (mbmi->tx_size <= TX_16X16 && cm->base_qindex > 0 && if (get_ext_tx_types(mbmi->tx_size, bsize, is_inter) > 1 &&
bsize >= BLOCK_8X8 && !mbmi->skip && cm->base_qindex > 0 && !mbmi->skip &&
!segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) { !segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) {
if (is_inter) int eset = get_ext_tx_set(mbmi->tx_size, bsize, is_inter);
vp10_write_token(w, vp10_tx_type_tree, if (is_inter) {
cm->fc->inter_tx_type_prob[mbmi->tx_size], if (eset > 0)
&tx_type_encodings[mbmi->tx_type]); vp10_write_token(w, vp10_ext_tx_inter_tree[eset],
else cm->fc->inter_ext_tx_prob[eset][mbmi->tx_size],
vp10_write_token(w, vp10_tx_type_tree, &ext_tx_inter_encodings[eset][mbmi->tx_type]);
cm->fc->intra_tx_type_prob[mbmi->tx_size][mbmi->mode], } else {
&tx_type_encodings[mbmi->tx_type]); if (eset > 0)
vp10_write_token(
w, vp10_ext_tx_intra_tree[eset],
cm->fc->intra_ext_tx_prob[eset][mbmi->tx_size][mbmi->mode],
&ext_tx_intra_encodings[eset][mbmi->tx_type]);
}
} }
#endif // CONFIG_EXT_TX #endif // CONFIG_EXT_TX
} }
...@@ -690,12 +716,15 @@ static void write_mb_modes_kf(const VP10_COMMON *cm, const MACROBLOCKD *xd, ...@@ -690,12 +716,15 @@ static void write_mb_modes_kf(const VP10_COMMON *cm, const MACROBLOCKD *xd,
#if CONFIG_EXT_TX #if CONFIG_EXT_TX
if (mbmi->tx_size <= TX_16X16 && cm->base_qindex > 0 && if (get_ext_tx_types(mbmi->tx_size, bsize, 0) > 1 &&
bsize >= BLOCK_8X8 && !mbmi->skip && cm->base_qindex > 0 && !mbmi->skip &&
!segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) { !segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) {
vp10_write_token(w, vp10_tx_type_tree, int eset = get_ext_tx_set(mbmi->tx_size, bsize, 0);
cm->fc->intra_tx_type_prob[mbmi->tx_size][mbmi->mode], if (eset > 0)
&tx_type_encodings[mbmi->tx_type]); vp10_write_token(
w, vp10_ext_tx_intra_tree[eset],
cm->fc->intra_ext_tx_prob[eset][mbmi->tx_size][mbmi->mode],
&ext_tx_intra_encodings[eset][mbmi->tx_type]);
} }
#endif // CONFIG_EXT_TX #endif // CONFIG_EXT_TX
} }
......
...@@ -2430,7 +2430,6 @@ static void rd_pick_partition(VP10_COMP *cpi, ThreadData *td, ...@@ -2430,7 +2430,6 @@ static void rd_pick_partition(VP10_COMP *cpi, ThreadData *td,
(void) best_rd; (void) best_rd;
*rd_cost = best_rdc; *rd_cost = best_rdc;
if (best_rdc.rate < INT_MAX && best_rdc.dist < INT64_MAX && if (best_rdc.rate < INT_MAX && best_rdc.dist < INT64_MAX &&
pc_tree->index != 3) { pc_tree->index != 3) {
int output_enabled = (bsize == BLOCK_64X64); int output_enabled = (bsize == BLOCK_64X64);
...@@ -3057,13 +3056,19 @@ static void encode_superblock(VP10_COMP *cpi, ThreadData *td, ...@@ -3057,13 +3056,19 @@ static void encode_superblock(VP10_COMP *cpi, ThreadData *td,
++td->counts->tx.tx_totals[mbmi->tx_size]; ++td->counts->tx.tx_totals[mbmi->tx_size];
++td->counts->tx.tx_totals[get_uv_tx_size(mbmi, &xd->plane[1])]; ++td->counts->tx.tx_totals[get_uv_tx_size(mbmi, &xd->plane[1])];
#if CONFIG_EXT_TX #if CONFIG_EXT_TX
if (mbmi->tx_size <= TX_16X16 && cm->base_qindex > 0 && if (get_ext_tx_types(mbmi->tx_size, bsize, is_inter_block(mbmi)) > 1 &&
bsize >= BLOCK_8X8 && !mbmi->skip && cm->base_qindex > 0 && !mbmi->skip &&
!segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) { !segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) {
if (is_inter_block(mbmi)) int eset = get_ext_tx_set(mbmi->tx_size, bsize,
++td->counts->inter_tx_type[mbmi->tx_size][mbmi->tx_type]; is_inter_block(mbmi));
else if (eset > 0) {
++td->counts->intra_tx_type[mbmi->tx_size][mbmi->mode][mbmi->tx_type]; if (is_inter_block(mbmi)) {
++td->counts->inter_ext_tx[eset][mbmi->tx_size][mbmi->tx_type];
} else {
++td->counts->intra_ext_tx[eset][mbmi->tx_size][mbmi->mode]
[mbmi->tx_type];
}
}
} }
#endif // CONFIG_EXT_TX #endif // CONFIG_EXT_TX
} }
......
...@@ -709,6 +709,11 @@ static void fwd_txfm_32x32(int rd_transform, const int16_t *src_diff, ...@@ -709,6 +709,11 @@ static void fwd_txfm_32x32(int rd_transform, const int16_t *src_diff,
case DCT_DCT: case DCT_DCT:
fdct32x32(rd_transform, src_diff, coeff, diff_stride); fdct32x32(rd_transform, src_diff, coeff, diff_stride);
break; break;
#if CONFIG_EXT_TX
case IDTX:
fwd_idtx_c(src_diff, coeff, diff_stride, 32);
break;
#endif // CONFIG_EXT_TX
case ADST_DCT: case ADST_DCT:
case DCT_ADST: case DCT_ADST:
case ADST_ADST: case ADST_ADST:
...@@ -727,6 +732,11 @@ static void fwd_txfm_32x32_1(const int16_t *src_diff, ...@@ -727,6 +732,11 @@ static void fwd_txfm_32x32_1(const int16_t *src_diff,
case DCT_DCT: case DCT_DCT:
vpx_fdct32x32_1(src_diff, coeff, diff_stride); vpx_fdct32x32_1(src_diff, coeff, diff_stride);
break; break;
#if CONFIG_EXT_TX
case IDTX:
fwd_idtx_c(src_diff, coeff, diff_stride, 32);
break;
#endif // CONFIG_EXT_TX
case ADST_DCT: case ADST_DCT:
case DCT_ADST: case DCT_ADST:
case ADST_ADST: case ADST_ADST:
...@@ -1056,6 +1066,11 @@ static void highbd_fwd_txfm_32x32(int rd_transform, const int16_t *src_diff, ...@@ -1056,6 +1066,11 @@ static void highbd_fwd_txfm_32x32(int rd_transform, const int16_t *src_diff,
case DCT_DCT: case DCT_DCT:
highbd_fdct32x32(rd_transform, src_diff, coeff, diff_stride); highbd_fdct32x32(rd_transform, src_diff, coeff, diff_stride);
break; break;
#if CONFIG_EXT_TX
case IDTX:
fwd_idtx_c(src_diff, coeff, diff_stride, 32);
break;
#endif // CONFIG_EXT_TX
case ADST_DCT: case ADST_DCT:
case DCT_ADST: case DCT_ADST:
case ADST_ADST: case ADST_ADST:
...@@ -1074,6 +1089,11 @@ static void highbd_fwd_txfm_32x32_1(const int16_t *src_diff, ...@@ -1074,6 +1089,11 @@ static void highbd_fwd_txfm_32x32_1(const int16_t *src_diff,
case DCT_DCT: case DCT_DCT:
vpx_highbd_fdct32x32_1(src_diff, coeff, diff_stride); vpx_highbd_fdct32x32_1(src_diff, coeff, diff_stride);
break; break;
#if CONFIG_EXT_TX
case IDTX:
fwd_idtx_c(src_diff, coeff, diff_stride, 32);
break;
#endif // CONFIG_EXT_TX
case ADST_DCT: case ADST_DCT:
case DCT_ADST: case DCT_ADST:
case ADST_ADST: case ADST_ADST:
......
...@@ -467,8 +467,9 @@ typedef struct VP10_COMP { ...@@ -467,8 +467,9 @@ typedef struct VP10_COMP {
int palette_uv_color_cost[PALETTE_MAX_SIZE - 1][PALETTE_COLOR_CONTEXTS]