Change-Id: I32b63fca020c410cef16e93379b4e6e281ccbccd
return s;
}
+static INLINE int uabs_read_literal(struct AnsDecoder *ans, int bits) {
+ int literal = 0, bit;
+ assert(bits < 31);
+
+ // TODO(aconverse): Investigate ways to read/write literals faster,
+ // e.g. 8-bit chunks.
+ for (bit = bits - 1; bit >= 0; bit--)
+ literal |= uabs_read_bit(ans) << bit;
+
+ return literal;
+}
+
struct rans_sym {
AnsP8 prob;
AnsP8 cum_prob; // not-inclusive
static INLINE int ans_read_end(struct AnsDecoder *const ans) {
return ans->state == l_base;
}
+
+static INLINE int ans_reader_has_error(const struct AnsDecoder *const ans) {
+ return ans->state < l_base && ans->buf_offset == 0;
+}
#undef ANS_DIVREM
#ifdef __cplusplus
} // extern "C"
}
}
+static INLINE void buf_uabs_write_bit(struct BufAnsCoder *c, int bit) {
+ buf_uabs_write(c, bit, 128);
+}
+
+static INLINE void buf_uabs_write_literal(struct BufAnsCoder *c,
+ int literal, int bits) {
+ int bit;
+
+ assert(bits < 31);
+ for (bit = bits - 1; bit >= 0; bit--)
+ buf_uabs_write_bit(c, 1 & (literal >> bit));
+}
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus