From f37352abfccb76e649b8b04f14dc2cfe903fdf31 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Tue, 24 May 2022 14:24:47 +0200 Subject: [PATCH] NDI cap, disp.: mark some conversions form optimization --- src/video_capture/ndi.cpp | 6 ++++-- src/video_display/ndi.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/video_capture/ndi.cpp b/src/video_capture/ndi.cpp index d62a08872..2493d00f0 100644 --- a/src/video_capture/ndi.cpp +++ b/src/video_capture/ndi.cpp @@ -363,7 +363,8 @@ static void convert_BGRA_RGBA(struct video_frame *out, const uint8_t *data, int auto *out_p = reinterpret_cast(out->tiles[0].data) + field_idx * out->tiles[0].width; for (unsigned int i = 0; i < out->tiles[0].height; i += total_fields) { const auto *in_p = reinterpret_cast(data + i * in_stride); - for (unsigned int j = 0; j < out->tiles[0].width; j++) { + unsigned int width = out->tiles[0].width; + OPTIMIZED_FOR (unsigned int j = 0; j < width; j++) { uint32_t argb = *in_p++; *out_p++ = (argb & 0xFF000000U) | ((argb & 0xFFU) << 16U) | (argb & 0xFF00U) | ((argb & 0xFF0000U) >> 16U); } @@ -377,7 +378,8 @@ static void convert_P216_Y216(struct video_frame *out, const uint8_t *data, [[ma const auto *in_cb_cr = reinterpret_cast(data) + out->tiles[0].width * out->tiles[0].height; auto *out_p = reinterpret_cast(out->tiles[0].data) + 2 * field_idx * out->tiles[0].width; for (unsigned int i = 0; i < out->tiles[0].height; i += total_fields) { - for (unsigned int j = 0; j < out->tiles[0].width; j += 2) { + unsigned int width = out->tiles[0].width; + OPTIMIZED_FOR (unsigned int j = 0; j < (width + 1) / 2; j += 1) { *out_p++ = *in_y++; *out_p++ = *in_cb_cr++; *out_p++ = *in_y++; diff --git a/src/video_display/ndi.c b/src/video_display/ndi.c index f5b482956..75c769f89 100644 --- a/src/video_display/ndi.c +++ b/src/video_display/ndi.c @@ -258,7 +258,8 @@ static void ndi_disp_convert_Y216_to_P216(const struct video_frame *f, char *out uint16_t *out_cb_cr = (uint16_t *)(void *) out + f->tiles[0].width * f->tiles[0].height; for (unsigned int i = 0; i < f->tiles[0].height; ++i) { - for (unsigned int j = 0; j < f->tiles[0].width; j += 2) { + unsigned int width = f->tiles[0].width; + OPTIMIZED_FOR (unsigned int j = 0; j < (width + 1) / 2; j += 1) { *out_y++ = *in++; *out_cb_cr++ = *in++; *out_y++ = *in++; @@ -276,7 +277,8 @@ static void ndi_disp_convert_Y416_to_P216(const struct video_frame *f, char *out uint16_t *out_cb_cr = (uint16_t *)(void *) out + f->tiles[0].width * f->tiles[0].height; for (unsigned int i = 0; i < f->tiles[0].height; ++i) { - OPTIMIZED_FOR (unsigned int j = 0; j < f->tiles[0].width; j += 2) { + unsigned int width = f->tiles[0].width; + OPTIMIZED_FOR (unsigned int j = 0; j < (width + 1) / 2; j += 1) { *out_y++ = in[1]; *out_cb_cr++ = (in[2] + in[6]) / 2; *out_y++ = in[5];