aboutsummaryrefslogtreecommitdiff
path: root/src/capture/kms.c
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2024-06-10 12:44:40 +0200
committerdec05eba <dec05eba@protonmail.com>2024-06-10 12:44:40 +0200
commitc17a717326d2cc1c0576e6dc9f2116e72e38b45a (patch)
treea132cd06c54a054ea7c0639427a28b4d1cf8f8f8 /src/capture/kms.c
parent3f0a58a1e61de8094d9ebf9db320c01b59ab441f (diff)
Workaround amd driver bug: hevc ffmpeg/mesa misaligned resolution causing glitched video output on right/bottom side
Diffstat (limited to 'src/capture/kms.c')
-rw-r--r--src/capture/kms.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/capture/kms.c b/src/capture/kms.c
index fed9e58..c2309d5 100644
--- a/src/capture/kms.c
+++ b/src/capture/kms.c
@@ -35,10 +35,6 @@ static void monitor_callback(const gsr_monitor *monitor, void *userdata) {
fprintf(stderr, "gsr warning: reached max connector ids\n");
}
-static int max_int(int a, int b) {
- return a > b ? a : b;
-}
-
int gsr_capture_kms_start(gsr_capture_kms *self, const char *display_to_capture, gsr_egl *egl, AVCodecContext *video_codec_context, AVFrame *frame) {
memset(self, 0, sizeof(*self));
self->base.video_codec_context = video_codec_context;
@@ -77,8 +73,14 @@ int gsr_capture_kms_start(gsr_capture_kms *self, const char *display_to_capture,
/* Disable vsync */
egl->eglSwapInterval(egl->egl_display, 0);
- self->base.video_codec_context->width = max_int(2, even_number_ceil(self->capture_size.x));
- self->base.video_codec_context->height = max_int(2, even_number_ceil(self->capture_size.y));
+ if(egl->gpu_info.vendor == GSR_GPU_VENDOR_AMD && video_codec_context->codec_id == AV_CODEC_ID_HEVC) {
+ // TODO: dont do this if using ffmpeg reports that this is not needed (AMD driver bug that was fixed recently)
+ self->base.video_codec_context->width = FFALIGN(self->capture_size.x, 64);
+ self->base.video_codec_context->height = FFALIGN(self->capture_size.y, 16);
+ } else {
+ self->base.video_codec_context->width = FFALIGN(self->capture_size.x, 2);
+ self->base.video_codec_context->height = FFALIGN(self->capture_size.y, 2);
+ }
frame->width = self->base.video_codec_context->width;
frame->height = self->base.video_codec_context->height;