Commit dd3cf832 authored by Thomas Davies's avatar Thomas Davies
Browse files

AOM_QM: remove spurious dependence on inter/intra.

Inter/intra matrices are the same. Reduce the dimensions
of the various matrices.

Change-Id: Ie5049af9195d9c48b6928143ac04ac0a5058d0d8
parent 63d190ae
......@@ -568,8 +568,8 @@ typedef struct macroblockd_plane {
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;
......
......@@ -299,15 +299,15 @@ typedef struct AV1Common {
#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;
......
......@@ -343,12 +343,12 @@ int av1_get_qindex(const struct segmentation *seg, int segment_id,
 
#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 wt_matrix_ref[NUM_QM_LEVELS][2][QM_TOTAL_SIZE];
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;
}
}
}
......
......@@ -33,7 +33,6 @@ extern "C" {
* blocks*/
#define DEFAULT_QM_FIRST 5
#define DEFAULT_QM_LAST 9
#define DEFAULT_QM_INTER_OFFSET 0
#endif
struct AV1Common;
......@@ -52,9 +51,9 @@ static INLINE int aom_get_qmlevel(int qindex, int first, int last) {
}
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
......
......@@ -1661,10 +1661,8 @@ static void setup_segmentation_dequant(AV1_COMMON *const cm) {
? 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
......
......@@ -120,7 +120,7 @@ static int decode_coefs(MACROBLOCKD *xd, PLANE_TYPE type, tran_low_t *dqcoeff,
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 @@ static int decode_coefs(MACROBLOCKD *xd, PLANE_TYPE type, tran_low_t *dqcoeff,
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;
......
......@@ -148,10 +148,9 @@ static int optimize_b_greedy(const AV1_COMMON *cm, MACROBLOCK *mb, int plane,
#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 @@ void av1_xform_quant(const AV1_COMMON *cm, MACROBLOCK *x, int plane, int block,
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 @@ void av1_xform_quant(const AV1_COMMON *cm, MACROBLOCK *x, int plane, int block,
#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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment