descampsa / yuv2rgb

C99 library for fast image conversion between yuv420p and rgb24
BSD 3-Clause "New" or "Revised" License
170 stars 62 forks source link

yuv420sp to rgb #9

Closed bellekci closed 5 years ago

bellekci commented 6 years ago

Thanks for the project. Do you plan to include yuv420sp-to-rgb conversion?

descampsa commented 6 years ago

Hey,

I do not know what yuv420sp is, is it the same as NV12? If it is, i may consider to include it, since it should not be too difficult to do and it is apparently a commonly used format.

bellekci commented 6 years ago

I am not so confident about what exactly nv12/nv21 or yuv420sp are. Only thing I know sp stands for semi-planar as opposed to planar and U V channels are interleaved in yuv420sp.

Plus one more curiosity: did you ever benchmark your implementation with opencv-conversion? It is pretty straight-forward in opencv:

cv::Mat yuv(height + height/2, width, CV_8UC1, pSrc_yuv420sp);
cv::Mat bgr(height, width, CV_8UC3, pDest_rgb); 
cv::cvtColor(yuv, bgr, CV_YUV420sp2BGR);

openCV does also use SSE optimizations by default. I was looking for a way to improve it further and I stumbled upon your project.

descampsa commented 6 years ago

Hey, sorry for the long delay, i finally found the time to have a look at this

NV12/NV21 are indeed semi-planar, with UV channels interleaved in different order. I have added the functions to convert from these formats to rgb in the last commit, so feel free to try them if you are interested.

I have not compared with the opencv functions, i would be interested to know the result if you do it.