mirror of
https://github.com/jojo61/vdr-plugin-softhdcuvid.git
synced 2023-10-10 13:37:41 +02:00
New Parameter -r for Refreshrate with DRM
Fixed aspectratio with DRM
This commit is contained in:
parent
3bed988b14
commit
d2dedb40dd
8
codec.c
8
codec.c
@ -473,7 +473,7 @@ void CodecVideoDecode(VideoDecoder * decoder, const AVPacket * avpkt)
|
||||
{
|
||||
AVCodecContext *video_ctx = decoder->VideoCtx;
|
||||
|
||||
if (video_ctx->codec_type == AVMEDIA_TYPE_VIDEO) {
|
||||
if (video_ctx->codec_type == AVMEDIA_TYPE_VIDEO && CuvidTestSurfaces()) {
|
||||
int ret;
|
||||
AVPacket pkt[1];
|
||||
AVFrame *frame;
|
||||
@ -483,7 +483,11 @@ void CodecVideoDecode(VideoDecoder * decoder, const AVPacket * avpkt)
|
||||
if (ret < 0) {
|
||||
Debug(4, "codec: sending video packet failed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!CuvidTestSurfaces())
|
||||
usleep(1000);
|
||||
|
||||
frame = av_frame_alloc();
|
||||
ret = avcodec_receive_frame(video_ctx, frame);
|
||||
if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) {
|
||||
|
10
drm.c
10
drm.c
@ -22,6 +22,7 @@ struct _Drm_Render_
|
||||
int bpp;
|
||||
uint32_t connector_id, crtc_id, video_plane;
|
||||
uint32_t hdr_metadata;
|
||||
uint32_t mmWidth,mmHeight; // Size in mm
|
||||
|
||||
};
|
||||
typedef struct _Drm_Render_ VideoRender;
|
||||
@ -199,6 +200,8 @@ static int FindDevice(VideoRender * render)
|
||||
|
||||
if (connector->connection == DRM_MODE_CONNECTED && connector->count_modes > 0) {
|
||||
render->connector_id = connector->connector_id;
|
||||
render->mmHeight = connector->mmHeight;
|
||||
render->mmWidth = connector->mmWidth;
|
||||
|
||||
// FIXME: use default encoder/crtc pair
|
||||
if ((encoder = drmModeGetEncoder(render->fd_drm, connector->encoder_id)) == NULL){
|
||||
@ -219,7 +222,7 @@ static int FindDevice(VideoRender * render)
|
||||
if (VideoWindowWidth && VideoWindowHeight) { // preset by command line
|
||||
if (VideoWindowWidth == mode->hdisplay &&
|
||||
VideoWindowHeight == mode->vdisplay &&
|
||||
mode->vrefresh == 50 &&
|
||||
mode->vrefresh == DRMRefresh &&
|
||||
!(mode->flags & DRM_MODE_FLAG_INTERLACE)) {
|
||||
memcpy(&render->mode, mode, sizeof(drmModeModeInfo));
|
||||
break;
|
||||
@ -363,6 +366,11 @@ void VideoInitDrm()
|
||||
|
||||
}
|
||||
|
||||
void get_drm_aspect(int *num,int *den)
|
||||
{
|
||||
*num = VideoWindowWidth * render->mmHeight;
|
||||
*den = VideoWindowHeight * render->mmWidth;
|
||||
}
|
||||
|
||||
struct gbm_bo *bo = NULL, *next_bo=NULL;
|
||||
struct drm_fb *fb;
|
||||
|
91
shaders.txt
91
shaders.txt
@ -1,91 +0,0 @@
|
||||
Pro 7 1080i
|
||||
|
||||
[vo/opengl] [ 1] color.r = 1.000000 * vec4(texture(texture0, texcoord0)).r;
|
||||
[vo/opengl] [ 2] color.gb = 1.000000 * vec4(texture(texture1, texcoord1)).rg;
|
||||
[vo/opengl] [ 3] // color conversion
|
||||
[vo/opengl] [ 4] color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c;
|
||||
[vo/opengl] [ 5] color.a = 1.0;
|
||||
[vo/opengl] [ 6] // color mapping
|
||||
|
||||
UHD 10 Bit
|
||||
[vo/opengl] [ 1] color.r = 1.003906 * vec4(texture(texture0, texcoord0)).r;
|
||||
[vo/opengl] [ 2] color.gb = 1.003906 * vec4(texture(texture1, texcoord1)).rg;
|
||||
[vo/opengl] [ 3] // color conversion
|
||||
[vo/opengl] [ 4] color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c;
|
||||
[vo/opengl] [ 5] color.a = 1.0;
|
||||
[vo/opengl] [ 6] // color mapping
|
||||
|
||||
|
||||
HEVC 8 Bit
|
||||
[vo/opengl] [ 1] color.r = 1.003906 * vec4(texture(texture0, texcoord0)).r;
|
||||
[vo/opengl] [ 2] color.gb = 1.003906 * vec4(texture(texture1, texcoord1)).rg;
|
||||
[vo/opengl] [ 3] // color conversion
|
||||
[vo/opengl] [ 4] color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c;
|
||||
[vo/opengl] [ 5] color.a = 1.0;
|
||||
[vo/opengl] [ 6] // color mapping
|
||||
|
||||
ZDF 720p
|
||||
[vo/opengl] [ 1] color.r = 1.000000 * vec4(texture(texture0, texcoord0)).r;
|
||||
[vo/opengl] [ 2] color.gb = 1.000000 * vec4(texture(texture1, texcoord1)).rg;
|
||||
[vo/opengl] [ 3] // color conversion
|
||||
[vo/opengl] [ 4] color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c;
|
||||
[vo/opengl] [ 5] color.a = 1.0;
|
||||
[vo/opengl] [ 6] // color mapping
|
||||
|
||||
VERTEX
|
||||
#version 330
|
||||
in vec2 vertex_position;
|
||||
in vec2 vertex_texcoord0;
|
||||
out vec2 texcoord0;
|
||||
in vec2 vertex_texcoord1;
|
||||
out vec2 texcoord1;
|
||||
in vec2 vertex_texcoord2;
|
||||
out vec2 texcoord2;
|
||||
in vec2 vertex_texcoord3;
|
||||
out vec2 texcoord3;
|
||||
in vec2 vertex_texcoord4;
|
||||
out vec2 texcoord4;
|
||||
in vec2 vertex_texcoord5;
|
||||
out vec2 texcoord5;
|
||||
void main() {
|
||||
gl_Position = vec4(vertex_position, 1.0, 1.0);
|
||||
texcoord0 = vertex_texcoord0;
|
||||
texcoord1 = vertex_texcoord1;
|
||||
texcoord2 = vertex_texcoord2;
|
||||
texcoord3 = vertex_texcoord3;
|
||||
texcoord4 = vertex_texcoord4;
|
||||
texcoord5 = vertex_texcoord5;
|
||||
}
|
||||
|
||||
FRAGMENT
|
||||
#version 330
|
||||
#define texture1D texture
|
||||
#define texture3D texture
|
||||
out vec4 out_color;
|
||||
in vec2 texcoord0;
|
||||
in vec2 texcoord1;
|
||||
in vec2 texcoord2;
|
||||
in vec2 texcoord3;
|
||||
in vec2 texcoord4;
|
||||
in vec2 texcoord5;
|
||||
uniform mat3 colormatrix;
|
||||
uniform vec3 colormatrix_c;
|
||||
uniform sampler2D texture0;
|
||||
uniform vec2 texture_size0;
|
||||
uniform mat2 texture_rot0;
|
||||
uniform vec2 pixel_size0;
|
||||
uniform sampler2D texture1;
|
||||
uniform vec2 texture_size1;
|
||||
uniform mat2 texture_rot1;
|
||||
uniform vec2 pixel_size1;
|
||||
#define LUT_POS(x, lut_size) mix(0.5 / (lut_size), 1.0 - 0.5 / (lut_size), (x))
|
||||
void main() {
|
||||
vec4 color = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
color.r = 1.000000 * vec4(texture(texture0, texcoord0)).r;
|
||||
color.gb = 1.000000 * vec4(texture(texture1, texcoord1)).rg;
|
||||
// color conversion
|
||||
color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c;
|
||||
color.a = 1.0;
|
||||
// color mapping
|
||||
out_color = color;
|
||||
}
|
13
softhddev.c
13
softhddev.c
@ -2872,7 +2872,10 @@ const char *CommandLineHelp(void)
|
||||
" -p device\taudio device for pass-through (hw:0,1 or /dev/dsp1)\n"
|
||||
" -c channel\taudio mixer channel name (fe. PCM)\n" " -d display\tdisplay of x11 server (fe. :0.0)\n"
|
||||
" -f\t\tstart with fullscreen window (only with window manager)\n"
|
||||
" -g geometry\tx11 window geometry wxh+x+y\n" " -v device\tvideo driver device (cuvid)\n"
|
||||
" -g geometry\tx11 window geometry wxh+x+y\n"
|
||||
" -r Refresh\tRefreshrate for DRM (default is 50 Hz)\n"
|
||||
" -C Connector\tConnector for DRM (default is current Connector)\n"
|
||||
" -v device\tvideo driver device (cuvid)\n"
|
||||
" -s\t\tstart in suspended mode\n" " -x\t\tstart x11 server, with -xx try to connect, if this fails\n"
|
||||
" -X args\tX11 server arguments (f.e. -nocursor)\n" " -w workaround\tenable/disable workarounds\n"
|
||||
"\tno-hw-decoder\t\tdisable hw decoder, use software decoder only\n"
|
||||
@ -2905,13 +2908,19 @@ int ProcessArgs(int argc, char *const argv[])
|
||||
#endif
|
||||
|
||||
for (;;) {
|
||||
switch (getopt(argc, argv, "-a:c:d:fg:p:sv:w:xDX:")) {
|
||||
switch (getopt(argc, argv, "-a:c:C:r:d:fg:p:sv:w:xDX:")) {
|
||||
case 'a': // audio device for pcm
|
||||
AudioSetDevice(optarg);
|
||||
continue;
|
||||
case 'c': // channel of audio mixer
|
||||
AudioSetChannel(optarg);
|
||||
continue;
|
||||
case 'C': // Connector for DRM
|
||||
VideoSetConnector(optarg);
|
||||
continue;
|
||||
case 'r': // Connector for DRM
|
||||
VideoSetRefresh(optarg);
|
||||
continue;
|
||||
case 'p': // pass-through audio device
|
||||
AudioSetPassthroughDevice(optarg);
|
||||
continue;
|
||||
|
23
video.c
23
video.c
@ -416,6 +416,12 @@ static VideoZoomModes Video4to3ZoomMode;
|
||||
/// Default zoom mode for 16:9 and others
|
||||
static VideoZoomModes VideoOtherZoomMode;
|
||||
|
||||
/// Default Value for DRM Connector
|
||||
static char *DRMConnector = NULL;
|
||||
|
||||
/// Default Value for DRM Refreshrate
|
||||
static int DRMRefresh = 50;
|
||||
|
||||
static char Video60HzMode; ///< handle 60hz displays
|
||||
static char VideoSoftStartSync; ///< soft start sync audio/video
|
||||
static const int VideoSoftStartFrames = 100; ///< soft start frames
|
||||
@ -636,8 +642,7 @@ static void VideoUpdateOutput(AVRational input_aspect_ratio, int input_width, in
|
||||
input_aspect_ratio.den = 1;
|
||||
}
|
||||
#ifdef USE_DRM
|
||||
display_aspect_ratio.num = 16;VideoWindowWidth;
|
||||
display_aspect_ratio.den = 9; VideoWindowHeight;
|
||||
get_drm_aspect(&display_aspect_ratio.num,&display_aspect_ratio.den);
|
||||
#else
|
||||
display_aspect_ratio.num = VideoScreen->width_in_pixels * VideoScreen->height_in_millimeters;
|
||||
display_aspect_ratio.den = VideoScreen->height_in_pixels * VideoScreen->width_in_millimeters;
|
||||
@ -2527,6 +2532,7 @@ static unsigned CuvidGetVideoSurface(CuvidDecoder * decoder, const AVCodecContex
|
||||
#if defined (VAAPI) || defined (YADIF)
|
||||
static void CuvidSyncRenderFrame(CuvidDecoder * decoder, const AVCodecContext * video_ctx, const AVFrame * frame);
|
||||
|
||||
|
||||
int push_filters(AVCodecContext * dec_ctx, CuvidDecoder * decoder, AVFrame * frame)
|
||||
{
|
||||
|
||||
@ -2543,7 +2549,7 @@ int push_filters(AVCodecContext * dec_ctx, CuvidDecoder * decoder, AVFrame * fra
|
||||
while ((ret = av_buffersink_get_frame(decoder->buffersink_ctx, filt_frame)) >= 0 ) {
|
||||
filt_frame->pts /= 2;
|
||||
decoder->Interlaced = 0;
|
||||
// printf("vaapideint video:new %#012" PRIx64 " old %#012" PRIx64 "\n",filt_frame->pts,frame->pts);
|
||||
// printf("vaapideint video:new %#012" PRIx64 " old %#012" PRIx64 "\n",filt_frame->pts,frame->pts);
|
||||
CuvidSyncRenderFrame(decoder, dec_ctx, filt_frame);
|
||||
filt_frame = av_frame_alloc(); // get new frame
|
||||
|
||||
@ -5930,7 +5936,18 @@ void VideoSetDevice(const char *device)
|
||||
{
|
||||
VideoDriverName = device;
|
||||
}
|
||||
|
||||
|
||||
void VideoSetConnector( char *c)
|
||||
{
|
||||
DRMConnector = c;
|
||||
}
|
||||
|
||||
void VideoSetRefresh(char *r)
|
||||
{
|
||||
DRMRefresh = atoi(r);
|
||||
}
|
||||
|
||||
///
|
||||
/// Get video driver name.
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user