aboutsummaryrefslogtreecommitdiff
path: root/src/capture
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2024-03-07 22:53:04 +0100
committerdec05eba <dec05eba@protonmail.com>2024-03-08 11:35:30 +0100
commit3d9a7065280e64797c5a68c794a04d60fb3f767c (patch)
tree75ad01478ec31296bf24dfd56dd1881347a54f1e /src/capture
parent0d89378021b9e8913b521164d1bc436d9bc2630f (diff)
Set frame size to video codec context size, nicer rgb to nv12
Diffstat (limited to 'src/capture')
-rw-r--r--src/capture/kms.c5
-rw-r--r--src/capture/kms_cuda.c2
-rw-r--r--src/capture/kms_vaapi.c4
-rw-r--r--src/capture/nvfbc.c3
-rw-r--r--src/capture/xcomposite_cuda.c3
-rw-r--r--src/capture/xcomposite_vaapi.c5
6 files changed, 17 insertions, 5 deletions
diff --git a/src/capture/kms.c b/src/capture/kms.c
index 32e5d3e..c3ec64b 100644
--- a/src/capture/kms.c
+++ b/src/capture/kms.c
@@ -39,7 +39,7 @@ static int max_int(int a, int b) {
return a > b ? a : b;
}
-int gsr_capture_kms_start(gsr_capture_kms *self, gsr_capture_base *base, const char *display_to_capture, gsr_egl *egl, AVCodecContext *video_codec_context) {
+int gsr_capture_kms_start(gsr_capture_kms *self, gsr_capture_base *base, const char *display_to_capture, gsr_egl *egl, AVCodecContext *video_codec_context, AVFrame *frame) {
base->video_codec_context = video_codec_context;
gsr_monitor monitor;
@@ -77,6 +77,9 @@ int gsr_capture_kms_start(gsr_capture_kms *self, gsr_capture_base *base, const c
base->video_codec_context->width = max_int(2, even_number_ceil(self->capture_size.x));
base->video_codec_context->height = max_int(2, even_number_ceil(self->capture_size.y));
+
+ frame->width = base->video_codec_context->width;
+ frame->height = base->video_codec_context->height;
return 0;
}
diff --git a/src/capture/kms_cuda.c b/src/capture/kms_cuda.c
index 8583d56..775aab5 100644
--- a/src/capture/kms_cuda.c
+++ b/src/capture/kms_cuda.c
@@ -79,7 +79,7 @@ static bool cuda_create_codec_context(gsr_capture_kms_cuda *cap_kms, AVCodecCont
static int gsr_capture_kms_cuda_start(gsr_capture *cap, AVCodecContext *video_codec_context, AVFrame *frame) {
gsr_capture_kms_cuda *cap_kms = cap->priv;
- const int res = gsr_capture_kms_start(&cap_kms->kms, &cap_kms->base, cap_kms->params.display_to_capture, cap_kms->params.egl, video_codec_context);
+ const int res = gsr_capture_kms_start(&cap_kms->kms, &cap_kms->base, cap_kms->params.display_to_capture, cap_kms->params.egl, video_codec_context, frame);
if(res != 0) {
gsr_capture_kms_cuda_stop(cap, video_codec_context);
return res;
diff --git a/src/capture/kms_vaapi.c b/src/capture/kms_vaapi.c
index 3363d9c..8fddf04 100644
--- a/src/capture/kms_vaapi.c
+++ b/src/capture/kms_vaapi.c
@@ -50,7 +50,7 @@ static bool drm_create_codec_context(gsr_capture_kms_vaapi *cap_kms, AVCodecCont
hw_frame_context->device_ref = device_ctx;
hw_frame_context->device_ctx = (AVHWDeviceContext*)device_ctx->data;
- hw_frame_context->initial_pool_size = 20;
+ //hw_frame_context->initial_pool_size = 20;
AVVAAPIDeviceContext *vactx =((AVHWDeviceContext*)device_ctx->data)->hwctx;
cap_kms->va_dpy = vactx->display;
@@ -71,7 +71,7 @@ static bool drm_create_codec_context(gsr_capture_kms_vaapi *cap_kms, AVCodecCont
static int gsr_capture_kms_vaapi_start(gsr_capture *cap, AVCodecContext *video_codec_context, AVFrame *frame) {
gsr_capture_kms_vaapi *cap_kms = cap->priv;
- int res = gsr_capture_kms_start(&cap_kms->kms, &cap_kms->base, cap_kms->params.display_to_capture, cap_kms->params.egl, video_codec_context);
+ int res = gsr_capture_kms_start(&cap_kms->kms, &cap_kms->base, cap_kms->params.display_to_capture, cap_kms->params.egl, video_codec_context, frame);
if(res != 0) {
gsr_capture_kms_vaapi_stop(cap, video_codec_context);
return res;
diff --git a/src/capture/nvfbc.c b/src/capture/nvfbc.c
index 0b7ce60..13ca160 100644
--- a/src/capture/nvfbc.c
+++ b/src/capture/nvfbc.c
@@ -349,6 +349,9 @@ static int gsr_capture_nvfbc_start(gsr_capture *cap, AVCodecContext *video_codec
video_codec_context->height = tracking_height & ~1;
}
+ frame->width = video_codec_context->width;
+ frame->height = video_codec_context->height;
+
if(!ffmpeg_create_cuda_contexts(cap_nvfbc, video_codec_context))
goto error_cleanup;
diff --git a/src/capture/xcomposite_cuda.c b/src/capture/xcomposite_cuda.c
index 1194edb..181aa70 100644
--- a/src/capture/xcomposite_cuda.c
+++ b/src/capture/xcomposite_cuda.c
@@ -204,6 +204,9 @@ static int gsr_capture_xcomposite_cuda_start(gsr_capture *cap, AVCodecContext *v
video_codec_context->height = max_int(2, cap_xcomp->params.region_size.y & ~1);
}
+ frame->width = video_codec_context->width;
+ frame->height = video_codec_context->height;
+
cap_xcomp->target_texture_id = gl_create_texture(cap_xcomp, video_codec_context->width, video_codec_context->height);
if(cap_xcomp->target_texture_id == 0) {
fprintf(stderr, "gsr error: gsr_capture_xcomposite_cuda_start: failed to create opengl texture\n");
diff --git a/src/capture/xcomposite_vaapi.c b/src/capture/xcomposite_vaapi.c
index 134c8bb..e387586 100644
--- a/src/capture/xcomposite_vaapi.c
+++ b/src/capture/xcomposite_vaapi.c
@@ -89,7 +89,7 @@ static bool drm_create_codec_context(gsr_capture_xcomposite_vaapi *cap_xcomp, AV
hw_frame_context->device_ref = device_ctx;
hw_frame_context->device_ctx = (AVHWDeviceContext*)device_ctx->data;
- hw_frame_context->initial_pool_size = 20;
+ //hw_frame_context->initial_pool_size = 20;
AVVAAPIDeviceContext *vactx =((AVHWDeviceContext*)device_ctx->data)->hwctx;
cap_xcomp->va_dpy = vactx->display;
@@ -178,6 +178,9 @@ static int gsr_capture_xcomposite_vaapi_start(gsr_capture *cap, AVCodecContext *
video_codec_context->height = max_int(2, even_number_ceil(cap_xcomp->params.region_size.y));
}
+ frame->width = video_codec_context->width;
+ frame->height = video_codec_context->height;
+
if(!drm_create_codec_context(cap_xcomp, video_codec_context)) {
gsr_capture_xcomposite_vaapi_stop(cap, video_codec_context);
return -1;