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
d15e7c1d
Commit
d15e7c1d
authored
Sep 26, 2017
by
RogerZhou
Committed by
Roger Zhou
Sep 29, 2017
Browse files
Enable hash based motion estimation in IntraBC
Change-Id: I8a9f634bf9a5776c752cc72a18e0f0eec4d1d58f
parent
23c61903
Changes
5
Hide whitespace changes
Inline
Side-by-side
av1/encoder/encodeframe.c
View file @
d15e7c1d
...
...
@@ -5159,6 +5159,70 @@ static void encode_frame_internal(AV1_COMP *cpi) {
#endif // !CONFIG_PVQ
}
#if CONFIG_HASH_ME
if
(
cpi
->
oxcf
.
pass
!=
1
&&
cpi
->
common
.
allow_screen_content_tools
)
{
// add to hash table
const
int
pic_width
=
cpi
->
source
->
y_crop_width
;
const
int
pic_height
=
cpi
->
source
->
y_crop_height
;
uint32_t
*
block_hash_values
[
2
][
2
];
int8_t
*
is_block_same
[
2
][
3
];
int
k
,
j
;
for
(
k
=
0
;
k
<
2
;
k
++
)
{
for
(
j
=
0
;
j
<
2
;
j
++
)
{
CHECK_MEM_ERROR
(
cm
,
block_hash_values
[
k
][
j
],
aom_malloc
(
sizeof
(
uint32_t
)
*
pic_width
*
pic_height
));
}
for
(
j
=
0
;
j
<
3
;
j
++
)
{
CHECK_MEM_ERROR
(
cm
,
is_block_same
[
k
][
j
],
aom_malloc
(
sizeof
(
int8_t
)
*
pic_width
*
pic_height
));
}
}
av1_hash_table_create
(
&
cm
->
cur_frame
->
hash_table
);
av1_generate_block_2x2_hash_value
(
cpi
->
source
,
block_hash_values
[
0
],
is_block_same
[
0
]);
av1_generate_block_hash_value
(
cpi
->
source
,
4
,
block_hash_values
[
0
],
block_hash_values
[
1
],
is_block_same
[
0
],
is_block_same
[
1
]);
av1_generate_block_hash_value
(
cpi
->
source
,
8
,
block_hash_values
[
1
],
block_hash_values
[
0
],
is_block_same
[
1
],
is_block_same
[
0
]);
av1_add_to_hash_map_by_row_with_precal_data
(
&
cm
->
cur_frame
->
hash_table
,
block_hash_values
[
0
],
is_block_same
[
0
][
2
],
pic_width
,
pic_height
,
8
);
av1_generate_block_hash_value
(
cpi
->
source
,
16
,
block_hash_values
[
0
],
block_hash_values
[
1
],
is_block_same
[
0
],
is_block_same
[
1
]);
av1_add_to_hash_map_by_row_with_precal_data
(
&
cm
->
cur_frame
->
hash_table
,
block_hash_values
[
1
],
is_block_same
[
1
][
2
],
pic_width
,
pic_height
,
16
);
av1_generate_block_hash_value
(
cpi
->
source
,
32
,
block_hash_values
[
1
],
block_hash_values
[
0
],
is_block_same
[
1
],
is_block_same
[
0
]);
av1_add_to_hash_map_by_row_with_precal_data
(
&
cm
->
cur_frame
->
hash_table
,
block_hash_values
[
0
],
is_block_same
[
0
][
2
],
pic_width
,
pic_height
,
32
);
av1_generate_block_hash_value
(
cpi
->
source
,
64
,
block_hash_values
[
0
],
block_hash_values
[
1
],
is_block_same
[
0
],
is_block_same
[
1
]);
av1_add_to_hash_map_by_row_with_precal_data
(
&
cm
->
cur_frame
->
hash_table
,
block_hash_values
[
1
],
is_block_same
[
1
][
2
],
pic_width
,
pic_height
,
64
);
for
(
k
=
0
;
k
<
2
;
k
++
)
{
for
(
j
=
0
;
j
<
2
;
j
++
)
{
aom_free
(
block_hash_values
[
k
][
j
]);
}
for
(
j
=
0
;
j
<
3
;
j
++
)
{
aom_free
(
is_block_same
[
k
][
j
]);
}
}
}
#endif
#if CONFIG_NCOBMC_ADAPT_WEIGHT
alloc_ncobmc_pred_buffer
(
xd
);
#endif
...
...
av1/encoder/encoder.c
View file @
d15e7c1d
...
...
@@ -6518,65 +6518,6 @@ int av1_get_compressed_data(AV1_COMP *cpi, unsigned int *frame_flags,
#endif
#if CONFIG_HASH_ME
if
(
oxcf
->
pass
!=
1
&&
cpi
->
common
.
allow_screen_content_tools
)
{
// add to hash table
const
int
pic_width
=
cpi
->
source
->
y_crop_width
;
const
int
pic_height
=
cpi
->
source
->
y_crop_height
;
uint32_t
*
block_hash_values
[
2
][
2
];
int8_t
*
is_block_same
[
2
][
3
];
int
k
,
j
;
for
(
k
=
0
;
k
<
2
;
k
++
)
{
for
(
j
=
0
;
j
<
2
;
j
++
)
{
CHECK_MEM_ERROR
(
cm
,
block_hash_values
[
k
][
j
],
aom_malloc
(
sizeof
(
uint32_t
)
*
pic_width
*
pic_height
));
}
for
(
j
=
0
;
j
<
3
;
j
++
)
{
CHECK_MEM_ERROR
(
cm
,
is_block_same
[
k
][
j
],
aom_malloc
(
sizeof
(
int8_t
)
*
pic_width
*
pic_height
));
}
}
av1_hash_table_create
(
&
cm
->
cur_frame
->
hash_table
);
av1_generate_block_2x2_hash_value
(
cpi
->
source
,
block_hash_values
[
0
],
is_block_same
[
0
]);
av1_generate_block_hash_value
(
cpi
->
source
,
4
,
block_hash_values
[
0
],
block_hash_values
[
1
],
is_block_same
[
0
],
is_block_same
[
1
]);
av1_generate_block_hash_value
(
cpi
->
source
,
8
,
block_hash_values
[
1
],
block_hash_values
[
0
],
is_block_same
[
1
],
is_block_same
[
0
]);
av1_add_to_hash_map_by_row_with_precal_data
(
&
cm
->
cur_frame
->
hash_table
,
block_hash_values
[
0
],
is_block_same
[
0
][
2
],
pic_width
,
pic_height
,
8
);
av1_generate_block_hash_value
(
cpi
->
source
,
16
,
block_hash_values
[
0
],
block_hash_values
[
1
],
is_block_same
[
0
],
is_block_same
[
1
]);
av1_add_to_hash_map_by_row_with_precal_data
(
&
cm
->
cur_frame
->
hash_table
,
block_hash_values
[
1
],
is_block_same
[
1
][
2
],
pic_width
,
pic_height
,
16
);
av1_generate_block_hash_value
(
cpi
->
source
,
32
,
block_hash_values
[
1
],
block_hash_values
[
0
],
is_block_same
[
1
],
is_block_same
[
0
]);
av1_add_to_hash_map_by_row_with_precal_data
(
&
cm
->
cur_frame
->
hash_table
,
block_hash_values
[
0
],
is_block_same
[
0
][
2
],
pic_width
,
pic_height
,
32
);
av1_generate_block_hash_value
(
cpi
->
source
,
64
,
block_hash_values
[
0
],
block_hash_values
[
1
],
is_block_same
[
0
],
is_block_same
[
1
]);
av1_add_to_hash_map_by_row_with_precal_data
(
&
cm
->
cur_frame
->
hash_table
,
block_hash_values
[
1
],
is_block_same
[
1
][
2
],
pic_width
,
pic_height
,
64
);
for
(
k
=
0
;
k
<
2
;
k
++
)
{
for
(
j
=
0
;
j
<
2
;
j
++
)
{
aom_free
(
block_hash_values
[
k
][
j
]);
}
for
(
j
=
0
;
j
<
3
;
j
++
)
{
aom_free
(
is_block_same
[
k
][
j
]);
}
}
#if CONFIG_AMVR
cpi
->
previsou_hash_table
=
&
cm
->
cur_frame
->
hash_table
;
{
...
...
av1/encoder/mcomp.c
View file @
d15e7c1d
...
...
@@ -2594,7 +2594,7 @@ static void add_to_sort_table(block_hash block_hashes[MAX_HASH_MV_TABLE_SIZE],
int
av1_full_pixel_search
(
const
AV1_COMP
*
cpi
,
MACROBLOCK
*
x
,
BLOCK_SIZE
bsize
,
MV
*
mvp_full
,
int
step_param
,
int
error_per_bit
,
int
*
cost_list
,
const
MV
*
ref_mv
,
int
var_max
,
int
rd
,
int
x_pos
,
int
y_pos
)
{
int
x_pos
,
int
y_pos
,
int
intra
)
{
#else
int
av1_full_pixel_search
(
const
AV1_COMP
*
cpi
,
MACROBLOCK
*
x
,
BLOCK_SIZE
bsize
,
MV
*
mvp_full
,
int
step_param
,
int
error_per_bit
,
...
...
@@ -2696,13 +2696,16 @@ int av1_full_pixel_search(const AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize,
// for the hashMap
hash_table
*
ref_frame_hash
=
get_ref_frame_hash_map
(
cpi
,
x
->
e_mbd
.
mi
[
0
]
->
mbmi
.
ref_frame
[
0
]);
intra
?
&
cpi
->
common
.
cur_frame
->
hash_table
:
get_ref_frame_hash_map
(
cpi
,
x
->
e_mbd
.
mi
[
0
]
->
mbmi
.
ref_frame
[
0
]);
av1_get_block_hash_value
(
what
,
what_stride
,
block_width
,
&
hash_value1
,
&
hash_value2
);
const
int
count
=
av1_hash_table_count
(
ref_frame_hash
,
hash_value1
);
if
(
count
==
0
)
{
// for intra, at lest one matching can be found, itself.
if
(
count
==
(
intra
?
1
:
0
))
{
break
;
}
...
...
@@ -2711,6 +2714,16 @@ int av1_full_pixel_search(const AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize,
for
(
i
=
0
;
i
<
count
;
i
++
,
iterator_increment
(
&
iterator
))
{
block_hash
ref_block_hash
=
*
(
block_hash
*
)(
iterator_get
(
&
iterator
));
if
(
hash_value2
==
ref_block_hash
.
hash_value2
)
{
// for intra, make sure the prediction is from valid area
// not predict from current block.
// TODO(roger): check if the constrain is necessary
if
(
intra
&&
ref_block_hash
.
y
+
block_height
>
((
y_pos
>>
MAX_SB_SIZE_LOG2
)
<<
MAX_SB_SIZE_LOG2
)
&&
ref_block_hash
.
x
+
block_width
>
((
x_pos
>>
MAX_SB_SIZE_LOG2
)
<<
MAX_SB_SIZE_LOG2
))
{
continue
;
}
int
refCost
=
abs
(
ref_block_hash
.
x
-
x_pos
)
+
abs
(
ref_block_hash
.
y
-
y_pos
);
add_to_sort_table
(
block_hashes
,
costs
,
&
existing
,
...
...
av1/encoder/mcomp.h
View file @
d15e7c1d
...
...
@@ -135,7 +135,7 @@ struct AV1_COMP;
int
av1_full_pixel_search
(
const
struct
AV1_COMP
*
cpi
,
MACROBLOCK
*
x
,
BLOCK_SIZE
bsize
,
MV
*
mvp_full
,
int
step_param
,
int
error_per_bit
,
int
*
cost_list
,
const
MV
*
ref_mv
,
int
var_max
,
int
rd
,
int
x_pos
,
int
y_pos
);
int
var_max
,
int
rd
,
int
x_pos
,
int
y_pos
,
int
intra
);
#else
int
av1_full_pixel_search
(
const
struct
AV1_COMP
*
cpi
,
MACROBLOCK
*
x
,
BLOCK_SIZE
bsize
,
MV
*
mvp_full
,
int
step_param
,
...
...
av1/encoder/rdopt.c
View file @
d15e7c1d
...
...
@@ -7141,7 +7141,7 @@ static void single_motion_search(const AV1_COMP *const cpi, MACROBLOCK *x,
bestsme = av1_full_pixel_search(cpi, x, bsize, &mvp_full, step_param,
sadpb, cond_cost_list(cpi, cost_list),
&ref_mv, INT_MAX, 1, (MI_SIZE * mi_col),
(MI_SIZE * mi_row));
(MI_SIZE * mi_row)
, 0
);
#else
bestsme = av1_full_pixel_search(cpi, x, bsize, &mvp_full, step_param, sadpb,
cond_cost_list(cpi, cost_list), &ref_mv,
...
...
@@ -9800,9 +9800,10 @@ static int64_t rd_pick_intrabc_mode_sb(const AV1_COMP *cpi, MACROBLOCK *x,
int sadpb = x->sadperbit16;
int cost_list[5];
#if CONFIG_HASH_ME
int bestsme = av1_full_pixel_search(cpi, x, bsize, &mvp_full, step_param,
sadpb, cond_cost_list(cpi, cost_list),
&dv_ref.as_mv, INT_MAX, 1, -1, -1);
int bestsme = av1_full_pixel_search(
cpi, x, bsize, &mvp_full, step_param, sadpb,
cond_cost_list(cpi, cost_list), &dv_ref.as_mv, INT_MAX, 1,
(MI_SIZE * mi_col), (MI_SIZE * mi_row), 1);
#else
int bestsme = av1_full_pixel_search(cpi, x, bsize, &mvp_full, step_param,
sadpb, cond_cost_list(cpi, cost_list),
...
...
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