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
ddf02e32
Commit
ddf02e32
authored
Aug 01, 2013
by
Dmitry Kovalev
Committed by
Gerrit Code Review
Aug 01, 2013
Browse files
Merge "Nice looking motion vector clamping functions."
parents
19d42de3
b621e2d7
Changes
5
Hide whitespace changes
Inline
Side-by-side
vp9/common/vp9_findnearmv.c
View file @
ddf02e32
...
...
@@ -32,7 +32,7 @@ void vp9_find_best_ref_mvs(MACROBLOCKD *xd,
// Make sure all the candidates are properly clamped etc
for
(
i
=
0
;
i
<
MAX_MV_REF_CANDIDATES
;
++
i
)
{
lower_mv_precision
(
&
mvlist
[
i
],
xd
->
allow_high_precision_mv
);
clamp_mv2
(
&
mvlist
[
i
],
xd
);
clamp_mv2
(
&
mvlist
[
i
]
.
as_mv
,
xd
);
}
*
nearest
=
mvlist
[
0
];
*
near
=
mvlist
[
1
];
...
...
vp9/common/vp9_findnearmv.h
View file @
ddf02e32
...
...
@@ -29,24 +29,17 @@ void vp9_find_best_ref_mvs(MACROBLOCKD *xd,
int_mv
*
near
);
// TODO(jingning): this mv clamping function should be block size dependent.
static
void
clamp_mv
(
int_mv
*
mv
,
int
mb_to_left_edge
,
int
mb_to_right_edge
,
int
mb_to_top_edge
,
int
mb_to_bottom_edge
)
{
mv
->
as_mv
.
col
=
clamp
(
mv
->
as_mv
.
col
,
mb_to_left_edge
,
mb_to_right_edge
);
mv
->
as_mv
.
row
=
clamp
(
mv
->
as_mv
.
row
,
mb_to_top_edge
,
mb_to_bottom_edge
);
static
void
clamp_mv
(
MV
*
mv
,
int
min_col
,
int
max_col
,
int
min_row
,
int
max_row
)
{
mv
->
col
=
clamp
(
mv
->
col
,
min_col
,
max_col
);
mv
->
row
=
clamp
(
mv
->
row
,
min_row
,
max_row
);
}
static
int
clamp_mv2
(
int_mv
*
mv
,
const
MACROBLOCKD
*
xd
)
{
int_mv
tmp_mv
;
tmp_mv
.
as_int
=
mv
->
as_int
;
clamp_mv
(
mv
,
xd
->
mb_to_left_edge
-
LEFT_TOP_MARGIN
,
xd
->
mb_to_right_edge
+
RIGHT_BOTTOM_MARGIN
,
xd
->
mb_to_top_edge
-
LEFT_TOP_MARGIN
,
xd
->
mb_to_bottom_edge
+
RIGHT_BOTTOM_MARGIN
);
return
tmp_mv
.
as_int
!=
mv
->
as_int
;
static
void
clamp_mv2
(
MV
*
mv
,
const
MACROBLOCKD
*
xd
)
{
clamp_mv
(
mv
,
xd
->
mb_to_left_edge
-
LEFT_TOP_MARGIN
,
xd
->
mb_to_right_edge
+
RIGHT_BOTTOM_MARGIN
,
xd
->
mb_to_top_edge
-
LEFT_TOP_MARGIN
,
xd
->
mb_to_bottom_edge
+
RIGHT_BOTTOM_MARGIN
);
}
void
vp9_append_sub8x8_mvs_for_idx
(
VP9_COMMON
*
pc
,
...
...
vp9/decoder/vp9_decodemv.c
View file @
ddf02e32
...
...
@@ -366,16 +366,6 @@ static INLINE COMPPREDMODE_TYPE read_comp_pred_mode(vp9_reader *r) {
return
mode
;
}
static
INLINE
void
assign_and_clamp_mv
(
int_mv
*
dst
,
const
int_mv
*
src
,
int
mb_to_left_edge
,
int
mb_to_right_edge
,
int
mb_to_top_edge
,
int
mb_to_bottom_edge
)
{
dst
->
as_int
=
src
->
as_int
;
clamp_mv
(
dst
,
mb_to_left_edge
,
mb_to_right_edge
,
mb_to_top_edge
,
mb_to_bottom_edge
);
}
static
INLINE
INTERPOLATIONFILTERTYPE
read_switchable_filter_type
(
VP9D_COMP
*
pbi
,
vp9_reader
*
r
)
{
VP9_COMMON
*
const
cm
=
&
pbi
->
common
;
...
...
@@ -558,36 +548,25 @@ static void read_inter_block_mode_info(VP9D_COMP *pbi, MODE_INFO *mi,
mv0
->
as_int
=
mi
->
bmi
[
3
].
as_mv
[
0
].
as_int
;
mv1
->
as_int
=
mi
->
bmi
[
3
].
as_mv
[
1
].
as_int
;
}
else
{
const
int
mb_to_top_edge
=
xd
->
mb_to_top_edge
-
LEFT_TOP_MARGIN
;
const
int
mb_to_bottom_edge
=
xd
->
mb_to_bottom_edge
+
RIGHT_BOTTOM_MARGIN
;
const
int
mb_to_left_edge
=
xd
->
mb_to_left_edge
-
LEFT_TOP_MARGIN
;
const
int
mb_to_right_edge
=
xd
->
mb_to_right_edge
+
RIGHT_BOTTOM_MARGIN
;
switch
(
mbmi
->
mode
)
{
case
NEARMV
:
// Clip "next_nearest" so that it does not extend to far out of image
assign_and_clamp_mv
(
mv0
,
&
nearby
,
mb_to_left_edge
,
mb_to_right_edge
,
mb_to_top_edge
,
mb_to_bottom_edge
);
if
(
ref1
>
0
)
assign_and_clamp_mv
(
mv1
,
&
nearby_second
,
mb_to_left_edge
,
mb_to_right_edge
,
mb_to_top_edge
,
mb_to_bottom_edge
);
mv0
->
as_int
=
nearby
.
as_int
;
clamp_mv2
(
&
mv0
->
as_mv
,
xd
);
if
(
ref1
>
0
)
{
mv1
->
as_int
=
nearby_second
.
as_int
;
clamp_mv2
(
&
mv1
->
as_mv
,
xd
);
}
break
;
case
NEARESTMV
:
// Clip "next_nearest" so that it does not extend to far out of image
assign_and_clamp_mv
(
mv0
,
&
nearest
,
mb_to_left_edge
,
mb_to_right_edge
,
mb_to_top_edge
,
mb_to_bottom_edge
);
if
(
ref1
>
0
)
assign_and_clamp_mv
(
mv1
,
&
nearest_second
,
mb_to_left_edge
,
mb_to_right_edge
,
mb_to_top_edge
,
mb_to_bottom_edge
);
mv0
->
as_int
=
nearest
.
as_int
;
clamp_mv2
(
&
mv0
->
as_mv
,
xd
);
if
(
ref1
>
0
)
{
mv1
->
as_int
=
nearest_second
.
as_int
;
clamp_mv2
(
&
mv1
->
as_mv
,
xd
);
}
break
;
case
ZEROMV
:
...
...
vp9/encoder/vp9_mcomp.c
View file @
ddf02e32
...
...
@@ -1319,7 +1319,8 @@ int vp9_hex_search
fcenter_mv
.
as_mv
.
col
=
center_mv
->
as_mv
.
col
>>
3
;
// adjust ref_mv to make sure it is within MV range
clamp_mv
(
ref_mv
,
x
->
mv_col_min
,
x
->
mv_col_max
,
x
->
mv_row_min
,
x
->
mv_row_max
);
clamp_mv
(
&
ref_mv
->
as_mv
,
x
->
mv_col_min
,
x
->
mv_col_max
,
x
->
mv_row_min
,
x
->
mv_row_max
);
br
=
ref_mv
->
as_mv
.
row
;
bc
=
ref_mv
->
as_mv
.
col
;
...
...
@@ -1475,7 +1476,8 @@ int vp9_diamond_search_sad_c(MACROBLOCK *x,
fcenter_mv
.
as_mv
.
row
=
center_mv
->
as_mv
.
row
>>
3
;
fcenter_mv
.
as_mv
.
col
=
center_mv
->
as_mv
.
col
>>
3
;
clamp_mv
(
ref_mv
,
x
->
mv_col_min
,
x
->
mv_col_max
,
x
->
mv_row_min
,
x
->
mv_row_max
);
clamp_mv
(
&
ref_mv
->
as_mv
,
x
->
mv_col_min
,
x
->
mv_col_max
,
x
->
mv_row_min
,
x
->
mv_row_max
);
ref_row
=
ref_mv
->
as_mv
.
row
;
ref_col
=
ref_mv
->
as_mv
.
col
;
*
num00
=
0
;
...
...
@@ -1615,7 +1617,8 @@ int vp9_diamond_search_sadx4(MACROBLOCK *x,
fcenter_mv
.
as_mv
.
row
=
center_mv
->
as_mv
.
row
>>
3
;
fcenter_mv
.
as_mv
.
col
=
center_mv
->
as_mv
.
col
>>
3
;
clamp_mv
(
ref_mv
,
x
->
mv_col_min
,
x
->
mv_col_max
,
x
->
mv_row_min
,
x
->
mv_row_max
);
clamp_mv
(
&
ref_mv
->
as_mv
,
x
->
mv_col_min
,
x
->
mv_col_max
,
x
->
mv_row_min
,
x
->
mv_row_max
);
ref_row
=
ref_mv
->
as_mv
.
row
;
ref_col
=
ref_mv
->
as_mv
.
col
;
*
num00
=
0
;
...
...
vp9/encoder/vp9_rdopt.c
View file @
ddf02e32
...
...
@@ -1973,7 +1973,7 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x,
// Should we do a full search (best quality only)
if
(
cpi
->
compressor_speed
==
0
)
{
/* Check if mvp_full is within the range. */
clamp_mv
(
&
mvp_full
,
x
->
mv_col_min
,
x
->
mv_col_max
,
clamp_mv
(
&
mvp_full
.
as_mv
,
x
->
mv_col_min
,
x
->
mv_col_max
,
x
->
mv_row_min
,
x
->
mv_row_max
);
thissme
=
cpi
->
full_search_sad
(
x
,
&
mvp_full
,
...
...
@@ -2833,10 +2833,8 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
for
(
i
=
0
;
i
<
num_refs
;
++
i
)
{
cur_mv
[
i
]
=
frame_mv
[
refs
[
i
]];
// Clip "next_nearest" so that it does not extend to far out of image
if
(
this_mode
==
NEWMV
)
assert
(
!
clamp_mv2
(
&
cur_mv
[
i
],
xd
));
else
clamp_mv2
(
&
cur_mv
[
i
],
xd
);
if
(
this_mode
!=
NEWMV
)
clamp_mv2
(
&
cur_mv
[
i
].
as_mv
,
xd
);
if
(
mv_check_bounds
(
x
,
&
cur_mv
[
i
]))
return
INT64_MAX
;
...
...
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