VSE: Speedup Subsampled 3x3 image filter #117125

Merged
Aras Pranckevicius merged 1 commits from aras_p/blender:vse-subsampling into main 2024-01-17 10:27:01 +01:00

Make Subsampling 3x3 filter twice faster (on 4K UHD resolution, Windows/VS2022/Ryzen5950X: 52.7ms -> 28.3ms), by reformulating how it works:

Conceptually Subsampling filter is a box filter: it sums up N source image pixels, computes their average and outputs the result. Critical
thing is, that should be done in premultiplied space so that colors from fully or mostly transparent regions do not "override" opaque colors.

Previously, when operating on byte images, the code achieved this by always working on byte values, doing "progressively smaller"
lerp into byte color result, taking care of premultiplication and again storing the "straight" alpha for each sample being processed.
This meant that for each sample, there are 3 divisions involved! This also led to some precision loss, since for all 9 samples all the intermediate results would only be stored at byte precision.

Reformulate that by simply accumulating the premultiplied color as a float. This gets rid of all divisions, except the last step when said float needs to be written back into a byte color.

The unit test results have a tiny difference, since now it is arguably better (as per above, previously it was having some precision loss).

Make Subsampling 3x3 filter twice faster (on 4K UHD resolution, Windows/VS2022/Ryzen5950X: 52.7ms -> 28.3ms), by reformulating how it works: Conceptually Subsampling filter is a box filter: it sums up N source image pixels, computes their average and outputs the result. Critical thing is, that should be done in premultiplied space so that colors from fully or mostly transparent regions do not "override" opaque colors. Previously, when operating on byte images, the code achieved this by always working on byte values, doing "progressively smaller" lerp into byte color result, taking care of premultiplication and again storing the "straight" alpha for each sample being processed. This meant that for each sample, there are 3 divisions involved! This also led to some precision loss, since for all 9 samples all the intermediate results would only be stored at byte precision. Reformulate that by simply accumulating the premultiplied color as a float. This gets rid of all divisions, except the last step when said float needs to be written back into a byte color. The unit test results have a tiny difference, since now it is arguably better (as per above, previously it was having some precision loss).
Aras Pranckevicius changed title from WIP: VSE: Optimize Subsampling 3x3 image filter to WIP: VSE: Optimize Subsampling 3x3 filter and simplify code 2024-01-15 10:50:48 +01:00
Aras Pranckevicius force-pushed vse-subsampling from 29889a28df to 2190b707a9 2024-01-16 21:03:23 +01:00 Compare
Aras Pranckevicius changed title from WIP: VSE: Optimize Subsampling 3x3 filter and simplify code to WIP: VSE: Speedup Subsampled 3x3 filter 2024-01-16 21:03:47 +01:00
Aras Pranckevicius force-pushed vse-subsampling from 2190b707a9 to cf619dd743 2024-01-16 21:09:57 +01:00 Compare
Aras Pranckevicius changed title from WIP: VSE: Speedup Subsampled 3x3 filter to VSE: Speedup Subsampled 3x3 image filter 2024-01-16 21:11:10 +01:00
Aras Pranckevicius force-pushed vse-subsampling from cf619dd743 to 724f0c2c9e 2024-01-16 21:18:50 +01:00 Compare
Author
Member

@blender-bot build

@blender-bot build
Aras Pranckevicius added this to the Video Sequencer project 2024-01-17 05:42:18 +01:00
Sergey Sharybin approved these changes 2024-01-17 09:47:12 +01:00
Aras Pranckevicius merged commit b85fecee67 into main 2024-01-17 10:27:01 +01:00
Aras Pranckevicius deleted branch vse-subsampling 2024-01-17 10:27:03 +01:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser Project (Legacy)
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#117125
No description provided.