代码如下,是我的储存方式有问题嘛?
```c++
#include<iostream>
#include<fstream>
using namespace std;
typedef struct YUVPixel {
int Y;
int U;
int V;
} YUVPixel;
int main()
{
FILE* orignal_data = fopen("ParkScene_1920x1080_24_16bit_444.yuv", "r");
FILE* f_r = fopen("r_data.yuv", "w");
if (orignal_data == NULL)
printf("open file error:\n");
unsigned int width = 1920, height = 1080;
unsigned char* raw_16bit_pixels = (unsigned char*)malloc(width * height * 3 * sizeof(unsigned char));
fread(raw_16bit_pixels, 1, width * height * 3, orignal_data); //暂时忽略其返回值
YUVPixel yuv_pixel;
unsigned char Ylow, Yhigh,Ulow,Uhigh,Vlow,Vhigh;
unsigned int Ytemp,Utemp,Vtemp;
for (int j = 0;j < height;j++)
for (int i = 0;i < width;i++)
{
yuv_pixel.Y = raw_16bit_pixels[1920 * j + i];//读入Y
yuv_pixel.U = raw_16bit_pixels[1920 * j + i + 1920 * 1080];//读入U
yuv_pixel.V = raw_16bit_pixels[1920 * j + i + 1920 * 1080 * 2];//读入V
Ylow = (yuv_pixel.Y )& 0xff;
Yhigh = (yuv_pixel.Y )>> 8;
Ytemp = Yhigh;
Ytemp <<= 8;
Ytemp += Ylow;//Y的合成
Ulow = (yuv_pixel.U) & 0xff;
Uhigh = (yuv_pixel.U) >> 8;
Utemp = Uhigh;
Utemp <<= 8;
Utemp += Ulow;//U的合成
Vlow = (yuv_pixel.V) & 0xff;
Vhigh = (yuv_pixel.V) >> 8;
Vtemp = Uhigh;
Vtemp <<= 8;
Vtemp += Vlow;//V的合成
// cout << Utemp << "比较" << yuv_pixel.U << endl;
fputc(Ytemp, f_r);//写入Y
fputc(Utemp, f_r);//写入U
fputc(Vtemp, f_r);//写入V
}
fclose(f_r);
return 0;
}
```