mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-27 11:24:05 +00:00
Add pixel offsets to encoder_state_config_tile_t
Adds fields offset_x and offset_y to encoder_state_config_tile_t.
This commit is contained in:
parent
924cf857ec
commit
6ce2fb1238
|
@ -1021,8 +1021,8 @@ void kvz_encode_coding_tree(encoder_state_t * const state,
|
|||
uint8_t split_model = 0;
|
||||
|
||||
// Absolute coordinates
|
||||
uint16_t abs_x = x + state->tile->lcu_offset_x * LCU_WIDTH;
|
||||
uint16_t abs_y = y + state->tile->lcu_offset_y * LCU_WIDTH;
|
||||
uint16_t abs_x = x + state->tile->offset_x;
|
||||
uint16_t abs_y = y + state->tile->offset_y;
|
||||
|
||||
// Check for slice border FIXME
|
||||
bool border_x = ctrl->in.width < abs_x + (LCU_WIDTH >> depth);
|
||||
|
|
|
@ -81,10 +81,12 @@ static int encoder_state_config_tile_init(encoder_state_t * const state,
|
|||
printf("Error allocating videoframe!\r\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
state->tile->lcu_offset_x = lcu_offset_x;
|
||||
state->tile->lcu_offset_y = lcu_offset_y;
|
||||
|
||||
state->tile->offset_x = lcu_offset_x * LCU_WIDTH;
|
||||
state->tile->offset_y = lcu_offset_y * LCU_WIDTH;
|
||||
|
||||
state->tile->lcu_offset_in_ts = encoder->tiles_ctb_addr_rs_to_ts[lcu_offset_x + lcu_offset_y * encoder->in.width_in_lcu];
|
||||
|
||||
// hor_buf_search and ver_buf_search store single row/col from each LCU row/col.
|
||||
|
|
|
@ -636,12 +636,11 @@ static void encoder_state_worker_encode_lcu(void * opaque)
|
|||
while (main_state->parent) main_state = main_state->parent;
|
||||
assert(main_state != state);
|
||||
|
||||
const unsigned tile_x_px = state->tile->lcu_offset_x << LOG2_LCU_WIDTH;
|
||||
const unsigned tile_y_px = state->tile->lcu_offset_y << LOG2_LCU_WIDTH;
|
||||
const unsigned x_px = lcu->position_px.x;
|
||||
const unsigned y_px = lcu->position_px.y;
|
||||
kvz_cu_array_copy(main_state->tile->frame->cu_array,
|
||||
x_px + tile_x_px, y_px + tile_y_px,
|
||||
x_px + state->tile->offset_x,
|
||||
y_px + state->tile->offset_y,
|
||||
state->tile->frame->cu_array,
|
||||
x_px, y_px,
|
||||
LCU_WIDTH, LCU_WIDTH);
|
||||
|
@ -889,8 +888,8 @@ static void encoder_state_encode(encoder_state_t * const main_state) {
|
|||
encoder_state_t *sub_state = &(main_state->children[i]);
|
||||
|
||||
if (sub_state->tile != main_state->tile) {
|
||||
const int offset_x = sub_state->tile->lcu_offset_x * LCU_WIDTH;
|
||||
const int offset_y = sub_state->tile->lcu_offset_y * LCU_WIDTH;
|
||||
const int offset_x = sub_state->tile->offset_x;
|
||||
const int offset_y = sub_state->tile->offset_y;
|
||||
const int width = MIN(sub_state->tile->frame->width_in_lcu * LCU_WIDTH, main_state->tile->frame->width - offset_x);
|
||||
const int height = MIN(sub_state->tile->frame->height_in_lcu * LCU_WIDTH, main_state->tile->frame->height - offset_y);
|
||||
|
||||
|
|
|
@ -153,11 +153,15 @@ typedef struct encoder_state_config_tile_t {
|
|||
videoframe_t *frame;
|
||||
|
||||
int32_t id;
|
||||
|
||||
|
||||
//Tile: offset in LCU for current encoder_state in global coordinates
|
||||
int32_t lcu_offset_x;
|
||||
int32_t lcu_offset_y;
|
||||
|
||||
|
||||
//Tile: offset in pixels
|
||||
int32_t offset_x;
|
||||
int32_t offset_y;
|
||||
|
||||
//Position of the first element in tile scan in global coordinates
|
||||
int32_t lcu_offset_in_ts;
|
||||
|
||||
|
|
52
src/inter.c
52
src/inter.c
|
@ -61,8 +61,8 @@ static void inter_recon_frac_luma(const encoder_state_t * const state,
|
|||
ypos,
|
||||
mv_param[0] >> 2,
|
||||
mv_param[1] >> 2,
|
||||
state->tile->lcu_offset_x * LCU_WIDTH,
|
||||
state->tile->lcu_offset_y * LCU_WIDTH,
|
||||
state->tile->offset_x,
|
||||
state->tile->offset_y,
|
||||
ref->y,
|
||||
ref->width,
|
||||
ref->height,
|
||||
|
@ -106,8 +106,8 @@ static void inter_recon_14bit_frac_luma(const encoder_state_t * const state,
|
|||
ypos,
|
||||
mv_param[0] >> 2,
|
||||
mv_param[1] >> 2,
|
||||
state->tile->lcu_offset_x * LCU_WIDTH,
|
||||
state->tile->lcu_offset_y * LCU_WIDTH,
|
||||
state->tile->offset_x,
|
||||
state->tile->offset_y,
|
||||
ref->y,
|
||||
ref->width,
|
||||
ref->height,
|
||||
|
@ -154,14 +154,34 @@ static void inter_recon_frac_chroma(const encoder_state_t * const state,
|
|||
kvz_extended_block src_v = { 0, 0, 0, 0 };
|
||||
|
||||
//Fractional chroma U
|
||||
kvz_get_extended_block(xpos, ypos, (mv_param[0] >> 2) >> 1, (mv_param[1] >> 2) >> 1, state->tile->lcu_offset_x * LCU_WIDTH_C, state->tile->lcu_offset_y * LCU_WIDTH_C,
|
||||
ref->u, ref->width >> 1, ref->height >> 1, FILTER_SIZE_C, block_width, block_height, &src_u);
|
||||
kvz_get_extended_block(xpos, ypos,
|
||||
(mv_param[0] >> 2) >> 1,
|
||||
(mv_param[1] >> 2) >> 1,
|
||||
state->tile->offset_x >> 1,
|
||||
state->tile->offset_y >> 1,
|
||||
ref->u,
|
||||
ref->width >> 1,
|
||||
ref->height >> 1,
|
||||
FILTER_SIZE_C,
|
||||
block_width,
|
||||
block_height,
|
||||
&src_u);
|
||||
kvz_sample_octpel_chroma(state->encoder_control, src_u.orig_topleft, src_u.stride, block_width,
|
||||
block_height, lcu->rec.u + (ypos % LCU_WIDTH_C)*LCU_WIDTH_C + (xpos % LCU_WIDTH_C), LCU_WIDTH_C, mv_frac_x, mv_frac_y, mv_param);
|
||||
|
||||
//Fractional chroma V
|
||||
kvz_get_extended_block(xpos, ypos, (mv_param[0] >> 2) >> 1, (mv_param[1] >> 2) >> 1, state->tile->lcu_offset_x * LCU_WIDTH_C, state->tile->lcu_offset_y * LCU_WIDTH_C,
|
||||
ref->v, ref->width >> 1, ref->height >> 1, FILTER_SIZE_C, block_width, block_height, &src_v);
|
||||
kvz_get_extended_block(xpos, ypos,
|
||||
(mv_param[0] >> 2) >> 1,
|
||||
(mv_param[1] >> 2) >> 1,
|
||||
state->tile->offset_x >> 1,
|
||||
state->tile->offset_y >> 1,
|
||||
ref->v,
|
||||
ref->width >> 1,
|
||||
ref->height >> 1,
|
||||
FILTER_SIZE_C,
|
||||
block_width,
|
||||
block_height,
|
||||
&src_v);
|
||||
kvz_sample_octpel_chroma(state->encoder_control, src_v.orig_topleft, src_v.stride, block_width,
|
||||
block_height, lcu->rec.v + (ypos % LCU_WIDTH_C)*LCU_WIDTH_C + (xpos % LCU_WIDTH_C), LCU_WIDTH_C, mv_frac_x, mv_frac_y, mv_param);
|
||||
|
||||
|
@ -198,8 +218,8 @@ static void inter_recon_14bit_frac_chroma(const encoder_state_t * const state,
|
|||
ypos,
|
||||
(mv_param[0] >> 2) >> 1,
|
||||
(mv_param[1] >> 2) >> 1,
|
||||
state->tile->lcu_offset_x * LCU_WIDTH_C,
|
||||
state->tile->lcu_offset_y * LCU_WIDTH_C,
|
||||
state->tile->offset_x >> 1,
|
||||
state->tile->offset_y >> 1,
|
||||
ref->u,
|
||||
ref->width >> 1,
|
||||
ref->height >> 1,
|
||||
|
@ -223,8 +243,8 @@ static void inter_recon_14bit_frac_chroma(const encoder_state_t * const state,
|
|||
ypos,
|
||||
(mv_param[0] >> 2) >> 1,
|
||||
(mv_param[1] >> 2) >> 1,
|
||||
state->tile->lcu_offset_x * LCU_WIDTH_C,
|
||||
state->tile->lcu_offset_y * LCU_WIDTH_C,
|
||||
state->tile->offset_x >> 1,
|
||||
state->tile->offset_y >> 1,
|
||||
ref->v,
|
||||
ref->width >> 1,
|
||||
ref->height >> 1,
|
||||
|
@ -308,17 +328,13 @@ void kvz_inter_recon_lcu(const encoder_state_t * const state,
|
|||
lcu_t *lcu,
|
||||
hi_prec_buf_t *hi_prec_out)
|
||||
{
|
||||
const vector2d_t tile_in_frame = {
|
||||
state->tile->lcu_offset_x * LCU_WIDTH,
|
||||
state->tile->lcu_offset_y * LCU_WIDTH
|
||||
};
|
||||
const vector2d_t pu_in_tile = { xpos, ypos };
|
||||
const vector2d_t pu_in_lcu = { xpos % LCU_WIDTH, ypos % LCU_WIDTH };
|
||||
|
||||
const vector2d_t mv_in_pu = { mv_param[0] >> 2, mv_param[1] >> 2 };
|
||||
const vector2d_t mv_in_frame = {
|
||||
mv_in_pu.x + pu_in_tile.x + tile_in_frame.x,
|
||||
mv_in_pu.y + pu_in_tile.y + tile_in_frame.y
|
||||
mv_in_pu.x + pu_in_tile.x + state->tile->offset_x,
|
||||
mv_in_pu.y + pu_in_tile.y + state->tile->offset_y
|
||||
};
|
||||
|
||||
const bool mv_is_outside_frame = mv_in_frame.x < 0 ||
|
||||
|
|
10
src/search.c
10
src/search.c
|
@ -719,11 +719,11 @@ static double search_cu(encoder_state_t * const state, int x, int y, int depth,
|
|||
}
|
||||
|
||||
PERFORMANCE_MEASURE_END(KVZ_PERF_SEARCHCU, state->encoder_control->threadqueue, "type=search_cu,frame=%d,tile=%d,slice=%d,px_x=%d-%d,px_y=%d-%d,depth=%d,split=%d,cur_cu_is_intra=%d", state->frame->num, state->tile->id, state->slice->id,
|
||||
(state->tile->lcu_offset_x * LCU_WIDTH) + x,
|
||||
(state->tile->lcu_offset_x * LCU_WIDTH) + x + (LCU_WIDTH >> depth),
|
||||
(state->tile->lcu_offset_y * LCU_WIDTH) + y,
|
||||
(state->tile->lcu_offset_y * LCU_WIDTH) + y + (LCU_WIDTH >> depth),
|
||||
depth, debug_split, (cur_cu->type==CU_INTRA)?1:0);
|
||||
state->tile->offset_x + x,
|
||||
state->tile->offset_x + x + cu_width,
|
||||
state->tile->offset_y + y,
|
||||
state->tile->offset_y + y + cu_width,
|
||||
depth, debug_split, (cur_cu->type == CU_INTRA) ? 1 : 0);
|
||||
|
||||
assert(cur_cu->type != CU_NOTSET);
|
||||
|
||||
|
|
|
@ -171,8 +171,8 @@ static unsigned select_starting_point(int16_t num_cand, inter_merge_cand_t *merg
|
|||
|
||||
uint32_t bitcost = 0;
|
||||
unsigned cost = kvz_image_calc_sad(pic, ref, orig->x, orig->y,
|
||||
(state->tile->lcu_offset_x * LCU_WIDTH) + orig->x + mv->x,
|
||||
(state->tile->lcu_offset_y * LCU_WIDTH) + orig->y + mv->y,
|
||||
state->tile->offset_x + orig->x + mv->x,
|
||||
state->tile->offset_y + orig->y + mv->y,
|
||||
width, height, -1);
|
||||
cost += calc_mvd(state, mv->x, mv->y, 2, mv_cand, merge_cand, num_cand, ref_idx, &bitcost);
|
||||
|
||||
|
@ -299,8 +299,8 @@ static bool early_terminate(int16_t num_cand, inter_merge_cand_t *merge_cand, ve
|
|||
}
|
||||
|
||||
unsigned cost = kvz_image_calc_sad(pic, ref, orig->x, orig->y,
|
||||
(state->tile->lcu_offset_x * LCU_WIDTH) + orig->x + mv->x + offset->x,
|
||||
(state->tile->lcu_offset_y * LCU_WIDTH) + orig->y + mv->y + offset->y,
|
||||
state->tile->offset_x + orig->x + mv->x + offset->x,
|
||||
state->tile->offset_y + orig->y + mv->y + offset->y,
|
||||
width, height, -1);
|
||||
unsigned bitcost;
|
||||
cost += calc_mvd(state, mv->x + offset->x, mv->y + offset->y, 2, mv_cand, merge_cand, num_cand, ref_idx, &bitcost);
|
||||
|
@ -457,8 +457,8 @@ unsigned kvz_tz_pattern_search(encoder_state_t * const state, const kvz_picture
|
|||
|
||||
{
|
||||
cost = kvz_image_calc_sad(pic, ref, orig->x, orig->y,
|
||||
(state->tile->lcu_offset_x * LCU_WIDTH) + orig->x + mv->x + current->x,
|
||||
(state->tile->lcu_offset_y * LCU_WIDTH) + orig->y + mv->y + current->y,
|
||||
state->tile->offset_x + orig->x + mv->x + current->x,
|
||||
state->tile->offset_y + orig->y + mv->y + current->y,
|
||||
width, height, -1);
|
||||
cost += calc_mvd(state, mv->x + current->x, mv->y + current->y, 2, mv_cand, merge_cand, num_cand, ref_idx, &bitcost);
|
||||
}
|
||||
|
@ -516,8 +516,8 @@ unsigned kvz_tz_raster_search(encoder_state_t * const state, const kvz_picture *
|
|||
|
||||
{
|
||||
cost = kvz_image_calc_sad(pic, ref, orig->x, orig->y,
|
||||
(state->tile->lcu_offset_x * LCU_WIDTH) + orig->x + mv->x + k,
|
||||
(state->tile->lcu_offset_y * LCU_WIDTH) + orig->y + mv->y + i,
|
||||
state->tile->offset_x + orig->x + mv->x + k,
|
||||
state->tile->offset_y + orig->y + mv->y + i,
|
||||
width, height, -1);
|
||||
cost += calc_mvd(state, mv->x + k, mv->y + i, 2, mv_cand, merge_cand, num_cand, ref_idx, &bitcost);
|
||||
}
|
||||
|
@ -572,8 +572,8 @@ static unsigned tz_search(encoder_state_t * const state,
|
|||
// Check the 0-vector, so we can ignore all 0-vectors in the merge cand list.
|
||||
if (intmv_within_tile(state, orig, 0, 0, width, height)) {
|
||||
best_cost = kvz_image_calc_sad(pic, ref, orig->x, orig->y,
|
||||
(state->tile->lcu_offset_x * LCU_WIDTH) + orig->x,
|
||||
(state->tile->lcu_offset_y * LCU_WIDTH) + orig->y,
|
||||
state->tile->offset_x + orig->x,
|
||||
state->tile->offset_y + orig->y,
|
||||
width, height, -1);
|
||||
best_cost += calc_mvd(state, 0, 0, 2, mv_cand, merge_cand, num_cand, ref_idx, &best_bitcost);
|
||||
best_index = num_cand + 1;
|
||||
|
@ -584,8 +584,8 @@ static unsigned tz_search(encoder_state_t * const state,
|
|||
intmv_within_tile(state, orig, mv.x, mv.y, width, height))
|
||||
{
|
||||
unsigned cost = kvz_image_calc_sad(pic, ref, orig->x, orig->y,
|
||||
(state->tile->lcu_offset_x * LCU_WIDTH) + orig->x + mv.x,
|
||||
(state->tile->lcu_offset_y * LCU_WIDTH) + orig->y + mv.y,
|
||||
state->tile->offset_x + orig->x + mv.x,
|
||||
state->tile->offset_y + orig->y + mv.y,
|
||||
width, height, -1);
|
||||
unsigned bitcost;
|
||||
cost += calc_mvd(state, mv.x, mv.y, 2, mv_cand, merge_cand, num_cand, ref_idx, &bitcost);
|
||||
|
@ -723,8 +723,8 @@ static unsigned hexagon_search(encoder_state_t * const state,
|
|||
// Check the 0-vector, so we can ignore all 0-vectors in the merge cand list.
|
||||
if (intmv_within_tile(state, orig, 0, 0, width, height)) {
|
||||
best_cost = kvz_image_calc_sad(pic, ref, orig->x, orig->y,
|
||||
(state->tile->lcu_offset_x * LCU_WIDTH) + orig->x,
|
||||
(state->tile->lcu_offset_y * LCU_WIDTH) + orig->y,
|
||||
state->tile->offset_x + orig->x,
|
||||
state->tile->offset_y + orig->y,
|
||||
width, height, -1);
|
||||
best_cost += calc_mvd(state, 0, 0, 2, mv_cand, merge_cand, num_cand, ref_idx, &bitcost);
|
||||
best_bitcost = bitcost;
|
||||
|
@ -736,8 +736,8 @@ static unsigned hexagon_search(encoder_state_t * const state,
|
|||
intmv_within_tile(state, orig, mv.x, mv.y, width, height))
|
||||
{
|
||||
unsigned cost = kvz_image_calc_sad(pic, ref, orig->x, orig->y,
|
||||
(state->tile->lcu_offset_x * LCU_WIDTH) + orig->x + mv.x,
|
||||
(state->tile->lcu_offset_y * LCU_WIDTH) + orig->y + mv.y,
|
||||
state->tile->offset_x + orig->x + mv.x,
|
||||
state->tile->offset_y + orig->y + mv.y,
|
||||
width, height, -1);
|
||||
cost += calc_mvd(state, mv.x, mv.y, 2, mv_cand, merge_cand, num_cand, ref_idx, &bitcost);
|
||||
|
||||
|
@ -768,8 +768,8 @@ static unsigned hexagon_search(encoder_state_t * const state,
|
|||
}
|
||||
|
||||
unsigned cost = kvz_image_calc_sad(pic, ref, orig->x, orig->y,
|
||||
(state->tile->lcu_offset_x * LCU_WIDTH) + orig->x + mv.x + pattern->x,
|
||||
(state->tile->lcu_offset_y * LCU_WIDTH) + orig->y + mv.y + pattern->y,
|
||||
state->tile->offset_x + orig->x + mv.x + pattern->x,
|
||||
state->tile->offset_y + orig->y + mv.y + pattern->y,
|
||||
width, height, -1);
|
||||
cost += calc_mvd(state, mv.x + pattern->x, mv.y + pattern->y, 2, mv_cand, merge_cand, num_cand, ref_idx, &bitcost);
|
||||
|
||||
|
@ -805,8 +805,8 @@ static unsigned hexagon_search(encoder_state_t * const state,
|
|||
}
|
||||
|
||||
unsigned cost = kvz_image_calc_sad(pic, ref, orig->x, orig->y,
|
||||
(state->tile->lcu_offset_x * LCU_WIDTH) + orig->x + mv.x + offset->x,
|
||||
(state->tile->lcu_offset_y * LCU_WIDTH) + orig->y + mv.y + offset->y,
|
||||
state->tile->offset_x + orig->x + mv.x + offset->x,
|
||||
state->tile->offset_y + orig->y + mv.y + offset->y,
|
||||
width, height, -1);
|
||||
cost += calc_mvd(state, mv.x + offset->x, mv.y + offset->y, 2, mv_cand, merge_cand, num_cand, ref_idx, &bitcost);
|
||||
|
||||
|
@ -831,8 +831,8 @@ static unsigned hexagon_search(encoder_state_t * const state,
|
|||
}
|
||||
|
||||
unsigned cost = kvz_image_calc_sad(pic, ref, orig->x, orig->y,
|
||||
(state->tile->lcu_offset_x * LCU_WIDTH) + orig->x + mv.x + offset->x,
|
||||
(state->tile->lcu_offset_y * LCU_WIDTH) + orig->y + mv.y + offset->y,
|
||||
state->tile->offset_x + orig->x + mv.x + offset->x,
|
||||
state->tile->offset_y + orig->y + mv.y + offset->y,
|
||||
width, height, -1);
|
||||
cost += calc_mvd(state, mv.x + offset->x, mv.y + offset->y, 2, mv_cand, merge_cand, num_cand, ref_idx, &bitcost);
|
||||
|
||||
|
@ -1064,8 +1064,8 @@ static unsigned search_frac(encoder_state_t * const state,
|
|||
}
|
||||
|
||||
kvz_get_extended_block(orig->x, orig->y, mv.x-1, mv.y-1,
|
||||
state->tile->lcu_offset_x * LCU_WIDTH,
|
||||
state->tile->lcu_offset_y * LCU_WIDTH,
|
||||
state->tile->offset_x,
|
||||
state->tile->offset_y,
|
||||
ref->y, ref->width, ref->height, FILTER_SIZE, width+1, height+1, &src);
|
||||
|
||||
kvz_filter_frac_blocks_luma(state->encoder_control, src.orig_topleft, src.stride, width,
|
||||
|
@ -1263,12 +1263,8 @@ static void search_pu_inter_ref(encoder_state_t * const state,
|
|||
// Take starting point for MV search from previous frame.
|
||||
// When temporal motion vector candidates are added, there is probably
|
||||
// no point to this anymore, but for now it helps.
|
||||
const vector2d_t tile_top_left_corner = {
|
||||
(state->tile->lcu_offset_x << LOG2_LCU_WIDTH),
|
||||
(state->tile->lcu_offset_y << LOG2_LCU_WIDTH)
|
||||
};
|
||||
const int mid_x = tile_top_left_corner.x + x + (width >> 1);
|
||||
const int mid_y = tile_top_left_corner.y + y + (height >> 1);
|
||||
const int mid_x = state->tile->offset_x + x + (width >> 1);
|
||||
const int mid_y = state->tile->offset_y + y + (height >> 1);
|
||||
const cu_array_t* ref_array = state->frame->ref->cu_arrays[ref_idx];
|
||||
const cu_info_t* ref_cu = kvz_cu_array_at_const(ref_array, mid_x, mid_y);
|
||||
if (ref_cu->type == CU_INTER) {
|
||||
|
|
Loading…
Reference in a new issue