From 57a3d9b4b919ab7154346f5bee17cace4de1afea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arttu=20Yl=C3=A4-Outinen?= Date: Tue, 12 Jan 2016 08:00:14 +0200 Subject: [PATCH] Add a function for copying CU data from LCUs. Adds function kvz_cu_array_copy_from_lcu which CU info data from an lcu_t structure to a cu_array_t structure. --- src/cu.c | 25 +++++++++++++++++++++++++ src/cu.h | 2 ++ src/search.c | 15 +-------------- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/cu.c b/src/cu.c index cb2dca92..9fb09e3f 100644 --- a/src/cu.c +++ b/src/cu.c @@ -200,3 +200,28 @@ void kvz_cu_array_copy(cu_array_t* dst, int dst_x, int dst_y, dst_ptr += dst_stride; } } + +/** + * \brief Copy an lcu to a cu array. + * + * All values are in luma pixels. + * + * \param dst destination array + * \param dst_x x-coordinate of the left edge of the copied area in dst + * \param dst_y y-coordinate of the top edge of the copied area in dst + * \param src source lcu + */ +void kvz_cu_array_copy_from_lcu(cu_array_t* dst, int dst_x, int dst_y, const lcu_t *src) +{ + // Convert values from pixel coordinates to array indices. + const int dst_x_scu = dst_x >> 3; + const int dst_y_scu = dst_y >> 3; + const int dst_stride = dst->width >> 3; + for (int y = 0; y < LCU_CU_WIDTH; ++y) { + for (int x = 0; x < LCU_CU_WIDTH; ++x) { + const cu_info_t *from_cu = LCU_GET_CU(src, x, y); + cu_info_t *to_cu = &dst->data[dst_x_scu + x + (dst_y_scu + y) * dst_stride]; + memcpy(to_cu, from_cu, sizeof(*to_cu)); + } + } +} diff --git a/src/cu.h b/src/cu.h index 153936ea..e865f817 100644 --- a/src/cu.h +++ b/src/cu.h @@ -268,6 +268,8 @@ typedef struct { cu_info_t cu[9*9+1]; } lcu_t; +void kvz_cu_array_copy_from_lcu(cu_array_t* dst, int dst_x, int dst_y, const lcu_t *src); + /** * \brief Return pointer to a given CU. * diff --git a/src/search.c b/src/search.c index 7f1193d6..7960e767 100644 --- a/src/search.c +++ b/src/search.c @@ -883,20 +883,7 @@ static void init_lcu_t(const encoder_state_t * const state, const int x, const i static void copy_lcu_to_cu_data(const encoder_state_t * const state, int x_px, int y_px, const lcu_t *lcu) { // Copy non-reference CUs to picture. - { - const int x_cu = x_px >> MAX_DEPTH; - const int y_cu = y_px >> MAX_DEPTH; - videoframe_t * const frame = state->tile->frame; - - int x, y; - for (y = 0; y < LCU_CU_WIDTH; ++y) { - for (x = 0; x < LCU_CU_WIDTH; ++x) { - const cu_info_t *from_cu = LCU_GET_CU(lcu, x, y); - cu_info_t *to_cu = kvz_videoframe_get_cu(frame, x_cu + x, y_cu + y); - memcpy(to_cu, from_cu, sizeof(*to_cu)); - } - } - } + kvz_cu_array_copy_from_lcu(state->tile->frame->cu_array, x_px, y_px, lcu); // Copy pixels to picture. {