Page MenuHome

Sequencer: Performance image crop transform.
ClosedPublic

Authored by Jeroen Bakker (jbakker) on Jun 8 2021, 2:51 PM.

Details

Summary

During transforming an image, a matrix multiplication per pixel was done.
The matrix in itself is always linear so it could be replaced by two additions.

Before

After

Diff Detail

Repository
rB Blender
Branch
temp-sequencer-image-transform (branched from master)
Build Status
Buildable 15031
Build 15031: arc lint + arc unit

Event Timeline

Jeroen Bakker (jbakker) requested review of this revision.Jun 8 2021, 2:51 PM
Jeroen Bakker (jbakker) created this revision.
Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)Jun 8 2021, 2:59 PM
Sebastian Parborg (zeddb) accepted this revision.EditedJun 8 2021, 3:59 PM

Wow, I went from 20fps in the debug build to ~300fps.

The next bottle neck seems to be in nearest_interpolation_color.

I think you could remove the if (x1 < 0 || y1 < 0) { check on line 266 as that has already been done on line 255.

However from looking at the perf data the slow part in that function seems to be the array index lookup (unsigned char *)in->rect + ((size_t)in->x) * y1 * 4 + 4 * x1;
Don't know if this could also be optimized further.
I guess we could be clever and only calculate the ((size_t)in->x) * y1 * 4 once per line.
But that might make the function more complex

However the current code looks good and because of the huge performance uplift, I think it can be committed as is.

This revision is now accepted and ready to land.Jun 8 2021, 3:59 PM

Great job!!!

No fps drop doing transforms while playing:

Add-on: https://github.com/zeograd/VSE_Transform_Tools