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
d432f7e3
Commit
d432f7e3
authored
Aug 07, 2012
by
Daniel Kang
Browse files
Some refactoring of mcomp functions.
Change-Id: Ic7a7cb1199b085e98ede0e634619b3077c348d57
parent
dce08962
Changes
3
Hide whitespace changes
Inline
Side-by-side
vp8/encoder/mcomp.c
View file @
d432f7e3
...
...
@@ -1249,20 +1249,11 @@ cal_neighbors:
#undef CHECK_POINT
#undef CHECK_BETTER
int
vp8_diamond_search_sad
(
MACROBLOCK
*
x
,
BLOCK
*
b
,
BLOCKD
*
d
,
int_mv
*
ref_mv
,
int_mv
*
best_mv
,
int
search_param
,
int
sad_per_bit
,
int
*
num00
,
vp8_variance_fn_ptr_t
*
fn_ptr
,
int
*
mvcost
[
2
],
int_mv
*
center_mv
)
{
int
vp8_diamond_search_sad
(
MACROBLOCK
*
x
,
BLOCK
*
b
,
BLOCKD
*
d
,
int_mv
*
ref_mv
,
int_mv
*
best_mv
,
int
search_param
,
int
sad_per_bit
,
int
*
num00
,
vp8_variance_fn_ptr_t
*
fn_ptr
,
int
*
mvcost
[
2
],
int_mv
*
center_mv
)
{
int
i
,
j
,
step
;
unsigned
char
*
what
=
(
*
(
b
->
base_src
)
+
b
->
src
);
...
...
@@ -1278,10 +1269,8 @@ int vp8_diamond_search_sad
int
best_site
=
0
;
int
last_site
=
0
;
int
ref_row
;
int
ref_col
;
int
this_row_offset
;
int
this_col_offset
;
int
ref_row
,
ref_col
;
int
this_row_offset
,
this_col_offset
;
search_site
*
ss
;
unsigned
char
*
check_here
;
...
...
@@ -1372,20 +1361,11 @@ int vp8_diamond_search_sad
xd
->
allow_high_precision_mv
);
}
int
vp8_diamond_search_sadx4
(
MACROBLOCK
*
x
,
BLOCK
*
b
,
BLOCKD
*
d
,
int_mv
*
ref_mv
,
int_mv
*
best_mv
,
int
search_param
,
int
sad_per_bit
,
int
*
num00
,
vp8_variance_fn_ptr_t
*
fn_ptr
,
int
*
mvcost
[
2
],
int_mv
*
center_mv
)
{
int
vp8_diamond_search_sadx4
(
MACROBLOCK
*
x
,
BLOCK
*
b
,
BLOCKD
*
d
,
int_mv
*
ref_mv
,
int_mv
*
best_mv
,
int
search_param
,
int
sad_per_bit
,
int
*
num00
,
vp8_variance_fn_ptr_t
*
fn_ptr
,
int
*
mvcost
[
2
],
int_mv
*
center_mv
)
{
int
i
,
j
,
step
;
unsigned
char
*
what
=
(
*
(
b
->
base_src
)
+
b
->
src
);
...
...
@@ -1528,6 +1508,49 @@ int vp8_diamond_search_sadx4
xd
->
allow_high_precision_mv
);
}
#define XMVCOST (x->e_mbd.allow_high_precision_mv?x->mvcost_hp:x->mvcost)
int
vp8_full_pixel_diamond
(
VP8_COMP
*
cpi
,
MACROBLOCK
*
x
,
BLOCK
*
b
,
BLOCKD
*
d
,
int_mv
*
mvp_full
,
int
step_param
,
int
sadpb
,
int
further_steps
,
int
*
do_refine
,
vp8_variance_fn_ptr_t
*
fn_ptr
,
int_mv
*
ref_mv
,
int_mv
*
dst_mv
)
{
int_mv
temp_mv
;
int
thissme
,
n
,
num00
;
int
bestsme
=
cpi
->
diamond_search_sad
(
x
,
b
,
d
,
mvp_full
,
&
temp_mv
,
step_param
,
sadpb
,
&
num00
,
fn_ptr
,
XMVCOST
,
ref_mv
);
dst_mv
->
as_int
=
temp_mv
.
as_int
;
n
=
num00
;
num00
=
0
;
/* If there won't be more n-step search, check to see if refining search is needed. */
if
(
n
>
further_steps
)
*
do_refine
=
0
;
while
(
n
<
further_steps
)
{
n
++
;
if
(
num00
)
num00
--
;
else
{
thissme
=
cpi
->
diamond_search_sad
(
x
,
b
,
d
,
mvp_full
,
&
temp_mv
,
step_param
+
n
,
sadpb
,
&
num00
,
fn_ptr
,
XMVCOST
,
ref_mv
);
/* check to see if refining search is needed. */
if
(
num00
>
(
further_steps
-
n
))
*
do_refine
=
0
;
if
(
thissme
<
bestsme
)
{
bestsme
=
thissme
;
dst_mv
->
as_int
=
temp_mv
.
as_int
;
}
}
}
return
bestsme
;
}
int
vp8_full_search_sad
(
MACROBLOCK
*
x
,
BLOCK
*
b
,
BLOCKD
*
d
,
int_mv
*
ref_mv
,
int
sad_per_bit
,
int
distance
,
vp8_variance_fn_ptr_t
*
fn_ptr
,
int
*
mvcost
[
2
],
...
...
vp8/encoder/mcomp.h
View file @
d432f7e3
...
...
@@ -30,7 +30,13 @@ extern int vp8_mv_bit_cost(int_mv *mv, int_mv *ref, int *mvcost[2],
int
Weight
,
int
ishp
);
extern
void
vp8_init_dsmotion_compensation
(
MACROBLOCK
*
x
,
int
stride
);
extern
void
vp8_init3smotion_compensation
(
MACROBLOCK
*
x
,
int
stride
);
// Runs sequence of diamond searches in smaller steps for RD
struct
VP8_COMP
;
int
vp8_full_pixel_diamond
(
struct
VP8_COMP
*
cpi
,
MACROBLOCK
*
x
,
BLOCK
*
b
,
BLOCKD
*
d
,
int_mv
*
mvp_full
,
int
step_param
,
int
sadpb
,
int
further_steps
,
int
*
do_refine
,
vp8_variance_fn_ptr_t
*
fn_ptr
,
int_mv
*
ref_mv
,
int_mv
*
dst_mv
);
extern
int
vp8_hex_search
(
...
...
vp8/encoder/rdopt.c
View file @
d432f7e3
...
...
@@ -1818,11 +1818,10 @@ static void rd_check_segment(VP8_COMP *cpi, MACROBLOCK *x,
// motion search for newmv (single predictor case only)
if
(
!
x
->
e_mbd
.
mode_info_context
->
mbmi
.
second_ref_frame
&&
this_mode
==
NEW4X4
)
{
int
sseshift
,
num00
,
n
;
int
sseshift
,
n
;
int
step_param
=
0
;
int
further_steps
;
int
thissme
,
bestsme
=
INT_MAX
;
int_mv
temp_mv
;
BLOCK
*
c
;
BLOCKD
*
e
;
...
...
@@ -1851,6 +1850,7 @@ static void rd_check_segment(VP8_COMP *cpi, MACROBLOCK *x,
further_steps
=
(
MAX_MVSEARCH_STEPS
-
1
)
-
step_param
;
{
int
dummy
;
int
sadpb
=
x
->
sadperbit4
;
int_mv
mvp_full
;
...
...
@@ -1863,36 +1863,11 @@ static void rd_check_segment(VP8_COMP *cpi, MACROBLOCK *x,
c
=
&
x
->
block
[
n
];
e
=
&
x
->
e_mbd
.
block
[
n
];
{
bestsme
=
cpi
->
diamond_search_sad
(
x
,
c
,
e
,
&
mvp_full
,
&
mode_mv
[
NEW4X4
],
step_param
,
sadpb
,
&
num00
,
v_fn_ptr
,
XMVCOST
,
bsi
->
ref_mv
);
n
=
num00
;
num00
=
0
;
while
(
n
<
further_steps
)
{
n
++
;
if
(
num00
)
num00
--
;
else
{
thissme
=
cpi
->
diamond_search_sad
(
x
,
c
,
e
,
&
mvp_full
,
&
temp_mv
,
step_param
+
n
,
sadpb
,
&
num00
,
v_fn_ptr
,
XMVCOST
,
bsi
->
ref_mv
);
if
(
thissme
<
bestsme
)
{
bestsme
=
thissme
;
mode_mv
[
NEW4X4
].
as_int
=
temp_mv
.
as_int
;
}
}
}
}
// dummy takes the place of do_refine -- which is used in other places
bestsme
=
vp8_full_pixel_diamond
(
cpi
,
x
,
c
,
e
,
&
mvp_full
,
step_param
,
sadpb
,
further_steps
,
&
dummy
,
v_fn_ptr
,
bsi
->
ref_mv
,
&
mode_mv
[
NEW4X4
]);
sseshift
=
segmentation_to_sseshift
[
segmentation
];
...
...
@@ -2664,8 +2639,7 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
int_mv
best_ref_mv
,
second_best_ref_mv
;
int_mv
mode_mv
[
MB_MODE_COUNT
];
MB_PREDICTION_MODE
this_mode
;
int
num00
,
i
;
int
best_mode_index
=
0
;
int
i
,
best_mode_index
=
0
;
int
mode8x8
[
2
][
4
];
unsigned
char
segment_id
=
xd
->
mode_info_context
->
mbmi
.
segment_id
;
...
...
@@ -3117,7 +3091,6 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
int
thissme
,
bestsme
=
INT_MAX
;
int
step_param
=
cpi
->
sf
.
first_step
;
int
further_steps
;
int
n
;
int
do_refine
=
1
;
/* If last step (1-away) of n-step search doesn't pick the center point as the best match,
we will do a final 1-away diamond refining search */
...
...
@@ -3146,48 +3119,14 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
if
(
sr
>
step_param
)
step_param
=
sr
;
// Initial step/diamond search
{
bestsme
=
cpi
->
diamond_search_sad
(
x
,
b
,
d
,
&
mvp_full
,
&
d
->
bmi
.
as_mv
.
first
,
step_param
,
sadpb
,
&
num00
,
&
cpi
->
fn_ptr
[
BLOCK_16X16
],
XMVCOST
,
&
best_ref_mv
);
mode_mv
[
NEWMV
].
as_int
=
d
->
bmi
.
as_mv
.
first
.
as_int
;
// Further step/diamond searches as necessary
further_steps
=
(
cpi
->
sf
.
max_step_search_steps
-
1
)
-
step_param
;
n
=
num00
;
num00
=
0
;
/* If there won't be more n-step search, check to see if refining search is needed. */
if
(
n
>
further_steps
)
do_refine
=
0
;
while
(
n
<
further_steps
)
{
n
++
;
if
(
num00
)
num00
--
;
else
{
thissme
=
cpi
->
diamond_search_sad
(
x
,
b
,
d
,
&
mvp_full
,
&
d
->
bmi
.
as_mv
.
first
,
step_param
+
n
,
sadpb
,
&
num00
,
&
cpi
->
fn_ptr
[
BLOCK_16X16
],
XMVCOST
,
&
best_ref_mv
);
/* check to see if refining search is needed. */
if
(
num00
>
(
further_steps
-
n
))
do_refine
=
0
;
if
(
thissme
<
bestsme
)
{
bestsme
=
thissme
;
mode_mv
[
NEWMV
].
as_int
=
d
->
bmi
.
as_mv
.
first
.
as_int
;
}
else
{
d
->
bmi
.
as_mv
.
first
.
as_int
=
mode_mv
[
NEWMV
].
as_int
;
}
}
}
}
// Further step/diamond searches as necessary
further_steps
=
(
cpi
->
sf
.
max_step_search_steps
-
1
)
-
step_param
;
bestsme
=
vp8_full_pixel_diamond
(
cpi
,
x
,
b
,
d
,
&
mvp_full
,
step_param
,
sadpb
,
further_steps
,
&
do_refine
,
&
cpi
->
fn_ptr
[
BLOCK_16X16
],
&
best_ref_mv
,
&
mode_mv
[
NEWMV
]);
d
->
bmi
.
as_mv
.
first
.
as_int
=
mode_mv
[
NEWMV
].
as_int
;
/* final 1-away diamond refining search */
if
(
do_refine
==
1
)
{
...
...
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