Skip to content

Commit ee525d9

Browse files
authored
Merge pull request #43 from ua0lnj/master
Version 1.7.3.
2 parents 89eb133 + c1be4c8 commit ee525d9

File tree

3 files changed

+61
-43
lines changed

3 files changed

+61
-43
lines changed

mpv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "menu_options.h"
2020
#include "mpv_service.h"
2121

22-
static const char *VERSION = "1.7.2"
22+
static const char *VERSION = "1.7.3"
2323
#ifdef GIT_REV
2424
"-GIT" GIT_REV
2525
#endif

player.c

Lines changed: 58 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <locale.h>
1010
#include <string>
1111
#include <vector>
12+
#include <vdr/plugin.h>
1213

1314
#include "player.h"
1415
#include "config.h"
@@ -49,6 +50,7 @@ xcb_connection_t *Connect = NULL;
4950
xcb_window_t VideoWindow = 0;
5051
xcb_pixmap_t pixmap = XCB_NONE;
5152
xcb_cursor_t cursor = XCB_NONE;
53+
int is_softhddevice = 0;
5254

5355
#ifdef __cplusplus
5456
extern "C"
@@ -70,6 +72,26 @@ static inline void check_error(int status)
7072
}
7173
}
7274

75+
void set_deinterlace(mpv_handle *h)
76+
{
77+
if (strstr(MpvPluginConfig->HwDec.c_str(),"vaapi"))
78+
{
79+
check_error(mpv_set_option_string(h, "vf", "vavpp=deint=auto"));
80+
}
81+
else if (strstr(MpvPluginConfig->HwDec.c_str(),"vdpau"))
82+
{
83+
check_error(mpv_set_option_string(h, "vf", "vdpaupp=deint=yes:deint-mode=temporal-spatial"));
84+
}
85+
else if (strstr(MpvPluginConfig->HwDec.c_str(),"cuda"))
86+
{
87+
check_error(mpv_set_option_string(h, "vd-lavc-o", "deint=adaptive"));
88+
}
89+
else
90+
{
91+
check_error(mpv_set_option_string(h, "deinterlace", "yes"));
92+
}
93+
}
94+
7395
void *cMpvPlayer::XEventThread(void *handle)
7496
{
7597
XEvent event;
@@ -88,25 +110,30 @@ void *cMpvPlayer::XEventThread(void *handle)
88110
XWindowEvent(Dpy, VideoWindow, KeyPressMask|ButtonPressMask|StructureNotifyMask|SubstructureNotifyMask, &event);
89111
switch (event.type) {
90112
case ButtonPress:
91-
if (event.xbutton.button == 1) {
92-
Time difftime = event.xbutton.time - clicktime;
93-
if (difftime < 500) {
94-
check_error(mpv_set_option_string(Player->hMpv, "fullscreen", toggle ? "yes" : "no"));
95-
toggle = !toggle;
113+
if (is_softhddevice) {
114+
if (event.xbutton.button == 1) {
115+
Time difftime = event.xbutton.time - clicktime;
116+
if (difftime < 500) {
117+
check_error(mpv_set_option_string(Player->hMpv, "fullscreen", toggle ? "yes" : "no"));
118+
toggle = !toggle;
119+
}
120+
clicktime = event.xbutton.time;
96121
}
97-
clicktime = event.xbutton.time;
98-
}
99-
else if (event.xbutton.button == 2) {
100-
FeedKeyPress("XKeySym", "Ok", 0, 0, NULL);
101-
}
102-
else if (event.xbutton.button == 3) {
103-
FeedKeyPress("XKeySym", "Menu", 0, 0, NULL);
104-
}
105-
if (event.xbutton.button == 4) {
106-
FeedKeyPress("XKeySym", "Volume+", 0, 0, NULL);
107-
}
108-
if (event.xbutton.button == 5) {
109-
FeedKeyPress("XKeySym", "Volume-", 0, 0, NULL);
122+
else if (event.xbutton.button == 2) {
123+
FeedKeyPress("XKeySym", "Ok", 0, 0, NULL);
124+
}
125+
else if (event.xbutton.button == 3) {
126+
FeedKeyPress("XKeySym", "Menu", 0, 0, NULL);
127+
}
128+
if (event.xbutton.button == 4) {
129+
FeedKeyPress("XKeySym", "Volume+", 0, 0, NULL);
130+
}
131+
if (event.xbutton.button == 5) {
132+
FeedKeyPress("XKeySym", "Volume-", 0, 0, NULL);
133+
}
134+
} else {
135+
check_error(mpv_set_option_string(Player->hMpv, "fullscreen", toggle ? "yes" : "no"));
136+
toggle = !toggle;
110137
}
111138
break;
112139
case ButtonRelease:
@@ -194,6 +221,7 @@ void *cMpvPlayer::ObserverThread(void *handle)
194221
case MPV_EVENT_PLAYBACK_RESTART :
195222
Player->ChangeFrameRate(Player->CurrentFps()); // switching directly after the fps event causes black screen
196223
Player->PlayerIdle = 0;
224+
if (MpvPluginConfig->UseDeinterlace && !Player->Image()) set_deinterlace(Player->hMpv);
197225
break;
198226

199227
case MPV_EVENT_LOG_MESSAGE :
@@ -517,6 +545,7 @@ void cMpvPlayer::PlayerStart()
517545
PlayerIdle = 0;
518546
PlayerSpeed = 1;
519547
PlayerDiscNav = 0;
548+
isImage = 0;
520549

521550
SwitchOsdToMpv();
522551

@@ -542,6 +571,7 @@ void cMpvPlayer::PlayerStart()
542571
check_error(mpv_set_option_string(hMpv, "vo", MpvPluginConfig->VideoOut.c_str()));
543572
check_error(mpv_set_option_string(hMpv, "hwdec", MpvPluginConfig->HwDec.c_str()));
544573
check_error(mpv_set_option_string(hMpv, "gpu-context", MpvPluginConfig->GpuCtx.c_str()));
574+
check_error(mpv_set_option_string(hMpv, "hwdec-codecs", "all"));
545575
#ifdef USE_DRM
546576
if (!strcmp(MpvPluginConfig->GpuCtx.c_str(),"drm") || !strcmp(MpvPluginConfig->VideoOut.c_str(),"drm"))
547577
{
@@ -567,30 +597,7 @@ void cMpvPlayer::PlayerStart()
567597
}
568598
if (MpvPluginConfig->UseDeinterlace)
569599
{
570-
if (strstr(MpvPluginConfig->HwDec.c_str(),"vaapi"))
571-
{
572-
check_error(mpv_set_option_string(hMpv, "hwdec-codecs", "all"));
573-
check_error(mpv_set_option_string(hMpv, "vf", "vavpp=deint=auto"));
574-
}
575-
else if (strstr(MpvPluginConfig->HwDec.c_str(),"vdpau"))
576-
{
577-
check_error(mpv_set_option_string(hMpv, "hwdec-codecs", "all"));
578-
check_error(mpv_set_option_string(hMpv, "vf", "vdpaupp=deint=yes:deint-mode=temporal-spatial"));
579-
}
580-
else if (strstr(MpvPluginConfig->HwDec.c_str(),"cuda"))
581-
{
582-
check_error(mpv_set_option_string(hMpv, "hwdec-codecs", "all"));
583-
check_error(mpv_set_option_string(hMpv, "vd-lavc-o", "deint=adaptive"));
584-
}
585-
else if (strstr(MpvPluginConfig->HwDec.c_str(),"nvdec"))
586-
{
587-
check_error(mpv_set_option_string(hMpv, "hwdec-codecs", "all"));
588-
check_error(mpv_set_option_string(hMpv, "deinterlace", "yes"));
589-
}
590-
else
591-
{
592-
check_error(mpv_set_option_string(hMpv, "deinterlace", "yes"));
593-
}
600+
set_deinterlace(hMpv);
594601
}
595602
check_error(mpv_set_option_string(hMpv, "audio-device", MpvPluginConfig->AudioOut.c_str()));
596603
check_error(mpv_set_option_string(hMpv, "slang", MpvPluginConfig->Languages.c_str()));
@@ -681,6 +688,10 @@ void cMpvPlayer::PlayerStart()
681688
pthread_create(&XEventThreadHandle, NULL, XEventThread, this);
682689
RemoteStart();
683690
}
691+
if (cPluginManager::GetPlugin("softhddevice"))
692+
{
693+
is_softhddevice = 1;
694+
}
684695
}
685696

686697
void cMpvPlayer::HandlePropertyChange(mpv_event *event)
@@ -820,6 +831,11 @@ void cMpvPlayer::HandleTracksChange()
820831
TrackLanguage = Node.u.list->values[i].u.list->values[j].u.string;
821832
if (strcmp(Node.u.list->values[i].u.list->keys[j], "title") == 0)
822833
TrackTitle = Node.u.list->values[i].u.list->values[j].u.string;
834+
if (strcmp(Node.u.list->values[i].u.list->keys[j], "image") == 0)
835+
{
836+
isImage = Node.u.list->values[i].u.list->values[j].u.flag;
837+
if (isImage) check_error(mpv_set_option_string(hMpv, "deinterlace", "no"));
838+
}
823839
}
824840
if (TrackType == "audio")
825841
{

player.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class cMpvPlayer:public cPlayer
6464
vector<string> ListFilenames; // filenames in playlist
6565
vector<string> ListTitles ; // titles in playlist
6666
int isNetwork; // detect network stream
67+
int isImage;
6768
int windowWidth;
6869
int windowHeight;
6970
int windowX;
@@ -136,6 +137,7 @@ class cMpvPlayer:public cPlayer
136137
string ListTitle(unsigned int pos) {if (pos <= ListTitles.size() && pos) return ListTitles[pos-1]; else return ""; }
137138
string ListFilename(unsigned int pos) {if (pos <= ListFilenames.size() && pos) return ListFilenames[pos-1]; else return ""; }
138139
int NetworkPlay() { return isNetwork; }
140+
int Image() {return isImage; }
139141
int WindowWidth() { return windowWidth; }
140142
int WindowHeight() { return windowHeight; }
141143
};

0 commit comments

Comments
 (0)