yuv420pの画像をlibyuv経由でRGB24に変換したいのですが、変換後の画像が全体的に青くなっています。理由が知りたいので修正していきますのでよろしくお願いします !
私のコード:
const int width = 1280, height = 720;
FILE *src_file = fopen("1280x720.yuv", "rb");
FILE *dst_file = fopen("1280x720.rgb", "wb");
int size_src = width * height * 3 / 2;
int size_dest = width * height * 4;
char *buffer_src = (char *)malloc(size_src);
char *buffer_dest = (char *)malloc(size_dest);
uint64_t start_time = os_gettime_ns();
while (1)
{
if (fread(buffer_src, 1, size_src, src_file) != size_src)
{
break;
}
libyuv::I420ToRGB24((const uint8*)buffer_src, width,
(const uint8*)(buffer_src + width * height), width / 2,
(const uint8*)(buffer_src + width * height * 5 / 4), width / 2,
(uint8*)buffer_dest, width * 3,
width, height);
fwrite(buffer_dest, 1, size_dest, dst_file);
fflush(dst_file);
}
uint64_t stop_time = os_gettime_ns();
printf("------ %ld \n", stop_time - start_time);
free(buffer_src);
free(buffer_dest);
//fclose(dst_file);
fclose(src_file);
return 0;