Skip to content
Snippets Groups Projects
Commit cf868c21 authored by Martin Pulec's avatar Martin Pulec
Browse files

UltraGrid plugin: opt to use memmove instead of memcpy

parent 370f22af
No related branches found
No related tags found
No related merge requests found
...@@ -344,6 +344,12 @@ void cesnet_set_render_buffer_rgba(unsigned char *rgba, int width, int height) ...@@ -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, bool copy_data(struct cesnet_shm *cesnet_shm,
unsigned char *y, unsigned char *u, unsigned char *v, int width, int height) 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 !defined WITH_CLIENT_CUDA
if (cesnet_shm->use_gpu) { if (cesnet_shm->use_gpu) {
fprintf(stderr, "CUDA support not compiled in! Use 'uv -t shm' to use standard SHM.\n"); 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, ...@@ -386,26 +392,26 @@ bool copy_data(struct cesnet_shm *cesnet_shm,
} else { } else {
// Y // Y
for (int i = 0; i < height; ++i) { for (int i = 0; i < height; ++i) {
memcpy(out1_y, y, width); copy_fn(out1_y, y, width);
out1_y += width; out1_y += width;
y += width; y += width;
memcpy(out2_y, y, width); copy_fn(out2_y, y, width);
out2_y += width; out2_y += width;
y += width; y += width;
} }
// U V // U V
for (int i = 0; i < height / 2; ++i) { 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; out1_u += width / 2;
u += width / 2; u += width / 2;
memcpy(out2_u, u, width / 2); copy_fn(out2_u, u, width / 2);
out2_u += width / 2; out2_u += width / 2;
u += width / 2; u += width / 2;
memcpy(out1_v, v, width / 2); copy_fn(out1_v, v, width / 2);
out1_v += width / 2; out1_v += width / 2;
v += width / 2; v += width / 2;
memcpy(out2_v, v, width / 2); copy_fn(out2_v, v, width / 2);
out2_v += width / 2; out2_v += width / 2;
v += width / 2; v += width / 2;
} }
...@@ -426,12 +432,12 @@ bool copy_data(struct cesnet_shm *cesnet_shm, ...@@ -426,12 +432,12 @@ bool copy_data(struct cesnet_shm *cesnet_shm,
# endif # endif
} else { } else {
int len = width * height; int len = width * height;
memcpy(tmp, y, len); copy_fn(tmp, y, len);
tmp += len; tmp += len;
len = width * height / 4; len = width * height / 4;
memcpy(tmp, u, len); copy_fn(tmp, u, len);
tmp += len; tmp += len;
memcpy(tmp, v, len); copy_fn(tmp, v, len);
} }
} }
return true; return true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment