|
@@ -9,22 +9,6 @@
|
|
#define VERTEX_ATTRIBUTE 0
|
|
#define VERTEX_ATTRIBUTE 0
|
|
#define TEX_COORD_ATTRIBUTE 1
|
|
#define TEX_COORD_ATTRIBUTE 1
|
|
|
|
|
|
-struct _GLES2Debayer {
|
|
|
|
- int format;
|
|
|
|
-
|
|
|
|
- GLuint frame_buffer;
|
|
|
|
- GLuint program;
|
|
|
|
- GLuint uniform_transform;
|
|
|
|
- GLuint uniform_pixel_size;
|
|
|
|
- GLuint uniform_padding_ratio;
|
|
|
|
- GLuint uniform_texture;
|
|
|
|
- GLuint uniform_color_matrix;
|
|
|
|
- GLuint uniform_row_length;
|
|
|
|
- GLuint uniform_inv_gamma;
|
|
|
|
-
|
|
|
|
- GLuint quad;
|
|
|
|
-};
|
|
|
|
-
|
|
|
|
GLES2Debayer *
|
|
GLES2Debayer *
|
|
gles2_debayer_new(int format)
|
|
gles2_debayer_new(int format)
|
|
{
|
|
{
|
|
@@ -79,6 +63,7 @@ gles2_debayer_new(int format)
|
|
self->uniform_color_matrix =
|
|
self->uniform_color_matrix =
|
|
glGetUniformLocation(self->program, "color_matrix");
|
|
glGetUniformLocation(self->program, "color_matrix");
|
|
self->uniform_inv_gamma = glGetUniformLocation(self->program, "inv_gamma");
|
|
self->uniform_inv_gamma = glGetUniformLocation(self->program, "inv_gamma");
|
|
|
|
+ self->uniform_blacklevel = glGetUniformLocation(self->program, "blacklevel");
|
|
if (libmegapixels_format_bits_per_pixel(self->format) == 10)
|
|
if (libmegapixels_format_bits_per_pixel(self->format) == 10)
|
|
self->uniform_row_length =
|
|
self->uniform_row_length =
|
|
glGetUniformLocation(self->program, "row_length");
|
|
glGetUniformLocation(self->program, "row_length");
|
|
@@ -109,6 +94,39 @@ gles2_debayer_use(GLES2Debayer *self)
|
|
gl_util_bind_quad(self->quad);
|
|
gl_util_bind_quad(self->quad);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void
|
|
|
|
+gles2_debayer_set_shading(GLES2Debayer *self,
|
|
|
|
+ float red,
|
|
|
|
+ float blue,
|
|
|
|
+ float blacklevel)
|
|
|
|
+{
|
|
|
|
+ if (self->forward_matrix[0]) {
|
|
|
|
+ float wb[9] = {
|
|
|
|
+ // clang-format off
|
|
|
|
+ red, 0, 0,
|
|
|
|
+ 0, 1, 0,
|
|
|
|
+ 0, 0, blue,
|
|
|
|
+ // clang-format on
|
|
|
|
+ };
|
|
|
|
+ float colormat[9];
|
|
|
|
+ float xyz[9];
|
|
|
|
+ float xyzd65[9];
|
|
|
|
+ multiply_matrices(wb, self->forward_matrix, xyz);
|
|
|
|
+ multiply_matrices(xyz, XYZD50_to_D65, xyzd65);
|
|
|
|
+ multiply_matrices(xyzd65, XYZD65_to_sRGB, colormat);
|
|
|
|
+ glUniformMatrix3fv(
|
|
|
|
+ self->uniform_color_matrix, 1, GL_FALSE, colormat);
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ glUniformMatrix3fv(
|
|
|
|
+ self->uniform_color_matrix, 1, GL_FALSE, IDENTITY);
|
|
|
|
+ }
|
|
|
|
+ check_gl();
|
|
|
|
+
|
|
|
|
+ glUniform1f(self->uniform_blacklevel, blacklevel);
|
|
|
|
+ check_gl();
|
|
|
|
+}
|
|
|
|
+
|
|
void
|
|
void
|
|
gles2_debayer_configure(GLES2Debayer *self,
|
|
gles2_debayer_configure(GLES2Debayer *self,
|
|
const uint32_t dst_width,
|
|
const uint32_t dst_width,
|
|
@@ -153,26 +171,13 @@ gles2_debayer_configure(GLES2Debayer *self,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
glUniform1f(self->uniform_inv_gamma, 1.0f / gamma);
|
|
glUniform1f(self->uniform_inv_gamma, 1.0f / gamma);
|
|
|
|
+ check_gl();
|
|
|
|
|
|
- if (calibration.forward_matrix_1[0]) {
|
|
|
|
- float colormat[9];
|
|
|
|
- float xyz[9];
|
|
|
|
- multiply_matrices(calibration.forward_matrix_1, XYZD50_to_D65, xyz);
|
|
|
|
- multiply_matrices(xyz, XYZD65_to_sRGB, colormat);
|
|
|
|
- glUniformMatrix3fv(
|
|
|
|
- self->uniform_color_matrix, 1, GL_FALSE, colormat);
|
|
|
|
- } else {
|
|
|
|
- static const GLfloat identity[9] = {
|
|
|
|
- // clang-format off
|
|
|
|
- 1, 0, 0,
|
|
|
|
- 0, 1, 0,
|
|
|
|
- 0, 0, 1,
|
|
|
|
- // clang-format on
|
|
|
|
- };
|
|
|
|
- glUniformMatrix3fv(
|
|
|
|
- self->uniform_color_matrix, 1, GL_FALSE, identity);
|
|
|
|
|
|
+ for (int i = 0; i < 9; i++) {
|
|
|
|
+ self->forward_matrix[i] = calibration.forward_matrix_1[i];
|
|
}
|
|
}
|
|
- check_gl();
|
|
|
|
|
|
+
|
|
|
|
+ gles2_debayer_set_shading(self, 1.0f, 1.0f, 0.0f);
|
|
|
|
|
|
GLuint row_length =
|
|
GLuint row_length =
|
|
libmegapixels_mode_width_to_bytes(self->format, src_width);
|
|
libmegapixels_mode_width_to_bytes(self->format, src_width);
|