Commit 6fc47e5f authored by Yaowu Xu's avatar Yaowu Xu

Add support of separte delta Qs for chroma channels

Change-Id: Iae7c054def0c0d5b5af52263f0c4d2e1e346282d
parent ebcee0b6
......@@ -325,6 +325,10 @@ typedef struct AV1Common {
int v_dc_delta_q;
int u_ac_delta_q;
int v_ac_delta_q;
#if CONFIG_EXT_QM
int separate_uv_delta_q;
#endif
// The dequantizers below are true dequntizers used only in the
// dequantization process. They have the same coefficient
// shift/scale as TX.
......
......@@ -1242,10 +1242,19 @@ static void setup_quantization(AV1_COMMON *const cm,
struct aom_read_bit_buffer *rb) {
cm->base_qindex = aom_rb_read_literal(rb, QINDEX_BITS);
cm->y_dc_delta_q = read_delta_q(rb);
int diff_uv_delta = 0;
#if CONFIG_EXT_QM
if (cm->separate_uv_delta_q) diff_uv_delta = aom_rb_read_bit(rb);
#endif
cm->u_dc_delta_q = read_delta_q(rb);
cm->u_ac_delta_q = read_delta_q(rb);
cm->v_dc_delta_q = cm->u_dc_delta_q;
cm->v_ac_delta_q = cm->u_ac_delta_q;
if (diff_uv_delta) {
cm->v_dc_delta_q = read_delta_q(rb);
cm->v_ac_delta_q = read_delta_q(rb);
} else {
cm->v_dc_delta_q = cm->u_dc_delta_q;
cm->v_ac_delta_q = cm->u_ac_delta_q;
}
cm->dequant_bit_depth = cm->bit_depth;
#if CONFIG_AOM_QM
cm->using_qmatrix = aom_rb_read_bit(rb);
......@@ -2423,6 +2432,9 @@ static void read_bitdepth_colorspace_sampling(AV1_COMMON *cm,
"4:4:4 color not supported in profile 0 or 2");
}
}
#if CONFIG_EXT_QM
cm->separate_uv_delta_q = aom_rb_read_bit(rb);
#endif
}
#if CONFIG_REFERENCE_BUFFER || CONFIG_OBU
......
......@@ -2661,10 +2661,19 @@ static void encode_quantization(const AV1_COMMON *const cm,
struct aom_write_bit_buffer *wb) {
aom_wb_write_literal(wb, cm->base_qindex, QINDEX_BITS);
write_delta_q(wb, cm->y_dc_delta_q);
assert(cm->u_dc_delta_q == cm->v_dc_delta_q);
int diff_uv_delta = (cm->u_dc_delta_q != cm->v_dc_delta_q) ||
(cm->u_ac_delta_q != cm->v_ac_delta_q);
#if CONFIG_EXT_QM
if (cm->separate_uv_delta_q) aom_wb_write_bit(wb, diff_uv_delta);
#else
assert(!diff_uv_delta);
#endif
write_delta_q(wb, cm->u_dc_delta_q);
assert(cm->u_ac_delta_q == cm->v_ac_delta_q);
write_delta_q(wb, cm->u_ac_delta_q);
if (diff_uv_delta) {
write_delta_q(wb, cm->v_dc_delta_q);
write_delta_q(wb, cm->v_ac_delta_q);
}
#if CONFIG_AOM_QM
aom_wb_write_bit(wb, cm->using_qmatrix);
if (cm->using_qmatrix) {
......@@ -3497,6 +3506,9 @@ static void write_bitdepth_colorspace_sampling(
assert(cm->profile == PROFILE_1 || cm->profile == PROFILE_3);
aom_wb_write_bit(wb, 0); // unused
}
#if CONFIG_EXT_QM
aom_wb_write_bit(wb, cm->separate_uv_delta_q);
#endif
}
#if CONFIG_REFERENCE_BUFFER || CONFIG_OBU
......
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