Rewrite YUV processing pipeline.

Use a 4-channel texture instead for packed YUV data so
every pixel in the texture has all the 4:2:2 color data
available.
This commit is contained in:
Martijn Braam
2024-12-23 17:29:46 +01:00
parent 1b5a871641
commit 8fbea82b2b
5 changed files with 55 additions and 37 deletions

View File

@@ -406,7 +406,7 @@ static void
auto_focus_step(const struct focus_stats *stats)
{
static uint64_t best_sharp, best_focus;
static const int debug = 1;
static const int debug = 0;
if (focus_phase >= PH_DONE) {
if (debug>1) printf("Phase %d, sharp %d best %d ", focus_phase, (int)(stats->sharp / 10000), (int)(best_sharp/ 10000));
@@ -616,7 +616,7 @@ process_aaa()
update_control(&state_proc.gain);
update_control(&state_proc.dgain);
update_control(&state_proc.exposure);
summarize();
//summarize();
}
if (auto_balance) {
@@ -682,19 +682,37 @@ process_image_for_preview(const uint8_t *image)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(
GL_TEXTURE_2D,
0,
GL_LUMINANCE,
libmegapixels_mode_width_to_bytes(state_proc.mode->format,
state_proc.mode->width) +
libmegapixels_mode_width_to_padding(state_proc.mode->format,
state_proc.mode->width),
state_proc.mode->height,
0,
GL_LUMINANCE,
GL_UNSIGNED_BYTE,
image);
switch(gles2_debayer->texture_mode) {
case TEXTURE_BAYER:
glTexImage2D(
GL_TEXTURE_2D,
0,
GL_LUMINANCE,
libmegapixels_mode_width_to_bytes(state_proc.mode->format,
state_proc.mode->width) +
libmegapixels_mode_width_to_padding(state_proc.mode->format,
state_proc.mode->width),
state_proc.mode->height,
0,
GL_LUMINANCE,
GL_UNSIGNED_BYTE,
image);
break;
case TEXTURE_YUV:
glTexImage2D(
GL_TEXTURE_2D,
0,
GL_RGBA8,
state_proc.mode->width/2 +
libmegapixels_mode_width_to_padding(state_proc.mode->format,
state_proc.mode->width),
state_proc.mode->height,
0,
GL_RGBA,
GL_UNSIGNED_BYTE,
image);
break;
}
check_gl();
gles2_debayer_process(