Skip to content
GitLab
Menu
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
66307bf2
Commit
66307bf2
authored
May 01, 2014
by
Dmitry Kovalev
Browse files
Moving costs from MACROBLOCK to VP9_COMP.
Change-Id: I61471dd0f77d1547abec13cbf9670e1c4eb9131a
parent
e05b92c0
Changes
5
Hide whitespace changes
Inline
Side-by-side
vp9/encoder/vp9_block.h
View file @
66307bf2
...
...
@@ -129,12 +129,6 @@ struct macroblock {
int
*
nmvsadcost_hp
[
2
];
int
**
mvsadcost
;
int
mbmode_cost
[
INTRA_MODES
];
unsigned
inter_mode_cost
[
INTER_MODE_CONTEXTS
][
INTER_MODES
];
int
intra_uv_mode_cost
[
FRAME_TYPES
][
INTRA_MODES
];
int
y_mode_costs
[
INTRA_MODES
][
INTRA_MODES
][
INTRA_MODES
];
int
switchable_interp_costs
[
SWITCHABLE_FILTER_CONTEXTS
][
SWITCHABLE_FILTERS
];
// These define limits to motion vector components to prevent them
// from extending outside the UMV borders
int
mv_col_min
;
...
...
vp9/encoder/vp9_encoder.h
View file @
66307bf2
...
...
@@ -499,6 +499,12 @@ typedef struct VP9_COMP {
search_site_config
ss_cfg
;
int
mbmode_cost
[
INTRA_MODES
];
unsigned
inter_mode_cost
[
INTER_MODE_CONTEXTS
][
INTER_MODES
];
int
intra_uv_mode_cost
[
FRAME_TYPES
][
INTRA_MODES
];
int
y_mode_costs
[
INTRA_MODES
][
INTRA_MODES
][
INTRA_MODES
];
int
switchable_interp_costs
[
SWITCHABLE_FILTER_CONTEXTS
][
SWITCHABLE_FILTERS
];
#if CONFIG_MULTIPLE_ARF
// ARF tracking variables.
int
multi_arf_enabled
;
...
...
vp9/encoder/vp9_pickmode.c
View file @
66307bf2
...
...
@@ -320,8 +320,8 @@ int64_t vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
if
(
frame_mv
[
NEWMV
][
ref_frame
].
as_int
==
INVALID_MV
)
continue
;
rate_mode
=
x
->
inter_mode_cost
[
mbmi
->
mode_context
[
ref_frame
]]
[
INTER_OFFSET
(
this_mode
)];
rate_mode
=
cpi
->
inter_mode_cost
[
mbmi
->
mode_context
[
ref_frame
]]
[
INTER_OFFSET
(
this_mode
)];
if
(
RDCOST
(
x
->
rdmult
,
x
->
rddiv
,
rate_mv
+
rate_mode
,
0
)
>
best_rd
)
continue
;
...
...
@@ -355,24 +355,24 @@ int64_t vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
model_rd_for_sb_y
(
cpi
,
bsize
,
x
,
xd
,
&
pf_rate
[
EIGHTTAP
],
&
pf_dist
[
EIGHTTAP
]);
tmp_rdcost1
=
RDCOST
(
x
->
rdmult
,
x
->
rddiv
,
vp9_get_switchable_rate
(
x
)
+
pf_rate
[
EIGHTTAP
],
vp9_get_switchable_rate
(
cpi
)
+
pf_rate
[
EIGHTTAP
],
pf_dist
[
EIGHTTAP
]);
mbmi
->
interp_filter
=
EIGHTTAP_SHARP
;
vp9_build_inter_predictors_sby
(
xd
,
mi_row
,
mi_col
,
bsize
);
model_rd_for_sb_y
(
cpi
,
bsize
,
x
,
xd
,
&
pf_rate
[
EIGHTTAP_SHARP
],
&
pf_dist
[
EIGHTTAP_SHARP
]);
tmp_rdcost2
=
RDCOST
(
x
->
rdmult
,
x
->
rddiv
,
vp9_get_switchable_rate
(
x
)
+
pf_rate
[
EIGHTTAP_SHARP
],
pf_dist
[
EIGHTTAP_SHARP
]);
tmp_rdcost2
=
RDCOST
(
x
->
rdmult
,
x
->
rddiv
,
vp9_get_switchable_rate
(
cpi
)
+
pf_rate
[
EIGHTTAP_SHARP
],
pf_dist
[
EIGHTTAP_SHARP
]);
mbmi
->
interp_filter
=
EIGHTTAP_SMOOTH
;
vp9_build_inter_predictors_sby
(
xd
,
mi_row
,
mi_col
,
bsize
);
model_rd_for_sb_y
(
cpi
,
bsize
,
x
,
xd
,
&
pf_rate
[
EIGHTTAP_SMOOTH
],
&
pf_dist
[
EIGHTTAP_SMOOTH
]);
tmp_rdcost3
=
RDCOST
(
x
->
rdmult
,
x
->
rddiv
,
vp9_get_switchable_rate
(
x
)
+
pf_rate
[
EIGHTTAP_SMOOTH
],
pf_dist
[
EIGHTTAP_SMOOTH
]);
tmp_rdcost3
=
RDCOST
(
x
->
rdmult
,
x
->
rddiv
,
vp9_get_switchable_rate
(
cpi
)
+
pf_rate
[
EIGHTTAP_SMOOTH
],
pf_dist
[
EIGHTTAP_SMOOTH
]);
if
(
tmp_rdcost2
<
tmp_rdcost1
)
{
if
(
tmp_rdcost2
<
tmp_rdcost3
)
...
...
@@ -395,7 +395,7 @@ int64_t vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
}
rate
+=
rate_mv
;
rate
+=
x
->
inter_mode_cost
[
mbmi
->
mode_context
[
ref_frame
]]
rate
+=
cpi
->
inter_mode_cost
[
mbmi
->
mode_context
[
ref_frame
]]
[
INTER_OFFSET
(
this_mode
)];
this_rd
=
RDCOST
(
x
->
rdmult
,
x
->
rddiv
,
rate
,
dist
);
...
...
@@ -426,7 +426,7 @@ int64_t vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
&
pd
->
dst
.
buf
[
0
],
pd
->
dst
.
stride
,
0
,
0
,
0
);
model_rd_for_sb_y
(
cpi
,
bsize
,
x
,
xd
,
&
rate
,
&
dist
);
rate
+=
x
->
mbmode_cost
[
this_mode
];
rate
+=
cpi
->
mbmode_cost
[
this_mode
];
rate
+=
intra_cost_penalty
;
this_rd
=
RDCOST
(
x
->
rdmult
,
x
->
rddiv
,
rate
,
dist
);
...
...
vp9/encoder/vp9_rdopt.c
View file @
66307bf2
...
...
@@ -152,24 +152,23 @@ static int16_t* raster_block_offset_int16(BLOCK_SIZE plane_bsize,
}
static
void
fill_mode_costs
(
VP9_COMP
*
cpi
)
{
MACROBLOCK
*
const
x
=
&
cpi
->
mb
;
const
FRAME_CONTEXT
*
const
fc
=
&
cpi
->
common
.
fc
;
int
i
,
j
;
for
(
i
=
0
;
i
<
INTRA_MODES
;
i
++
)
for
(
j
=
0
;
j
<
INTRA_MODES
;
j
++
)
vp9_cost_tokens
(
(
int
*
)
x
->
y_mode_costs
[
i
][
j
],
vp9_kf_y_mode_prob
[
i
][
j
],
vp9_cost_tokens
(
cpi
->
y_mode_costs
[
i
][
j
],
vp9_kf_y_mode_prob
[
i
][
j
],
vp9_intra_mode_tree
);
// TODO(rbultje) separate tables for superblock costing?
vp9_cost_tokens
(
x
->
mbmode_cost
,
fc
->
y_mode_prob
[
1
],
vp9_intra_mode_tree
);
vp9_cost_tokens
(
x
->
intra_uv_mode_cost
[
KEY_FRAME
],
vp9_cost_tokens
(
cpi
->
mbmode_cost
,
fc
->
y_mode_prob
[
1
],
vp9_intra_mode_tree
);
vp9_cost_tokens
(
cpi
->
intra_uv_mode_cost
[
KEY_FRAME
],
vp9_kf_uv_mode_prob
[
TM_PRED
],
vp9_intra_mode_tree
);
vp9_cost_tokens
(
x
->
intra_uv_mode_cost
[
INTER_FRAME
],
vp9_cost_tokens
(
cpi
->
intra_uv_mode_cost
[
INTER_FRAME
],
fc
->
uv_mode_prob
[
TM_PRED
],
vp9_intra_mode_tree
);
for
(
i
=
0
;
i
<
SWITCHABLE_FILTER_CONTEXTS
;
++
i
)
vp9_cost_tokens
(
(
int
*
)
x
->
switchable_interp_costs
[
i
],
vp9_cost_tokens
(
cpi
->
switchable_interp_costs
[
i
],
fc
->
switchable_interp_prob
[
i
],
vp9_switchable_interp_tree
);
}
...
...
@@ -313,7 +312,7 @@ void vp9_initialize_rd_consts(VP9_COMP *cpi) {
&
cm
->
fc
.
nmvc
,
cm
->
allow_high_precision_mv
);
for
(
i
=
0
;
i
<
INTER_MODE_CONTEXTS
;
++
i
)
vp9_cost_tokens
((
int
*
)
x
->
inter_mode_cost
[
i
],
vp9_cost_tokens
((
int
*
)
cpi
->
inter_mode_cost
[
i
],
cm
->
fc
.
inter_mode_probs
[
i
],
vp9_inter_mode_tree
);
}
}
...
...
@@ -1187,7 +1186,7 @@ static int64_t rd_pick_intra_sub_8x8_y_mode(VP9_COMP *cpi, MACROBLOCK *mb,
int
tot_rate_y
=
0
;
int64_t
total_rd
=
0
;
ENTROPY_CONTEXT
t_above
[
4
],
t_left
[
4
];
const
int
*
bmode_costs
=
mb
->
mbmode_cost
;
const
int
*
bmode_costs
=
cpi
->
mbmode_cost
;
vpx_memcpy
(
t_above
,
xd
->
plane
[
0
].
above_context
,
sizeof
(
t_above
));
vpx_memcpy
(
t_left
,
xd
->
plane
[
0
].
left_context
,
sizeof
(
t_left
));
...
...
@@ -1203,7 +1202,7 @@ static int64_t rd_pick_intra_sub_8x8_y_mode(VP9_COMP *cpi, MACROBLOCK *mb,
const
PREDICTION_MODE
A
=
vp9_above_block_mode
(
mic
,
above_mi
,
i
);
const
PREDICTION_MODE
L
=
vp9_left_block_mode
(
mic
,
left_mi
,
i
);
bmode_costs
=
mb
->
y_mode_costs
[
A
][
L
];
bmode_costs
=
cpi
->
y_mode_costs
[
A
][
L
];
}
this_rd
=
rd_pick_intra4x4block
(
cpi
,
mb
,
i
,
&
best_mode
,
bmode_costs
,
...
...
@@ -1250,7 +1249,7 @@ static int64_t rd_pick_intra_sby_mode(VP9_COMP *cpi, MACROBLOCK *x,
int64_t
this_distortion
,
this_rd
;
TX_SIZE
best_tx
=
TX_4X4
;
int
i
;
int
*
bmode_costs
=
x
->
mbmode_cost
;
int
*
bmode_costs
=
cpi
->
mbmode_cost
;
if
(
cpi
->
sf
.
tx_size_search_method
==
USE_FULL_RD
)
for
(
i
=
0
;
i
<
TX_MODES
;
i
++
)
...
...
@@ -1269,7 +1268,7 @@ static int64_t rd_pick_intra_sby_mode(VP9_COMP *cpi, MACROBLOCK *x,
const
PREDICTION_MODE
A
=
vp9_above_block_mode
(
mic
,
above_mi
,
0
);
const
PREDICTION_MODE
L
=
vp9_left_block_mode
(
mic
,
left_mi
,
0
);
bmode_costs
=
x
->
y_mode_costs
[
A
][
L
];
bmode_costs
=
cpi
->
y_mode_costs
[
A
][
L
];
}
mic
->
mbmi
.
mode
=
mode
;
...
...
@@ -1378,7 +1377,7 @@ static int64_t rd_pick_intra_sbuv_mode(VP9_COMP *cpi, MACROBLOCK *x,
if
(
this_rate_tokenonly
==
INT_MAX
)
continue
;
this_rate
=
this_rate_tokenonly
+
x
->
intra_uv_mode_cost
[
cpi
->
common
.
frame_type
][
mode
];
cpi
->
intra_uv_mode_cost
[
cpi
->
common
.
frame_type
][
mode
];
this_rd
=
RDCOST
(
x
->
rdmult
,
x
->
rddiv
,
this_rate
,
this_distortion
);
if
(
this_rd
<
best_rd
)
{
...
...
@@ -1426,7 +1425,7 @@ static int64_t rd_sbuv_dcpred(const VP9_COMP *cpi, MACROBLOCK *x,
x
->
e_mbd
.
mi
[
0
]
->
mbmi
.
uv_mode
=
DC_PRED
;
super_block_uvrd
(
cpi
,
x
,
rate_tokenonly
,
distortion
,
skippable
,
&
unused
,
bsize
,
INT64_MAX
);
*
rate
=
*
rate_tokenonly
+
x
->
intra_uv_mode_cost
[
cm
->
frame_type
][
DC_PRED
];
*
rate
=
*
rate_tokenonly
+
cpi
->
intra_uv_mode_cost
[
cm
->
frame_type
][
DC_PRED
];
return
RDCOST
(
x
->
rdmult
,
x
->
rddiv
,
*
rate
,
*
distortion
);
}
...
...
@@ -1460,7 +1459,7 @@ static int cost_mv_ref(const VP9_COMP *cpi, PREDICTION_MODE mode,
// Don't account for mode here if segment skip is enabled.
if
(
!
vp9_segfeature_active
(
&
cpi
->
common
.
seg
,
segment_id
,
SEG_LVL_SKIP
))
{
assert
(
is_inter_mode
(
mode
));
return
x
->
inter_mode_cost
[
mode_context
][
INTER_OFFSET
(
mode
)];
return
cpi
->
inter_mode_cost
[
mode_context
][
INTER_OFFSET
(
mode
)];
}
else
{
return
0
;
}
...
...
@@ -2334,12 +2333,12 @@ const YV12_BUFFER_CONFIG *vp9_get_scaled_ref_frame(const VP9_COMP *cpi,
return
(
scaled_idx
!=
ref_idx
)
?
&
cm
->
frame_bufs
[
scaled_idx
].
buf
:
NULL
;
}
int
vp9_get_switchable_rate
(
const
MACROBLOCK
*
x
)
{
const
MACROBLOCKD
*
const
xd
=
&
x
->
e_mbd
;
int
vp9_get_switchable_rate
(
const
VP9_COMP
*
cpi
)
{
const
MACROBLOCKD
*
const
xd
=
&
cpi
->
mb
.
e_mbd
;
const
MB_MODE_INFO
*
const
mbmi
=
&
xd
->
mi
[
0
]
->
mbmi
;
const
int
ctx
=
vp9_get_pred_context_switchable_interp
(
xd
);
return
SWITCHABLE_INTERP_RATE_FACTOR
*
x
->
switchable_interp_costs
[
ctx
][
mbmi
->
interp_filter
];
cpi
->
switchable_interp_costs
[
ctx
][
mbmi
->
interp_filter
];
}
static
void
single_motion_search
(
VP9_COMP
*
cpi
,
MACROBLOCK
*
x
,
...
...
@@ -2788,7 +2787,7 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
int
j
;
int64_t
rs_rd
;
mbmi
->
interp_filter
=
i
;
rs
=
vp9_get_switchable_rate
(
x
);
rs
=
vp9_get_switchable_rate
(
cpi
);
rs_rd
=
RDCOST
(
x
->
rdmult
,
x
->
rddiv
,
rs
,
0
);
if
(
i
>
0
&&
intpel_mv
)
{
...
...
@@ -2858,7 +2857,7 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
// Set the appropriate filter
mbmi
->
interp_filter
=
cm
->
interp_filter
!=
SWITCHABLE
?
cm
->
interp_filter
:
*
best_filter
;
rs
=
cm
->
interp_filter
==
SWITCHABLE
?
vp9_get_switchable_rate
(
x
)
:
0
;
rs
=
cm
->
interp_filter
==
SWITCHABLE
?
vp9_get_switchable_rate
(
cpi
)
:
0
;
if
(
pred_exists
)
{
if
(
best_needs_copy
)
{
...
...
@@ -2888,7 +2887,7 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
}
if
(
cm
->
interp_filter
==
SWITCHABLE
)
*
rate2
+=
vp9_get_switchable_rate
(
x
);
*
rate2
+=
vp9_get_switchable_rate
(
cpi
);
if
(
!
is_comp_pred
)
{
if
(
!
x
->
in_active_map
)
{
...
...
@@ -3436,7 +3435,7 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
skippable
=
skippable
&&
skip_uv
[
uv_tx
];
mbmi
->
uv_mode
=
mode_uv
[
uv_tx
];
rate2
=
rate_y
+
x
->
mbmode_cost
[
mbmi
->
mode
]
+
rate_uv_intra
[
uv_tx
];
rate2
=
rate_y
+
cpi
->
mbmode_cost
[
mbmi
->
mode
]
+
rate_uv_intra
[
uv_tx
];
if
(
this_mode
!=
DC_PRED
&&
this_mode
!=
TM_PRED
)
rate2
+=
intra_cost_penalty
;
distortion2
=
distortion_y
+
distortion_uv
;
...
...
@@ -4035,7 +4034,7 @@ int64_t vp9_rd_pick_inter_mode_sub8x8(VP9_COMP *cpi, MACROBLOCK *x,
if
(
tmp_rd
==
INT64_MAX
)
continue
;
rs
=
vp9_get_switchable_rate
(
x
);
rs
=
vp9_get_switchable_rate
(
cpi
);
rs_rd
=
RDCOST
(
x
->
rdmult
,
x
->
rddiv
,
rs
,
0
);
rd_opt
->
filter_cache
[
switchable_filter_index
]
=
tmp_rd
;
rd_opt
->
filter_cache
[
SWITCHABLE_FILTERS
]
=
...
...
@@ -4113,7 +4112,7 @@ int64_t vp9_rd_pick_inter_mode_sub8x8(VP9_COMP *cpi, MACROBLOCK *x,
distortion2
+=
distortion
;
if
(
cm
->
interp_filter
==
SWITCHABLE
)
rate2
+=
vp9_get_switchable_rate
(
x
);
rate2
+=
vp9_get_switchable_rate
(
cpi
);
if
(
!
mode_excluded
)
mode_excluded
=
comp_pred
?
cm
->
reference_mode
==
SINGLE_REFERENCE
...
...
vp9/encoder/vp9_rdopt.h
View file @
66307bf2
...
...
@@ -40,7 +40,7 @@ void vp9_model_rd_from_var_lapndz(unsigned int var, unsigned int n,
unsigned
int
qstep
,
int
*
rate
,
int64_t
*
dist
);
int
vp9_get_switchable_rate
(
const
MACROBLOCK
*
x
);
int
vp9_get_switchable_rate
(
const
VP9_COMP
*
cpi
);
void
vp9_setup_buffer_inter
(
VP9_COMP
*
cpi
,
MACROBLOCK
*
x
,
const
TileInfo
*
const
tile
,
...
...
Write
Preview
Supports
Markdown
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