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:
@@ -7,6 +7,7 @@
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
#include "./vpx_config.h"
|
||||
#include "./bitreader_buffer.h"
|
||||
|
||||
size_t vpx_rb_bytes_read(struct vpx_read_bit_buffer *rb) {
|
||||
@@ -39,3 +40,14 @@ int vpx_rb_read_signed_literal(struct vpx_read_bit_buffer *rb,
|
||||
const int value = vpx_rb_read_literal(rb, bits);
|
||||
return vpx_rb_read_bit(rb) ? -value : value;
|
||||
}
|
||||
|
||||
int vpx_rb_read_inv_signed_literal(struct vpx_read_bit_buffer *rb,
|
||||
int bits) {
|
||||
#if CONFIG_MISC_FIXES
|
||||
const int nbits = sizeof(unsigned) * 8 - bits - 1;
|
||||
const unsigned value = vpx_rb_read_literal(rb, bits + 1) << nbits;
|
||||
return ((int) value) >> nbits;
|
||||
#else
|
||||
return vpx_rb_read_signed_literal(rb, bits);
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user