diff options
-rw-r--r-- | TODO | 4 | ||||
-rw-r--r-- | src/capture/kms_vaapi.c | 24 |
2 files changed, 14 insertions, 14 deletions
@@ -43,4 +43,6 @@ Better configure vaapi. The file size is too large. Better colors for vaapi. It looks a bit off when recording vscode for example. Clear vaapi surface (for focused window). -Support -h and --help. -h should only show the first line and --help the full help. On error, only show that -h.
\ No newline at end of file +Support -h and --help. -h should only show the first line and --help the full help. On error, only show that -h. + +Rotated display on amd doesn't work correctly (if you only have 1 monitor connected and it's rotated), even with ffmpeg kmsgrab. The drmfd is rotated as well so it needs to be rotated in the surface copy.
\ No newline at end of file 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, |