Use mp_pixel_format_width_to_bytes to get row length (MR 13)

This commit is contained in:
Yassine Oudjana
2022-02-24 09:12:39 +04:00
committed by Martijn Braam
parent 5f65d910f5
commit f107a2ff3f
2 changed files with 11 additions and 9 deletions

View File

@@ -158,7 +158,8 @@ gles2_debayer_configure(GLES2Debayer *self,
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, src_width + src_width / 4); glUniform1f(self->uniform_row_length,
mp_pixel_format_width_to_bytes(self->format, src_width));
check_gl(); check_gl();
} }
} }

View File

@@ -177,21 +177,23 @@ mp_process_pipeline_buffer_get_texture_id(MPProcessPipelineBuffer *buf)
} }
static void static void
repack_image_sequencial(const uint8_t *src_buf, repack_image_sequencial(const uint8_t *src_buf, uint8_t *dst_buf, MPMode *mode)
uint8_t *dst_buf,
size_t width,
size_t height)
{ {
uint16_t pixels[4]; uint16_t pixels[4];
// Image data must be 10-bit packed
assert(mp_pixel_format_bits_per_pixel(mode->pixel_format) == 10);
/* /*
* Repack 40 bits stored in sensor format into sequencial format * Repack 40 bits stored in sensor format into sequencial format
* *
* src_buf: 11111111 22222222 33333333 44444444 11223344 ... * src_buf: 11111111 22222222 33333333 44444444 11223344 ...
* dst_buf: 11111111 11222222 22223333 33333344 44444444 ... * dst_buf: 11111111 11222222 22223333 33333344 44444444 ...
*/ */
assert(width % 4 == 0); for (size_t i = 0;
for (size_t i = 0; i < (width + width / 4) * height; i += 5) { i < mp_pixel_format_width_to_bytes(mode->pixel_format, mode->width) *
mode->height;
i += 5) {
/* Extract pixels from packed sensor format */ /* Extract pixels from packed sensor format */
pixels[0] = (src_buf[i] << 2) | (src_buf[i + 4] >> 6); pixels[0] = (src_buf[i] << 2) | (src_buf[i + 4] >> 6);
pixels[1] = (src_buf[i + 1] << 2) | (src_buf[i + 4] >> 4 & 0x03); pixels[1] = (src_buf[i + 1] << 2) | (src_buf[i + 4] >> 4 & 0x03);
@@ -521,8 +523,7 @@ process_image_for_capture(const uint8_t *image, int count)
mode.pixel_format, mode.width) * mode.pixel_format, mode.width) *
mode.height); mode.height);
repack_image_sequencial( repack_image_sequencial(image, output_image, &mode);
image, output_image, mode.width, mode.height);
} }
for (int row = 0; row < mode.height; row++) { for (int row = 0; row < mode.height; row++) {