VSE: speed up solid color effect #117058

Merged
Aras Pranckevicius merged 1 commits from aras_p/blender:vse-solidcolor-perf into main 2024-01-12 18:04:48 +01:00
1 changed files with 25 additions and 35 deletions

View File

@ -1925,51 +1925,41 @@ static ImBuf *do_solid_color(const SeqRenderData *context,
ImBuf *ibuf2, ImBuf *ibuf2,
ImBuf *ibuf3) ImBuf *ibuf3)
{ {
using namespace blender;
ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3);
SolidColorVars *cv = (SolidColorVars *)seq->effectdata; SolidColorVars *cv = (SolidColorVars *)seq->effectdata;
int x = out->x; threading::parallel_for(IndexRange(out->y), 64, [&](const IndexRange y_range) {
int y = out->y; if (out->byte_buffer.data) {
/* Byte image. */
uchar color[4];
rgb_float_to_uchar(color, cv->col);
color[3] = 255;
if (out->byte_buffer.data) { uchar *dst = out->byte_buffer.data + y_range.first() * out->x * 4;
uchar color[4]; uchar *dst_end = dst + y_range.size() * out->x * 4;
color[0] = cv->col[0] * 255; while (dst < dst_end) {
color[1] = cv->col[1] * 255; memcpy(dst, color, sizeof(color));
color[2] = cv->col[2] * 255; dst += 4;
color[3] = 255;
uchar *rect = out->byte_buffer.data;
for (int i = 0; i < y; i++) {
for (int j = 0; j < x; j++) {
rect[0] = color[0];
rect[1] = color[1];
rect[2] = color[2];
rect[3] = color[3];
rect += 4;
} }
} }
} else {
else if (out->float_buffer.data) { /* Float image. */
float color[4]; float color[4];
color[0] = cv->col[0]; color[0] = cv->col[0];
color[1] = cv->col[1]; color[1] = cv->col[1];
color[2] = cv->col[2]; color[2] = cv->col[2];
color[3] = 255; color[3] = 1.0f;
float *rect_float = out->float_buffer.data; float *dst = out->float_buffer.data + y_range.first() * out->x * 4;
float *dst_end = dst + y_range.size() * out->x * 4;
for (int i = 0; i < y; i++) { while (dst < dst_end) {
for (int j = 0; j < x; j++) { memcpy(dst, color, sizeof(color));
rect_float[0] = color[0]; dst += 4;
rect_float[1] = color[1];
rect_float[2] = color[2];
rect_float[3] = color[3];
rect_float += 4;
} }
} }
} });
out->planes = R_IMF_PLANES_RGB; out->planes = R_IMF_PLANES_RGB;