Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Xiph.Org
aom-rav1e
Commits
64e2f105
Commit
64e2f105
authored
Jun 28, 2016
by
Alex Converse
Committed by
Yaowu Xu
Oct 21, 2016
Browse files
Use divide by multiply in the ans writer.
Change-Id: Ide4e9b3a605571ec41c265347217e103df8d0821
parent
e29ea12f
Changes
1
Hide whitespace changes
Inline
Side-by-side
aom_dsp/answriter.h
View file @
64e2f105
...
...
@@ -20,8 +20,23 @@
#include
"aom_dsp/ans.h"
#include
"aom_dsp/prob.h"
#include
"aom_ports/mem_ops.h"
#include
"av1/common/odintrin.h"
#define ANS_DIV(dividend, divisor) ((dividend) / (divisor))
#if RANS_PRECISION <= OD_DIVU_DMAX
#define ANS_DIVREM(quotient, remainder, dividend, divisor) \
do { \
quotient = OD_DIVU_SMALL((dividend), (divisor)); \
remainder = (dividend) - (quotient) * (divisor); \
} while (0)
#else
#define ANS_DIVREM(quotient, remainder, dividend, divisor) \
do { \
quotient = (dividend) / (divisor); \
remainder = (dividend) % (divisor); \
} while (0)
#endif
#define ANS_DIV8(dividend, divisor) OD_DIVU_SMALL((dividend), (divisor))
#ifdef __cplusplus
extern
"C"
{
...
...
@@ -72,9 +87,9 @@ static INLINE void uabs_write(struct AnsCoder *ans, int val, AnsP8 p0) {
ans
->
state
/=
IO_BASE
;
}
if
(
!
val
)
ans
->
state
=
ANS_DIV
(
ans
->
state
*
ANS_P8_PRECISION
,
p0
);
ans
->
state
=
ANS_DIV
8
(
ans
->
state
*
ANS_P8_PRECISION
,
p0
);
else
ans
->
state
=
ANS_DIV
((
ans
->
state
+
1
)
*
ANS_P8_PRECISION
+
p
-
1
,
p
)
-
1
;
ans
->
state
=
ANS_DIV
8
((
ans
->
state
+
1
)
*
ANS_P8_PRECISION
+
p
-
1
,
p
)
-
1
;
}
struct
rans_sym
{
...
...
@@ -88,15 +103,17 @@ struct rans_sym {
static
INLINE
void
rans_write
(
struct
AnsCoder
*
ans
,
const
struct
rans_sym
*
const
sym
)
{
const
aom_cdf_prob
p
=
sym
->
prob
;
unsigned
quot
,
rem
;
while
(
ans
->
state
>=
L_BASE
/
RANS_PRECISION
*
IO_BASE
*
p
)
{
ans
->
buf
[
ans
->
buf_offset
++
]
=
ans
->
state
%
IO_BASE
;
ans
->
state
/=
IO_BASE
;
}
ans
->
state
=
(
ans
->
state
/
p
)
*
RANS_PRECISION
+
ans
->
state
%
p
+
sym
->
cum_prob
;
ANS_DIVREM
(
quot
,
rem
,
ans
->
state
,
p
);
ans
->
state
=
quot
*
RANS_PRECISION
+
rem
+
sym
->
cum_prob
;
}
#undef ANS_DIV
#undef ANS_DIV8
#undef ANS_DIVREM
#ifdef __cplusplus
}
// extern "C"
#endif // __cplusplus
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment