mirror of
https://github.com/jojo61/vdr-plugin-softhdcuvid.git
synced 2023-10-10 13:37:41 +02:00
Reworked the aspect function. Now we calculate the display aspect from the pixel width and
pixel height (and not from the physical size, which was the root cause for rounding errors). Cropping calculation is reworking, now the rounding is correct. I introduce a new aspect mode "original" which displays the output with the original size (but after correction the pixel aspect ratio). Tested with vaapi(X11) and vaapi(DRM) with and without libplacebo.
This commit is contained in:
parent
36c208967e
commit
23651104f2
@ -283,11 +283,13 @@ Setup: /etc/vdr/setup.conf
|
||||
0 pan and scan
|
||||
1 letter box
|
||||
2 center cut-out
|
||||
3 original
|
||||
|
||||
softhddevice.VideoOtherDisplayFormat = 1
|
||||
0 pan and scan
|
||||
1 pillar box
|
||||
2 center cut-out
|
||||
3 original
|
||||
|
||||
softhddevice.pip.X = 79
|
||||
softhddevice.pip.Y = 78
|
||||
@ -378,6 +380,3 @@ Running:
|
||||
Known Bugs:
|
||||
-----------
|
||||
SD Streams not working very well on vaapi
|
||||
|
||||
|
||||
|
||||
|
5
drm.c
5
drm.c
@ -475,9 +475,8 @@ void VideoInitDrm()
|
||||
|
||||
void get_drm_aspect(int *num,int *den)
|
||||
{
|
||||
Debug(3,"mmHeight %d mmWidth %d VideoHeight %d VideoWidth %d\n",render->mmHeight,render->mmWidth,VideoWindowHeight,VideoWindowWidth);
|
||||
*num = VideoWindowWidth * render->mmHeight;
|
||||
*den = VideoWindowHeight * render->mmWidth;
|
||||
*num = VideoWindowWidth;
|
||||
*den = VideoWindowHeight;
|
||||
}
|
||||
|
||||
struct gbm_bo *bo = NULL, *next_bo=NULL;
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
/*
|
||||
* Copyright 1993-2013 NVIDIA Corporation. All rights reserved.
|
||||
*
|
||||
|
40
po/de_DE.po
40
po/de_DE.po
@ -7,7 +7,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: VDR \n"
|
||||
"Report-Msgid-Bugs-To: <see README>\n"
|
||||
"POT-Creation-Date: 2019-10-26 18:41+0200\n"
|
||||
"POT-Creation-Date: 2020-04-13 16:26+0200\n"
|
||||
"PO-Revision-Date: blabla\n"
|
||||
"Last-Translator: blabla\n"
|
||||
"Language-Team: blabla\n"
|
||||
@ -263,9 +263,6 @@ msgstr ""
|
||||
msgid "codec: can't allocate video codec context\n"
|
||||
msgstr ""
|
||||
|
||||
msgid "VAAPI Refcounts invalid\n"
|
||||
msgstr ""
|
||||
|
||||
msgid "codec: can't set option deint to video codec!\n"
|
||||
msgstr ""
|
||||
|
||||
@ -306,24 +303,6 @@ msgstr ""
|
||||
msgid "codec/audio: decoded data smaller than encoded\n"
|
||||
msgstr ""
|
||||
|
||||
msgid "codec/audio: resample setup error\n"
|
||||
msgstr ""
|
||||
|
||||
msgid "codec/audio: overwrite resample\n"
|
||||
msgstr ""
|
||||
|
||||
msgid "codec/audio: AvResample setup error\n"
|
||||
msgstr ""
|
||||
|
||||
msgid "codec: latm\n"
|
||||
msgstr ""
|
||||
|
||||
msgid "codec: error audio data\n"
|
||||
msgstr ""
|
||||
|
||||
msgid "codec: error more than one frame data\n"
|
||||
msgstr ""
|
||||
|
||||
msgid "codec/audio: can't setup resample\n"
|
||||
msgstr ""
|
||||
|
||||
@ -642,7 +621,7 @@ msgid " Frames missed(%d) duped(%d) dropped(%d) total(%d)"
|
||||
msgstr " Frames verloren(%d) verdoppelt(%d) übersprungen(%d) Gesamt(%d)"
|
||||
|
||||
#, c-format
|
||||
msgid " Frame Process time %2.2fms"
|
||||
msgid " Video %dx%d Color: %s Gamma: %s"
|
||||
msgstr ""
|
||||
|
||||
msgid "pass-through disabled"
|
||||
@ -807,10 +786,6 @@ msgstr ""
|
||||
msgid "video/glx: no GLX support\n"
|
||||
msgstr ""
|
||||
|
||||
#, c-format
|
||||
msgid "video/glx: glx version %d.%d\n"
|
||||
msgstr ""
|
||||
|
||||
msgid "did not get FBconfig"
|
||||
msgstr ""
|
||||
|
||||
@ -898,11 +873,10 @@ msgid "Failed rendering frame!\n"
|
||||
msgstr ""
|
||||
|
||||
#, c-format
|
||||
msgid "video/vdpau: output buffer full, dropping frame (%d/%d)\n"
|
||||
msgid "video/cuvid: output buffer full, dropping frame (%d/%d)\n"
|
||||
msgstr ""
|
||||
|
||||
#, c-format
|
||||
msgid "video/vdpau: pixel format %d not supported\n"
|
||||
msgid "Could not dynamically load CUDA\n"
|
||||
msgstr ""
|
||||
|
||||
msgid "Kein Cuda device gefunden"
|
||||
@ -943,12 +917,6 @@ msgstr ""
|
||||
msgid "video/egl: can't create thread egl context\n"
|
||||
msgstr ""
|
||||
|
||||
msgid "video: can't queue cancel video display thread\n"
|
||||
msgstr ""
|
||||
|
||||
msgid "video: can't cancel video display thread\n"
|
||||
msgstr ""
|
||||
|
||||
#, c-format
|
||||
msgid "video: repeated pict %d found, but not handled\n"
|
||||
msgstr ""
|
||||
|
@ -1096,10 +1096,10 @@ void cMenuSetupSoft::Create(void)
|
||||
"auto", "1920x1080", "1280x720", "custom",
|
||||
};
|
||||
static const char *const video_display_formats_4_3[] = {
|
||||
"pan&scan", "letterbox", "center cut-out",
|
||||
"pan&scan", "letterbox", "center cut-out", "original"
|
||||
};
|
||||
static const char *const video_display_formats_16_9[] = {
|
||||
"pan&scan", "pillarbox", "center cut-out",
|
||||
"pan&scan", "pillarbox", "center cut-out", "original"
|
||||
};
|
||||
#ifdef YADIF
|
||||
static const char *const deinterlace[] = {
|
||||
@ -1182,9 +1182,9 @@ void cMenuSetupSoft::Create(void)
|
||||
Add(new cMenuEditBoolItem(tr("Enable Screensaver(DPMS) at black screen"), &EnableDPMSatBlackScreen,
|
||||
trVDR("no"), trVDR("yes")));
|
||||
#endif
|
||||
Add(new cMenuEditStraItem(trVDR("4:3 video display format"), &Video4to3DisplayFormat, 3,
|
||||
Add(new cMenuEditStraItem(trVDR("4:3 video display format"), &Video4to3DisplayFormat, 4,
|
||||
video_display_formats_4_3));
|
||||
Add(new cMenuEditStraItem(trVDR("16:9+other video display format"), &VideoOtherDisplayFormat, 3,
|
||||
Add(new cMenuEditStraItem(trVDR("16:9+other video display format"), &VideoOtherDisplayFormat, 4,
|
||||
video_display_formats_16_9));
|
||||
|
||||
#if 0
|
||||
|
125
video.c
125
video.c
@ -253,7 +253,7 @@ typedef enum _video_zoom_modes_
|
||||
VideoNormal, ///< normal
|
||||
VideoStretch, ///< stretch to all edges
|
||||
VideoCenterCutOut, ///< center and cut out
|
||||
VideoAnamorphic, ///< anamorphic scaled (unsupported)
|
||||
VideoNone, ///< no scaling
|
||||
} VideoZoomModes;
|
||||
|
||||
///
|
||||
@ -679,44 +679,35 @@ static void VideoUpdateOutput(AVRational input_aspect_ratio, int input_width, in
|
||||
AVRational display_aspect_ratio;
|
||||
AVRational tmp_ratio;
|
||||
|
||||
// input not initialized yet, return immediately
|
||||
if (!input_aspect_ratio.num || !input_aspect_ratio.den) {
|
||||
input_aspect_ratio.num = 1;
|
||||
input_aspect_ratio.den = 1;
|
||||
Debug(3, "video: aspect defaults to %d:%d\n", input_aspect_ratio.num, input_aspect_ratio.den);
|
||||
|
||||
}
|
||||
|
||||
av_reduce(&input_aspect_ratio.num, &input_aspect_ratio.den, input_width * input_aspect_ratio.num,
|
||||
input_height * input_aspect_ratio.den, 1024 * 1024);
|
||||
|
||||
// InputWidth/Height can be zero = uninitialized
|
||||
if (!input_aspect_ratio.num || !input_aspect_ratio.den) {
|
||||
input_aspect_ratio.num = 1;
|
||||
input_aspect_ratio.den = 1;
|
||||
output_width = video_width;
|
||||
output_height = video_height;
|
||||
return;
|
||||
}
|
||||
#ifdef USE_DRM
|
||||
get_drm_aspect(&display_aspect_ratio.num, &display_aspect_ratio.den);
|
||||
#else
|
||||
Debug(3, "mmHeight %d mm Width %d VideoHeight %d VideoWidth %d\n", VideoScreen->height_in_millimeters,
|
||||
VideoScreen->width_in_millimeters, VideoScreen->height_in_pixels, VideoScreen->width_in_pixels);
|
||||
display_aspect_ratio.num = VideoScreen->width_in_pixels * VideoScreen->height_in_millimeters;
|
||||
display_aspect_ratio.den = VideoScreen->height_in_pixels * VideoScreen->width_in_millimeters;
|
||||
display_aspect_ratio.num = VideoScreen->width_in_pixels;
|
||||
display_aspect_ratio.den = VideoScreen->height_in_pixels;
|
||||
#endif
|
||||
display_aspect_ratio = av_mul_q(input_aspect_ratio, display_aspect_ratio);
|
||||
Debug(3, "video: aspect %d:%d Resolution %d\n", display_aspect_ratio.num, display_aspect_ratio.den, resolution);
|
||||
av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den, display_aspect_ratio.num, display_aspect_ratio.den,
|
||||
1024 * 1024);
|
||||
|
||||
Debug(3, "video: input %dx%d (%d:%d)\n", input_width, input_height, input_aspect_ratio.num,
|
||||
input_aspect_ratio.den);
|
||||
Debug(3, "video: display aspect %d:%d Resolution %d\n", display_aspect_ratio.num, display_aspect_ratio.den,
|
||||
resolution);
|
||||
Debug(3, "video: video %+d%+d %dx%d\n", video_x, video_y, video_width, video_height);
|
||||
|
||||
*crop_x = VideoCutLeftRight[resolution];
|
||||
*crop_y = VideoCutTopBottom[resolution];
|
||||
*crop_width = input_width - VideoCutLeftRight[resolution] * 2;
|
||||
*crop_height = input_height - VideoCutTopBottom[resolution] * 2;
|
||||
CuvidMessage(2, "video: crop to %+d%+d %dx%d\n", *crop_x, *crop_y, *crop_width, *crop_height);
|
||||
|
||||
// FIXME: store different positions for the ratios
|
||||
tmp_ratio.num = 4;
|
||||
tmp_ratio.den = 3;
|
||||
#ifdef DEBUG
|
||||
Debug(4, "ratio: %d:%d %d:%d\n", input_aspect_ratio.num, input_aspect_ratio.den, display_aspect_ratio.num,
|
||||
display_aspect_ratio.den);
|
||||
#endif
|
||||
if (!av_cmp_q(input_aspect_ratio, tmp_ratio)) {
|
||||
switch (Video4to3ZoomMode) {
|
||||
case VideoNormal:
|
||||
@ -725,9 +716,8 @@ static void VideoUpdateOutput(AVRational input_aspect_ratio, int input_width, in
|
||||
goto stretch;
|
||||
case VideoCenterCutOut:
|
||||
goto center_cut_out;
|
||||
case VideoAnamorphic:
|
||||
// FIXME: rest should be done by hardware
|
||||
goto stretch;
|
||||
case VideoNone:
|
||||
goto video_none;
|
||||
}
|
||||
}
|
||||
switch (VideoOtherZoomMode) {
|
||||
@ -737,28 +727,24 @@ static void VideoUpdateOutput(AVRational input_aspect_ratio, int input_width, in
|
||||
goto stretch;
|
||||
case VideoCenterCutOut:
|
||||
goto center_cut_out;
|
||||
case VideoAnamorphic:
|
||||
// FIXME: rest should be done by hardware
|
||||
goto stretch;
|
||||
case VideoNone:
|
||||
goto video_none;
|
||||
}
|
||||
|
||||
normal:
|
||||
*output_x = video_x;
|
||||
*output_y = video_y;
|
||||
*output_width =
|
||||
(video_height * display_aspect_ratio.num + display_aspect_ratio.den - 1) / display_aspect_ratio.den;
|
||||
*output_height =
|
||||
(video_width * display_aspect_ratio.den + display_aspect_ratio.num - 1) / display_aspect_ratio.num;
|
||||
*output_height = video_height;
|
||||
*output_width = (*crop_width * *output_height * input_aspect_ratio.num) / (input_aspect_ratio.den * *crop_height);
|
||||
if (*output_width > video_width) {
|
||||
*output_width = video_width;
|
||||
*output_height =
|
||||
(*crop_height * *output_width * input_aspect_ratio.den) / (input_aspect_ratio.num * *crop_width);
|
||||
*output_y += (video_height - *output_height) / 2;
|
||||
} else if (*output_height > video_height) {
|
||||
*output_height = video_height;
|
||||
} else if (*output_width < video_width) {
|
||||
*output_x += (video_width - *output_width) / 2;
|
||||
}
|
||||
|
||||
CuvidMessage(2, "video: normal aspect output %dx%d%+d%+d Video %dx%d\n", *output_width, *output_height, *output_x,
|
||||
*output_y, video_width, video_height);
|
||||
CuvidMessage(2, "video: normal aspect output %dx%d%+d%+d\n", *output_width, *output_height, *output_x, *output_y);
|
||||
return;
|
||||
|
||||
stretch:
|
||||
@ -766,49 +752,34 @@ static void VideoUpdateOutput(AVRational input_aspect_ratio, int input_width, in
|
||||
*output_y = video_y;
|
||||
*output_width = video_width;
|
||||
*output_height = video_height;
|
||||
Debug(3, "video: stretch output %dx%d%+d%+d\n", *output_width, *output_height, *output_x, *output_y);
|
||||
CuvidMessage(2, "video: stretch output %dx%d%+d%+d\n", *output_width, *output_height, *output_x, *output_y);
|
||||
return;
|
||||
|
||||
center_cut_out:
|
||||
*output_x = video_x;
|
||||
*output_y = video_y;
|
||||
*output_height = video_height;
|
||||
*output_width = (*crop_width * *output_height * input_aspect_ratio.num) / (input_aspect_ratio.den * *crop_height);
|
||||
if (*output_width > video_width) {
|
||||
// fix height cropping
|
||||
*crop_width = (int)((*crop_width * video_width) / (*output_width * 2.0) + 0.5) * 2;
|
||||
*crop_x = (input_width - *crop_width) / 2;
|
||||
*output_width = video_width;
|
||||
} else if (*output_width < video_width) {
|
||||
// fix width cropping
|
||||
*crop_height = (int)((*crop_height * *output_width) / (video_width * 2.0) + 0.5) * 2;
|
||||
*crop_y = (input_height - *crop_height) / 2;
|
||||
*output_width = video_width;
|
||||
|
||||
*crop_width = (video_height * display_aspect_ratio.num + display_aspect_ratio.den - 1) / display_aspect_ratio.den;
|
||||
*crop_height = (video_width * display_aspect_ratio.den + display_aspect_ratio.num - 1) / display_aspect_ratio.num;
|
||||
|
||||
// look which side must be cut
|
||||
if (*crop_width > video_width) {
|
||||
int tmp;
|
||||
|
||||
*crop_height = input_height - VideoCutTopBottom[resolution] * 2;
|
||||
|
||||
// adjust scaling
|
||||
tmp = ((*crop_width - video_width) * input_width) / (2 * video_width);
|
||||
// FIXME: round failure?
|
||||
if (tmp > *crop_x) {
|
||||
*crop_x = tmp;
|
||||
}
|
||||
*crop_width = input_width - *crop_x * 2;
|
||||
} else if (*crop_height > video_height) {
|
||||
int tmp;
|
||||
CuvidMessage(2, "video: aspect crop %dx%d%+d%+d\n", *crop_width, *crop_height, *crop_x, *crop_y);
|
||||
return;
|
||||
|
||||
*crop_width = input_width - VideoCutLeftRight[resolution] * 2;
|
||||
|
||||
// adjust scaling
|
||||
tmp = ((*crop_height - video_height) * input_height)
|
||||
/ (2 * video_height);
|
||||
// FIXME: round failure?
|
||||
if (tmp > *crop_y) {
|
||||
*crop_y = tmp;
|
||||
}
|
||||
*crop_height = input_height - *crop_y * 2;
|
||||
} else {
|
||||
*crop_width = input_width - VideoCutLeftRight[resolution] * 2;
|
||||
*crop_height = input_height - VideoCutTopBottom[resolution] * 2;
|
||||
}
|
||||
Debug(3, "video: aspect crop %dx%d%+d%+d\n", *crop_width, *crop_height, *crop_x, *crop_y);
|
||||
video_none:
|
||||
*output_height = *crop_height;
|
||||
*output_width = (*crop_width * input_aspect_ratio.num) / input_aspect_ratio.den; // normalize pixel aspect ratio
|
||||
*output_x = video_x + (video_width - *output_width) / 2;
|
||||
*output_y = video_y + (video_height - *output_height) / 2;
|
||||
CuvidMessage(2, "video: original aspect output %dx%d%+d%+d\n", *output_width, *output_height, *output_x, *output_y);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2649,7 +2620,7 @@ int init_filters(AVCodecContext * dec_ctx, CuvidDecoder * decoder, AVFrame * fra
|
||||
enum AVPixelFormat format = PIXEL_FORMAT;
|
||||
|
||||
#ifdef VAAPI
|
||||
const char *filters_descr = "deinterlace_vaapi=rate=field:auto=1"; //
|
||||
const char *filters_descr = "deinterlace_vaapi=rate=field:auto=1";
|
||||
#endif
|
||||
#ifdef YADIF
|
||||
const char *filters_descr = "yadif_cuda=1:0:1"; // mode=send_field,parity=tff,deint=interlaced";
|
||||
@ -6515,13 +6486,13 @@ void VideoSetDeinterlace(int mode[VideoResolutionMax])
|
||||
VideoDeinterlace[1] = 1; //mode[1]; // 720p
|
||||
VideoDeinterlace[2] = mode[2]; // fake 1080
|
||||
VideoDeinterlace[3] = mode[3]; // 1080
|
||||
VideoDeinterlace[4] = 1, //mode[4]; 2160p
|
||||
VideoDeinterlace[4] = 1; //mode[4]; 2160p
|
||||
#else
|
||||
VideoDeinterlace[0] = 1; // 576i
|
||||
VideoDeinterlace[1] = 0; //mode[1]; // 720p
|
||||
VideoDeinterlace[2] = 1; // fake 1080
|
||||
VideoDeinterlace[3] = 1; // 1080
|
||||
VideoDeinterlace[4] = 0, //mode[4]; 2160p
|
||||
VideoDeinterlace[4] = 0; //mode[4]; 2160p
|
||||
#endif
|
||||
VideoSurfaceModesChanged = 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user