1/* GStreamer 2 * Copyright (C) 2020 Matthew Waters <matthew@centricular.com> 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Library General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Library General Public License for more details. 13 * 14 * You should have received a copy of the GNU Library General Public 15 * License along with this library; if not, write to the 16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 * Boston, MA 02111-1307, USA. 18 */ 19 20struct ColorMatrices 21{ 22 mat4 to_RGB_matrix; 23 mat4 primaries_matrix; 24 mat4 to_YUV_matrix; 25}; 26 27vec3 color_matrix_convert (in vec3 texel, in mat4 color_matrix) 28{ 29 vec4 rgb_ = color_matrix * vec4(texel, 1.0); 30 return rgb_.rgb; 31} 32 33vec3 color_convert_texel (in vec3 texel, in ColorMatrices m) 34{ 35 /* FIXME: need to add gamma remapping between these stages */ 36 vec3 tmp = color_matrix_convert (texel, m.to_RGB_matrix); 37 tmp = color_matrix_convert (tmp, m.primaries_matrix); 38 return color_matrix_convert (tmp, m.to_YUV_matrix); 39} 40