aboutsummaryrefslogtreecommitdiff
path: root/src/capture
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2023-04-10 22:46:56 +0200
committerdec05eba <dec05eba@protonmail.com>2023-04-10 22:46:56 +0200
commit59046178c4adeb37c044dd300308cd3159aa7ba5 (patch)
treeaee292a357450633ed94ca0231f40e10d29b89aa /src/capture
parent4996266f28f2f275be9f08d8d591f1245efddafc (diff)
Remove unecessary vaCreatebuffer every frame
Diffstat (limited to 'src/capture')
-rw-r--r--src/capture/kms_vaapi.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/capture/kms_vaapi.c b/src/capture/kms_vaapi.c
index 6500cd2..2e023ab 100644
--- a/src/capture/kms_vaapi.c
+++ b/src/capture/kms_vaapi.c
@@ -148,6 +148,7 @@ static void gsr_capture_kms_vaapi_tick(gsr_capture *cap, AVCodecContext *video_c
//const double window_resize_timeout = 1.0; // 1 second
if(!cap_kms->created_hw_frame) {
cap_kms->created_hw_frame = true;
+
av_frame_free(frame);
*frame = av_frame_alloc();
if(!frame) {
@@ -173,6 +174,8 @@ static void gsr_capture_kms_vaapi_tick(gsr_capture *cap, AVCodecContext *video_c
return;
}
+ VASurfaceID target_surface_id = (uintptr_t)(*frame)->data[3];
+
VAStatus va_status = vaCreateConfig(cap_kms->va_dpy, VAProfileNone, VAEntrypointVideoProc, NULL, 0, &cap_kms->config_id);
if(va_status != VA_STATUS_SUCCESS) {
fprintf(stderr, "gsr error: gsr_capture_kms_vaapi_tick: vaCreateConfig failed: %d\n", va_status);
@@ -180,6 +183,14 @@ static void gsr_capture_kms_vaapi_tick(gsr_capture *cap, AVCodecContext *video_c
cap_kms->stop_is_error = true;
return;
}
+
+ va_status = vaCreateContext(cap_kms->va_dpy, cap_kms->config_id, cap_kms->kms_size.x, cap_kms->kms_size.y, VA_PROGRESSIVE, &target_surface_id, 1, &cap_kms->context_id);
+ if(va_status != VA_STATUS_SUCCESS) {
+ fprintf(stderr, "gsr error: gsr_capture_kms_vaapi_tick: vaCreateContext failed: %d\n", va_status);
+ cap_kms->should_stop = true;
+ cap_kms->stop_is_error = true;
+ return;
+ }
}
}
@@ -223,11 +234,6 @@ static int gsr_capture_kms_vaapi_capture(gsr_capture *cap, AVFrame *frame) {
cap_kms->buffer_id = 0;
}
- if(cap_kms->context_id) {
- vaDestroyContext(cap_kms->va_dpy, cap_kms->context_id);
- cap_kms->context_id = 0;
- }
-
if(cap_kms->input_surface) {
vaDestroySurfaces(cap_kms->va_dpy, &cap_kms->input_surface, 1);
cap_kms->input_surface = 0;
@@ -272,14 +278,6 @@ static int gsr_capture_kms_vaapi_capture(gsr_capture *cap, AVFrame *frame) {
return -1;
}
- va_status = vaCreateContext(cap_kms->va_dpy, cap_kms->config_id, cap_kms->kms_size.x, cap_kms->kms_size.y, VA_PROGRESSIVE, &target_surface_id, 1, &cap_kms->context_id);
- if(va_status != VA_STATUS_SUCCESS) {
- fprintf(stderr, "gsr error: gsr_capture_kms_vaapi_capture: vaCreateContext failed: %d\n", va_status);
- cap_kms->should_stop = true;
- cap_kms->stop_is_error = true;
- return -1;
- }
-
cap_kms->input_region = (VARectangle) {
.x = cap_kms->capture_pos.x,
.y = cap_kms->capture_pos.y,