diff --git a/client/ultragrid/ultragrid.cpp b/client/ultragrid/ultragrid.cpp index dd670d3e044a9874feb51c92d2d29ce46f75a9a5..91131a78f9da657989ceaeb868c329f6c66835cd 100644 --- a/client/ultragrid/ultragrid.cpp +++ b/client/ultragrid/ultragrid.cpp @@ -344,6 +344,12 @@ void cesnet_set_render_buffer_rgba(unsigned char *rgba, int width, int height) bool copy_data(struct cesnet_shm *cesnet_shm, unsigned char *y, unsigned char *u, unsigned char *v, int width, int height) { + void *(*copy_fn)(void *dest, const void *src, size_t n) = memcpy; + + if (getenv("MEMMOVE_INSTEAD_MEMCPY")) { + copy_fn = memmove; + } + # if !defined WITH_CLIENT_CUDA if (cesnet_shm->use_gpu) { fprintf(stderr, "CUDA support not compiled in! Use 'uv -t shm' to use standard SHM.\n"); @@ -386,26 +392,26 @@ bool copy_data(struct cesnet_shm *cesnet_shm, } else { // Y for (int i = 0; i < height; ++i) { - memcpy(out1_y, y, width); + copy_fn(out1_y, y, width); out1_y += width; y += width; - memcpy(out2_y, y, width); + copy_fn(out2_y, y, width); out2_y += width; y += width; } // U V for (int i = 0; i < height / 2; ++i) { - memcpy(out1_u, u, width / 2); + copy_fn(out1_u, u, width / 2); out1_u += width / 2; u += width / 2; - memcpy(out2_u, u, width / 2); + copy_fn(out2_u, u, width / 2); out2_u += width / 2; u += width / 2; - memcpy(out1_v, v, width / 2); + copy_fn(out1_v, v, width / 2); out1_v += width / 2; v += width / 2; - memcpy(out2_v, v, width / 2); + copy_fn(out2_v, v, width / 2); out2_v += width / 2; v += width / 2; } @@ -426,12 +432,12 @@ bool copy_data(struct cesnet_shm *cesnet_shm, # endif } else { int len = width * height; - memcpy(tmp, y, len); + copy_fn(tmp, y, len); tmp += len; len = width * height / 4; - memcpy(tmp, u, len); + copy_fn(tmp, u, len); tmp += len; - memcpy(tmp, v, len); + copy_fn(tmp, v, len); } } return true;