Merge "Add some ANS helpers needed to replace the vpx bool coder with pure ANS." into nextgenv2
This commit is contained in:
Коммит
b5454b245a
|
@ -230,6 +230,18 @@ static INLINE int uabs_read_bit(struct AnsDecoder *ans) {
|
|||
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
|
||||
|
@ -327,6 +339,10 @@ static INLINE int ans_read_init(struct AnsDecoder *const ans,
|
|||
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"
|
||||
|
|
|
@ -81,6 +81,18 @@ static INLINE void buf_ans_flush(const struct BufAnsCoder *const 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
|
||||
|
|
Загрузка…
Ссылка в новой задаче