mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-24 02:24:07 +00:00
Take advantage of the new buffers to remove uneeded item assignment
This commit is contained in:
parent
6607c9f563
commit
bb86f24000
|
@ -1204,9 +1204,6 @@ static void encoder_state_encode_leaf(encoder_state * const encoder_state) {
|
|||
const unsigned long long int debug_bitstream_position = bitstream_tell(&(encoder_state->stream));
|
||||
#endif
|
||||
|
||||
// Allocate 2 extra luma pixels so we get 1 extra chroma pixel for the
|
||||
// for the extra pixel on the top right.
|
||||
yuv_t *ver_buf = yuv_t_alloc(LCU_WIDTH + 2);
|
||||
//Picture
|
||||
picture* const cur_pic = encoder_state->tile->cur_pic;
|
||||
int i = 0;
|
||||
|
@ -1224,30 +1221,6 @@ static void encoder_state_encode_leaf(encoder_state * const encoder_state) {
|
|||
|
||||
for (i = 0; i < encoder_state->lcu_order_count; ++i) {
|
||||
const lcu_order_element * const lcu = &encoder_state->lcu_order[i];
|
||||
yuv_t hor_buf;
|
||||
|
||||
if (lcu->position.y > 0) {
|
||||
hor_buf.size = encoder_state->tile->cur_pic->width;
|
||||
hor_buf.y = &cur_pic->y_recdata[(lcu->position_px.y - 1) * cur_pic->width];
|
||||
hor_buf.u = &cur_pic->u_recdata[(lcu->position_px.y/2 - 1) * cur_pic->width/2];
|
||||
hor_buf.v = &cur_pic->v_recdata[(lcu->position_px.y/2 - 1) * cur_pic->width/2];
|
||||
}
|
||||
if (lcu->position.x > 0) {
|
||||
if (lcu->position.y > 0) {
|
||||
ver_buf->y[0] = hor_buf.y[lcu->position_px.x - 1];
|
||||
ver_buf->u[0] = hor_buf.u[lcu->position_px.x/2 - 1];
|
||||
ver_buf->v[0] = hor_buf.v[lcu->position_px.x/2 - 1];
|
||||
}
|
||||
picture_blit_pixels(&cur_pic->y_recdata[lcu->position_px.y * cur_pic->width + lcu->position_px.x - 1],
|
||||
&ver_buf->y[1],
|
||||
1, lcu->size.y, cur_pic->width, 1);
|
||||
picture_blit_pixels(&cur_pic->u_recdata[lcu->position_px.y * cur_pic->width / 4 + (lcu->position_px.x / 2) - 1],
|
||||
&ver_buf->u[1],
|
||||
1, lcu->size.y / 2, cur_pic->width / 2, 1);
|
||||
picture_blit_pixels(&cur_pic->v_recdata[lcu->position_px.y * cur_pic->width / 4 + (lcu->position_px.x / 2) - 1],
|
||||
&ver_buf->v[1],
|
||||
1, lcu->size.y / 2, cur_pic->width / 2, 1);
|
||||
}
|
||||
|
||||
search_lcu(encoder_state, lcu->position_px.x, lcu->position_px.y, hor_buf_search, ver_buf_search);
|
||||
|
||||
|
@ -1294,8 +1267,6 @@ static void encoder_state_encode_leaf(encoder_state * const encoder_state) {
|
|||
//We should not have written to bitstream!
|
||||
assert(debug_bitstream_position == bitstream_tell(&(encoder_state->stream)));
|
||||
|
||||
yuv_t_free(ver_buf);
|
||||
|
||||
yuv_t_free(hor_buf_search);
|
||||
yuv_t_free(ver_buf_search);
|
||||
}
|
||||
|
|
25
src/search.c
25
src/search.c
|
@ -1026,26 +1026,17 @@ static void init_lcu_t(const encoder_state * const encoder_state, const int x, c
|
|||
// hor_buf is of size pic_width so there might not be LCU_REF_PX_WIDTH
|
||||
// number of allocated pixels left.
|
||||
int x_max = MIN(LCU_REF_PX_WIDTH, pic_width - x);
|
||||
memcpy(&lcu->top_ref.y[1], &hor_buf->y[OFFSET_HOR_BUF(x, y, cur_pic, 0)], x_max);
|
||||
memcpy(&lcu->top_ref.u[1], &hor_buf->u[OFFSET_HOR_BUF_C(x, y, cur_pic, 0)], x_max / 2);
|
||||
memcpy(&lcu->top_ref.v[1], &hor_buf->v[OFFSET_HOR_BUF_C(x, y, cur_pic, 0)], x_max / 2);
|
||||
int x_min_in_lcu = (x>0) ? 0 : 1;
|
||||
memcpy(&lcu->top_ref.y[x_min_in_lcu], &hor_buf->y[OFFSET_HOR_BUF(x, y, cur_pic, x_min_in_lcu-1)], x_max + (1-x_min_in_lcu));
|
||||
memcpy(&lcu->top_ref.u[x_min_in_lcu], &hor_buf->u[OFFSET_HOR_BUF_C(x, y, cur_pic, x_min_in_lcu-1)], x_max / 2 + (1-x_min_in_lcu));
|
||||
memcpy(&lcu->top_ref.v[x_min_in_lcu], &hor_buf->v[OFFSET_HOR_BUF_C(x, y, cur_pic, x_min_in_lcu-1)], x_max / 2 + (1-x_min_in_lcu));
|
||||
}
|
||||
// Copy left reference pixels.
|
||||
if (x > 0) {
|
||||
memcpy(&lcu->left_ref.y[1], &ver_buf->y[OFFSET_VER_BUF(x, y, cur_pic, 0)], LCU_WIDTH);
|
||||
memcpy(&lcu->left_ref.u[1], &ver_buf->u[OFFSET_VER_BUF_C(x, y, cur_pic, 0)], LCU_WIDTH / 2);
|
||||
memcpy(&lcu->left_ref.v[1], &ver_buf->v[OFFSET_VER_BUF_C(x, y, cur_pic, 0)], LCU_WIDTH / 2);
|
||||
}
|
||||
// Copy top-left reference pixel.
|
||||
if (x > 0 && y > 0) {
|
||||
lcu->top_ref.y[0] = ver_buf->y[OFFSET_VER_BUF(x, y, cur_pic, -1)];
|
||||
lcu->left_ref.y[0] = ver_buf->y[OFFSET_VER_BUF(x, y, cur_pic, -1)];
|
||||
|
||||
lcu->top_ref.u[0] = ver_buf->u[OFFSET_VER_BUF(x, y, cur_pic, -1)];
|
||||
lcu->left_ref.u[0] = ver_buf->u[OFFSET_VER_BUF(x, y, cur_pic, -1)];
|
||||
|
||||
lcu->top_ref.v[0] = ver_buf->v[OFFSET_VER_BUF(x, y, cur_pic, -1)];
|
||||
lcu->left_ref.v[0] = ver_buf->v[OFFSET_VER_BUF(x, y, cur_pic, -1)];
|
||||
int y_min_in_lcu = (y>0) ? 0 : 1;
|
||||
memcpy(&lcu->left_ref.y[y_min_in_lcu], &ver_buf->y[OFFSET_VER_BUF(x, y, cur_pic, y_min_in_lcu-1)], LCU_WIDTH + (1-y_min_in_lcu));
|
||||
memcpy(&lcu->left_ref.u[y_min_in_lcu], &ver_buf->u[OFFSET_VER_BUF_C(x, y, cur_pic, y_min_in_lcu-1)], LCU_WIDTH / 2 + (1-y_min_in_lcu));
|
||||
memcpy(&lcu->left_ref.v[y_min_in_lcu], &ver_buf->v[OFFSET_VER_BUF_C(x, y, cur_pic, y_min_in_lcu-1)], LCU_WIDTH / 2 + (1-y_min_in_lcu));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue