gpt4 book ai didi

复制 yuv420 缓冲区

转载 作者:太空宇宙 更新时间:2023-11-04 04:05:16 26 4
gpt4 key购买 nike

我想将 yuv420P 像素写入缓冲区而不是二进制文件。假设我在指针中存储了 luma 、 Cb 和 Cr。

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)

相反,如果通过 memcpy 写入缓冲区,则它不起作用,例如

/* 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);

附言。只是想复制 o/p 缓冲区中的像素。

最佳答案

调用 memcpy 时参数颠倒了。

啊,C 的乐趣。:)

关于复制 yuv420 缓冲区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6762798/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com