Ffmpeg 如何镜像swscale PIX_FMT_YUYV422
我正在尝试水平镜像libswscale PIX_FMT_YUYV422类型的图像。对每行使用每像素16位的简单循环会导致颜色错误,例如蓝色对象为橙色。这是我的密码:Ffmpeg 如何镜像swscale PIX_FMT_YUYV422,ffmpeg,yuv,color-space,Ffmpeg,Yuv,Color Space,我正在尝试水平镜像libswscale PIX_FMT_YUYV422类型的图像。对每行使用每像素16位的简单循环会导致颜色错误,例如蓝色对象为橙色。这是我的密码: typedef unsigned short YUVPixel; // 16 bits per pixel for (int y = 0; y < outHeight; y++) { YUVPixel *p1 = (YUVPixel*)pBits + y * outWidth;
typedef unsigned short YUVPixel; // 16 bits per pixel
for (int y = 0; y < outHeight; y++)
{
YUVPixel *p1 = (YUVPixel*)pBits + y * outWidth;
YUVPixel *p2 = p1 + outWidth - 1;
for (int x = 0; x < outWidth/2; x++) // outWidth is image width in pixels
{
// packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
unsigned short tmp;
tmp = *p1;
*p1 = *p2;
*p2 = tmp;
}
}
typedef无符号短YUVPixel;//每像素16位
对于(int y=0;y
然后我尝试将YUVPixel重新定义为32位类型,并相应地修改我的循环。这将生成正确的颜色,但看起来相邻像素已交换。有什么想法吗,我完全不明白吗?您使用32位YUVPixel类型的方法很好,您只需确保在移动像素结构后交换该像素结构内的两个Y值,例如:
Y0 U Y1 V
move to new position
-------------------------------->
Y0 U Y1 V
<swap>
Y1 U Y0 V
y0uy1v
调到新位置
-------------------------------->
y0uy1v
Y1 U Y0 V
U和V值对整个2像素结构都有效,Y值必须翻转