Commit e15b8ad5 authored by Debargha Mukherjee's avatar Debargha Mukherjee

Add dq_type to frame header in new_quant expt

Change-Id: I9c013f1c7bd1ae5adf58ac884f884ea0c59a382c
parent 997e46d3
......@@ -669,6 +669,14 @@ typedef enum ATTRIBUTE_PACKED {
#define SUPERRES_SCALE_DENOMINATOR_MIN (SCALE_NUMERATOR + 1)
#endif // CONFIG_HORZONLY_FRAME_SUPERRES
#if CONFIG_NEW_QUANT
typedef enum ATTRIBUTE_PACKED {
DQ_MULT_OFFSET,
DQ_MULT_OFFSET_DZ,
DQ_TYPES
} DqType;
#endif // CONFIG_NEW_QUANT
#ifdef __cplusplus
} // extern "C"
#endif
......
......@@ -575,6 +575,9 @@ typedef struct AV1Common {
// TODO(jingning): This can be combined with sign_bias later.
int8_t ref_frame_side[TOTAL_REFS_PER_FRAME];
#endif
#if CONFIG_NEW_QUANT
DqType dq_type;
#endif // CONFIG_NEW_QUANT
#if TXCOEFF_TIMER
int64_t cum_txcoeff_timer;
......
......@@ -38,22 +38,44 @@ static const qprofile_type nuq[QUANT_PROFILES][2] = {
{ { 64, 128, 128 }, 0 }, // ac
},
{
// intra
// intra, dq_type 0, high quality
{ { 64, 128, 128 }, 3 }, // dc
{ { 64, 128, 128 }, 3 }, // ac
},
{
// intra, dq_type 0, low quality
{ { 64, 128, 128 }, 14 }, // dc
{ { 64, 128, 128 }, 14 }, // ac
},
{
// inter
// inter, dq_type 0, high quality
{ { 64, 128, 128 }, 4 }, // dc
{ { 64, 128, 128 }, 4 }, // ac
},
{
// inter, dq_type 0, low quality
{ { 64, 128, 128 }, 8 }, // dc
{ { 64, 128, 128 }, 8 }, // ac
},
{
// intra, dq_type 1, high quality
{ { 82, 128, 128 }, 4 }, // dc
{ { 80, 128, 128 }, 8 }, // ac
},
{
// intra, dq_type 1, low quality
{ { 76, 128, 128 }, 12 }, // dc
{ { 72, 128, 128 }, 16 }, // ac
},
{
// inter, dq_type 1, high quality
{ { 82, 128, 128 }, 4 }, // dc
{ { 80, 128, 128 }, 8 }, // ac
},
{
// inter, dq_type 1, low quality
{ { 76, 128, 128 }, 12 }, // dc
{ { 72, 128, 128 }, 16 }, // ac
}
};
......
......@@ -60,7 +60,7 @@ qm_val_t *aom_qmatrix(struct AV1Common *cm, int qindex, int comp,
#if CONFIG_NEW_QUANT
#define QUANT_PROFILES 5
#define QUANT_PROFILES 9
#define QUANT_RANGES 2
#define NUQ_KNOTS 3
......@@ -75,23 +75,23 @@ static INLINE int qindex_to_qrange(int qindex) {
return (qindex < 140 ? 1 : 0);
}
static INLINE int get_dq_profile(int qindex, int is_inter,
static INLINE int get_dq_profile(DqType dqtype, int qindex, int is_inter,
PLANE_TYPE plane_type) {
// intra/inter, Y/UV, ctx, qrange
static const int dq_profile_lookup[REF_TYPES][PLANE_TYPES][QUANT_RANGES] = {
{
// intra
{ 2, 1 }, // Y
{ 2, 1 }, // UV
},
{
// inter
{ 4, 3 }, // Y
{ 4, 3 }, // UV
},
};
static const int
dq_profile_lookup[DQ_TYPES][REF_TYPES][PLANE_TYPES][QUANT_RANGES] = {
{
{ { 2, 1 }, { 2, 1 } }, // intra: Y, UV
{ { 4, 3 }, { 4, 3 } }, // inter: Y, UV
},
{
{ { 6, 5 }, { 6, 5 } }, // intra: Y, UV
{ { 8, 7 }, { 8, 7 } }, // inter: Y, UV
},
};
if (!qindex) return 0; // lossless
return dq_profile_lookup[is_inter][plane_type][qindex_to_qrange(qindex)];
return dq_profile_lookup[dqtype][is_inter][plane_type]
[qindex_to_qrange(qindex)];
}
#endif // CONFIG_NEW_QUANT
......
......@@ -3005,6 +3005,13 @@ static size_t read_uncompressed_header(AV1Decoder *pbi,
}
cm->all_lossless = all_lossless(cm, xd);
setup_segmentation_dequant(cm);
#if CONFIG_NEW_QUANT
if (!cm->all_lossless) {
cm->dq_type = aom_rb_read_bit(rb);
} else {
cm->dq_type = DQ_MULT_OFFSET;
}
#endif // CONFIG_NEW_QUANT
if (!cm->all_lossless) {
setup_cdef(cm, rb);
}
......
......@@ -517,7 +517,7 @@ uint8_t av1_read_coeffs_txb_facade(const AV1_COMMON *const cm,
#if CONFIG_NEW_QUANT
const int seg_id = mbmi->segment_id;
const int ref = is_inter_block(mbmi);
int dq = get_dq_profile(xd->qindex[seg_id], ref, pd->plane_type);
int dq = get_dq_profile(cm->dq_type, xd->qindex[seg_id], ref, pd->plane_type);
#endif // CONFIG_NEW_QUANT
TXB_CTX txb_ctx;
......
......@@ -292,7 +292,7 @@ int av1_decode_block_tokens(AV1_COMMON *cm, MACROBLOCKD *const xd, int plane,
get_entropy_context(tx_size, pd->above_context + x, pd->left_context + y);
#if CONFIG_NEW_QUANT
const int ref = is_inter_block(&xd->mi[0]->mbmi);
int dq = get_dq_profile(xd->qindex[seg_id], ref, pd->plane_type);
int dq = get_dq_profile(cm->dq_type, xd->qindex[seg_id], ref, pd->plane_type);
#endif // CONFIG_NEW_QUANT
const int eob =
......
......@@ -3779,6 +3779,11 @@ static void write_uncompressed_header_frame(AV1_COMP *cpi,
}
}
}
#if CONFIG_NEW_QUANT
if (!cm->all_lossless) {
aom_wb_write_bit(wb, cm->dq_type);
}
#endif // CONFIG_NEW_QUANT
if (!cm->all_lossless) {
encode_cdef(cm, wb);
}
......@@ -4156,6 +4161,11 @@ static void write_uncompressed_header_obu(AV1_COMP *cpi,
}
}
}
#if CONFIG_NEW_QUANT
if (!cm->all_lossless) {
aom_wb_write_bit(wb, cm->dq_type);
}
#endif // CONFIG_NEW_QUANT
if (!cm->all_lossless) {
encode_cdef(cm, wb);
}
......
......@@ -3942,6 +3942,9 @@ void av1_encode_frame(AV1_COMP *cpi) {
// Indicates whether or not to use a default reduced set for ext-tx
// rather than the potential full set of 16 transforms
cm->reduced_tx_set_used = 0;
#if CONFIG_NEW_QUANT
cm->dq_type = cpi->sf.optimize_coefficients != FULL_TRELLIS_OPT;
#endif // CONFIG_NEW_QUANT
#if CONFIG_FRAME_MARKER
if (cm->show_frame == 0) {
......
......@@ -161,7 +161,7 @@ static int optimize_b_greedy(const AV1_COMMON *cm, MACROBLOCK *mb, int plane,
: cm->giqmatrix[NUM_QM_LEVELS - 1][0][qm_tx_size];
#endif // CONFIG_AOM_QM
#if CONFIG_NEW_QUANT
int dq = get_dq_profile(mb->qindex, ref, plane_type);
int dq = get_dq_profile(cm->dq_type, mb->qindex, ref, plane_type);
const dequant_val_type_nuq *dequant_val = p->dequant_val_nuq_QTX[dq];
#endif // CONFIG_NEW_QUANT
int64_t rd_cost0, rd_cost1;
......@@ -509,7 +509,7 @@ void av1_xform_quant(const AV1_COMMON *cm, MACROBLOCK *x, int plane, int block,
#endif
qparam.tx_size = tx_size;
#if CONFIG_NEW_QUANT
qparam.dq = get_dq_profile(x->qindex, is_inter, plane_type);
qparam.dq = get_dq_profile(cm->dq_type, x->qindex, is_inter, plane_type);
#endif // CONFIG_NEW_QUANT
#if CONFIG_AOM_QM
qparam.qmatrix = qmatrix;
......
......@@ -2208,7 +2208,7 @@ int av1_optimize_txb(const AV1_COMMON *cm, MACROBLOCK *x, int plane,
const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, mbmi);
const LV_MAP_COEFF_COST txb_costs = x->coeff_costs[txs_ctx][plane_type];
#if CONFIG_NEW_QUANT
int dq = get_dq_profile(x->qindex, is_inter, plane_type);
int dq = get_dq_profile(cm->dq_type, x->qindex, is_inter, plane_type);
const dequant_val_type_nuq *dequant_val = p->dequant_val_nuq_QTX[dq];
#endif // CONFIG_NEW_QUANT
#if CONFIG_LV_MAP_MULTI
......
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