Add support of separte delta Qs for chroma channels
Change-Id: Iae7c054def0c0d5b5af52263f0c4d2e1e346282d
diff --git a/av1/common/onyxc_int.h b/av1/common/onyxc_int.h
index e43f520..1e3245a 100644
--- a/av1/common/onyxc_int.h
+++ b/av1/common/onyxc_int.h
@@ -325,6 +325,10 @@
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.
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index 2b27499..08db2ad 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -1242,10 +1242,19 @@
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 @@
"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
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index 3b83d0c..d914fc3 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -2661,10 +2661,19 @@
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 @@
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