vp10: code sign bit before absolute value in non-arithcoded header.

For reading, this makes the operation branchless, although it still
requires two shifts. For writing, this makes the operation as fast
as writing an unsigned value, branchlessly. This is also how other
codecs typically code signed, non-arithcoded bitstream elements.

See issue 1039.

Change-Id: I6a8182cc88a16842fb431688c38f6b52d7f24ead
This commit is contained in:
Ronald S. Bultje
2015-09-08 14:26:42 -04:00
parent 3c8e04e939
commit a3df343cda
6 changed files with 34 additions and 9 deletions

View File

@@ -714,8 +714,7 @@ static void encode_loopfilter(struct loopfilter *lf,
vpx_wb_write_bit(wb, changed);
if (changed) {
lf->last_ref_deltas[i] = delta;
vpx_wb_write_literal(wb, abs(delta) & 0x3F, 6);
vpx_wb_write_bit(wb, delta < 0);
vpx_wb_write_inv_signed_literal(wb, delta, 6);
}
}
@@ -725,8 +724,7 @@ static void encode_loopfilter(struct loopfilter *lf,
vpx_wb_write_bit(wb, changed);
if (changed) {
lf->last_mode_deltas[i] = delta;
vpx_wb_write_literal(wb, abs(delta) & 0x3F, 6);
vpx_wb_write_bit(wb, delta < 0);
vpx_wb_write_inv_signed_literal(wb, delta, 6);
}
}
}
@@ -736,8 +734,7 @@ static void encode_loopfilter(struct loopfilter *lf,
static void write_delta_q(struct vpx_write_bit_buffer *wb, int delta_q) {
if (delta_q != 0) {
vpx_wb_write_bit(wb, 1);
vpx_wb_write_literal(wb, abs(delta_q), 4);
vpx_wb_write_bit(wb, delta_q < 0);
vpx_wb_write_inv_signed_literal(wb, delta_q, 4);
} else {
vpx_wb_write_bit(wb, 0);
}