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
b3c66f8a
Commit
b3c66f8a
authored
Dec 23, 2014
by
Jim Bankoski
Browse files
WIP: Remove giant value cost table
Change-Id: Iabe8a8868a747626c24bb13f1796f4c7827af367
parent
4e04fa6d
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
vp9/common/vp9_entropy.h
View file @
b3c66f8a
...
...
@@ -81,6 +81,7 @@ typedef struct {
const
vp9_prob
*
prob
;
int
len
;
int
base_val
;
const
int16_t
*
cost
;
}
vp9_extra_bit
;
// indexed by token value
...
...
vp9/encoder/vp9_encodemb.c
View file @
b3c66f8a
...
...
@@ -147,9 +147,15 @@ static int optimize_b(MACROBLOCK *mb, int plane, int block,
int
next
=
eob
,
sz
=
0
;
int64_t
rdmult
=
mb
->
rdmult
*
plane_rd_mult
[
type
],
rddiv
=
mb
->
rddiv
;
int64_t
rd_cost0
,
rd_cost1
;
int
rate0
,
rate1
,
error0
,
error1
,
t0
,
t1
;
int
rate0
,
rate1
,
error0
,
error1
;
int16_t
t0
,
t1
;
EXTRABIT
e0
;
int
best
,
band
,
pt
,
i
,
final_eob
;
const
int16_t
*
dct_value_cost
;
#if CONFIG_VP9_HIGHBITDEPTH
const
int16_t
*
cat6_high_cost
=
vp9_get_high_cost_table
(
xd
->
bd
);
#else
const
int16_t
*
cat6_high_cost
=
vp9_get_high_cost_table
(
8
);
#endif
assert
((
!
type
&&
!
plane
)
||
(
type
&&
plane
));
assert
(
eob
<=
default_eob
);
...
...
@@ -166,17 +172,6 @@ static int optimize_b(MACROBLOCK *mb, int plane, int block,
tokens
[
eob
][
0
].
qc
=
0
;
tokens
[
eob
][
1
]
=
tokens
[
eob
][
0
];
#if CONFIG_VP9_HIGHBITDEPTH
if
(
xd
->
bd
==
12
)
{
dct_value_cost
=
vp9_dct_value_cost_high12_ptr
;
}
else
if
(
xd
->
bd
==
10
)
{
dct_value_cost
=
vp9_dct_value_cost_high10_ptr
;
}
else
{
dct_value_cost
=
vp9_dct_value_cost_ptr
;
}
#else
dct_value_cost
=
vp9_dct_value_cost_ptr
;
#endif
for
(
i
=
0
;
i
<
eob
;
i
++
)
token_cache
[
scan
[
i
]]
=
vp9_pt_energy_class
[
vp9_get_token
(
qcoeff
[
scan
[
i
]])];
...
...
@@ -193,7 +188,7 @@ static int optimize_b(MACROBLOCK *mb, int plane, int block,
/* Evaluate the first possibility for this state. */
rate0
=
tokens
[
next
][
0
].
rate
;
rate1
=
tokens
[
next
][
1
].
rate
;
t0
=
vp9_get_token
(
x
);
vp9_get_token
_extra
(
x
,
&
t0
,
&
e0
);
/* Consider both possible successor states. */
if
(
next
<
default_eob
)
{
band
=
band_translate
[
i
+
1
];
...
...
@@ -206,7 +201,7 @@ static int optimize_b(MACROBLOCK *mb, int plane, int block,
UPDATE_RD_COST
();
/* And pick the best. */
best
=
rd_cost1
<
rd_cost0
;
base_bits
=
dct_value
_cost
[
x
]
;
base_bits
=
vp9_get_cost
(
t0
,
e0
,
cat6_high
_cost
)
;
dx
=
mul
*
(
dqcoeff
[
rc
]
-
coeff
[
rc
]);
#if CONFIG_VP9_HIGHBITDEPTH
if
(
xd
->
cur_buf
->
flags
&
YV12_FLAG_HIGHBITDEPTH
)
{
...
...
@@ -244,8 +239,10 @@ static int optimize_b(MACROBLOCK *mb, int plane, int block,
*/
t0
=
tokens
[
next
][
0
].
token
==
EOB_TOKEN
?
EOB_TOKEN
:
ZERO_TOKEN
;
t1
=
tokens
[
next
][
1
].
token
==
EOB_TOKEN
?
EOB_TOKEN
:
ZERO_TOKEN
;
e0
=
0
;
}
else
{
t0
=
t1
=
vp9_get_token
(
x
);
vp9_get_token_extra
(
x
,
&
t0
,
&
e0
);
t1
=
t0
;
}
if
(
next
<
default_eob
)
{
band
=
band_translate
[
i
+
1
];
...
...
@@ -264,7 +261,7 @@ static int optimize_b(MACROBLOCK *mb, int plane, int block,
UPDATE_RD_COST
();
/* And pick the best. */
best
=
rd_cost1
<
rd_cost0
;
base_bits
=
dct_value
_cost
[
x
]
;
base_bits
=
vp9_get_cost
(
t0
,
e0
,
cat6_high
_cost
)
;
if
(
shortcut
)
{
#if CONFIG_VP9_HIGHBITDEPTH
...
...
vp9/encoder/vp9_encoder.c
View file @
b3c66f8a
...
...
@@ -186,7 +186,6 @@ void vp9_initialize_enc(void) {
if
(
!
init_done
)
{
vp9_rtcd
();
vp9_init_intra_predictors
();
vp9_tokenize_initialize
();
vp9_init_me_luts
();
vp9_rc_init_minq_luts
();
vp9_entropy_mv_init
();
...
...
vp9/encoder/vp9_rdopt.c
View file @
b3c66f8a
...
...
@@ -360,6 +360,12 @@ static INLINE int cost_coeffs(MACROBLOCK *x,
uint8_t
token_cache
[
32
*
32
];
int
pt
=
combine_entropy_contexts
(
*
A
,
*
L
);
int
c
,
cost
;
#if CONFIG_VP9_HIGHBITDEPTH
const
int16_t
*
cat6_high_cost
=
vp9_get_high_cost_table
(
xd
->
bd
);
#else
const
int16_t
*
cat6_high_cost
=
vp9_get_high_cost_table
(
8
);
#endif
// Check for consistency of tx_size with mode info
assert
(
type
==
PLANE_TYPE_Y
?
mbmi
->
tx_size
==
tx_size
:
get_uv_tx_size
(
mbmi
,
pd
)
==
tx_size
);
...
...
@@ -373,23 +379,29 @@ static INLINE int cost_coeffs(MACROBLOCK *x,
// dc token
int
v
=
qcoeff
[
0
];
int
prev_t
=
vp9_get_token
(
v
);
cost
=
(
*
token_costs
)[
0
][
pt
][
prev_t
]
+
vp9_dct_value_cost_ptr
[
v
];
int16_t
prev_t
;
EXTRABIT
e
;
vp9_get_token_extra
(
v
,
&
prev_t
,
&
e
);
cost
=
(
*
token_costs
)[
0
][
pt
][
prev_t
]
+
vp9_get_cost
(
prev_t
,
e
,
cat6_high_cost
);
token_cache
[
0
]
=
vp9_pt_energy_class
[
prev_t
];
++
token_costs
;
// ac tokens
for
(
c
=
1
;
c
<
eob
;
c
++
)
{
const
int
rc
=
scan
[
c
];
int
t
;
int
16_t
t
;
v
=
qcoeff
[
rc
];
t
=
vp9_get_token
(
v
);
vp9_get_token
_extra
(
v
,
&
t
,
&
e
);
if
(
use_fast_coef_costing
)
{
cost
+=
(
*
token_costs
)[
!
prev_t
][
!
prev_t
][
t
]
+
vp9_dct_value_cost_ptr
[
v
];
cost
+=
(
*
token_costs
)[
!
prev_t
][
!
prev_t
][
t
]
+
vp9_get_cost
(
t
,
e
,
cat6_high_cost
);
}
else
{
pt
=
get_coef_context
(
nb
,
token_cache
,
c
);
cost
+=
(
*
token_costs
)[
!
prev_t
][
pt
][
t
]
+
vp9_dct_value_cost_ptr
[
v
];
cost
+=
(
*
token_costs
)[
!
prev_t
][
pt
][
t
]
+
vp9_get_cost
(
t
,
e
,
cat6_high_cost
);
token_cache
[
rc
]
=
vp9_pt_energy_class
[
t
];
}
prev_t
=
t
;
...
...
vp9/encoder/vp9_tokenize.c
View file @
b3c66f8a
This diff is collapsed.
Click to expand it.
vp9/encoder/vp9_tokenize.h
View file @
b3c66f8a
...
...
@@ -20,8 +20,6 @@
extern
"C"
{
#endif
void
vp9_tokenize_initialize
();
#define EOSB_TOKEN 127 // Not signalled, encoder only
#if CONFIG_VP9_HIGHBITDEPTH
...
...
@@ -63,11 +61,29 @@ extern const int16_t *vp9_dct_value_cost_ptr;
*/
extern
const
TOKENVALUE
*
vp9_dct_value_tokens_ptr
;
extern
const
TOKENVALUE
*
vp9_dct_cat_lt_10_value_tokens
;
extern
const
int16_t
vp9_cat6_low_cost
[
256
];
extern
const
int16_t
vp9_cat6_high_cost
[
128
];
extern
const
int16_t
vp9_cat6_high10_high_cost
[
512
];
extern
const
int16_t
vp9_cat6_high12_high_cost
[
2048
];
static
INLINE
int16_t
vp9_get_cost
(
uint8_t
token
,
EXTRABIT
extrabits
,
const
int16_t
*
cat6_high_table
)
{
if
(
token
!=
CATEGORY6_TOKEN
)
return
vp9_extra_bits
[
token
].
cost
[
extrabits
];
return
vp9_cat6_low_cost
[
extrabits
&
0xff
]
+
cat6_high_table
[
extrabits
>>
8
];
}
#if CONFIG_VP9_HIGHBITDEPTH
extern
const
int16_t
*
vp9_dct_value_cost_high10_ptr
;
extern
const
TOKENVALUE
*
vp9_dct_value_tokens_high10_ptr
;
extern
const
int16_t
*
vp9_dct_value_cost_high12_ptr
;
extern
const
TOKENVALUE
*
vp9_dct_value_tokens_high12_ptr
;
static
INLINE
const
int16_t
*
vp9_get_high_cost_table
(
int
bit_depth
)
{
return
bit_depth
==
8
?
vp9_cat6_high_cost
:
(
bit_depth
==
10
?
vp9_cat6_high10_high_cost
:
vp9_cat6_high12_high_cost
);
}
#else
static
INLINE
const
int16_t
*
vp9_get_high_cost_table
(
int
bit_depth
)
{
(
void
)
bit_depth
;
return
vp9_cat6_high_cost
;
}
#endif // CONFIG_VP9_HIGHBITDEPTH
static
INLINE
void
vp9_get_token_extra
(
int
v
,
int16_t
*
token
,
EXTRABIT
*
extra
)
{
...
...
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