mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-24 02:24:07 +00:00
Constrain the search not to go under the LCU below if OWF is enabled
This commit is contained in:
parent
ef9c2258e9
commit
91de92134f
|
@ -373,9 +373,14 @@ static unsigned image_interpolated_sad(const image *pic, const image *ref,
|
||||||
|
|
||||||
|
|
||||||
unsigned image_calc_sad(const image *pic, const image *ref, int pic_x, int pic_y, int ref_x, int ref_y,
|
unsigned image_calc_sad(const image *pic, const image *ref, int pic_x, int pic_y, int ref_x, int ref_y,
|
||||||
int block_width, int block_height) {
|
int block_width, int block_height, int max_lcu_below) {
|
||||||
assert(pic_x >= 0 && pic_x <= pic->width - block_width);
|
assert(pic_x >= 0 && pic_x <= pic->width - block_width);
|
||||||
assert(pic_y >= 0 && pic_y <= pic->height - block_height);
|
assert(pic_y >= 0 && pic_y <= pic->height - block_height);
|
||||||
|
|
||||||
|
if ((((ref_y + block_height)/LCU_WIDTH) > (pic_y/LCU_WIDTH) + max_lcu_below) && max_lcu_below >= 0) {
|
||||||
|
//printf("OOB %d %d -> %d\n", ref_y + block_height, pic_y, ref_y + block_height - pic_y);
|
||||||
|
return INT_MAX;
|
||||||
|
}
|
||||||
if (ref_x >= 0 && ref_x <= ref->width - block_width &&
|
if (ref_x >= 0 && ref_x <= ref->width - block_width &&
|
||||||
ref_y >= 0 && ref_y <= ref->height - block_height)
|
ref_y >= 0 && ref_y <= ref->height - block_height)
|
||||||
{
|
{
|
||||||
|
|
|
@ -72,7 +72,7 @@ void yuv_t_free(yuv_t * yuv);
|
||||||
|
|
||||||
//Algorithms
|
//Algorithms
|
||||||
unsigned image_calc_sad(const image *pic, const image *ref, int pic_x, int pic_y, int ref_x, int ref_y,
|
unsigned image_calc_sad(const image *pic, const image *ref, int pic_x, int pic_y, int ref_x, int ref_y,
|
||||||
int block_width, int block_height);
|
int block_width, int block_height, int max_lcu_below);
|
||||||
|
|
||||||
|
|
||||||
typedef unsigned (*cost_16bit_nxn_func)(const pixel *block1, const pixel *block2);
|
typedef unsigned (*cost_16bit_nxn_func)(const pixel *block1, const pixel *block2);
|
||||||
|
|
15
src/search.c
15
src/search.c
|
@ -197,6 +197,11 @@ static unsigned hexagon_search(const encoder_state * const encoder_state, unsign
|
||||||
uint32_t best_bitcost = 0, bitcost;
|
uint32_t best_bitcost = 0, bitcost;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
unsigned best_index = 0; // Index of large_hexbs or finally small_hexbs.
|
unsigned best_index = 0; // Index of large_hexbs or finally small_hexbs.
|
||||||
|
int max_lcu_below = -1;
|
||||||
|
|
||||||
|
if (encoder_state->encoder_control->owf) {
|
||||||
|
max_lcu_below = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Search the initial 7 points of the hexagon.
|
// Search the initial 7 points of the hexagon.
|
||||||
|
@ -205,7 +210,7 @@ static unsigned hexagon_search(const encoder_state * const encoder_state, unsign
|
||||||
unsigned cost = image_calc_sad(pic, ref, orig->x, orig->y,
|
unsigned cost = image_calc_sad(pic, ref, orig->x, orig->y,
|
||||||
(encoder_state->tile->lcu_offset_x * LCU_WIDTH) + orig->x + mv.x + pattern->x,
|
(encoder_state->tile->lcu_offset_x * LCU_WIDTH) + orig->x + mv.x + pattern->x,
|
||||||
(encoder_state->tile->lcu_offset_y * LCU_WIDTH) + orig->y + mv.y + pattern->y,
|
(encoder_state->tile->lcu_offset_y * LCU_WIDTH) + orig->y + mv.y + pattern->y,
|
||||||
block_width, block_width);
|
block_width, block_width, max_lcu_below);
|
||||||
cost += calc_mvd_cost(encoder_state, mv.x + pattern->x, mv.y + pattern->y, mv_cand,merge_cand,num_cand,ref_idx, &bitcost);
|
cost += calc_mvd_cost(encoder_state, mv.x + pattern->x, mv.y + pattern->y, mv_cand,merge_cand,num_cand,ref_idx, &bitcost);
|
||||||
|
|
||||||
if (cost < best_cost) {
|
if (cost < best_cost) {
|
||||||
|
@ -220,7 +225,7 @@ static unsigned hexagon_search(const encoder_state * const encoder_state, unsign
|
||||||
unsigned cost = image_calc_sad(pic, ref, orig->x, orig->y,
|
unsigned cost = image_calc_sad(pic, ref, orig->x, orig->y,
|
||||||
(encoder_state->tile->lcu_offset_x * LCU_WIDTH) + orig->x,
|
(encoder_state->tile->lcu_offset_x * LCU_WIDTH) + orig->x,
|
||||||
(encoder_state->tile->lcu_offset_y * LCU_WIDTH) + orig->y,
|
(encoder_state->tile->lcu_offset_y * LCU_WIDTH) + orig->y,
|
||||||
block_width, block_width);
|
block_width, block_width, max_lcu_below);
|
||||||
cost += calc_mvd_cost(encoder_state, 0, 0, mv_cand,merge_cand,num_cand,ref_idx, &bitcost);
|
cost += calc_mvd_cost(encoder_state, 0, 0, mv_cand,merge_cand,num_cand,ref_idx, &bitcost);
|
||||||
|
|
||||||
// If the 0,0 is better, redo the hexagon around that point.
|
// If the 0,0 is better, redo the hexagon around that point.
|
||||||
|
@ -236,7 +241,7 @@ static unsigned hexagon_search(const encoder_state * const encoder_state, unsign
|
||||||
unsigned cost = image_calc_sad(pic, ref, orig->x, orig->y,
|
unsigned cost = image_calc_sad(pic, ref, orig->x, orig->y,
|
||||||
(encoder_state->tile->lcu_offset_x * LCU_WIDTH) + orig->x + pattern->x,
|
(encoder_state->tile->lcu_offset_x * LCU_WIDTH) + orig->x + pattern->x,
|
||||||
(encoder_state->tile->lcu_offset_y * LCU_WIDTH) + orig->y + pattern->y,
|
(encoder_state->tile->lcu_offset_y * LCU_WIDTH) + orig->y + pattern->y,
|
||||||
block_width, block_width);
|
block_width, block_width, max_lcu_below);
|
||||||
cost += calc_mvd_cost(encoder_state, pattern->x, pattern->y, mv_cand,merge_cand,num_cand,ref_idx, &bitcost);
|
cost += calc_mvd_cost(encoder_state, pattern->x, pattern->y, mv_cand,merge_cand,num_cand,ref_idx, &bitcost);
|
||||||
|
|
||||||
if (cost < best_cost) {
|
if (cost < best_cost) {
|
||||||
|
@ -271,7 +276,7 @@ static unsigned hexagon_search(const encoder_state * const encoder_state, unsign
|
||||||
unsigned cost = image_calc_sad(pic, ref, orig->x, orig->y,
|
unsigned cost = image_calc_sad(pic, ref, orig->x, orig->y,
|
||||||
(encoder_state->tile->lcu_offset_x * LCU_WIDTH) + orig->x + mv.x + offset->x,
|
(encoder_state->tile->lcu_offset_x * LCU_WIDTH) + orig->x + mv.x + offset->x,
|
||||||
(encoder_state->tile->lcu_offset_y * LCU_WIDTH) + orig->y + mv.y + offset->y,
|
(encoder_state->tile->lcu_offset_y * LCU_WIDTH) + orig->y + mv.y + offset->y,
|
||||||
block_width, block_width);
|
block_width, block_width, max_lcu_below);
|
||||||
cost += calc_mvd_cost(encoder_state, mv.x + offset->x, mv.y + offset->y, mv_cand,merge_cand,num_cand,ref_idx, &bitcost);
|
cost += calc_mvd_cost(encoder_state, mv.x + offset->x, mv.y + offset->y, mv_cand,merge_cand,num_cand,ref_idx, &bitcost);
|
||||||
|
|
||||||
if (cost < best_cost) {
|
if (cost < best_cost) {
|
||||||
|
@ -294,7 +299,7 @@ static unsigned hexagon_search(const encoder_state * const encoder_state, unsign
|
||||||
unsigned cost = image_calc_sad(pic, ref, orig->x, orig->y,
|
unsigned cost = image_calc_sad(pic, ref, orig->x, orig->y,
|
||||||
(encoder_state->tile->lcu_offset_x * LCU_WIDTH) + orig->x + mv.x + offset->x,
|
(encoder_state->tile->lcu_offset_x * LCU_WIDTH) + orig->x + mv.x + offset->x,
|
||||||
(encoder_state->tile->lcu_offset_y * LCU_WIDTH) + orig->y + mv.y + offset->y,
|
(encoder_state->tile->lcu_offset_y * LCU_WIDTH) + orig->y + mv.y + offset->y,
|
||||||
block_width, block_width);
|
block_width, block_width, max_lcu_below);
|
||||||
cost += calc_mvd_cost(encoder_state, mv.x + offset->x, mv.y + offset->y, mv_cand,merge_cand,num_cand,ref_idx, &bitcost);
|
cost += calc_mvd_cost(encoder_state, mv.x + offset->x, mv.y + offset->y, mv_cand,merge_cand,num_cand,ref_idx, &bitcost);
|
||||||
|
|
||||||
if (cost > 0 && cost < best_cost) {
|
if (cost > 0 && cost < best_cost) {
|
||||||
|
|
Loading…
Reference in a new issue