Issue with writing YUV image frame in C/C++

大城市里の小女人 提交于 2019-12-03 04:58:08

It looks to me like you have too many bytes per frame for 4:2:0 data. ACcording to the spec you linked to, the number of bytes for a 200x200 pixel 4:2:0 frame should be 200 * 200 * 3 / 2 = 60,000. But you have ~90,000 bytes. Looking at your code, I don't see where you are convert from 4:4:4 to 4:2:0. So you have 2 choices - either set the header to 4:4:4, or convert the YCbCr data to 4:2:0 before writing it out.

I compiled your code and surely there is a problem when computing upos and vpos values. For me this worked (RGB to YUV NV12):

vpos = length + (windowWidth * (j/2)) + (i/2)*2;
upos = vpos + 1;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!