开发者

Copying yuv420 buffer

开发者 https://www.devze.com 2023-03-21 11:53 出处:网络
i want write the yuv420P pixel into a buffer instead of a binary file. suppose i have luma , Cb and Cr stored in the pointers.

i want write the yuv420P pixel into a buffer instead of a binary file. suppose i have luma , Cb and Cr stored in the pointers.

luma = output_pixel.luma;
cb = output_pixel.cb;
cr = output_pixel.cr;

int size = lenght * width;

/* this is working */
fwrite(out_pixel.luma,1,size,out_file)
fwrite(out_pixel.cb,1, size>> 2,out_file)
fwrite(out_pixel.cr,1,size >>2 ,out_file)

instead if write in a 开发者_如何学JAVAbuffer thorugh memcpy it is not working, like

/* this is not working */
char *buffer = (char *)malloc(sizeof(size * 1.5));
memcpy(out_pixel.luma ,buffer,size);
memcpy(out_pixel.cb + size,buffer,size >> 2);
memcpy(out_pixel.cr + size + (size >> 2),buffer,size >> 2);

PS . simply want to copy the pixels in a o/p buffer.


you have the arguments reversed when you call memcpy.

ahh, the joys of C. :)

0

精彩评论

暂无评论...
验证码 换一张
取 消