Commit 28444be6 authored by Thomas Davies's avatar Thomas Davies Committed by Frédéric BARBIER
Browse files

EXT_DELTA_Q: make segment and SB deltas add.

As per spec, if delta quant is signalled at the superblock
and at the segment level both should be allowed and the
deltas should be summed to get the correct quant.

BUG=aomedia:897

Change-Id: Ia07265c944c9969befa16f194e02bf4e7a8dd142
parent 43061b3a
......@@ -4014,6 +4014,8 @@ static size_t read_uncompressed_header(AV1Decoder *pbi,
setup_segmentation(cm, rb);
{
int delta_q_allowed = 1;
#if !CONFIG_EXT_DELTA_Q
struct segmentation *const seg = &cm->seg;
int segment_quantizer_active = 0;
for (i = 0; i < MAX_SEGMENTS; i++) {
......@@ -4021,6 +4023,8 @@ static size_t read_uncompressed_header(AV1Decoder *pbi,
segment_quantizer_active = 1;
}
}
delta_q_allowed = !segment_quantizer_active;
#endif
cm->delta_q_res = 1;
#if CONFIG_EXT_DELTA_Q
......@@ -4030,7 +4034,7 @@ static size_t read_uncompressed_header(AV1Decoder *pbi,
cm->delta_lf_multi = 0;
#endif // CONFIG_LOOPFILTER_LEVEL
#endif
if (segment_quantizer_active == 0 && cm->base_qindex > 0) {
if (delta_q_allowed == 1 && cm->base_qindex > 0) {
cm->delta_q_present_flag = aom_rb_read_bit(rb);
} else {
cm->delta_q_present_flag = 0;
......@@ -4039,7 +4043,6 @@ static size_t read_uncompressed_header(AV1Decoder *pbi,
xd->prev_qindex = cm->base_qindex;
cm->delta_q_res = 1 << aom_rb_read_literal(rb, 2);
#if CONFIG_EXT_DELTA_Q
assert(!segment_quantizer_active);
cm->delta_lf_present_flag = aom_rb_read_bit(rb);
if (cm->delta_lf_present_flag) {
xd->prev_delta_lf_from_base = 0;
......
......@@ -4488,6 +4488,8 @@ static void write_uncompressed_header_frame(AV1_COMP *cpi,
encode_quantization(cm, wb);
encode_segmentation(cm, xd, wb);
{
int delta_q_allowed = 1;
#if !CONFIG_EXT_DELTA_Q
int i;
struct segmentation *const seg = &cm->seg;
int segment_quantizer_active = 0;
......@@ -4496,15 +4498,18 @@ static void write_uncompressed_header_frame(AV1_COMP *cpi,
segment_quantizer_active = 1;
}
}
delta_q_allowed = !segment_quantizer_active;
#endif
if (cm->delta_q_present_flag) assert(cm->base_qindex > 0);
if (segment_quantizer_active == 0 && cm->base_qindex > 0) {
// Segment quantizer and delta_q both allowed if CONFIG_EXT_DELTA_Q
if (delta_q_allowed == 1 && cm->base_qindex > 0) {
aom_wb_write_bit(wb, cm->delta_q_present_flag);
if (cm->delta_q_present_flag) {
aom_wb_write_literal(wb, OD_ILOG_NZ(cm->delta_q_res) - 1, 2);
xd->prev_qindex = cm->base_qindex;
#if CONFIG_EXT_DELTA_Q
assert(seg->abs_delta == SEGMENT_DELTADATA);
assert(cm->seg.abs_delta == SEGMENT_DELTADATA);
aom_wb_write_bit(wb, cm->delta_lf_present_flag);
if (cm->delta_lf_present_flag) {
aom_wb_write_literal(wb, OD_ILOG_NZ(cm->delta_lf_res) - 1, 2);
......@@ -4821,6 +4826,8 @@ static void write_uncompressed_header_obu(AV1_COMP *cpi,
encode_quantization(cm, wb);
encode_segmentation(cm, xd, wb);
{
int delta_q_allowed = 1;
#if !CONFIG_EXT_DELTA_Q
int i;
struct segmentation *const seg = &cm->seg;
int segment_quantizer_active = 0;
......@@ -4829,10 +4836,12 @@ static void write_uncompressed_header_obu(AV1_COMP *cpi,
segment_quantizer_active = 1;
}
}
delta_q_allowed = !segment_quantizer_active;
#endif
if (cm->delta_q_present_flag)
assert(segment_quantizer_active == 0 && cm->base_qindex > 0);
if (segment_quantizer_active == 0 && cm->base_qindex > 0) {
assert(delta_q_allowed == 1 && cm->base_qindex > 0);
if (delta_q_allowed == 1 && cm->base_qindex > 0) {
aom_wb_write_bit(wb, cm->delta_q_present_flag);
if (cm->delta_q_present_flag) {
aom_wb_write_literal(wb, OD_ILOG_NZ(cm->delta_q_res) - 1, 2);
......
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