ffmpeg: slightly improve performance of yuv2rgb
This commit is contained in:
@@ -235,10 +235,10 @@ TexturePtr FFmpegDecoder::RetrieveVideoInternal(const RetrieveVideoParams &p)
|
||||
job.Insert(QStringLiteral("full_range"), NodeValue(NodeValue::kBoolean, hw_in->color_range == AVCOL_RANGE_JPEG));
|
||||
|
||||
const int *yuv_coeffs = sws_getCoefficients(FFmpegUtils::GetSwsColorspaceFromAVColorSpace(hw_in->colorspace));
|
||||
job.Insert(QStringLiteral("yuv_crv"), NodeValue(NodeValue::kInt, yuv_coeffs[0]));
|
||||
job.Insert(QStringLiteral("yuv_cgu"), NodeValue(NodeValue::kInt, yuv_coeffs[2]));
|
||||
job.Insert(QStringLiteral("yuv_cgv"), NodeValue(NodeValue::kInt, yuv_coeffs[3]));
|
||||
job.Insert(QStringLiteral("yuv_cbu"), NodeValue(NodeValue::kInt, yuv_coeffs[1]));
|
||||
job.Insert(QStringLiteral("yuv_crv"), NodeValue(NodeValue::kFloat, yuv_coeffs[0]/65536.0));
|
||||
job.Insert(QStringLiteral("yuv_cgu"), NodeValue(NodeValue::kFloat, yuv_coeffs[2]/65536.0));
|
||||
job.Insert(QStringLiteral("yuv_cgv"), NodeValue(NodeValue::kFloat, yuv_coeffs[3]/65536.0));
|
||||
job.Insert(QStringLiteral("yuv_cbu"), NodeValue(NodeValue::kFloat, yuv_coeffs[1]/65536.0));
|
||||
|
||||
int interlacing = 0;
|
||||
if (p.src_interlacing != VideoParams::kInterlaceNone) {
|
||||
|
||||
@@ -5,10 +5,10 @@ uniform sampler2D v_channel;
|
||||
uniform int bits_per_pixel;
|
||||
uniform bool full_range;
|
||||
|
||||
uniform int yuv_crv;
|
||||
uniform int yuv_cgu;
|
||||
uniform int yuv_cgv;
|
||||
uniform int yuv_cbu;
|
||||
uniform float yuv_crv;
|
||||
uniform float yuv_cgu;
|
||||
uniform float yuv_cgv;
|
||||
uniform float yuv_cbu;
|
||||
|
||||
uniform int interlacing;
|
||||
uniform int pixel_height;
|
||||
@@ -51,15 +51,10 @@ void main()
|
||||
yuv.b = yuv.b - 0.5;
|
||||
|
||||
// Use coefficients to weigh YUV into RGB
|
||||
float crv = float(yuv_crv) / 65536.0;
|
||||
float cgu = float(yuv_cgu) / 65536.0;
|
||||
float cgv = float(yuv_cgv) / 65536.0;
|
||||
float cbu = float(yuv_cbu) / 65536.0;
|
||||
|
||||
vec4 rgba;
|
||||
rgba.r = yuv.r + crv * yuv.b;
|
||||
rgba.g = yuv.r - cgu * yuv.g - cgv * yuv.b;
|
||||
rgba.b = yuv.r + cbu * yuv.g;
|
||||
rgba.r = yuv.r + yuv_crv * yuv.b;
|
||||
rgba.g = yuv.r - yuv_cgu * yuv.g - yuv_cgv * yuv.b;
|
||||
rgba.b = yuv.r + yuv_cbu * yuv.g;
|
||||
|
||||
// If the expected value is full range, transform to full range here
|
||||
if (full_range) {
|
||||
|
||||
Reference in New Issue
Block a user