|
@@ -3,6 +3,7 @@
|
|
#include "camera.h"
|
|
#include "camera.h"
|
|
#include "dcp.h"
|
|
#include "dcp.h"
|
|
#include "gl_util.h"
|
|
#include "gl_util.h"
|
|
|
|
+#include "matrix.h"
|
|
#include <stdlib.h>
|
|
#include <stdlib.h>
|
|
|
|
|
|
#define VERTEX_ATTRIBUTE 0
|
|
#define VERTEX_ATTRIBUTE 0
|
|
@@ -121,6 +122,7 @@ gles2_debayer_configure(GLES2Debayer *self,
|
|
glViewport(0, 0, (int)dst_width, (int)dst_height);
|
|
glViewport(0, 0, (int)dst_width, (int)dst_height);
|
|
check_gl();
|
|
check_gl();
|
|
|
|
|
|
|
|
+ /* Rotation matrix for orientation correction */
|
|
GLfloat rotation_list[4] = { 0, -1, 0, 1 };
|
|
GLfloat rotation_list[4] = { 0, -1, 0, 1 };
|
|
int rotation_index = 4 - (int)rotation / 90;
|
|
int rotation_index = 4 - (int)rotation / 90;
|
|
|
|
|
|
@@ -142,8 +144,9 @@ gles2_debayer_configure(GLES2Debayer *self,
|
|
glUniform2f(self->uniform_pixel_size, pixel_size_x, pixel_size_y);
|
|
glUniform2f(self->uniform_pixel_size, pixel_size_x, pixel_size_y);
|
|
check_gl();
|
|
check_gl();
|
|
|
|
|
|
|
|
+ /* Color calibration curves and matrices */
|
|
float gamma = 1.0f;
|
|
float gamma = 1.0f;
|
|
- for (int i = 0; i < calibration.tone_curve_length * 2; i += 2) {
|
|
|
|
|
|
+ for (int i = 2; i < calibration.tone_curve_length; i += 2) {
|
|
float g = calibration.tone_curve[i + 1] / calibration.tone_curve[i];
|
|
float g = calibration.tone_curve[i + 1] / calibration.tone_curve[i];
|
|
if (g > gamma) {
|
|
if (g > gamma) {
|
|
gamma = g;
|
|
gamma = g;
|
|
@@ -153,11 +156,11 @@ gles2_debayer_configure(GLES2Debayer *self,
|
|
|
|
|
|
if (calibration.color_matrix_1[0]) {
|
|
if (calibration.color_matrix_1[0]) {
|
|
GLfloat transposed[9];
|
|
GLfloat transposed[9];
|
|
- for (int i = 0; i < 3; ++i)
|
|
|
|
- for (int j = 0; j < 3; ++j)
|
|
|
|
- transposed[i + j * 3] =
|
|
|
|
- calibration.color_matrix_1[j + i * 3];
|
|
|
|
-
|
|
|
|
|
|
+ float colormat_inv[9];
|
|
|
|
+ float colormat[9];
|
|
|
|
+ invert_matrix(calibration.color_matrix_1, colormat_inv);
|
|
|
|
+ multiply_matrices(xyz_to_srgb, colormat_inv, colormat);
|
|
|
|
+ transpose_matrix(colormat, transposed);
|
|
glUniformMatrix3fv(
|
|
glUniformMatrix3fv(
|
|
self->uniform_color_matrix, 1, GL_FALSE, transposed);
|
|
self->uniform_color_matrix, 1, GL_FALSE, transposed);
|
|
} else {
|
|
} else {
|