mirror of
https://github.com/jojo61/vdr-plugin-softhdcuvid.git
synced 2025-03-01 10:39:28 +00:00
Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
2562c4eac5 | ||
|
017ad3f61b | ||
|
dfeb75cc51 | ||
|
b2247ebb9b | ||
|
8c89787269 | ||
|
a4fe3aa31c | ||
|
fde863adaf | ||
|
891d432536 | ||
|
c09bad125d | ||
|
e9cfe530ba | ||
|
8018f7d921 |
6
Makefile
6
Makefile
@@ -36,7 +36,7 @@ LIBPLACEBO_GL ?= 0
|
||||
|
||||
|
||||
|
||||
CONFIG := #-DDEBUG # remove # to enable debug output
|
||||
CONFIG := -DDEBUG # remove # to enable debug output
|
||||
|
||||
|
||||
|
||||
@@ -214,7 +214,7 @@ endif
|
||||
|
||||
|
||||
ifeq ($(CUVID),1)
|
||||
CONFIG += -DUSE_PIP # PIP support
|
||||
#CONFIG += -DUSE_PIP # PIP support
|
||||
CONFIG += -DCUVID # enable CUVID decoder
|
||||
LIBS += -lEGL -lGL
|
||||
ifeq ($(YADIF),1)
|
||||
@@ -321,7 +321,7 @@ DEFINES += -DPLUGIN_NAME_I18N='"$(PLUGIN)"' -D_GNU_SOURCE $(CONFIG) \
|
||||
override CXXFLAGS += $(_CFLAGS) $(DEFINES) $(INCLUDES) \
|
||||
-g -W -Wextra -Winit-self -Werror=overloaded-virtual -Wno-unused-parameter
|
||||
override CFLAGS += $(_CFLAGS) $(DEFINES) $(INCLUDES) \
|
||||
-g -W -Wextra -Winit-self -Wdeclaration-after-statement
|
||||
-g -W -Wextra -Winit-self -std=gnu99
|
||||
|
||||
|
||||
### The object files (add further files here):
|
||||
|
33
README.md
33
README.md
@@ -71,16 +71,22 @@ Quickstart:
|
||||
|
||||
You have to adapt the Makefile. There are 3 possible Version that you can build:
|
||||
|
||||
softhdcuvid
|
||||
softhdcuvid (CUVID=1)
|
||||
This is for NVIDA cards and uses cuvid as decoder. It uses xcb for output and needs a X Server to run.
|
||||
I recommend to use libplacebo and set LIBPLACEBO=1 in the Makefile
|
||||
|
||||
softhdvaapi
|
||||
softhdvaapi (VAAPI=1)
|
||||
This is for INTEL cards and uses Vaapi as decoder. It uses xcb for output and needs a X Server to run.
|
||||
I recommend to use libplacebo and set LIBPLACEBO=1 in the Makefile. Also LIBPLACEBO_GL is supportet here.
|
||||
|
||||
softhddrm
|
||||
softhddrm (DRM=1)
|
||||
This is for INTEL cards and also uses Vaapi as decoder. It uses the DRM API for output and
|
||||
runs without X Server. There are several commandline options to select the resolution and refresh rate.
|
||||
|
||||
I recommend to use libplacebo and set LIBPLACEBO_GL=1 in the Makefile.
|
||||
|
||||
Libplacebo API Version >= 113 is needed.
|
||||
|
||||
|
||||
Install:
|
||||
--------
|
||||
1a) git
|
||||
@@ -100,17 +106,20 @@ Beginners Guide for libplacebo:
|
||||
When using libplacebo you will find several config options.
|
||||
|
||||
First of all you need to set the right scaler for each resolution:
|
||||
Best you beginn with setting all to "bilinear". If that works ok for you, you can try to change them
|
||||
Best you begin with setting all to "bilinear". If that works ok for you, you can try to change them
|
||||
for more advanced scaler. I use ewa_robidouxsharp on my GTX1050, but your mileage may vary.
|
||||
Unfortunatly on INTEL not all scalers may work or crash.
|
||||
The Intel GPU is much slower than NVIDIA and for UHD you most likly need to set the scaler to bilinear.
|
||||
|
||||
You can enable a Scaler Test feature. When enabled then the screen is split.On the left half you will
|
||||
see the scaler defined by Scaler Test and on the right side you will see the scaler defined at the
|
||||
Resolution setting. There is as small black line between the halfs to remaind you that Scaler Test
|
||||
is activ.
|
||||
|
||||
Then you should set the Monitor Colorspace to "sRGB". This guarantees you the best colors on your screen.
|
||||
Then you should set the Monitor Type to "sRGB". This guarantees you the best colors on your screen.
|
||||
At the moment all calculations internaly are done in RGB space and all cards output also RGB.
|
||||
If you use the softhddrm Version then you should set the Monitor Type to HD TV or UHD-HDR TV if you have
|
||||
connected one of those.
|
||||
|
||||
If you are colorblind you could try to remedy this with the Colorblind Settings. Realy only needed
|
||||
in rare cases.
|
||||
@@ -121,7 +130,17 @@ Beginners Guide for libplacebo:
|
||||
The plugins searches the shaders in $ConfigDir/plugins/shaders for the shaders. One example shader is
|
||||
provided in the shader subdirectory. Copy it to e.g.: /etc/vdr/plugins/shaders and then start
|
||||
vdr -P 'softhdcuvid -S filmgrain.glsl ...'
|
||||
|
||||
I use KrigBilateral for UV scaling and then adaptive-sharpen for sharpening. This results in a perfect
|
||||
picture for me.
|
||||
|
||||
You can also use a custon LUT File. It is located in $ConfigDir/shaders/lut/lut.cube. If you provide there
|
||||
a lut file it will be automaticly used. In the Mainmenue you can switch LUT on and off.
|
||||
|
||||
Konfig Guide for softhddrm Version
|
||||
----------------------------------
|
||||
You should set the Monitor Type to HD TV or UHD-HDR TV depending on your TV Set
|
||||
With softhddrm and a HDR TV Set you can view HDR-HLG content. This is tested with Kernel 5.12 and a Intel NUC.
|
||||
|
||||
|
||||
|
||||
Setup: environment
|
||||
|
201
drm.c
201
drm.c
@@ -23,7 +23,7 @@ struct _Drm_Render_
|
||||
uint32_t connector_id, crtc_id, video_plane;
|
||||
uint32_t hdr_metadata;
|
||||
uint32_t mmWidth,mmHeight; // Size in mm
|
||||
uint32_t hdr_blob_id;
|
||||
uint32_t hdr_blob_id;
|
||||
|
||||
};
|
||||
typedef struct _Drm_Render_ VideoRender;
|
||||
@@ -186,33 +186,33 @@ static int SetPropertyRequest(drmModeAtomicReqPtr ModeReq, int fd_drm,
|
||||
static void CuvidSetVideoMode(void);
|
||||
void set_video_mode(int width, int height)
|
||||
{
|
||||
drmModeConnector *connector;
|
||||
drmModeModeInfo *mode;
|
||||
int ii;
|
||||
if (height != 1080 && height != 2160)
|
||||
return;
|
||||
connector = drmModeGetConnector(render->fd_drm, render->connector_id);
|
||||
for (ii = 0; ii < connector->count_modes; ii++) {
|
||||
mode = &connector->modes[ii];
|
||||
printf("Mode %d %dx%d Rate %d\n",ii,mode->hdisplay,mode->vdisplay,mode->vrefresh);
|
||||
if (width == mode->hdisplay &&
|
||||
height == mode->vdisplay &&
|
||||
mode->vrefresh == DRMRefresh &&
|
||||
render->mode.hdisplay != width &&
|
||||
render->mode.vdisplay != height &&
|
||||
!(mode->flags & DRM_MODE_FLAG_INTERLACE)) {
|
||||
memcpy(&render->mode, mode, sizeof(drmModeModeInfo));
|
||||
VideoWindowWidth = mode->hdisplay;
|
||||
drmModeConnector *connector;
|
||||
drmModeModeInfo *mode;
|
||||
int ii;
|
||||
if (height != 1080 && height != 2160)
|
||||
return;
|
||||
connector = drmModeGetConnector(render->fd_drm, render->connector_id);
|
||||
for (ii = 0; ii < connector->count_modes; ii++) {
|
||||
mode = &connector->modes[ii];
|
||||
printf("Mode %d %dx%d Rate %d\n",ii,mode->hdisplay,mode->vdisplay,mode->vrefresh);
|
||||
if (width == mode->hdisplay &&
|
||||
height == mode->vdisplay &&
|
||||
mode->vrefresh == DRMRefresh &&
|
||||
render->mode.hdisplay != width &&
|
||||
render->mode.vdisplay != height &&
|
||||
!(mode->flags & DRM_MODE_FLAG_INTERLACE)) {
|
||||
memcpy(&render->mode, mode, sizeof(drmModeModeInfo));
|
||||
VideoWindowWidth = mode->hdisplay;
|
||||
VideoWindowHeight = mode->vdisplay;
|
||||
eglDestroySurface (eglDisplay, eglSurface);
|
||||
EglCheck();
|
||||
gbm_surface_destroy (gbm.surface);
|
||||
InitBo(render->bpp);
|
||||
CuvidSetVideoMode();
|
||||
Debug(3,"Set new mode %d:%d\n",mode->hdisplay,mode->vdisplay);
|
||||
break;
|
||||
}
|
||||
}
|
||||
eglDestroySurface (eglDisplay, eglSurface);
|
||||
EglCheck();
|
||||
gbm_surface_destroy (gbm.surface);
|
||||
InitBo(render->bpp);
|
||||
CuvidSetVideoMode();
|
||||
Debug(3,"Set new mode %d:%d\n",mode->hdisplay,mode->vdisplay);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int FindDevice(VideoRender * render)
|
||||
@@ -234,33 +234,33 @@ static int FindDevice(VideoRender * render)
|
||||
#ifdef RASPI
|
||||
render->fd_drm = open("/dev/dri/card1", O_RDWR);
|
||||
#else
|
||||
render->fd_drm = open("/dev/dri/card0", O_RDWR);
|
||||
render->fd_drm = open("/dev/dri/card0", O_RDWR);
|
||||
#endif
|
||||
if (render->fd_drm < 0) {
|
||||
fprintf(stderr, "FindDevice: cannot open /dev/dri/card0: %m\n");
|
||||
return -errno;
|
||||
}
|
||||
|
||||
int ret = drmSetMaster(render->fd_drm);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
drm_magic_t magic;
|
||||
|
||||
int ret = drmSetMaster(render->fd_drm);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
drm_magic_t magic;
|
||||
|
||||
ret = drmGetMagic(render->fd_drm, &magic);
|
||||
if (ret < 0)
|
||||
{
|
||||
Debug(3, "drm:%s - failed to get drm magic: %s\n", __FUNCTION__, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
ret = drmGetMagic(render->fd_drm, &magic);
|
||||
if (ret < 0)
|
||||
{
|
||||
Debug(3, "drm:%s - failed to get drm magic: %s\n", __FUNCTION__, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = drmAuthMagic(render->fd_drm, magic);
|
||||
if (ret < 0)
|
||||
{
|
||||
Debug(3, "drm:%s - failed to authorize drm magic: %s\n", __FUNCTION__, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
ret = drmAuthMagic(render->fd_drm, magic);
|
||||
if (ret < 0)
|
||||
{
|
||||
Debug(3, "drm:%s - failed to authorize drm magic: %s\n", __FUNCTION__, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
version = drmGetVersion(render->fd_drm);
|
||||
fprintf(stderr, "FindDevice: open /dev/dri/card0: %s\n", version->name);
|
||||
@@ -309,15 +309,15 @@ static int FindDevice(VideoRender * render)
|
||||
continue;
|
||||
|
||||
if (connector->connection == DRM_MODE_CONNECTED && connector->count_modes > 0) {
|
||||
float aspect = (float)connector->mmWidth / (float)connector->mmHeight;
|
||||
if ((aspect > 1.70) && (aspect < 1.85)) {
|
||||
render->mmHeight = 90;
|
||||
render->mmWidth = 160;
|
||||
} else {
|
||||
render->mmHeight = connector->mmHeight;
|
||||
render->mmWidth = connector->mmWidth;
|
||||
}
|
||||
render->connector_id = connector->connector_id;
|
||||
float aspect = (float)connector->mmWidth / (float)connector->mmHeight;
|
||||
if ((aspect > 1.70) && (aspect < 1.85)) {
|
||||
render->mmHeight = 90;
|
||||
render->mmWidth = 160;
|
||||
} else {
|
||||
render->mmHeight = connector->mmHeight;
|
||||
render->mmWidth = connector->mmWidth;
|
||||
}
|
||||
render->connector_id = connector->connector_id;
|
||||
// FIXME: use default encoder/crtc pair
|
||||
if ((encoder = drmModeGetEncoder(render->fd_drm, connector->encoder_id)) == NULL){
|
||||
fprintf(stderr, "FindDevice: cannot retrieve encoder (%d): %m\n", errno);
|
||||
@@ -403,7 +403,7 @@ static int FindDevice(VideoRender * render)
|
||||
#ifdef RASPI
|
||||
case DRM_FORMAT_ARGB8888:
|
||||
#else
|
||||
case DRM_FORMAT_XRGB2101010:
|
||||
case DRM_FORMAT_XRGB2101010:
|
||||
#endif
|
||||
if (!render->video_plane) {
|
||||
render->video_plane = plane->plane_id;
|
||||
@@ -440,7 +440,6 @@ void VideoInitDrm()
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
if (!(render = calloc(1, sizeof(*render)))) {
|
||||
Fatal(_("video/DRM: out of memory\n"));
|
||||
return;
|
||||
@@ -454,12 +453,15 @@ void VideoInitDrm()
|
||||
assert (gbm.dev != NULL);
|
||||
|
||||
PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display = NULL;
|
||||
|
||||
get_platform_display =
|
||||
(void *) eglGetProcAddress("eglGetPlatformDisplay");
|
||||
(void *) eglGetProcAddress("eglGetPlatformDisplayEXT");
|
||||
assert(get_platform_display != NULL);
|
||||
|
||||
eglDisplay = get_platform_display(EGL_PLATFORM_GBM_KHR, gbm.dev, NULL);
|
||||
|
||||
EglCheck();
|
||||
|
||||
assert (eglDisplay != NULL);
|
||||
// return;
|
||||
|
||||
@@ -475,7 +477,7 @@ void VideoInitDrm()
|
||||
fprintf(stderr, "cannot allocate atomic request (%d): %m\n", errno);
|
||||
return;
|
||||
}
|
||||
printf("set CRTC %d of Connector %d aktiv\n",render->crtc_id,render->connector_id);
|
||||
printf("set CRTC %d of Connector %d aktiv\n",render->crtc_id,render->connector_id);
|
||||
SetPropertyRequest(ModeReq, render->fd_drm, render->crtc_id,
|
||||
DRM_MODE_OBJECT_CRTC, "MODE_ID", modeID);
|
||||
SetPropertyRequest(ModeReq, render->fd_drm, render->connector_id,
|
||||
@@ -506,6 +508,7 @@ static int old_color=-1,old_trc=-1;
|
||||
|
||||
void InitBo(int bpp) {
|
||||
// create the GBM and EGL surface
|
||||
|
||||
render->bpp = bpp;
|
||||
gbm.surface = gbm_surface_create (gbm.dev, VideoWindowWidth,VideoWindowHeight,
|
||||
bpp==10?GBM_FORMAT_XRGB2101010:GBM_FORMAT_ARGB8888,
|
||||
@@ -518,6 +521,7 @@ void InitBo(int bpp) {
|
||||
|
||||
static struct gbm_bo *previous_bo = NULL;
|
||||
static uint32_t previous_fb;
|
||||
static int has_modeset = 0;
|
||||
|
||||
static void drm_swap_buffers () {
|
||||
|
||||
@@ -556,10 +560,13 @@ static void drm_swap_buffers () {
|
||||
DRM_MODE_OBJECT_CRTC, "ACTIVE", 0);
|
||||
if (drmModeAtomicCommit(render->fd_drm, ModeReq, flags, NULL) != 0)
|
||||
fprintf(stderr, "cannot set atomic mode (%d): %m\n", errno);
|
||||
sleep(2);
|
||||
|
||||
|
||||
SetPropertyRequest(ModeReq, render->fd_drm, render->connector_id,
|
||||
DRM_MODE_OBJECT_CONNECTOR, "Colorspace",old_color==AVCOL_PRI_BT2020?9:2 );
|
||||
SetPropertyRequest(ModeReq, render->fd_drm, render->video_plane,
|
||||
DRM_MODE_OBJECT_PLANE, "COLOR_ENCODING",old_color==AVCOL_PRI_BT2020?2:1 );
|
||||
SetPropertyRequest(ModeReq, render->fd_drm, render->video_plane,
|
||||
DRM_MODE_OBJECT_PLANE, "COLOR_RANGE",0 );
|
||||
SetPropertyRequest(ModeReq, render->fd_drm, render->crtc_id,
|
||||
DRM_MODE_OBJECT_CRTC, "MODE_ID", modeID);
|
||||
SetPropertyRequest(ModeReq, render->fd_drm, render->connector_id,
|
||||
@@ -568,13 +575,14 @@ static void drm_swap_buffers () {
|
||||
DRM_MODE_OBJECT_CRTC, "ACTIVE", 1);
|
||||
|
||||
if (drmModeAtomicCommit(render->fd_drm, ModeReq, flags, NULL) != 0)
|
||||
fprintf(stderr, "cannot set atomic mode (%d): %m\n", errno);
|
||||
fprintf(stderr, "cannot set atomic mode modeset 2 (%d): %m\n", errno);
|
||||
|
||||
if (drmModeDestroyPropertyBlob(render->fd_drm, modeID) != 0)
|
||||
fprintf(stderr, "cannot destroy prperty blob (%d): %m\n", errno);
|
||||
|
||||
drmModeAtomicFree(ModeReq);
|
||||
m_need_modeset = 0;
|
||||
has_modeset = 1;
|
||||
}
|
||||
drmModeSetCrtc (render->fd_drm, render->crtc_id, fb, 0, 0, &render->connector_id, 1, &render->mode);
|
||||
|
||||
@@ -594,7 +602,7 @@ static void drm_clean_up () {
|
||||
return;
|
||||
Debug(3,"drm clean up\n");
|
||||
|
||||
if (previous_bo) {
|
||||
if (previous_bo) {
|
||||
drmModeRmFB (render->fd_drm, previous_fb);
|
||||
gbm_surface_release_buffer (gbm.surface, previous_bo);
|
||||
}
|
||||
@@ -602,27 +610,72 @@ static void drm_clean_up () {
|
||||
drmModeSetCrtc (render->fd_drm, render->saved_crtc->crtc_id, render->saved_crtc->buffer_id,
|
||||
render->saved_crtc->x, render->saved_crtc->y, &render->connector_id, 1, &render->saved_crtc->mode);
|
||||
drmModeFreeCrtc (render->saved_crtc);
|
||||
|
||||
if (has_modeset) {
|
||||
drmModeAtomicReqPtr ModeReq;
|
||||
const uint32_t flags = DRM_MODE_ATOMIC_ALLOW_MODESET;
|
||||
uint32_t modeID = 0;
|
||||
|
||||
if (drmModeCreatePropertyBlob(render->fd_drm, &render->mode, sizeof(render->mode), &modeID) != 0) {
|
||||
fprintf(stderr, "Failed to create mode property.\n");
|
||||
return;
|
||||
}
|
||||
if (!(ModeReq = drmModeAtomicAlloc())) {
|
||||
fprintf(stderr, "cannot allocate atomic request (%d): %m\n", errno);
|
||||
return;
|
||||
}
|
||||
|
||||
// Need to disable the CRTC in order to submit the HDR data....
|
||||
SetPropertyRequest(ModeReq, render->fd_drm, render->crtc_id,
|
||||
DRM_MODE_OBJECT_CRTC, "ACTIVE", 0);
|
||||
if (drmModeAtomicCommit(render->fd_drm, ModeReq, flags, NULL) != 0)
|
||||
fprintf(stderr, "cannot set atomic mode (%d): %m\n", errno);
|
||||
|
||||
SetPropertyRequest(ModeReq, render->fd_drm, render->connector_id,
|
||||
DRM_MODE_OBJECT_CONNECTOR, "HDR_OUTPUT_METADATA", 0);
|
||||
SetPropertyRequest(ModeReq, render->fd_drm, render->connector_id,
|
||||
DRM_MODE_OBJECT_CONNECTOR, "Colorspace",2 );
|
||||
SetPropertyRequest(ModeReq, render->fd_drm, render->video_plane,
|
||||
DRM_MODE_OBJECT_PLANE, "COLOR_ENCODING",1 );
|
||||
SetPropertyRequest(ModeReq, render->fd_drm, render->video_plane,
|
||||
DRM_MODE_OBJECT_PLANE, "COLOR_RANGE",1 );
|
||||
SetPropertyRequest(ModeReq, render->fd_drm, render->crtc_id,
|
||||
DRM_MODE_OBJECT_CRTC, "MODE_ID", modeID);
|
||||
SetPropertyRequest(ModeReq, render->fd_drm, render->connector_id,
|
||||
DRM_MODE_OBJECT_CONNECTOR, "CRTC_ID", render->crtc_id);
|
||||
SetPropertyRequest(ModeReq, render->fd_drm, render->crtc_id,
|
||||
DRM_MODE_OBJECT_CRTC, "ACTIVE", 1);
|
||||
|
||||
if (drmModeAtomicCommit(render->fd_drm, ModeReq, flags, NULL) != 0)
|
||||
fprintf(stderr, "cannot set atomic mode (%d): %m\n", errno);
|
||||
|
||||
if (drmModeDestroyPropertyBlob(render->fd_drm, modeID) != 0)
|
||||
fprintf(stderr, "cannot destroy prperty blob (%d): %m\n", errno);
|
||||
|
||||
drmModeAtomicFree(ModeReq);
|
||||
has_modeset = 0;
|
||||
}
|
||||
|
||||
if (render->hdr_blob_id)
|
||||
drmModeDestroyPropertyBlob(render->fd_drm, render->hdr_blob_id);
|
||||
render->hdr_blob_id = 0;
|
||||
render->hdr_blob_id = 0;
|
||||
|
||||
eglDestroySurface (eglDisplay, eglSurface);
|
||||
EglCheck();
|
||||
EglCheck();
|
||||
gbm_surface_destroy (gbm.surface);
|
||||
eglDestroyContext (eglDisplay, eglContext);
|
||||
EglCheck();
|
||||
eglDestroyContext (eglDisplay, eglSharedContext);
|
||||
EglCheck();
|
||||
eglSharedContext = NULL;
|
||||
EglCheck();
|
||||
eglDestroyContext (eglDisplay, eglSharedContext);
|
||||
EglCheck();
|
||||
eglSharedContext = NULL;
|
||||
|
||||
eglTerminate (eglDisplay);
|
||||
EglCheck();
|
||||
EglCheck();
|
||||
|
||||
gbm_device_destroy (gbm.dev);
|
||||
drmDropMaster(render->fd_drm);
|
||||
drmDropMaster(render->fd_drm);
|
||||
close (render->fd_drm);
|
||||
eglDisplay = NULL;
|
||||
free(render);
|
||||
eglDisplay = NULL;
|
||||
free(render);
|
||||
|
||||
}
|
||||
|
51
hdr.c
51
hdr.c
@@ -1,5 +1,5 @@
|
||||
#include <libavutil/mastering_display_metadata.h>
|
||||
|
||||
#ifndef _DRM_MODE_H
|
||||
/**
|
||||
* struct hdr_metadata_infoframe - HDR Metadata Infoframe Data.
|
||||
*
|
||||
@@ -85,7 +85,7 @@ struct hdr_output_metadata {
|
||||
struct hdr_metadata_infoframe hdmi_metadata_type1;
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
enum hdr_metadata_eotf {
|
||||
@@ -335,17 +335,12 @@ static void set_hdr_metadata(int color,int trc, AVFrameSideData *sd1, AVFrameSid
|
||||
struct AVMasteringDisplayMetadata *md = NULL;
|
||||
struct AVContentLightMetadata *ld = NULL;
|
||||
|
||||
if (render->hdr_metadata == -1) { // Metadata not supported
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// clean up FFMEPG stuff
|
||||
if (trc == AVCOL_TRC_BT2020_10)
|
||||
trc = AVCOL_TRC_ARIB_STD_B67;
|
||||
if (trc == AVCOL_TRC_UNSPECIFIED)
|
||||
trc = AVCOL_TRC_BT709;
|
||||
if (color == AVCOL_PRI_UNSPECIFIED)
|
||||
color = AVCOL_PRI_BT709;
|
||||
|
||||
|
||||
if ((old_color == color && old_trc == trc && !sd1 && !sd2) || !render->hdr_metadata)
|
||||
return; // nothing to do
|
||||
@@ -371,12 +366,15 @@ static void set_hdr_metadata(int color,int trc, AVFrameSideData *sd1, AVFrameSid
|
||||
|
||||
Debug(3,"Update HDR to TRC %d color %d\n",trc,color);
|
||||
|
||||
if (trc == AVCOL_TRC_BT2020_10)
|
||||
trc = AVCOL_TRC_ARIB_STD_B67;
|
||||
|
||||
old_color = color;
|
||||
old_trc = trc;
|
||||
|
||||
|
||||
if (VulkanTargetColorSpace != 3) { // no HDR TV
|
||||
m_need_modeset = 1; // change in colorsettings
|
||||
return;
|
||||
}
|
||||
|
||||
if (render->hdr_blob_id)
|
||||
drmModeDestroyPropertyBlob(render->fd_drm, render->hdr_blob_id);
|
||||
|
||||
@@ -467,24 +465,25 @@ static void set_hdr_metadata(int color,int trc, AVFrameSideData *sd1, AVFrameSid
|
||||
eotf);
|
||||
|
||||
|
||||
|
||||
ret = drmModeCreatePropertyBlob(render->fd_drm, &data, sizeof(data), &render->hdr_blob_id);
|
||||
if (ret) {
|
||||
printf("DRM: HDR metadata: failed blob create \n");
|
||||
|
||||
ret = drmModeCreatePropertyBlob(render->fd_drm, &data, sizeof(data), &render->hdr_blob_id);
|
||||
if (ret) {
|
||||
printf("DRM: HDR metadata: failed blob create \n");
|
||||
render->hdr_blob_id = 0;
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
ret = drmModeConnectorSetProperty(render->fd_drm, render->connector_id,
|
||||
render->hdr_metadata, render->hdr_blob_id);
|
||||
if (ret) {
|
||||
printf("DRM: HDR metadata: failed property set %d\n",ret);
|
||||
ret = drmModeConnectorSetProperty(render->fd_drm, render->connector_id,
|
||||
render->hdr_metadata, render->hdr_blob_id);
|
||||
if (ret) {
|
||||
printf("DRM: HDR metadata: failed property set %d\n",ret);
|
||||
|
||||
if (render->hdr_blob_id)
|
||||
drmModeDestroyPropertyBlob(render->fd_drm, render->hdr_blob_id);
|
||||
if (render->hdr_blob_id)
|
||||
drmModeDestroyPropertyBlob(render->fd_drm, render->hdr_blob_id);
|
||||
render->hdr_blob_id = 0;
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
m_need_modeset = 1;
|
||||
|
||||
Debug(3,"DRM: HDR metadata: prop set\n");
|
||||
|
13
shaders.h
13
shaders.h
@@ -123,17 +123,17 @@ static const struct gl_vao_entry vertex_vao[] = {
|
||||
char sh[SHADER_LENGTH];
|
||||
char shv[SHADER_LENGTH];
|
||||
|
||||
GL_init()
|
||||
void GL_init()
|
||||
{
|
||||
sh[0] = 0;
|
||||
}
|
||||
|
||||
GLV_init()
|
||||
void GLV_init()
|
||||
{
|
||||
shv[0] = 0;
|
||||
}
|
||||
|
||||
pl_shader_append(const char *fmt, ...)
|
||||
void pl_shader_append(const char *fmt, ...)
|
||||
{
|
||||
char temp[1000];
|
||||
va_list ap;
|
||||
@@ -148,7 +148,7 @@ pl_shader_append(const char *fmt, ...)
|
||||
|
||||
}
|
||||
|
||||
pl_shader_append_v(const char *fmt, ...)
|
||||
void pl_shader_append_v(const char *fmt, ...)
|
||||
{
|
||||
char temp[1000];
|
||||
va_list ap;
|
||||
@@ -280,6 +280,7 @@ static GLuint sc_generate(GLuint gl_prog, enum AVColorSpace colorspace)
|
||||
|
||||
switch (colorspace) {
|
||||
case AVCOL_SPC_RGB:
|
||||
case AVCOL_SPC_BT470BG:
|
||||
m = &yuv_bt601.m[0][0];
|
||||
c = &yuv_bt601.c[0];
|
||||
Debug(3, "BT601 Colorspace used\n");
|
||||
@@ -339,8 +340,9 @@ static GLuint sc_generate(GLuint gl_prog, enum AVColorSpace colorspace)
|
||||
GLSL("color.rgb = max(color.rgb, 0.0); \n");
|
||||
// GLSL("color.rgb = clamp(color.rgb, 0.0, 1.0); \n");
|
||||
// GLSL("color.rgb = pow(color.rgb, vec3(2.4)); \n");
|
||||
// GLSL("color.rgb = mix(vec3(4.0) * color.rgb * color.rgb,exp((color.rgb - vec3(%f)) * vec3(1.0/%f)) + vec3(%f),bvec3(lessThan(vec3(0.5), color.rgb)));\n",HLG_C, HLG_A, HLG_B);
|
||||
// GLSL("color.rgb = mix(vec3(4.0) * color.rgb * color.rgb,exp((color.rgb - vec3(%f)) * vec3(1.0/%f)) + vec3(%f) , bvec3(lessThan(vec3(0.5), color.rgb)));\n",HLG_C, HLG_A, HLG_B);
|
||||
GLSL("color.rgb = mix(vec3(4.0) * color.rgb * color.rgb,exp((color.rgb - vec3(0.55991073)) * vec3(1.0/0.17883277)) + vec3(0.28466892), bvec3(lessThan(vec3(0.5), color.rgb)));\n");
|
||||
GLSL("color.rgb *= vec3(1.0/3.17955); \n"); // PL_COLOR_SDR_WHITE_HLG
|
||||
GLSL("// color mapping \n");
|
||||
GLSL("color.rgb = cms_matrix * color.rgb; \n");
|
||||
#ifndef GAMMA
|
||||
@@ -348,6 +350,7 @@ static GLuint sc_generate(GLuint gl_prog, enum AVColorSpace colorspace)
|
||||
GLSL("color.rgb = max(color.rgb, 0.0); \n");
|
||||
// GLSL("color.rgb = clamp(color.rgb, 0.0, 1.0); \n");
|
||||
// GLSL("color.rgb = pow(color.rgb, vec3(1.0/2.4)); \n");
|
||||
GLSL("color.rgb *= vec3(3.17955); \n"); // PL_COLOR_SDR_WHITE_HLG
|
||||
GLSL("color.rgb = mix(vec3(0.5) * sqrt(color.rgb), vec3(0.17883277) * log(color.rgb - vec3(0.28466892)) + vec3(0.55991073), bvec3(lessThan(vec3(1.0), color.rgb))); \n");
|
||||
|
||||
#endif
|
||||
|
@@ -51,9 +51,11 @@ extern "C"
|
||||
#include "video.h"
|
||||
#include "codec.h"
|
||||
#endif
|
||||
#if PLACEBO
|
||||
#ifdef PLACEBO
|
||||
#include <libplacebo/filters.h>
|
||||
extern void ToggleLUT();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@@ -61,7 +63,7 @@ extern "C"
|
||||
/// vdr-plugin version number.
|
||||
/// Makefile extracts the version number for generating the file name
|
||||
/// for the distribution archive.
|
||||
static const char *const VERSION = "3.3.1"
|
||||
static const char *const VERSION = "3.5"
|
||||
#ifdef GIT_REV
|
||||
"-GIT" GIT_REV
|
||||
#endif
|
||||
@@ -106,7 +108,8 @@ static int ConfigVideoBrightness; ///< config video brightness
|
||||
static int ConfigVideoContrast = 100; ///< config video contrast
|
||||
static int ConfigVideoSaturation = 100; ///< config video saturation
|
||||
static int ConfigVideoHue; ///< config video hue
|
||||
static int ConfigGamma=100; ///< config Gamma
|
||||
static int ConfigGamma=100; ///< config Gamma
|
||||
static int ConfigTemperature=0; ///< config Temperature
|
||||
static int ConfigTargetColorSpace; ///< config Target Colrospace
|
||||
static int ConfigScalerTest; /// Test for Scalers
|
||||
static int ConfigColorBlindness;
|
||||
@@ -977,6 +980,7 @@ class cMenuSetupSoft:public cMenuSetupPage
|
||||
int Saturation;
|
||||
int Hue;
|
||||
int Gamma;
|
||||
int Temperature;
|
||||
int TargetColorSpace;
|
||||
int ScalerTest;
|
||||
int ColorBlindnessFaktor;
|
||||
@@ -1107,10 +1111,11 @@ void cMenuSetupSoft::Create(void)
|
||||
static const char *const resolution[RESOLUTIONS] = {
|
||||
"576i", "720p", "fake 1080", "1080", "2160p"
|
||||
};
|
||||
#ifdef PLACEBO
|
||||
|
||||
static const char *const target_colorspace[] = {
|
||||
"Monitor", "sRGB", "BT709", "HDR-HLG", "HDR10",
|
||||
"default Monitor", "sRGB Monitor", "HD TV (BT.709)", "UHD-HDR TV (BT.2020)",
|
||||
};
|
||||
#ifdef PLACEBO
|
||||
static const char *const target_colorblindness[] = {
|
||||
"None", "Protanomaly", "Deuteranomaly", "Tritanomaly", "Monochromacy",
|
||||
};
|
||||
@@ -1125,7 +1130,7 @@ void cMenuSetupSoft::Create(void)
|
||||
|
||||
if (scalers == 0) {
|
||||
scalingtest[0] = (char *)"Off";
|
||||
for (scalers = 0; pl_named_filters[scalers].filter != NULL; scalers++) {
|
||||
for (scalers = 0; pl_named_filters[scalers].name != NULL; scalers++) {
|
||||
scaling[scalers] = (char *)pl_named_filters[scalers].name;
|
||||
scalingtest[scalers + 1] = (char *)pl_named_filters[scalers].name;
|
||||
// printf("Scaler %s\n",pl_named_filters[scalers].name);
|
||||
@@ -1199,12 +1204,12 @@ void cMenuSetupSoft::Create(void)
|
||||
Add(new cMenuEditIntItem(tr("Saturation (0..100)"), &Saturation, 0, 100, tr("min"), tr("max")));
|
||||
Add(new cMenuEditIntItem(tr("Gamma (0..100)"), &Gamma, 0, 100, tr("min"), tr("max")));
|
||||
Add(new cMenuEditIntItem(tr("Hue (-314..314) "), &Hue, -314, 314, tr("min"), tr("max")));
|
||||
Add(new cMenuEditStraItem(tr("Monitor Colorspace"), &TargetColorSpace, 5, target_colorspace));
|
||||
Add(new cMenuEditIntItem(tr("Temperature 6500K + x * 100K"), &Temperature, -35, 35, NULL, NULL));
|
||||
|
||||
Add(new cMenuEditStraItem(tr("Color Blindness"), &ColorBlindness, 5, target_colorblindness));
|
||||
Add(new cMenuEditIntItem(tr("Color Correction (-100..100) "), &ColorBlindnessFaktor, -100, 100, tr("min"),
|
||||
tr("max")));
|
||||
Add(new cMenuEditIntItem(tr("Color Correction (-100..100) "), &ColorBlindnessFaktor, -100, 100, tr("min"), tr("max")));
|
||||
#endif
|
||||
|
||||
Add(new cMenuEditStraItem(tr("Monitor Type"), &TargetColorSpace, 4, target_colorspace));
|
||||
for (i = 0; i < RESOLUTIONS; ++i) {
|
||||
cString msg;
|
||||
|
||||
@@ -1399,6 +1404,7 @@ cMenuSetupSoft::cMenuSetupSoft(void)
|
||||
Saturation = ConfigVideoSaturation;
|
||||
Hue = ConfigVideoHue;
|
||||
Gamma = ConfigGamma;
|
||||
Temperature = ConfigTemperature;
|
||||
TargetColorSpace = ConfigTargetColorSpace;
|
||||
ColorBlindness = ConfigColorBlindness;
|
||||
ColorBlindnessFaktor = ConfigColorBlindnessFaktor;
|
||||
@@ -1531,6 +1537,8 @@ void cMenuSetupSoft::Store(void)
|
||||
VideoSetSaturation(ConfigVideoSaturation);
|
||||
SetupStore("Gamma", ConfigGamma = Gamma);
|
||||
VideoSetGamma(ConfigGamma);
|
||||
SetupStore("Temperature", ConfigTemperature = Temperature);
|
||||
VideoSetTemperature(ConfigTemperature);
|
||||
SetupStore("TargetColorSpace", ConfigTargetColorSpace = TargetColorSpace);
|
||||
VideoSetTargetColor(ConfigTargetColorSpace);
|
||||
SetupStore("Hue", ConfigVideoHue = Hue);
|
||||
@@ -2143,13 +2151,15 @@ void cSoftHdMenu::Create(void)
|
||||
} else {
|
||||
Add(new cOsdItem(hk(tr("Suspend SoftHdDevice")), osUser1));
|
||||
}
|
||||
#ifdef PLACEBO
|
||||
Add(new cOsdItem(hk(tr("Toggle LUT on/off")), osUser2));
|
||||
#endif
|
||||
#ifdef USE_PIP
|
||||
if (PipReceiver) {
|
||||
Add(new cOsdItem(hk(tr("PIP toggle on/off: off")), osUser2));
|
||||
Add(new cOsdItem(hk(tr("PIP toggle on/off: off")), osUser3));
|
||||
} else {
|
||||
Add(new cOsdItem(hk(tr("PIP toggle on/off: on")), osUser2));
|
||||
Add(new cOsdItem(hk(tr("PIP toggle on/off: on")), osUser3));
|
||||
}
|
||||
Add(new cOsdItem(hk(tr("PIP zapmode (not working)")), osUser3));
|
||||
Add(new cOsdItem(hk(tr("PIP channel +")), osUser4));
|
||||
Add(new cOsdItem(hk(tr("PIP channel -")), osUser5));
|
||||
if (PipReceiver) {
|
||||
@@ -2163,6 +2173,7 @@ void cSoftHdMenu::Create(void)
|
||||
Add(new cOsdItem(hk(tr("PIP swap position: alternative")), osUser7));
|
||||
}
|
||||
Add(new cOsdItem(hk(tr("PIP close")), osUser8));
|
||||
|
||||
#endif
|
||||
Add(new cOsdItem(NULL, osUnknown, false));
|
||||
Add(new cOsdItem(NULL, osUnknown, false));
|
||||
@@ -2402,8 +2413,13 @@ eOSState cSoftHdMenu::ProcessKey(eKeys key)
|
||||
}
|
||||
}
|
||||
return osEnd;
|
||||
#ifdef PLACEBO
|
||||
case osUser2:
|
||||
ToggleLUT();
|
||||
return osEnd;
|
||||
#endif
|
||||
#ifdef USE_PIP
|
||||
case osUser2:
|
||||
case osUser3:
|
||||
TogglePip();
|
||||
return osEnd;
|
||||
case osUser4:
|
||||
@@ -2613,6 +2629,8 @@ bool cSoftHdDevice::SetPlayMode(ePlayMode play_mode)
|
||||
case pmExtern_THIS_SHOULD_BE_AVOIDED:
|
||||
dsyslog("[softhddev] play mode external\n");
|
||||
// FIXME: what if already suspended?
|
||||
Setup.CurrentVolume = cDevice::CurrentVolume();
|
||||
Setup.Save();
|
||||
Suspend(1, 1, 0);
|
||||
SuspendMode = SUSPEND_EXTERNAL;
|
||||
#ifdef USE_OPENGLOSD
|
||||
@@ -2632,7 +2650,8 @@ bool cSoftHdDevice::SetPlayMode(ePlayMode play_mode)
|
||||
Resume();
|
||||
SuspendMode = NOT_SUSPENDED;
|
||||
}
|
||||
|
||||
if (!cDevice::IsMute())
|
||||
SetVolume(cDevice::CurrentVolume(), true);
|
||||
return::SetPlayMode(play_mode);
|
||||
}
|
||||
|
||||
@@ -3311,6 +3330,14 @@ bool cPluginSoftHdDevice::SetupParse(const char *name, const char *value)
|
||||
ConfigGamma = i > 100 ? 100 : i;
|
||||
VideoSetGamma(ConfigGamma);
|
||||
return true;
|
||||
}
|
||||
if (!strcasecmp(name, "Temperature")) {
|
||||
int i;
|
||||
|
||||
i = atoi(value);
|
||||
ConfigTemperature = i > 100 ? 100 : i;
|
||||
VideoSetTemperature(ConfigTemperature);
|
||||
return true;
|
||||
}
|
||||
if (!strcasecmp(name, "TargetColorSpace")) {
|
||||
VideoSetTargetColor(ConfigTargetColorSpace = atoi(value));
|
||||
|
10
softhddev.c
10
softhddev.c
@@ -1793,7 +1793,7 @@ static void VideoStreamClose(VideoStream * stream, int delhw)
|
||||
*/
|
||||
int VideoPollInput(VideoStream * stream)
|
||||
{
|
||||
if (!stream->Decoder) { // closing
|
||||
if (!stream->Decoder || !stream->HwDecoder) { // closing
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "no decoder\n");
|
||||
#endif
|
||||
@@ -1810,9 +1810,9 @@ int VideoPollInput(VideoStream * stream)
|
||||
stream->PacketRead = stream->PacketWrite;
|
||||
// FIXME: ->Decoder already checked
|
||||
Debug(3, "Clear buffer request in Poll\n");
|
||||
if (stream->Decoder) {
|
||||
if (stream->Decoder && stream->HwDecoder) {
|
||||
CodecVideoFlushBuffers(stream->Decoder);
|
||||
VideoResetStart(stream->HwDecoder);
|
||||
// VideoResetStart(stream->HwDecoder);
|
||||
}
|
||||
stream->ClearBuffers = 0;
|
||||
return 1;
|
||||
@@ -3391,8 +3391,8 @@ void GetStats(int *missed, int *duped, int *dropped, int *counter, float *framet
|
||||
*frametime = 0.0f;
|
||||
*width = 0;
|
||||
*height = 0;
|
||||
*color = NULL;
|
||||
*eotf = NULL;
|
||||
*color = 0;
|
||||
*eotf = 0;
|
||||
if (MyVideoStream->HwDecoder) {
|
||||
VideoGetStats(MyVideoStream->HwDecoder, missed, duped, dropped, counter, frametime, width, height, color,
|
||||
eotf);
|
||||
|
Reference in New Issue
Block a user