From 80f0e483a44527753ca5bba9ce035f933a2486a6 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 16 Nov 2025 18:58:57 +0100 Subject: [PATCH] screenshot: improve jpeg very high quality to 91 (enables yuv444 instead of yuv420) --- TODO | 2 -- include/image_writer.h | 9 --------- src/image_writer.c | 19 +------------------ src/main.cpp | 2 +- 4 files changed, 2 insertions(+), 30 deletions(-) diff --git a/TODO b/TODO index 34954c9..6bd0da3 100644 --- a/TODO +++ b/TODO @@ -81,8 +81,6 @@ When vulkan encode is added, mention minimum nvidia driver required. (550.54.14? Investigate if there is a way to do gpu->gpu copy directly without touching system ram to enable video encoding on a different gpu. On nvidia this is possible with cudaMemcpyPeer, but how about from an intel/amd gpu to an nvidia gpu or the other way around or any combination of iGPU and dedicated GPU? Maybe something with clEnqueueMigrateMemObjects? on AMD something with DirectGMA maybe? -Go back to using pure vaapi without opengl for video encoding? rotation (transpose) can be done if its done after (rgb to yuv) color conversion. - Use lanczos resampling for better scaling quality. Lanczos resampling can also be used for YUV chroma for better color quality on small text. Flac is disabled because the frame sizes are too large which causes big audio/video desync. diff --git a/include/image_writer.h b/include/image_writer.h index 65e7497..01101b2 100644 --- a/include/image_writer.h +++ b/include/image_writer.h @@ -10,23 +10,14 @@ typedef enum { GSR_IMAGE_FORMAT_PNG } gsr_image_format; -typedef enum { - GSR_IMAGE_WRITER_SOURCE_OPENGL, - GSR_IMAGE_WRITER_SOURCE_MEMORY -} gsr_image_writer_source; - typedef struct { - gsr_image_writer_source source; gsr_egl *egl; int width; int height; unsigned int texture; - const void *memory; /* Reference */ } gsr_image_writer; bool gsr_image_writer_init_opengl(gsr_image_writer *self, gsr_egl *egl, int width, int height); -/* |memory| is taken as a reference. The data is expected to be in rgba8 format (8 bit rgba) */ -bool gsr_image_writer_init_memory(gsr_image_writer *self, const void *memory, int width, int height); void gsr_image_writer_deinit(gsr_image_writer *self); /* Quality is between 1 and 100 where 100 is the max quality. Quality doesn't apply to lossless formats */ diff --git a/src/image_writer.c b/src/image_writer.c index 3d731a0..afa9744 100644 --- a/src/image_writer.c +++ b/src/image_writer.c @@ -13,7 +13,6 @@ /* TODO: Support hdr/10-bit */ bool gsr_image_writer_init_opengl(gsr_image_writer *self, gsr_egl *egl, int width, int height) { memset(self, 0, sizeof(*self)); - self->source = GSR_IMAGE_WRITER_SOURCE_OPENGL; self->egl = egl; self->width = width; self->height = height; @@ -25,15 +24,6 @@ bool gsr_image_writer_init_opengl(gsr_image_writer *self, gsr_egl *egl, int widt return true; } -bool gsr_image_writer_init_memory(gsr_image_writer *self, const void *memory, int width, int height) { - memset(self, 0, sizeof(*self)); - self->source = GSR_IMAGE_WRITER_SOURCE_OPENGL; - self->width = width; - self->height = height; - self->memory = memory; - return true; -} - void gsr_image_writer_deinit(gsr_image_writer *self) { if(self->texture) { self->egl->glDeleteTextures(1, &self->texture); @@ -64,7 +54,6 @@ static bool gsr_image_writer_write_memory_to_file(gsr_image_writer *self, const } static bool gsr_image_writer_write_opengl_texture_to_file(gsr_image_writer *self, const char *filepath, gsr_image_format image_format, int quality) { - assert(self->source == GSR_IMAGE_WRITER_SOURCE_OPENGL); uint8_t *frame_data = malloc(self->width * self->height * 4); if(!frame_data) { fprintf(stderr, "gsr error: gsr_image_writer_write_to_file: failed to allocate memory for image frame\n"); @@ -90,11 +79,5 @@ static bool gsr_image_writer_write_opengl_texture_to_file(gsr_image_writer *self } bool gsr_image_writer_write_to_file(gsr_image_writer *self, const char *filepath, gsr_image_format image_format, int quality) { - switch(self->source) { - case GSR_IMAGE_WRITER_SOURCE_OPENGL: - return gsr_image_writer_write_opengl_texture_to_file(self, filepath, image_format, quality); - case GSR_IMAGE_WRITER_SOURCE_MEMORY: - return gsr_image_writer_write_memory_to_file(self, filepath, image_format, quality, self->memory); - } - return false; + return gsr_image_writer_write_opengl_texture_to_file(self, filepath, image_format, quality); } diff --git a/src/main.cpp b/src/main.cpp index b7041ed..95bbfc2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2310,7 +2310,7 @@ static int video_quality_to_image_quality_value(gsr_video_quality video_quality) case GSR_VIDEO_QUALITY_HIGH: return 85; case GSR_VIDEO_QUALITY_VERY_HIGH: - return 90; + return 91; case GSR_VIDEO_QUALITY_ULTRA: return 97; }