src/fmtc/Matrix.cpp
void	Matrix::make_mat_ycgco (fmtcl::Mat4 &m, bool to_rgb_flag)
{
	if (to_rgb_flag)
	{
		m[0][0] = 1; m[0][1] = -1; m[0][2] =  1;
		m[1][0] = 1; m[1][1] =  1; m[1][2] =  0;
		m[2][0] = 1; m[2][1] = -1; m[2][2] = -1;
	}
	else
	{
		m[0][0] =  0.25; m[0][1] = 0.5; m[0][2] =  0.25;
		m[1][0] = -0.25; m[1][1] = 0.5; m[1][2] = -0.25;
		m[2][0] =  0.5 ; m[2][1] = 0  ; m[2][2] = -0.5 ;
	}

	m.clean3 (1);
}
/*
YCgCo matrix (Rec. ITU-T H.265 2019-06, p. 413):

R  = Y - Cg + Co
G  = Y + Cg
B  = Y - Cg - Co

Y  =  0.25 * R + 0.5  * G + 0.25 * B
Cg = -0.25 * R + 0.5  * G - 0.25 * B
Co =  0.5  * R            - 0.5  * B

R, G, B, Y range : [0 ; 1]
Cg, Co range : [-0.5 ; 0.5]

Note: this implementation is not exactly the same as specified because the
standard specifies specific steps to apply the RGB-to-YCgCo matrix, leading
to different roundings.
*/






this implementation is not exactly the same as specified because the
standard specifies specific steps to apply the RGB-to-YCgCo matrix, leading
to different roundings.
this implementation is not exactly the same as specified because the standard specifies specific steps to apply the RGB - to - YCgCo matrix leading to different roundings .
void	Matrix::make_mat_ycgco (fmtcl::Mat4 &m, bool to_rgb_flag)
{
	if (to_rgb_flag)
	{
		m[0][0] = 1; m[0][1] = -1; m[0][2] =  1;
		m[1][0] = 1; m[1][1] =  1; m[1][2] =  0;
		m[2][0] = 1; m[2][1] = -1; m[2][2] = -1;
	}
	else
	{
		m[0][0] =  0.25; m[0][1] = 0.5; m[0][2] =  0.25;
		m[1][0] = -0.25; m[1][1] = 0.5; m[1][2] = -0.25;
		m[2][0] =  0.5 ; m[2][1] = 0  ; m[2][2] = -0.5 ;
	}
	m.clean3 (1);
}
void Matrix :: make_mat_ycgco ( fmtcl :: Mat4 & m , bool to_rgb_flag ) { if ( to_rgb_flag ) { m [ 0 ] [ 0 ] = 1 ; m [ 0 ] [ 1 ] = -1 ; m [ 0 ] [ 2 ] = 1 ; m [ 1 ] [ 0 ] = 1 ; m [ 1 ] [ 1 ] = 1 ; m [ 1 ] [ 2 ] = 0 ; m [ 2 ] [ 0 ] = 1 ; m [ 2 ] [ 1 ] = -1 ; m [ 2 ] [ 2 ] = -1 ; } else { m [ 0 ] [ 0 ] = 0.25 ; m [ 0 ] [ 1 ] = 0.5 ; m [ 0 ] [ 2 ] = 0.25 ; m [ 1 ] [ 0 ] = -0.25 ; m [ 1 ] [ 1 ] = 0.5 ; m [ 1 ] [ 2 ] = -0.25 ; m [ 2 ] [ 0 ] = 0.5 ; m [ 2 ] [ 1 ] = 0 ; m [ 2 ] [ 2 ] = -0.5 ; } m . clean3 ( 1 ) ; }
YCgCo matrix (Rec.
YCgCo matrix ( Rec .