AOM_QM: remove spurious dependence on inter/intra.
Inter/intra matrices are the same. Reduce the dimensions
of the various matrices.
Change-Id: Ie5049af9195d9c48b6928143ac04ac0a5058d0d8
diff --git a/av1/common/blockd.h b/av1/common/blockd.h
index 27c668b..1c50596 100644
--- a/av1/common/blockd.h
+++ b/av1/common/blockd.h
@@ -568,8 +568,8 @@
uint8_t width, height;
#if CONFIG_AOM_QM
- qm_val_t *seg_iqmatrix[MAX_SEGMENTS][2][TX_SIZES_ALL];
- qm_val_t *seg_qmatrix[MAX_SEGMENTS][2][TX_SIZES_ALL];
+ qm_val_t *seg_iqmatrix[MAX_SEGMENTS][TX_SIZES_ALL];
+ qm_val_t *seg_qmatrix[MAX_SEGMENTS][TX_SIZES_ALL];
#endif
// encoder
const int16_t *dequant;
diff --git a/av1/common/onyxc_int.h b/av1/common/onyxc_int.h
index 06007c5..15db2ab 100644
--- a/av1/common/onyxc_int.h
+++ b/av1/common/onyxc_int.h
@@ -299,15 +299,15 @@
#if CONFIG_AOM_QM
// Global quant matrix tables
- qm_val_t *giqmatrix[NUM_QM_LEVELS][2][2][TX_SIZES_ALL];
- qm_val_t *gqmatrix[NUM_QM_LEVELS][2][2][TX_SIZES_ALL];
+ qm_val_t *giqmatrix[NUM_QM_LEVELS][2][TX_SIZES_ALL];
+ qm_val_t *gqmatrix[NUM_QM_LEVELS][2][TX_SIZES_ALL];
// Local quant matrix tables for each frame
- qm_val_t *y_iqmatrix[MAX_SEGMENTS][2][TX_SIZES_ALL];
- qm_val_t *uv_iqmatrix[MAX_SEGMENTS][2][TX_SIZES_ALL];
+ qm_val_t *y_iqmatrix[MAX_SEGMENTS][TX_SIZES_ALL];
+ qm_val_t *uv_iqmatrix[MAX_SEGMENTS][TX_SIZES_ALL];
// Encoder
- qm_val_t *y_qmatrix[MAX_SEGMENTS][2][TX_SIZES_ALL];
- qm_val_t *uv_qmatrix[MAX_SEGMENTS][2][TX_SIZES_ALL];
+ qm_val_t *y_qmatrix[MAX_SEGMENTS][TX_SIZES_ALL];
+ qm_val_t *uv_qmatrix[MAX_SEGMENTS][TX_SIZES_ALL];
int using_qmatrix;
int min_qmlevel;
diff --git a/av1/common/quant_common.c b/av1/common/quant_common.c
index 1b0af4c..10dd88a 100644
--- a/av1/common/quant_common.c
+++ b/av1/common/quant_common.c
@@ -343,12 +343,12 @@
#if CONFIG_AOM_QM
qm_val_t *aom_iqmatrix(AV1_COMMON *cm, int qmlevel, int is_chroma,
- TX_SIZE tx_size, int is_intra) {
- return &cm->giqmatrix[qmlevel][!!is_chroma][!!is_intra][tx_size][0];
+ TX_SIZE tx_size) {
+ return &cm->giqmatrix[qmlevel][!!is_chroma][tx_size][0];
}
qm_val_t *aom_qmatrix(AV1_COMMON *cm, int qmlevel, int is_chroma,
- TX_SIZE tx_size, int is_intra) {
- return &cm->gqmatrix[qmlevel][!!is_chroma][!!is_intra][tx_size][0];
+ TX_SIZE tx_size) {
+ return &cm->gqmatrix[qmlevel][!!is_chroma][tx_size][0];
}
#define QM_TOTAL_SIZE 3344
@@ -356,28 +356,22 @@
static uint16_t iwt_matrix_ref[NUM_QM_LEVELS][2][QM_TOTAL_SIZE];
void aom_qm_init(AV1_COMMON *cm) {
- int q, c, f, t;
+ int q, c, t;
int current;
for (q = 0; q < NUM_QM_LEVELS; ++q) {
for (c = 0; c < 2; ++c) {
- for (f = 0; f < 2; ++f) {
- current = 0;
- for (t = 0; t < TX_SIZES_ALL; ++t) {
- const int size = tx_size_2d[t];
- // Don't use QM for sizes > 32x32
- if (q == NUM_QM_LEVELS - 1 || size > 1024) {
- cm->gqmatrix[q][c][f][t] = NULL;
- cm->giqmatrix[q][c][f][t] = NULL;
- } else {
- assert(current + size <= QM_TOTAL_SIZE);
- cm->gqmatrix[q][c][f][t] = &wt_matrix_ref[AOMMIN(
- NUM_QM_LEVELS - 1, f == 0 ? q + DEFAULT_QM_INTER_OFFSET : q)][c]
- [current];
- cm->giqmatrix[q][c][f][t] = &iwt_matrix_ref[AOMMIN(
- NUM_QM_LEVELS - 1, f == 0 ? q + DEFAULT_QM_INTER_OFFSET : q)][c]
- [current];
- current += size;
- }
+ current = 0;
+ for (t = 0; t < TX_SIZES_ALL; ++t) {
+ const int size = tx_size_2d[t];
+ // Don't use QM for sizes > 32x32
+ if (q == NUM_QM_LEVELS - 1 || size > 1024) {
+ cm->gqmatrix[q][c][t] = NULL;
+ cm->giqmatrix[q][c][t] = NULL;
+ } else {
+ assert(current + size <= QM_TOTAL_SIZE);
+ cm->gqmatrix[q][c][t] = &wt_matrix_ref[q][c][current];
+ cm->giqmatrix[q][c][t] = &iwt_matrix_ref[q][c][current];
+ current += size;
}
}
}
diff --git a/av1/common/quant_common.h b/av1/common/quant_common.h
index 3e2e9b3..516e325 100644
--- a/av1/common/quant_common.h
+++ b/av1/common/quant_common.h
@@ -33,7 +33,6 @@
* blocks*/
#define DEFAULT_QM_FIRST 5
#define DEFAULT_QM_LAST 9
-#define DEFAULT_QM_INTER_OFFSET 0
#endif
struct AV1Common;
@@ -52,9 +51,9 @@
}
void aom_qm_init(struct AV1Common *cm);
qm_val_t *aom_iqmatrix(struct AV1Common *cm, int qindex, int comp,
- TX_SIZE tx_size, int is_intra);
+ TX_SIZE tx_size);
qm_val_t *aom_qmatrix(struct AV1Common *cm, int qindex, int comp,
- TX_SIZE tx_size, int is_intra);
+ TX_SIZE tx_size);
#endif
#if CONFIG_NEW_QUANT
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index bcb4b32..be57c15 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -1661,10 +1661,8 @@
? NUM_QM_LEVELS - 1
: aom_get_qmlevel(cm->base_qindex, minqm, maxqm);
for (int j = 0; j < TX_SIZES_ALL; ++j) {
- cm->y_iqmatrix[i][1][j] = aom_iqmatrix(cm, qmlevel, 0, j, 1);
- cm->y_iqmatrix[i][0][j] = aom_iqmatrix(cm, qmlevel, 0, j, 0);
- cm->uv_iqmatrix[i][1][j] = aom_iqmatrix(cm, qmlevel, 1, j, 1);
- cm->uv_iqmatrix[i][0][j] = aom_iqmatrix(cm, qmlevel, 1, j, 0);
+ cm->y_iqmatrix[i][j] = aom_iqmatrix(cm, qmlevel, 0, j);
+ cm->uv_iqmatrix[i][j] = aom_iqmatrix(cm, qmlevel, 1, j);
}
#endif // CONFIG_AOM_QM
#if CONFIG_NEW_QUANT
diff --git a/av1/decoder/detokenize.c b/av1/decoder/detokenize.c
index b352c65..9d7d89c 100644
--- a/av1/decoder/detokenize.c
+++ b/av1/decoder/detokenize.c
@@ -120,7 +120,7 @@
dequant_val_type_nuq *dq_val,
#else
#if CONFIG_AOM_QM
- qm_val_t *iqm[2][TX_SIZES_ALL],
+ qm_val_t *iqm[TX_SIZES_ALL],
#endif // CONFIG_AOM_QM
#endif // CONFIG_NEW_QUANT
int ctx, const int16_t *scan, const int16_t *nb,
@@ -129,7 +129,7 @@
const int max_eob = tx_size_2d[tx_size];
const int ref = is_inter_block(&xd->mi[0]->mbmi);
#if CONFIG_AOM_QM && !CONFIG_NEW_QUANT
- const qm_val_t *iqmatrix = iqm[!ref][tx_size];
+ const qm_val_t *iqmatrix = iqm[tx_size];
#endif // CONFIG_AOM_QM
(void)tx_type;
int band, c = 0;
diff --git a/av1/encoder/encodemb.c b/av1/encoder/encodemb.c
index 2cc8c74..04abc0d 100644
--- a/av1/encoder/encodemb.c
+++ b/av1/encoder/encodemb.c
@@ -148,10 +148,9 @@
#if CONFIG_AOM_QM
int seg_id = xd->mi[0]->mbmi.segment_id;
// Use a flat matrix (i.e. no weighting) for 1D and Identity transforms
- const qm_val_t *iqmatrix =
- IS_2D_TRANSFORM(tx_type)
- ? pd->seg_iqmatrix[seg_id][!ref][tx_size]
- : cm->giqmatrix[NUM_QM_LEVELS - 1][0][0][tx_size];
+ const qm_val_t *iqmatrix = IS_2D_TRANSFORM(tx_type)
+ ? pd->seg_iqmatrix[seg_id][tx_size]
+ : cm->giqmatrix[NUM_QM_LEVELS - 1][0][tx_size];
#endif
#if CONFIG_NEW_QUANT
int dq = get_dq_profile_from_ctx(mb->qindex, ctx, ref, plane_type);
@@ -455,10 +454,9 @@
TX_TYPE tx_type =
av1_get_tx_type(plane_type, xd, blk_row, blk_col, block, tx_size);
-#if CONFIG_AOM_QM || CONFIG_NEW_QUANT
+#if CONFIG_NEW_QUANT
const int is_inter = is_inter_block(mbmi);
#endif
-
const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, mbmi);
tran_low_t *const coeff = BLOCK_OFFSET(p->coeff, block);
tran_low_t *const qcoeff = BLOCK_OFFSET(p->qcoeff, block);
@@ -468,13 +466,12 @@
#if CONFIG_AOM_QM
int seg_id = mbmi->segment_id;
// Use a flat matrix (i.e. no weighting) for 1D and Identity transforms
- const qm_val_t *qmatrix =
- IS_2D_TRANSFORM(tx_type) ? pd->seg_qmatrix[seg_id][!is_inter][tx_size]
- : cm->gqmatrix[NUM_QM_LEVELS - 1][0][0][tx_size];
- const qm_val_t *iqmatrix =
- IS_2D_TRANSFORM(tx_type)
- ? pd->seg_iqmatrix[seg_id][!is_inter][tx_size]
- : cm->giqmatrix[NUM_QM_LEVELS - 1][0][0][tx_size];
+ const qm_val_t *qmatrix = IS_2D_TRANSFORM(tx_type)
+ ? pd->seg_qmatrix[seg_id][tx_size]
+ : cm->gqmatrix[NUM_QM_LEVELS - 1][0][tx_size];
+ const qm_val_t *iqmatrix = IS_2D_TRANSFORM(tx_type)
+ ? pd->seg_iqmatrix[seg_id][tx_size]
+ : cm->giqmatrix[NUM_QM_LEVELS - 1][0][tx_size];
#endif
TxfmParam txfm_param;