mirror of
https://github.com/jojo61/vdr-plugin-softhdcuvid.git
synced 2023-10-10 13:37:41 +02:00
Improved libplacebo opengl performance for UHD content
This commit is contained in:
parent
d553a8108d
commit
8018f7d921
58
video.c
58
video.c
@ -345,7 +345,7 @@ typedef struct
|
||||
#endif
|
||||
#ifdef CUVID
|
||||
#define PIXEL_FORMAT AV_PIX_FMT_CUDA
|
||||
#define SWAP_BUFFER_SIZE 1
|
||||
#define SWAP_BUFFER_SIZE 3
|
||||
#endif
|
||||
#if defined RASPI
|
||||
#define PIXEL_FORMAT AV_PIX_FMT_MMAL
|
||||
@ -3807,11 +3807,11 @@ static void CuvidMixVideo(CuvidDecoder * decoder, __attribute__((unused))
|
||||
|
||||
memcpy(&deband, &pl_deband_default_params, sizeof(deband));
|
||||
memcpy(&render_params, &pl_render_default_params, sizeof(render_params));
|
||||
render_params.deband_params = &deband;
|
||||
|
||||
switch (decoder->ColorSpace) {
|
||||
case AVCOL_SPC_RGB: // BT 601 is reportet as RGB
|
||||
img->repr.sys = PL_COLOR_SYSTEM_BT_601;
|
||||
img->repr.levels = PL_COLOR_LEVELS_TV;
|
||||
memcpy(&img->repr, &pl_color_repr_sdtv, sizeof(struct pl_color_repr));
|
||||
img->color.primaries = PL_COLOR_PRIM_BT_601_625;
|
||||
img->color.transfer = PL_COLOR_TRC_BT_1886;
|
||||
img->color.light = PL_COLOR_LIGHT_DISPLAY;
|
||||
@ -3819,19 +3819,12 @@ static void CuvidMixVideo(CuvidDecoder * decoder, __attribute__((unused))
|
||||
break;
|
||||
case AVCOL_SPC_BT709:
|
||||
case AVCOL_SPC_UNSPECIFIED: // comes with UHD
|
||||
img->repr.sys = PL_COLOR_SYSTEM_BT_709;
|
||||
img->repr.levels = PL_COLOR_LEVELS_TV;
|
||||
memcpy(&img->repr, &pl_color_repr_hdtv, sizeof(struct pl_color_repr));
|
||||
memcpy(&img->color, &pl_color_space_bt709, sizeof(struct pl_color_space));
|
||||
// img->color.primaries = PL_COLOR_PRIM_BT_709;
|
||||
// img->color.transfer = PL_COLOR_TRC_BT_1886;
|
||||
// img->color.light = PL_COLOR_LIGHT_SCENE_709_1886;
|
||||
// img->color.light = PL_COLOR_LIGHT_DISPLAY;
|
||||
pl->shift_x = -0.5f;
|
||||
break;
|
||||
|
||||
case AVCOL_SPC_BT2020_NCL:
|
||||
img->repr.sys = PL_COLOR_SYSTEM_BT_2020_NC;
|
||||
img->repr.levels = PL_COLOR_LEVELS_TV;
|
||||
memcpy(&img->repr, &pl_color_repr_uhdtv, sizeof(struct pl_color_repr));
|
||||
memcpy(&img->color, &pl_color_space_bt2020_hlg, sizeof(struct pl_color_space));
|
||||
deband.grain = 0.0f; // no grain in HDR
|
||||
@ -3839,19 +3832,15 @@ static void CuvidMixVideo(CuvidDecoder * decoder, __attribute__((unused))
|
||||
pl->shift_x = -0.5f;
|
||||
#if defined VAAPI || defined USE_DRM
|
||||
render_params.peak_detect_params = NULL;
|
||||
render_params.deband_params = NULL;
|
||||
render_params.dither_params = NULL;
|
||||
render_params.skip_anti_aliasing = true;
|
||||
#endif
|
||||
// img->color.primaries = PL_COLOR_PRIM_BT_2020;
|
||||
// img->color.transfer = PL_COLOR_TRC_HLG;
|
||||
// img->color.light = PL_COLOR_LIGHT_SCENE_HLG;
|
||||
break;
|
||||
|
||||
default: // fallback
|
||||
img->repr.sys = PL_COLOR_SYSTEM_BT_709;
|
||||
img->repr.levels = PL_COLOR_LEVELS_TV;
|
||||
memcpy(&img->repr, &pl_color_repr_hdtv, sizeof(struct pl_color_repr));
|
||||
memcpy(&img->color, &pl_color_space_bt709, sizeof(struct pl_color_space));
|
||||
// img->color.primaries = PL_COLOR_PRIM_BT_709;
|
||||
// img->color.transfer = PL_COLOR_TRC_BT_1886;
|
||||
// img->color.light = PL_COLOR_LIGHT_DISPLAY;
|
||||
pl->shift_x = -0.5f;
|
||||
break;
|
||||
}
|
||||
@ -3955,7 +3944,6 @@ static void CuvidMixVideo(CuvidDecoder * decoder, __attribute__((unused))
|
||||
render_params.upscaler = pl_named_filters[VideoScaling[decoder->Resolution]].filter;
|
||||
render_params.downscaler = pl_named_filters[VideoScaling[decoder->Resolution]].filter;
|
||||
render_params.color_adjustment = &colors;
|
||||
render_params.deband_params = &deband;
|
||||
|
||||
colors.brightness = VideoBrightness;
|
||||
colors.contrast = VideoContrast;
|
||||
@ -4011,10 +3999,12 @@ static void CuvidMixVideo(CuvidDecoder * decoder, __attribute__((unused))
|
||||
}
|
||||
|
||||
decoder->newchannel = 0;
|
||||
|
||||
// uint64_t tt = GetusTicks();
|
||||
if (!pl_render_image(p->renderer, &decoder->pl_images[current], target, &render_params)) {
|
||||
Debug(4, "Failed rendering frame!\n");
|
||||
}
|
||||
// pl_gpu_finish(p->gpu);
|
||||
//printf("Rendertime %ld -- \n,",GetusTicks() - tt);
|
||||
|
||||
if (VideoScalerTest) { // left side test scaler
|
||||
#if PL_API_VER >= 100
|
||||
@ -4141,7 +4131,6 @@ static void CuvidDisplayFrame(void)
|
||||
int RTS_flag;
|
||||
int valid_frame = 0;
|
||||
float ldiff;
|
||||
static int first = 1;
|
||||
float turnaround;
|
||||
|
||||
#ifdef PLACEBO
|
||||
@ -4192,32 +4181,14 @@ static void CuvidDisplayFrame(void)
|
||||
}
|
||||
|
||||
round_time = GetusTicks();
|
||||
#if 1
|
||||
diff = (GetusTicks() - last_time) / 1000;
|
||||
|
||||
// last_time = GetusTicks();
|
||||
// printf("Roundtrip Displayframe %d\n",diff);
|
||||
if (diff < 5000 && diff > 0) {
|
||||
// printf("Sleep %d\n",15000-diff);
|
||||
usleep((5000 - diff)); // * 1000);
|
||||
}
|
||||
|
||||
#endif
|
||||
if (!p->swapchain)
|
||||
return;
|
||||
|
||||
#ifdef CUVID
|
||||
VideoThreadLock();
|
||||
#if 0
|
||||
if (!first) {
|
||||
if (!pl_swapchain_submit_frame(p->swapchain))
|
||||
Error(_("Failed to submit swapchain buffer\n"));
|
||||
pl_swapchain_swap_buffers(p->swapchain); // swap buffers
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
first = 0;
|
||||
last_time = GetusTicks();
|
||||
|
||||
while (!pl_swapchain_start_frame(p->swapchain, &frame)) { // get new frame wait for previous to swap
|
||||
@ -4234,7 +4205,7 @@ static void CuvidDisplayFrame(void)
|
||||
VideoThreadLock();
|
||||
#endif
|
||||
|
||||
pl_render_target_from_swapchain(&target, &frame); // make target frame
|
||||
pl_frame_from_swapchain(&target, &frame); // make target frame
|
||||
|
||||
if (VideoSurfaceModesChanged) {
|
||||
pl_renderer_destroy(&p->renderer);
|
||||
@ -5092,12 +5063,12 @@ static const VideoModule NoopModule = {
|
||||
.SetClock = (void(*const)(VideoHwDecoder *, int64_t))NoopSetClock,
|
||||
.GetClock = (int64_t(*const)(const VideoHwDecoder *))NoopGetClock,
|
||||
.SetClosing = (void(*const)(const VideoHwDecoder *))NoopSetClosing,
|
||||
.ResetStart = (void(*const)(const VideoHwDecoder *))NoopResetStart,
|
||||
.SetTrickSpeed = (void(*const)(const VideoHwDecoder *, int))NoopSetTrickSpeed,
|
||||
.GrabOutput = NoopGrabOutputSurface,
|
||||
.GetStats = (void(*const)(VideoHwDecoder *, int *, int *, int *,
|
||||
int *, float *, int *, int *, int *, int *))NoopGetStats,
|
||||
#endif
|
||||
.ResetStart = (void(*const)(const VideoHwDecoder *))NoopVoid,
|
||||
.SetBackground = NoopSetBackground,
|
||||
.SetVideoMode = NoopVoid,
|
||||
|
||||
@ -5486,7 +5457,7 @@ void InitPlacebo()
|
||||
.swap_buffers = (void (*)(void *)) CuvidSwapBuffer,
|
||||
.framebuffer.flipped = true,
|
||||
.framebuffer.id = 0,
|
||||
.max_swapchain_depth = 2,
|
||||
.max_swapchain_depth = 3,
|
||||
.priv = VideoWindow,
|
||||
});
|
||||
|
||||
@ -5536,7 +5507,6 @@ void InitPlacebo()
|
||||
Fatal(_("Failed to create Vulkan Device"));
|
||||
|
||||
p->gpu = p->vk->gpu;
|
||||
|
||||
// Create initial swapchain
|
||||
p->swapchain = pl_vulkan_create_swapchain(p->vk, &(struct pl_vulkan_swapchain_params) {
|
||||
.surface = p->pSurface,
|
||||
|
Loading…
Reference in New Issue
Block a user