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

Jpeg RGB & grayscale encoders can be accelerated with intrinsics #1763

Closed
br3aker opened this issue Sep 17, 2021 · 0 comments · Fixed by #2039
Closed

Jpeg RGB & grayscale encoders can be accelerated with intrinsics #1763

br3aker opened this issue Sep 17, 2021 · 0 comments · Fixed by #2039

Comments

@br3aker
Copy link
Contributor

br3aker commented Sep 17, 2021

Current rgb and grayscale encoders use scalar code to cast data from byte to float:

for (int i = 0; i < Block8x8F.Size; i++)
{
ref L8 c = ref Unsafe.Add(ref l8Start, i);
yBlock[i] = c.PackedValue;
}

for (int i = 0; i < Block8x8F.Size; i++)
{
Rgb24 c = Unsafe.Add(ref rgbStart, (nint)(uint)i);
redBlock[i] = c.R;
greenBlock[i] = c.G;
blueBlock[i] = c.B;
}

Grayscale code can be simd'ified via avx VPMOVZXBD aka Avx2.ConvertToVector256Int32 & VCVTDQ2PS aka Avx.ConvertToVector256Single commands. Rgb encoder is a bit trickier as it would involve shuffles - needs further benchmarking.

Anyway, this is fairly straightforward so it's a 'good first issue' issue.

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

Successfully merging a pull request may close this issue.

1 participant