无损RGB24到YUV444转换 [英] Lossless RGB24 to YUV444 transformation

查看:256
本文介绍了无损RGB24到YUV444转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试使用FFMPEG上的H264对RGB24文件进行无损压缩.但是,事实证明,在H264压缩(RGB24-> YUV444)中使用的色彩空间转换是有损的(我猜测是由于量化误差).在用无损H264压缩RGB24文件之前,还有其他方法可以使用(例如程序)将RGB24文件无损转换为YUV吗?

I am currently attempting to undergo lossless compression of RGB24 files using H264 on FFMPEG. However, the color space transformation used in the H264 compression (RGB24 -> YUV444) has proven to be lossy (I'm guessing due to quantisation error). Is there anything else I can use (eg a program) to transform my RGB24 files to YUV losslessly, before compressing them with lossless H264?

最终目标是压缩RGB24文件,然后对其进行解压缩,使解压缩后的文件与原始文件完全匹配.例如RGB24-> YUV444->压缩YUV44->解压缩的YUV444-> RGB24.

The ultimate goal is to compress an RGB24 file then decompress it, with the decompressed file exactly matching the original file. eg RGB24 -> YUV444 -> compressed YUV44 -> decompressed YUV444 -> RGB24.

这有可能吗?

推荐答案

这是我在此处给出的答案的副本/粘贴内容: RGB帧编码-FFmpeg/libav

This is a copy/paste from my answer here: RGB-frame encoding - FFmpeg/libav

让我们看看色彩空间的转换.

lets look at the colorspace conversion.

void YUVfromRGB(double& Y, double& U, double& V, const double R, const double G, const double B)
{
    Y =  0.257 * R + 0.504 * G + 0.098 * B +  16;
    U = -0.148 * R - 0.291 * G + 0.439 * B + 128;
    V =  0.439 * R - 0.368 * G - 0.071 * B + 128;
}

并插入一些虚拟值:

R = 255, G = 255, B = 255
Y = 235

R = 0, G = 0, B = 0
Y = 16

如您所见,范围0-> 255被压缩为16->235.因此,我们显示了RGB颜色空间中的某些颜色在(数字)YUV颜色空间中不存在.因此,根据定义,转换是有损耗的.

As you can see, the range 0 -> 255 is squished to 16 -> 235. Thus we have shown that there are some colors in the RGB colorspace that do not exist in the (digital) YUV color space. Hence the conversion is lossy by definition.

这篇关于无损RGB24到YUV444转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆