gallium/vl: Remove vl_csc_get_matrix

Not used anymore.

Acked-by: Ruijing Dong <ruijing.dong@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37058>
This commit is contained in:
David Rosca 2025-10-02 10:32:14 +02:00 committed by Marge Bot
parent 9393a0510b
commit 40df7363b9
3 changed files with 4 additions and 234 deletions

View file

@ -888,7 +888,7 @@ vl_compositor_init_state(struct vl_compositor_state *s, struct pipe_context *pip
pipe->screen,
PIPE_BIND_CONSTANT_BUFFER,
PIPE_USAGE_DEFAULT,
sizeof(csc_matrix) + 32 * sizeof(float) + 2 * sizeof(int)
sizeof(vl_csc_matrix) + 32 * sizeof(float) + 2 * sizeof(int)
);
if (!s->shader_params)
@ -896,7 +896,9 @@ vl_compositor_init_state(struct vl_compositor_state *s, struct pipe_context *pip
vl_compositor_clear_layers(s);
vl_csc_get_matrix(VL_CSC_COLOR_STANDARD_IDENTITY, NULL, true, &csc_matrix);
vl_csc_get_rgbyuv_matrix(PIPE_VIDEO_VPP_MCF_BT709, PIPE_FORMAT_NV12, PIPE_FORMAT_B8G8R8A8_UNORM,
PIPE_VIDEO_VPP_CHROMA_COLOR_RANGE_REDUCED, PIPE_VIDEO_VPP_CHROMA_COLOR_RANGE_FULL,
&csc_matrix);
if (!vl_compositor_set_csc_matrix(s, (const vl_csc_matrix *)&csc_matrix, 1.0f, 0.0f))
return false;

View file

@ -30,131 +30,6 @@
#include "vl_csc.h"
/*
* Color space conversion formulas
*
* To convert YCbCr to RGB,
* vec4 ycbcr, rgb
* mat44 csc
* rgb = csc * ycbcr
*
* To calculate the color space conversion matrix csc with ProcAmp adjustments,
* mat44 csc, cstd, procamp, bias
* csc = cstd * (procamp * bias)
*
* Where cstd is a matrix corresponding to one of the color standards (BT.601, BT.709, etc)
* adjusted for the kind of YCbCr -> RGB mapping wanted (1:1, full),
* bias is a matrix corresponding to the kind of YCbCr -> RGB mapping wanted (1:1, full)
*
* To calculate procamp,
* mat44 procamp, hue, saturation, brightness, contrast
* procamp = brightness * (saturation * (contrast * hue))
* Alternatively,
* procamp = saturation * (brightness * (contrast * hue))
*
* contrast
* [ c, 0, 0, 0]
* [ 0, c, 0, 0]
* [ 0, 0, c, 0]
* [ 0, 0, 0, 1]
*
* brightness
* [ 1, 0, 0, b/c]
* [ 0, 1, 0, 0]
* [ 0, 0, 1, 0]
* [ 0, 0, 0, 1]
*
* saturation
* [ 1, 0, 0, 0]
* [ 0, s, 0, 0]
* [ 0, 0, s, 0]
* [ 0, 0, 0, 1]
*
* hue
* [ 1, 0, 0, 0]
* [ 0, cos(h), sin(h), 0]
* [ 0, -sin(h), cos(h), 0]
* [ 0, 0, 0, 1]
*
* procamp
* [ c, 0, 0, b]
* [ 0, c*s*cos(h), c*s*sin(h), 0]
* [ 0, -c*s*sin(h), c*s*cos(h), 0]
* [ 0, 0, 0, 1]
*
* bias
* [ 1, 0, 0, ybias]
* [ 0, 1, 0, cbbias]
* [ 0, 0, 1, crbias]
* [ 0, 0, 0, 1]
*
* csc
* [ c*cstd[ 0], c*cstd[ 1]*s*cos(h) - c*cstd[ 2]*s*sin(h), c*cstd[ 2]*s*cos(h) + c*cstd[ 1]*s*sin(h), cstd[ 3] + cstd[ 0]*(b + c*ybias) + cstd[ 1]*(c*cbbias*s*cos(h) + c*crbias*s*sin(h)) + cstd[ 2]*(c*crbias*s*cos(h) - c*cbbias*s*sin(h))]
* [ c*cstd[ 4], c*cstd[ 5]*s*cos(h) - c*cstd[ 6]*s*sin(h), c*cstd[ 6]*s*cos(h) + c*cstd[ 5]*s*sin(h), cstd[ 7] + cstd[ 4]*(b + c*ybias) + cstd[ 5]*(c*cbbias*s*cos(h) + c*crbias*s*sin(h)) + cstd[ 6]*(c*crbias*s*cos(h) - c*cbbias*s*sin(h))]
* [ c*cstd[ 8], c*cstd[ 9]*s*cos(h) - c*cstd[10]*s*sin(h), c*cstd[10]*s*cos(h) + c*cstd[ 9]*s*sin(h), cstd[11] + cstd[ 8]*(b + c*ybias) + cstd[ 9]*(c*cbbias*s*cos(h) + c*crbias*s*sin(h)) + cstd[10]*(c*crbias*s*cos(h) - c*cbbias*s*sin(h))]
* [ c*cstd[12], c*cstd[13]*s*cos(h) - c*cstd[14]*s*sin(h), c*cstd[14]*s*cos(h) + c*cstd[13]*s*sin(h), cstd[15] + cstd[12]*(b + c*ybias) + cstd[13]*(c*cbbias*s*cos(h) + c*crbias*s*sin(h)) + cstd[14]*(c*crbias*s*cos(h) - c*cbbias*s*sin(h))]
*/
/*
* Converts ITU-R BT.601 YCbCr pixels to RGB pixels where:
* Y is in [16,235], Cb and Cr are in [16,240]
* R, G, and B are in [16,235]
*/
static const vl_csc_matrix bt_601 =
{
{ 1.0f, 0.0f, 1.371f, 0.0f, },
{ 1.0f, -0.336f, -0.698f, 0.0f, },
{ 1.0f, 1.732f, 0.0f, 0.0f, }
};
/*
* Converts ITU-R BT.709 YCbCr pixels to RGB pixels where:
* Y is in [16,235], Cb and Cr are in [16,240]
* R, G, and B are in [16,235]
*/
static const vl_csc_matrix bt_709 =
{
{ 1.0f, 0.0f, 1.540f, 0.0f, },
{ 1.0f, -0.183f, -0.459f, 0.0f, },
{ 1.0f, 1.816f, 0.0f, 0.0f, }
};
/*
* Converts ITU-R BT.709 YCbCr pixels to RGB pixels where:
* Y, Cb, and Cr are in [0,255]
* R, G, and B are in [16,235]
*/
static const vl_csc_matrix bt_709_full =
{
{ 0.859f, 0.0f, 1.352f, 0.0625f, },
{ 0.859f, -0.161f, -0.402f, 0.0625f, },
{ 0.859f, 1.594f, 0.0f, 0.0625f, }
};
/*
* Converts SMPTE 240M YCbCr pixels to RGB pixels where:
* Y is in [16,235], Cb and Cr are in [16,240]
* R, G, and B are in [16,235]
*/
static const vl_csc_matrix smpte240m =
{
{ 1.0f, 0.0f, 1.541f, 0.0f, },
{ 1.0f, -0.221f, -0.466f, 0.0f, },
{ 1.0f, 1.785f, 0.0f, 0.0f, }
};
static const vl_csc_matrix bt_709_rev = {
{ 0.183f, 0.614f, 0.062f, 0.0625f},
{-0.101f, -0.338f, 0.439f, 0.5f },
{ 0.439f, -0.399f, -0.040f, 0.5f }
};
static const vl_csc_matrix bt_709_rev_full = {
{ 0.213f, 0.715f, 0.072f, 0.0f },
{-0.115f, -0.385f, 0.5f, 0.5f },
{ 0.5f, -0.454f, -0.046f, 0.5f }
};
static const vl_csc_matrix identity =
{
{ 1.0f, 0.0f, 0.0f, 0.0f, },
@ -162,87 +37,6 @@ static const vl_csc_matrix identity =
{ 0.0f, 0.0f, 1.0f, 0.0f, }
};
const struct vl_procamp vl_default_procamp = {
0.0f, /* brightness */
1.0f, /* contrast */
1.0f, /* saturation */
0.0f /* hue */
};
void vl_csc_get_matrix(enum VL_CSC_COLOR_STANDARD cs,
struct vl_procamp *procamp,
bool full_range,
vl_csc_matrix *matrix)
{
float cbbias = -128.0f/255.0f;
float crbias = -128.0f/255.0f;
const struct vl_procamp *p = procamp ? procamp : &vl_default_procamp;
float c = p->contrast;
float s = p->saturation;
float b = p->brightness;
float h = p->hue;
float x, y;
const vl_csc_matrix *cstd;
if (full_range) {
c *= 1.164f; /* Adjust for the y range */
b *= 1.164f; /* Adjust for the y range */
b -= c * 16.0f / 255.0f; /* Adjust for the y bias */
}
/* Parameter substitutions */
x = c * s * cosf(h);
y = c * s * sinf(h);
assert(matrix);
switch (cs) {
case VL_CSC_COLOR_STANDARD_BT_601:
cstd = &bt_601;
break;
case VL_CSC_COLOR_STANDARD_BT_709:
cstd = &bt_709;
break;
case VL_CSC_COLOR_STANDARD_BT_709_FULL:
cstd = &bt_709_full;
break;
case VL_CSC_COLOR_STANDARD_SMPTE_240M:
cstd = &smpte240m;
break;
case VL_CSC_COLOR_STANDARD_BT_709_REV:
memcpy(matrix, full_range ? bt_709_rev_full : bt_709_rev, sizeof(vl_csc_matrix));
return;
case VL_CSC_COLOR_STANDARD_IDENTITY:
default:
assert(cs == VL_CSC_COLOR_STANDARD_IDENTITY);
memcpy(matrix, identity, sizeof(vl_csc_matrix));
return;
}
(*matrix)[0][0] = c * (*cstd)[0][0];
(*matrix)[0][1] = (*cstd)[0][1] * x - (*cstd)[0][2] * y;
(*matrix)[0][2] = (*cstd)[0][2] * x + (*cstd)[0][1] * y;
(*matrix)[0][3] = (*cstd)[0][3] + (*cstd)[0][0] * b +
(*cstd)[0][1] * (x * cbbias + y * crbias) +
(*cstd)[0][2] * (x * crbias - y * cbbias);
(*matrix)[1][0] = c * (*cstd)[1][0];
(*matrix)[1][1] = (*cstd)[1][1] * x - (*cstd)[1][2] * y;
(*matrix)[1][2] = (*cstd)[1][2] * x + (*cstd)[1][1] * y;
(*matrix)[1][3] = (*cstd)[1][3] + (*cstd)[1][0] * b +
(*cstd)[1][1] * (x * cbbias + y * crbias) +
(*cstd)[1][2] * (x * crbias - y * cbbias);
(*matrix)[2][0] = c * (*cstd)[2][0];
(*matrix)[2][1] = (*cstd)[2][1] * x - (*cstd)[2][2] * y;
(*matrix)[2][2] = (*cstd)[2][2] * x + (*cstd)[2][1] * y;
(*matrix)[2][3] = (*cstd)[2][3] + (*cstd)[2][0] * b +
(*cstd)[2][1] * (x * cbbias + y * crbias) +
(*cstd)[2][2] * (x * crbias - y * cbbias);
}
static unsigned format_bpc(enum pipe_format format)
{
const enum pipe_format plane_format = util_format_get_plane_format(format, 0);

View file

@ -28,37 +28,11 @@
#ifndef vl_csc_h
#define vl_csc_h
#include "util/compiler.h"
#include "util/format/u_format.h"
#include "pipe/p_video_enums.h"
typedef float vl_csc_matrix[3][4];
struct vl_procamp
{
float brightness;
float contrast;
float saturation;
float hue;
};
enum VL_CSC_COLOR_STANDARD
{
VL_CSC_COLOR_STANDARD_IDENTITY,
VL_CSC_COLOR_STANDARD_BT_601,
VL_CSC_COLOR_STANDARD_BT_709,
VL_CSC_COLOR_STANDARD_BT_709_FULL,
VL_CSC_COLOR_STANDARD_SMPTE_240M,
VL_CSC_COLOR_STANDARD_BT_709_REV
};
extern const struct vl_procamp vl_default_procamp;
void vl_csc_get_matrix(enum VL_CSC_COLOR_STANDARD cs,
struct vl_procamp *procamp,
bool full_range,
vl_csc_matrix *matrix);
void vl_csc_get_rgbyuv_matrix(enum pipe_video_vpp_matrix_coefficients coefficients,
enum pipe_format in_format, enum pipe_format out_format,
enum pipe_video_vpp_color_range in_color_range,