From: Urvang Joshi Date: Wed, 3 Aug 2016 23:42:11 +0000 (-0700) Subject: Make palette code faster: replace nested for loops by a single memcpy(). X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a0a23b7f0c09295c3254e02f3c30b323eeb2aa9c;p=libvpx Make palette code faster: replace nested for loops by a single memcpy(). Change-Id: Ia14df45a35c98d680822454fbb8d1763884c1852 --- diff --git a/vp10/encoder/rdopt.c b/vp10/encoder/rdopt.c index 2b867ef61..e8cea33a8 100644 --- a/vp10/encoder/rdopt.c +++ b/vp10/encoder/rdopt.c @@ -1949,9 +1949,7 @@ static int rd_pick_palette_intra_sby(VP10_COMP *cpi, MACROBLOCK *x, pmi->palette_size[0] = k; vp10_calc_indices(data, centroids, indices, rows * cols, k, 1); - for (r = 0; r < rows; ++r) - for (c = 0; c < cols; ++c) - color_map[r * cols + c] = indices[r * cols + c]; + memcpy(color_map, indices, rows * cols * sizeof(*color_map)); super_block_yrd(cpi, x, &this_rate_tokenonly, &this_distortion, &s, NULL, bsize, *best_rd); @@ -3825,9 +3823,7 @@ static void rd_pick_palette_intra_sbuv(VP10_COMP *cpi, MACROBLOCK *x, clip_pixel((int)lroundf(centroids[j * 2 + i - 1])); } } - for (r = 0; r < rows; ++r) - for (c = 0; c < cols; ++c) - color_map[r * cols + c] = indices[r * cols + c]; + memcpy(color_map, indices, rows * cols * sizeof(*color_map)); super_block_uvrd(cpi, x, &this_rate_tokenonly, &this_distortion, &s, &this_sse, bsize, *best_rd); @@ -8343,10 +8339,7 @@ static void restore_uv_color_map(VP10_COMP *cpi, MACROBLOCK *x) { vp10_calc_indices(data, centroids, indices, rows * cols, pmi->palette_size[1], 2); - - for (r = 0; r < rows; ++r) - for (c = 0; c < cols; ++c) - color_map[r * cols + c] = indices[r * cols + c]; + memcpy(color_map, indices, rows * cols * sizeof(*color_map)); } #if CONFIG_EXT_INTRA