Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Xiph.Org
aom-rav1e
Commits
50f19111
Commit
50f19111
authored
Jun 27, 2017
by
Nathan E. Egge
Committed by
Nathan Egge
Jun 28, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the av1_cost_tokens_from_cdf() function.
Change-Id: I148f8c7045d179c0a1ba7f1fe33b859f66bfc7f3
parent
05b45e6b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
0 deletions
+28
-0
av1/encoder/cost.c
av1/encoder/cost.c
+18
-0
av1/encoder/cost.h
av1/encoder/cost.h
+10
-0
No files found.
av1/encoder/cost.c
View file @
50f19111
...
...
@@ -65,3 +65,21 @@ void av1_cost_tokens_skip(int *costs, const aom_prob *probs, aom_tree tree) {
costs
[
-
tree
[
0
]]
=
av1_cost_bit
(
probs
[
0
],
0
);
cost
(
costs
,
tree
,
probs
,
2
,
0
);
}
void
av1_cost_tokens_from_cdf
(
int
*
costs
,
const
aom_cdf_prob
*
cdf
,
const
int
*
inv_map
)
{
int
i
;
aom_cdf_prob
prev_cdf
=
0
;
for
(
i
=
0
;;
++
i
)
{
const
aom_cdf_prob
p15
=
AOM_ICDF
(
cdf
[
i
])
-
prev_cdf
;
prev_cdf
=
AOM_ICDF
(
cdf
[
i
]);
if
(
inv_map
)
costs
[
inv_map
[
i
]]
=
av1_cost_symbol
(
p15
);
else
costs
[
i
]
=
av1_cost_symbol
(
p15
);
// Stop once we reach the end of the CDF
if
(
cdf
[
i
]
==
AOM_ICDF
(
CDF_PROB_TOP
))
break
;
}
}
av1/encoder/cost.h
View file @
50f19111
...
...
@@ -34,6 +34,14 @@ extern const uint16_t av1_prob_cost[256];
// for each bit.
#define av1_cost_literal(n) ((n) * (1 << AV1_PROB_COST_SHIFT))
// Calculate the cost of a symbol with probability p15 / 2^15
static
INLINE
int
av1_cost_symbol
(
aom_cdf_prob
p15
)
{
assert
(
0
<
p15
&&
p15
<
CDF_PROB_TOP
);
const
int
shift
=
CDF_PROB_BITS
-
1
-
get_msb
(
p15
);
return
av1_cost_zero
(
get_prob
(
p15
<<
shift
,
CDF_PROB_TOP
))
+
av1_cost_literal
(
shift
);
}
static
INLINE
unsigned
int
cost_branch256
(
const
unsigned
int
ct
[
2
],
aom_prob
p
)
{
return
ct
[
0
]
*
av1_cost_zero
(
p
)
+
ct
[
1
]
*
av1_cost_one
(
p
);
...
...
@@ -55,6 +63,8 @@ static INLINE int treed_cost(aom_tree tree, const aom_prob *probs, int bits,
void
av1_cost_tokens
(
int
*
costs
,
const
aom_prob
*
probs
,
aom_tree
tree
);
void
av1_cost_tokens_skip
(
int
*
costs
,
const
aom_prob
*
probs
,
aom_tree
tree
);
void
av1_cost_tokens_from_cdf
(
int
*
costs
,
const
aom_cdf_prob
*
cdf
,
const
int
*
inv_map
);
#ifdef __cplusplus
}
// extern "C"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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