Crop out padding on preview processing (MR 13)
This commit is contained in:

committed by
Martijn Braam

parent
f107a2ff3f
commit
81859e54e7
@@ -6,6 +6,7 @@ uniform sampler2D texture;
|
|||||||
uniform mat3 color_matrix;
|
uniform mat3 color_matrix;
|
||||||
#ifdef BITS_10
|
#ifdef BITS_10
|
||||||
uniform float row_length;
|
uniform float row_length;
|
||||||
|
uniform float padding_ratio;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
varying vec2 top_left_uv;
|
varying vec2 top_left_uv;
|
||||||
@@ -22,6 +23,9 @@ skip_5th_pixel(vec2 uv)
|
|||||||
new_uv.x *= 0.8;
|
new_uv.x *= 0.8;
|
||||||
new_uv.x += floor(uv.x * row_length / 5.0) / row_length;
|
new_uv.x += floor(uv.x * row_length / 5.0) / row_length;
|
||||||
|
|
||||||
|
// Crop out padding
|
||||||
|
new_uv.x *= padding_ratio;
|
||||||
|
|
||||||
return new_uv;
|
return new_uv;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -14,6 +14,7 @@ struct _GLES2Debayer {
|
|||||||
GLuint program;
|
GLuint program;
|
||||||
GLuint uniform_transform;
|
GLuint uniform_transform;
|
||||||
GLuint uniform_pixel_size;
|
GLuint uniform_pixel_size;
|
||||||
|
GLuint uniform_padding_ratio;
|
||||||
GLuint uniform_texture;
|
GLuint uniform_texture;
|
||||||
GLuint uniform_color_matrix;
|
GLuint uniform_color_matrix;
|
||||||
GLuint uniform_row_length;
|
GLuint uniform_row_length;
|
||||||
@@ -68,6 +69,8 @@ gles2_debayer_new(MPPixelFormat format)
|
|||||||
|
|
||||||
self->uniform_transform = glGetUniformLocation(self->program, "transform");
|
self->uniform_transform = glGetUniformLocation(self->program, "transform");
|
||||||
self->uniform_pixel_size = glGetUniformLocation(self->program, "pixel_size");
|
self->uniform_pixel_size = glGetUniformLocation(self->program, "pixel_size");
|
||||||
|
self->uniform_padding_ratio =
|
||||||
|
glGetUniformLocation(self->program, "padding_ratio");
|
||||||
self->uniform_texture = glGetUniformLocation(self->program, "texture");
|
self->uniform_texture = glGetUniformLocation(self->program, "texture");
|
||||||
self->uniform_color_matrix =
|
self->uniform_color_matrix =
|
||||||
glGetUniformLocation(self->program, "color_matrix");
|
glGetUniformLocation(self->program, "color_matrix");
|
||||||
@@ -156,12 +159,17 @@ gles2_debayer_configure(GLES2Debayer *self,
|
|||||||
}
|
}
|
||||||
check_gl();
|
check_gl();
|
||||||
|
|
||||||
|
GLuint row_length = mp_pixel_format_width_to_bytes(self->format, src_width);
|
||||||
if (mp_pixel_format_bits_per_pixel(self->format) == 10) {
|
if (mp_pixel_format_bits_per_pixel(self->format) == 10) {
|
||||||
assert(src_width % 4 == 0);
|
assert(src_width % 4 == 0);
|
||||||
glUniform1f(self->uniform_row_length,
|
glUniform1f(self->uniform_row_length, row_length);
|
||||||
mp_pixel_format_width_to_bytes(self->format, src_width));
|
|
||||||
check_gl();
|
check_gl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLuint padding_bytes =
|
||||||
|
mp_pixel_format_width_to_padding(self->format, src_width);
|
||||||
|
GLfloat padding_ratio = (float)row_length / (row_length + padding_bytes);
|
||||||
|
glUniform1f(self->uniform_padding_ratio, padding_ratio);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@@ -327,7 +327,9 @@ process_image_for_preview(const uint8_t *image)
|
|||||||
glTexImage2D(GL_TEXTURE_2D,
|
glTexImage2D(GL_TEXTURE_2D,
|
||||||
0,
|
0,
|
||||||
GL_LUMINANCE,
|
GL_LUMINANCE,
|
||||||
mp_pixel_format_width_to_bytes(mode.pixel_format, mode.width),
|
mp_pixel_format_width_to_bytes(mode.pixel_format, mode.width) +
|
||||||
|
mp_pixel_format_width_to_padding(mode.pixel_format,
|
||||||
|
mode.width),
|
||||||
mode.height,
|
mode.height,
|
||||||
0,
|
0,
|
||||||
GL_LUMINANCE,
|
GL_LUMINANCE,
|
||||||
@@ -681,8 +683,10 @@ process_image(MPPipeline *pipeline, const MPBuffer *buffer)
|
|||||||
clock_t t1 = clock();
|
clock_t t1 = clock();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
size_t size = mp_pixel_format_width_to_bytes(mode.pixel_format, mode.width) *
|
size_t size =
|
||||||
mode.height;
|
(mp_pixel_format_width_to_bytes(mode.pixel_format, mode.width) +
|
||||||
|
mp_pixel_format_width_to_padding(mode.pixel_format, mode.width)) *
|
||||||
|
mode.height;
|
||||||
uint8_t *image = malloc(size);
|
uint8_t *image = malloc(size);
|
||||||
memcpy(image, buffer->data, size);
|
memcpy(image, buffer->data, size);
|
||||||
mp_io_pipeline_release_buffer(buffer->index);
|
mp_io_pipeline_release_buffer(buffer->index);
|
||||||
|
Reference in New Issue
Block a user