Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate performance impact of flat image buffers (Vec<f32>) vs planar buffers ([Vec<f32>; 3]) #19

Open
FreezyLemon opened this issue Feb 12, 2024 · 0 comments

Comments

@FreezyLemon
Copy link
Contributor

FreezyLemon commented Feb 12, 2024

Potential option for #11.

For every scale, we first convert to Xyb (which uses the same data: Vec<[f32; 3]> as LinearRgb) and then to a planar data representation. Instead of a Vec<[f32; 3]>, we get three Vec<f32>, both with len == amount_of_pixels.

The conversion between these two representations is probably not that important in terms of speed (although it does require three fairly large allocations), I wonder if we could use a single Vec<f32> with len == 3*amount_of_pixels instead.

The naive thought I had was to just inline all planes after each other (&data[0..plane_size] is the X plane, for example). This would still require a new allocation, but might be faster when blurring or doing the metric calculations.

Another thought I just had: Maybe we could even reuse the Vec<[f32; 3]>'s allocation. Casting to Vec<f32> is relatively simple with some unsafe code (we already do it in yuvxyb). Bit difficult to tell what performance implications this would have though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant