1
0
mirror of https://github.com/jojo61/vdr-plugin-softhdcuvid.git synced 2023-10-10 13:37:41 +02:00

more fixes

This commit is contained in:
jojo61 2018-11-24 09:34:55 +01:00
parent 4f4472d4a7
commit 36072dd1c6
2 changed files with 134 additions and 23 deletions

50
skindesigner_patch.txt Normal file
View File

@ -0,0 +1,50 @@
diff -Naur skindesignerold/coreengine/animation.c skindesigner/coreengine/animation.c
--- skindesignerold/coreengine/animation.c 2018-03-03 09:03:00.000000000 +0100
+++ skindesigner/coreengine/animation.c 2018-11-18 14:56:31.147849032 +0100
@@ -671,9 +671,9 @@
}
animLock.Unlock();
reactivate = false;
- osd->Flush();
if (!animActive)
break;
+ osd->Flush();
Sleep(start);
}
}
diff -Naur skindesignerold/coreengine/view.c skindesigner/coreengine/view.c
--- skindesignerold/coreengine/view.c 2018-03-03 09:03:00.000000000 +0100
+++ skindesigner/coreengine/view.c 2018-11-18 11:59:24.870281811 +0100
@@ -279,7 +279,7 @@
continue;
viewElements[i]->Close();
}
- sdOsd.Flush();
+// sdOsd.Flush();
sdOsd.DeleteOsd();
}
diff -Naur skindesignerold/coreengine/viewdisplaychannel.c skindesigner/coreengine/viewdisplaychannel.c
--- skindesignerold/coreengine/viewdisplaychannel.c 2018-03-03 09:03:00.000000000 +0100
+++ skindesigner/coreengine/viewdisplaychannel.c 2018-11-18 12:01:10.460722220 +0100
@@ -396,7 +396,7 @@
if (groupChannelList)
groupChannelList->Close();
#endif
- sdOsd.Flush();
+// sdOsd.Flush();
sdOsd.DeleteOsd();
}
diff -Naur skindesignerold/coreengine/viewdisplaymenu.c skindesigner/coreengine/viewdisplaymenu.c
--- skindesignerold/coreengine/viewdisplaymenu.c 2018-03-03 09:03:00.000000000 +0100
+++ skindesigner/coreengine/viewdisplaymenu.c 2018-11-18 12:00:20.301464616 +0100
@@ -556,7 +556,7 @@
}
UnScaleTv();
ClearVariables();
- sdOsd.Flush();
+// sdOsd.Flush();
sdOsd.DeleteOsd();
}

101
video.c
View File

@ -2197,6 +2197,7 @@ createTextureDst(CuvidDecoder * decoder,int anz, unsigned int size_x, unsigned i
struct pl_tex *tex; struct pl_tex *tex;
struct pl_image *img; struct pl_image *img;
struct pl_plane *pl; struct pl_plane *pl;
const float black[4] = { 0.0f,0.0f,0.0f,1.0f};
//printf("Create textures and planes %d %d\n",size_x,size_y); //printf("Create textures and planes %d %d\n",size_x,size_y);
Debug(3,"video/vulkan: create %d Textures Format %s w %d h %d \n",anz,PixFmt==AV_PIX_FMT_NV12?"NV12":"P010",size_x,size_y); Debug(3,"video/vulkan: create %d Textures Format %s w %d h %d \n",anz,PixFmt==AV_PIX_FMT_NV12?"NV12":"P010",size_x,size_y);
@ -2265,9 +2266,9 @@ createTextureDst(CuvidDecoder * decoder,int anz, unsigned int size_x, unsigned i
.host_mapped = false, .host_mapped = false,
.host_writable = false, .host_writable = false,
.memory_type = PL_BUF_MEM_DEVICE, .memory_type = PL_BUF_MEM_DEVICE,
.ext_handles = PL_HANDLE_FD, .handle_type = PL_HANDLE_FD,
}); });
decoder->ebuf[0].fd = dup(decoder->pl_buf_Y->handles.fd); // dup fd decoder->ebuf[0].fd = dup(decoder->pl_buf_Y->shared_mem.handle.fd); // dup fd
// printf("Y Offset %d Size %d FD %d\n",decoder->pl_buf_Y->handle_offset,decoder->pl_buf_Y->handles.size,decoder->pl_buf_Y->handles.fd); // printf("Y Offset %d Size %d FD %d\n",decoder->pl_buf_Y->handle_offset,decoder->pl_buf_Y->handles.size,decoder->pl_buf_Y->handles.fd);
decoder->pl_buf_UV = pl_buf_create(p->gpu, &(struct pl_buf_params) { // buffer für UV texture upload decoder->pl_buf_UV = pl_buf_create(p->gpu, &(struct pl_buf_params) { // buffer für UV texture upload
@ -2276,22 +2277,22 @@ createTextureDst(CuvidDecoder * decoder,int anz, unsigned int size_x, unsigned i
.host_mapped = false, .host_mapped = false,
.host_writable = false, .host_writable = false,
.memory_type = PL_BUF_MEM_DEVICE, .memory_type = PL_BUF_MEM_DEVICE,
.ext_handles = PL_HANDLE_FD, .handle_type = PL_HANDLE_FD,
}); });
decoder->ebuf[1].fd = dup(decoder->pl_buf_UV->handles.fd); // dup fd decoder->ebuf[1].fd = dup(decoder->pl_buf_UV->shared_mem.handle.fd); // dup fd
// printf("UV Offset %d Size %d FD %d\n",decoder->pl_buf_UV->handle_offset,decoder->pl_buf_UV->handles.size,decoder->pl_buf_UV->handles.fd); // printf("UV Offset %d Size %d FD %d\n",decoder->pl_buf_UV->handle_offset,decoder->pl_buf_UV->handles.size,decoder->pl_buf_UV->handles.fd);
CUDA_EXTERNAL_MEMORY_HANDLE_DESC ext_desc = { CUDA_EXTERNAL_MEMORY_HANDLE_DESC ext_desc = {
.type = CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD, .type = CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD,
.handle.fd = decoder->ebuf[0].fd, .handle.fd = decoder->ebuf[0].fd,
.size = decoder->pl_buf_Y->handles.size, // image_width * image_height * bytes, .size = decoder->pl_buf_Y->shared_mem.size, // image_width * image_height * bytes,
.flags = 0, .flags = 0,
}; };
checkCudaErrors(cuImportExternalMemory(&decoder->ebuf[0].mem, &ext_desc)); // Import Memory segment checkCudaErrors(cuImportExternalMemory(&decoder->ebuf[0].mem, &ext_desc)); // Import Memory segment
CUDA_EXTERNAL_MEMORY_BUFFER_DESC buf_desc = { CUDA_EXTERNAL_MEMORY_BUFFER_DESC buf_desc = {
.offset = decoder->pl_buf_Y->handle_offset, .offset = decoder->pl_buf_Y->shared_mem.offset,
.size = size_x * size_y * size, .size = size_x * size_y * size,
.flags = 0, .flags = 0,
}; };
@ -2300,13 +2301,13 @@ createTextureDst(CuvidDecoder * decoder,int anz, unsigned int size_x, unsigned i
CUDA_EXTERNAL_MEMORY_HANDLE_DESC ext_desc1 = { CUDA_EXTERNAL_MEMORY_HANDLE_DESC ext_desc1 = {
.type = CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD, .type = CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD,
.handle.fd = decoder->ebuf[1].fd, .handle.fd = decoder->ebuf[1].fd,
.size = decoder->pl_buf_UV->handles.size, // image_width * image_height * bytes / 2, .size = decoder->pl_buf_UV->shared_mem.size, // image_width * image_height * bytes / 2,
.flags = 0, .flags = 0,
}; };
checkCudaErrors(cuImportExternalMemory(&decoder->ebuf[1].mem, &ext_desc1)); // Import Memory Segment checkCudaErrors(cuImportExternalMemory(&decoder->ebuf[1].mem, &ext_desc1)); // Import Memory Segment
CUDA_EXTERNAL_MEMORY_BUFFER_DESC buf_desc1 = { CUDA_EXTERNAL_MEMORY_BUFFER_DESC buf_desc1 = {
.offset = decoder->pl_buf_UV->handle_offset, .offset = decoder->pl_buf_UV->shared_mem.offset,
.size = size_x * size_y * size / 2, .size = size_x * size_y * size / 2,
.flags = 0, .flags = 0,
}; };
@ -3155,7 +3156,7 @@ static void CuvidRenderFrame(CuvidDecoder * decoder,
Debug(3, "video/vdpau: aspect ratio changed\n"); Debug(3, "video/vdpau: aspect ratio changed\n");
decoder->InputAspect = frame->sample_aspect_ratio; decoder->InputAspect = frame->sample_aspect_ratio;
printf("new aspect %d:%d\n",frame->sample_aspect_ratio.num,frame->sample_aspect_ratio.den); //printf("new aspect %d:%d\n",frame->sample_aspect_ratio.num,frame->sample_aspect_ratio.den);
CuvidUpdateOutput(decoder); CuvidUpdateOutput(decoder);
} }
#else #else
@ -3297,10 +3298,11 @@ static void *CuvidGetHwAccelContext(CuvidDecoder * decoder)
/// ///
static void CuvidBlackSurface(CuvidDecoder * decoder) static void CuvidBlackSurface(CuvidDecoder * decoder)
{ {
#ifndef PLACEBO
VdpRect source_rect; VdpRect source_rect;
VdpRect output_rect; VdpRect output_rect;
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
#endif
return; return;
} }
@ -3359,6 +3361,7 @@ static void CuvidMixVideo(CuvidDecoder * decoder, int level)
VkImage Image; VkImage Image;
struct pl_image *img; struct pl_image *img;
bool ok; bool ok;
const float black[4] = { 0.0f,0.0f,0.0f,1.0f};
#endif #endif
int current; int current;
@ -3491,6 +3494,7 @@ static void CuvidMixVideo(CuvidDecoder * decoder, int level)
colors.gamma = VideoGamma; colors.gamma = VideoGamma;
if (ovl) { if (ovl) {
pl_tex_clear(p->gpu,target->fbo,black); // clear frame
target->overlays = ovl; target->overlays = ovl;
target->num_overlays = 1; target->num_overlays = 1;
} else { } else {
@ -3501,7 +3505,26 @@ static void CuvidMixVideo(CuvidDecoder * decoder, int level)
if (!pl_render_image(p->renderer, &decoder->pl_images[current], target, &render_params)) { if (!pl_render_image(p->renderer, &decoder->pl_images[current], target, &render_params)) {
Fatal(_("Failed rendering frame!\n")); Fatal(_("Failed rendering frame!\n"));
} }
#if 0
if (1) {
// Source crop
img->src_rect.x0 = video_src_rect.x0;
img->src_rect.y0 = video_src_rect.y0;
img->src_rect.x1 = video_src_rect.x1/2;
img->src_rect.y1 = video_src_rect.y1;
// Video aspect ratio
target->dst_rect.x0 = dst_video_rect.x0;
target->dst_rect.y0 = dst_video_rect.y0;
target->dst_rect.x1 = dst_video_rect.x1/2+dst_video_rect.x0/2;
target->dst_rect.y1 = dst_video_rect.y1;
render_params.upscaler = NULL;
render_params.downscaler = NULL;
if (!pl_render_image(p->renderer, &decoder->pl_images[current], target, &render_params)) {
Fatal(_("Failed rendering frame!\n"));
}
}
#endif
#endif #endif
Debug(4, "video/vdpau: yy video surface %p displayed\n", current, decoder->SurfaceRead); Debug(4, "video/vdpau: yy video surface %p displayed\n", current, decoder->SurfaceRead);
@ -3569,7 +3592,7 @@ static void CuvidDisplayFrame(void)
struct pl_swapchain_frame frame; struct pl_swapchain_frame frame;
struct pl_render_target target; struct pl_render_target target;
bool ok; bool ok;
const float black[4] = { 0.0f,0.0f,0.0f,1.0f};
#endif #endif
@ -3586,9 +3609,9 @@ static void CuvidDisplayFrame(void)
last_time = GetusTicks(); last_time = GetusTicks();
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
#else #else
// last_time = GetusTicks();
pl_swapchain_swap_buffers(p->swapchain); pl_swapchain_swap_buffers(p->swapchain);
// last_time = GetusTicks();
// pl_swapchain_swap_buffers(p->swapchain);
// printf(" Latency %d Time wait %2.2f\n",pl_swapchain_latency(p->swapchain),(float)(GetusTicks()-last_time)/1000000.0); // printf(" Latency %d Time wait %2.2f\n",pl_swapchain_latency(p->swapchain),(float)(GetusTicks()-last_time)/1000000.0);
last_time = GetusTicks(); last_time = GetusTicks();
if (!p->swapchain) if (!p->swapchain)
@ -3600,7 +3623,7 @@ static void CuvidDisplayFrame(void)
pl_render_target_from_swapchain(&target, &frame); // make target frame pl_render_target_from_swapchain(&target, &frame); // make target frame
pl_tex_clear(p->gpu,target.fbo,black); // clear frame
target.repr.sys = PL_COLOR_SYSTEM_RGB; target.repr.sys = PL_COLOR_SYSTEM_RGB;
if (VideoStudioLevels) if (VideoStudioLevels)
@ -3720,8 +3743,10 @@ static void CuvidDisplayFrame(void)
if (!pl_swapchain_submit_frame(p->swapchain)) if (!pl_swapchain_submit_frame(p->swapchain))
Fatal(_("Failed to submit swapchain buffer\n")); Fatal(_("Failed to submit swapchain buffer\n"));
if (CuvidDecoderN) if (CuvidDecoderN)
CuvidDecoders[0]->Frameproc = (float)(GetusTicks()-last_time)/1000000.0; CuvidDecoders[0]->Frameproc = (float)(GetusTicks()-last_time)/1000000.0;
#else #else
glXGetVideoSyncSGI (&Count); // get current frame glXGetVideoSyncSGI (&Count); // get current frame
glXSwapBuffers(XlibDisplay, VideoWindow); glXSwapBuffers(XlibDisplay, VideoWindow);
@ -4161,6 +4186,9 @@ static void CuvidDisplayHandlerThread(void)
// FIXME: sleep on wakeup // FIXME: sleep on wakeup
usleep(1 * 100); usleep(1 * 100);
} }
#ifdef PLACEBO
usleep(100);
#endif
// all decoder buffers are full // all decoder buffers are full
// and display is not preempted // and display is not preempted
@ -4522,6 +4550,7 @@ void VideoGetOsdSize(int *width, int *height)
{ {
*width = 1920; *width = 1920;
*height = 1080; // unknown default *height = 1080; // unknown default
if (OsdWidth && OsdHeight) { if (OsdWidth && OsdHeight) {
*width = OsdWidth; *width = OsdWidth;
*height = OsdHeight; *height = OsdHeight;
@ -4789,11 +4818,28 @@ static void VideoThreadUnlock(void)
} }
#ifdef PLACEBO #ifdef PLACEBO
void pl_log_intern(void *stream, enum pl_log_level level, const char *msg)
{
static const char *prefix[] = {
[PL_LOG_FATAL] = "fatal",
[PL_LOG_ERR] = "error",
[PL_LOG_WARN] = "warn",
[PL_LOG_INFO] = "info",
[PL_LOG_DEBUG] = "debug",
[PL_LOG_TRACE] = "trace",
};
printf("%5s: %s\n", prefix[level], msg);
}
void InitPlacebo(){ void InitPlacebo(){
struct pl_vulkan_params params; struct pl_vulkan_params params;
struct pl_vk_inst_params iparams = pl_vk_inst_default_params; struct pl_vk_inst_params iparams = pl_vk_inst_default_params;
VkXcbSurfaceCreateInfoKHR xcbinfo; VkXcbSurfaceCreateInfoKHR xcbinfo;
char xcbext[] = {"VK_KHR_xcb_surface"}; char xcbext[] = {"VK_KHR_xcb_surface"};
char surfext[] = {"VK_KHR_surface"}; char surfext[] = {"VK_KHR_surface"};
@ -4805,7 +4851,7 @@ void InitPlacebo(){
// Create context // Create context
p->context.log_cb = &pl_log_simple; p->context.log_cb = &pl_log_intern;
p->context.log_level = PL_LOG_WARN; p->context.log_level = PL_LOG_WARN;
p->ctx = pl_context_create(PL_API_VER, &p->context); p->ctx = pl_context_create(PL_API_VER, &p->context);
@ -4819,6 +4865,7 @@ void InitPlacebo(){
iparams.num_extensions = 2; iparams.num_extensions = 2;
iparams.extensions = malloc(2 * sizeof(const char *)); iparams.extensions = malloc(2 * sizeof(const char *));
*iparams.extensions = xcbext; *iparams.extensions = xcbext;
iparams.debug = false;
*(iparams.extensions+1) = surfext; *(iparams.extensions+1) = surfext;
p->vk_inst = pl_vk_inst_create(p->ctx, &iparams); p->vk_inst = pl_vk_inst_create(p->ctx, &iparams);
@ -4841,7 +4888,7 @@ void InitPlacebo(){
params.instance = p->vk_inst->instance; params.instance = p->vk_inst->instance;
params.async_transfer = true; params.async_transfer = true;
params.async_compute = true; params.async_compute = true;
// params.queue_count = 8; // params.queue_count = 8;
params.surface = p->pSurface; params.surface = p->pSurface;
params.allow_software = true; params.allow_software = true;
@ -4883,7 +4930,7 @@ static void *VideoDisplayHandlerThread(void *dummy)
unsigned int device_count,version; unsigned int device_count,version;
CUdevice device; CUdevice device;
#ifdef PLACEBO #ifdef PLACEBO_
InitPlacebo(); InitPlacebo();
#endif #endif
@ -4912,7 +4959,7 @@ static void *VideoDisplayHandlerThread(void *dummy)
VideoUsedModule->DisplayHandlerThread(); VideoUsedModule->DisplayHandlerThread();
} }
#ifdef PLACEBO #ifdef PLACEBO_
pl_renderer_destroy(&p->renderer); pl_renderer_destroy(&p->renderer);
// pl_tex_destroy(p->gpu, &p->final_fbo); // pl_tex_destroy(p->gpu, &p->final_fbo);
pl_swapchain_destroy(&p->swapchain); pl_swapchain_destroy(&p->swapchain);
@ -6172,6 +6219,7 @@ void VideoInit(const char *display_name)
// if no environment variable, use :0.0 as default display name // if no environment variable, use :0.0 as default display name
display_name = ":0.0"; display_name = ":0.0";
} }
if (!(XlibDisplay = XOpenDisplay(display_name))) { if (!(XlibDisplay = XOpenDisplay(display_name))) {
Error(_("video: Can't connect to X11 server on '%s'\n"), display_name); Error(_("video: Can't connect to X11 server on '%s'\n"), display_name);
// FIXME: we need to retry connection // FIXME: we need to retry connection
@ -6290,7 +6338,9 @@ void VideoInit(const char *display_name)
//xcb_prefetch_maximum_request_length(Connection); //xcb_prefetch_maximum_request_length(Connection);
xcb_flush(Connection); xcb_flush(Connection);
#ifdef PLACEBO
InitPlacebo();
#endif
// I would like to start threads here, but this produces: // I would like to start threads here, but this produces:
// [xcb] Unknown sequence number while processing queue // [xcb] Unknown sequence number while processing queue
// [xcb] Most likely this is a multi-threaded client and XInitThreads // [xcb] Most likely this is a multi-threaded client and XInitThreads
@ -6326,6 +6376,17 @@ void VideoExit(void)
GlxExit(); // delete all contexts GlxExit(); // delete all contexts
} }
#endif #endif
#ifdef PLACEBO
pl_renderer_destroy(&p->renderer);
pl_swapchain_destroy(&p->swapchain);
vkDestroySurfaceKHR(p->vk_inst->instance, p->pSurface, NULL);
pl_vk_inst_destroy(&p->vk_inst);
// pl_vulkan_destroy(&p->vk);
pl_context_destroy(&p->ctx);
free(p);
#endif
// //
// FIXME: cleanup. // FIXME: cleanup.
// //