ermig1979 / Simd

C++ image processing and machine learning library with using of SIMD: SSE, AVX, AVX-512, AMX for x86/x64, VMX(Altivec) and VSX(Power7) for PowerPC, NEON for ARM.
http://ermig1979.github.io/Simd
MIT License
2.03k stars 406 forks source link

writing text to YUV #190

Closed mikeversteeg closed 2 years ago

mikeversteeg commented 2 years ago

Just wanted to confirm there are no plans to add text functions in the making? I realise this may fall outside the purpose of this library. Not a big problem if there are no plans, I'll just write text to RGB using Windows functions, convert that to YUV and then alpha blend it over the YUV image.. Thanks.

ermig1979 commented 2 years ago

See file SimdFont.hpp. The file contains simple functions to draw text (for debug purposes) built in Simd.

P.S. I tried to draw text and other primitives (lines, rectangles, ellipses) direct to YUV. It works for YUV444P, but for YUV420P the result is not good mainly due to different resolution of Y, U and V planes.

mikeversteeg commented 2 years ago

Drawing lines and rectangles indeed is also what I need to do, as well as text (but I need to be able to pick my own font). So I will use the RGB route for this then. Thanks!

mikeversteeg commented 2 years ago

P.S. I tried to draw text and other primitives (lines, rectangles, ellipses) direct to YUV. It works for YUV444P, but for YUV420P the result is not good mainly due to different resolution of Y, U and V planes.

Thinking of this some more: drawing text to YUV444P and then convert this to the YUV420P target would, I assume, still be a lot faster then drawing text to an RGB bitmap, convert that to YUV420P and then copy it to the YUV420P target?

ermig1979 commented 2 years ago

I think that YUV444P to UV420P conversion is very fast (SimdReduceGray2x2 function), so first method is preferable.

mikeversteeg commented 2 years ago

I think that YUV444P to UV420P conversion is very fast (SimdReduceGray2x2 function), so first method is preferable.

So does that mean you are thinking about adding (optimised) text support after all?

ermig1979 commented 2 years ago

No. I think that current solution (Simd::Font) is enough for debug purposes. The developing of full-fledged text renderer lies outside the sphere of my interests.