0

我想通过libyuv将yuv420p图像转换成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;
4

0 回答 0