Copying yuv420 buffer
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. :)
精彩评论