aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/capture/capture.h1
-rw-r--r--include/capture/kms.h1
-rw-r--r--src/capture/kms.c8
-rw-r--r--src/capture/xcomposite.c25
-rw-r--r--src/utils.c4
5 files changed, 21 insertions, 18 deletions
diff --git a/include/capture/capture.h b/include/capture/capture.h
index 2eb8e42..c8b0cdf 100644
--- a/include/capture/capture.h
+++ b/include/capture/capture.h
@@ -42,6 +42,7 @@ struct gsr_capture_base {
gsr_color_conversion color_conversion;
AVCodecContext *video_codec_context;
+ vec2i video_alignment_padding;
};
typedef struct {
diff --git a/include/capture/kms.h b/include/capture/kms.h
index 674813a..b6965fd 100644
--- a/include/capture/kms.h
+++ b/include/capture/kms.h
@@ -39,6 +39,7 @@ struct gsr_capture_kms {
AVContentLightMetadata *light_metadata;
gsr_monitor_rotation monitor_rotation;
+ vec2i video_alignment_padding;
};
/* Returns 0 on success */
diff --git a/src/capture/kms.c b/src/capture/kms.c
index 40db34b..be7e58d 100644
--- a/src/capture/kms.c
+++ b/src/capture/kms.c
@@ -82,6 +82,9 @@ int gsr_capture_kms_start(gsr_capture_kms *self, const char *display_to_capture,
self->base.video_codec_context->height = FFALIGN(self->capture_size.y, 2);
}
+ self->base.video_alignment_padding.x = self->base.video_codec_context->width - self->capture_size.x;
+ self->base.video_alignment_padding.y = self->base.video_codec_context->height - self->capture_size.y;
+
frame->width = self->base.video_codec_context->width;
frame->height = self->base.video_codec_context->height;
return 0;
@@ -298,7 +301,7 @@ bool gsr_capture_kms_capture(gsr_capture_kms *self, AVFrame *frame, bool hdr, bo
const float texture_rotation = monitor_rotation_to_radians(self->monitor_rotation);
gsr_color_conversion_draw(&self->base.color_conversion, self->base.input_texture,
- (vec2i){0, 0}, self->capture_size,
+ (vec2i){self->base.video_alignment_padding.x / 2, self->base.video_alignment_padding.y / 2}, self->capture_size,
capture_pos, self->capture_size,
texture_rotation, false);
@@ -329,6 +332,9 @@ bool gsr_capture_kms_capture(gsr_capture_kms *self, AVFrame *frame, bool hdr, bo
break;
}
+ cursor_pos.x += (self->base.video_alignment_padding.x / 2);
+ cursor_pos.y += (self->base.video_alignment_padding.y / 2);
+
const intptr_t img_attr_cursor[] = {
EGL_LINUX_DRM_FOURCC_EXT, cursor_drm_fd->pixel_format,
EGL_WIDTH, cursor_drm_fd->width,
diff --git a/src/capture/xcomposite.c b/src/capture/xcomposite.c
index bb2b0e3..b8f8962 100644
--- a/src/capture/xcomposite.c
+++ b/src/capture/xcomposite.c
@@ -98,25 +98,22 @@ int gsr_capture_xcomposite_start(gsr_capture_xcomposite *self, AVCodecContext *v
self->params.egl->glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &self->texture_size.y);
self->params.egl->glBindTexture(GL_TEXTURE_2D, 0);
+ vec2i video_size = self->texture_size;
+
+ if(self->params.region_size.x > 0 && self->params.region_size.y > 0)
+ video_size = self->params.region_size;
+
if(self->params.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)
- video_codec_context->width = FFALIGN(self->texture_size.x, 64);
- video_codec_context->height = FFALIGN(self->texture_size.y, 16);
+ video_codec_context->width = FFALIGN(video_size.x, 64);
+ video_codec_context->height = FFALIGN(video_size.y, 16);
} else {
- video_codec_context->width = FFALIGN(self->texture_size.x, 2);
- video_codec_context->height = FFALIGN(self->texture_size.y, 2);
+ video_codec_context->width = FFALIGN(video_size.x, 2);
+ video_codec_context->height = FFALIGN(video_size.y, 2);
}
- if(self->params.region_size.x > 0 && self->params.region_size.y > 0) {
- if(self->params.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)
- video_codec_context->width = FFALIGN(self->params.region_size.x, 64);
- video_codec_context->height = FFALIGN(self->params.region_size.y, 16);
- } else {
- video_codec_context->width = FFALIGN(self->params.region_size.x, 2);
- video_codec_context->height = FFALIGN(self->params.region_size.y, 2);
- }
- }
+ self->base.video_alignment_padding.x = self->base.video_codec_context->width - video_size.x;
+ self->base.video_alignment_padding.y = self->base.video_codec_context->height - video_size.y;
frame->width = video_codec_context->width;
frame->height = video_codec_context->height;
diff --git a/src/utils.c b/src/utils.c
index 92abbb0..e00f3c5 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -329,10 +329,8 @@ gsr_monitor_rotation drm_monitor_get_display_server_rotation(const gsr_egl *egl,
userdata.rotation = GSR_MONITOR_ROT_0;
userdata.match_found = false;
for_each_active_monitor_output_wayland(egl, get_monitor_by_name_and_size_callback, &userdata);
- if(userdata.match_found) {
- fprintf(stderr, "found!\n");
+ if(userdata.match_found)
return userdata.rotation;
- }
}
{
get_monitor_by_connector_id_userdata userdata;