|
0 |
Author: Lucian Muresan <lucianm@users.sourceforge.net>
|
|
1 |
Origin: https://patchwork.linuxtv.org/patch/16100/
|
|
2 |
|
|
3 |
Index: vdr-plugin-xine-0.9.4/xineDevice.c
|
|
4 |
===================================================================
|
|
5 |
--- vdr-plugin-xine-0.9.4.orig/xineDevice.c 2013-11-28 23:06:14.746527860 +0100
|
|
6 |
+++ vdr-plugin-xine-0.9.4/xineDevice.c 2013-11-28 23:06:14.742527860 +0100
|
|
7 |
@@ -4409,5 +4409,83 @@
|
|
8 |
{
|
|
9 |
return theXineDevice;
|
|
10 |
}
|
|
11 |
+#if APIVERSNUM >= 10733
|
|
12 |
+ ///< Asks the output device whether it can scale the currently shown video in
|
|
13 |
+ ///< such a way that it fits into the given Rect, while retaining its proper
|
|
14 |
+ ///< aspect ratio. If the scaled video doesn't exactly fit into Rect, Alignment
|
|
15 |
+ ///< is used to determine how to align the actual rectangle with the requested
|
|
16 |
+ ///< one. The actual rectangle can be smaller, larger or the same size as the
|
|
17 |
+ ///< given Rect, and its location may differ, depending on the capabilities of
|
|
18 |
+ ///< the output device, which may not be able to display a scaled video at
|
|
19 |
+ ///< arbitrary sizes and locations. The device shall, however, do its best to
|
|
20 |
+ ///< match the requested Rect as closely as possible, preferring a size and
|
|
21 |
+ ///< location that fits completely into the requested Rect if possible.
|
|
22 |
+ ///< Returns the rectangle that can actually be used when scaling the video.
|
|
23 |
+ ///< A skin plugin using this function should rearrange its content according
|
|
24 |
+ ///< to the rectangle returned from calling this function, and should especially
|
|
25 |
+ ///< be prepared for cases where the returned rectangle is way off the requested
|
|
26 |
+ ///< Rect, or even Null. In such cases, the skin may want to fall back to
|
|
27 |
+ ///< working with full screen video.
|
|
28 |
+ ///< If this device can't scale the video, a Null rectangle is returned (this
|
|
29 |
+ ///< is also the default implementation).
|
|
30 |
+ cRect cXineDevice::CanScaleVideo(const cRect &Rect, int Alignment/* = taCenter*/)
|
|
31 |
+ {
|
|
32 |
+ // first implementation: we can always scale, we're a soft device ;-), ignore alignment for now
|
|
33 |
+
|
|
34 |
+ // we need to store the value for the case we have to call ScaleVideo ourselves in vdr-xine
|
|
35 |
+ vidWinRect = Rect;
|
|
36 |
+ return vidWinRect;
|
|
37 |
+ }
|
|
38 |
+
|
|
39 |
+ ///< Scales the currently shown video in such a way that it fits into the given
|
|
40 |
+ ///< Rect. Rect should be one retrieved through a previous call to
|
|
41 |
+ ///< CanScaleVideo() (otherwise results may be undefined).
|
|
42 |
+ ///< Even if video output is scaled, the functions GetVideoSize() and
|
|
43 |
+ ///< GetOsdSize() must still return the same values as if in full screen mode!
|
|
44 |
+ ///< If this device can't scale the video, nothing happens.
|
|
45 |
+ ///< To restore full screen video, call this function with a Null rectangle.
|
|
46 |
+ void cXineDevice::ScaleVideo(const cRect &Rect/* = cRect::Null*/)
|
|
47 |
+ {
|
|
48 |
+ // refresh stored value
|
|
49 |
+ vidWinRect = Rect;
|
|
50 |
+ // let our specialized code do the actual resizing / repositioning, get accurate parameters first
|
|
51 |
+ int videoLeft, videoTop, videoWidth, videoHeight, videoZoomX, videoZoomY, osdWidth, osdHeight;
|
|
52 |
+ double videoAspect, pixelAspect;
|
|
53 |
+ m_xineLib.execFuncVideoSize(videoLeft, videoTop, videoWidth, videoHeight, videoZoomX, videoZoomY, &videoAspect);
|
|
54 |
+ GetOsdSize(osdWidth, osdHeight, pixelAspect);
|
|
55 |
+ tArea vidWinArea;
|
|
56 |
+ vidWinArea.x1 = vidWinRect.X();
|
|
57 |
+ vidWinArea.y1 = vidWinRect.Y();
|
|
58 |
+ vidWinArea.x2 = vidWinRect.X() + vidWinRect.Width();
|
|
59 |
+ vidWinArea.y2 = vidWinRect.Y() + vidWinRect.Height();
|
|
60 |
+ if (vidWinRect == cRect::Null) {
|
|
61 |
+ // will just resize to full size
|
|
62 |
+ vidWinArea.bpp = 0;
|
|
63 |
+ } else {
|
|
64 |
+ vidWinArea.bpp = 12;
|
|
65 |
+ // make corrections
|
|
66 |
+ double aspectFactor = (double(osdWidth) / double(osdHeight)) / videoAspect;
|
|
67 |
+ int output_width = vidWinRect.Height() * (videoAspect * aspectFactor);
|
|
68 |
+ int output_height = vidWinRect.Width() / (videoAspect * aspectFactor);
|
|
69 |
+ if (double(vidWinRect.Width())/double(vidWinRect.Height()) > videoAspect * aspectFactor) {
|
|
70 |
+ output_height = vidWinRect.Height();
|
|
71 |
+ vidWinArea.x1 += (vidWinRect.Width() - output_width) / 2;
|
|
72 |
+ }
|
|
73 |
+ else if (double(vidWinRect.Width())/double(vidWinRect.Height()) < videoAspect * aspectFactor) {
|
|
74 |
+ output_width = vidWinRect.Width();
|
|
75 |
+ vidWinArea.y1 += (vidWinRect.Height() - output_height) / 2;
|
|
76 |
+ }
|
|
77 |
+ vidWinArea.x2 = vidWinArea.x1 + output_width;
|
|
78 |
+ vidWinArea.y2 = vidWinArea.y1 + output_height;
|
|
79 |
+ }
|
|
80 |
+ m_xineLib.SetVideoWindow(videoWidth, videoHeight, vidWinArea);
|
|
81 |
+ }
|
|
82 |
+
|
|
83 |
+ const cRect & cXineDevice::GetScaleRect()
|
|
84 |
+ {
|
|
85 |
+ // just return the stored value
|
|
86 |
+ return vidWinRect;
|
|
87 |
+ }
|
|
88 |
|
|
89 |
+#endif // APIVERSNUM >= 10733
|
|
90 |
};
|
|
91 |
Index: vdr-plugin-xine-0.9.4/xineDevice.h
|
|
92 |
===================================================================
|
|
93 |
--- vdr-plugin-xine-0.9.4.orig/xineDevice.h 2013-11-28 23:06:14.746527860 +0100
|
|
94 |
+++ vdr-plugin-xine-0.9.4/xineDevice.h 2013-11-28 23:06:14.742527860 +0100
|
|
95 |
@@ -162,7 +162,14 @@
|
|
96 |
#else
|
|
97 |
void OnFreeOsd(cOsd *const osd);
|
|
98 |
#endif
|
|
99 |
-
|
|
100 |
+#if APIVERSNUM >= 10733
|
|
101 |
+ virtual cRect CanScaleVideo(const cRect &Rect, int Alignment = taCenter);
|
|
102 |
+ virtual void ScaleVideo(const cRect &Rect = cRect::Null);
|
|
103 |
+ const cRect & GetScaleRect();
|
|
104 |
+ private:
|
|
105 |
+ cRect vidWinRect;
|
|
106 |
+ public:
|
|
107 |
+#endif // APIVERSNUM >= 10733
|
|
108 |
cXineLib m_xineLib;
|
|
109 |
cMutex m_osdMutex;
|
|
110 |
|
|
111 |
Index: vdr-plugin-xine-0.9.4/xineOsd.c
|
|
112 |
===================================================================
|
|
113 |
--- vdr-plugin-xine-0.9.4.orig/xineOsd.c 2013-11-28 23:06:14.746527860 +0100
|
|
114 |
+++ vdr-plugin-xine-0.9.4/xineOsd.c 2013-11-28 23:08:24.570528259 +0100
|
|
115 |
@@ -105,11 +105,20 @@
|
|
116 |
|
|
117 |
#else
|
|
118 |
|
|
119 |
+#if APIVERSNUM >= 10733
|
|
120 |
+
|
|
121 |
+ // scale to the size and position stored by the last call to cDevice::CanScaleVideo
|
|
122 |
+ m_xineDevice.ScaleVideo(m_xineDevice.GetScaleRect());
|
|
123 |
+
|
|
124 |
+#else
|
|
125 |
+
|
|
126 |
#ifdef SET_VIDEO_WINDOW
|
|
127 |
|
|
128 |
m_xineLib.SetVideoWindow(maxOsdWidth, maxOsdHeight, vidWin, dontOptimize);
|
|
129 |
|
|
130 |
#endif
|
|
131 |
+
|
|
132 |
+#endif // APIVERSNUM >= 10733
|
|
133 |
|
|
134 |
int videoLeft = frameLeft;
|
|
135 |
int videoTop = frameTop;
|
|
136 |
@@ -175,6 +184,7 @@
|
|
137 |
|
|
138 |
cXineOsd::~cXineOsd()
|
|
139 |
{
|
|
140 |
+
|
|
141 |
#if APIVERSNUM < 10509
|
|
142 |
HideOsd();
|
|
143 |
#else
|
|
144 |
@@ -410,12 +420,20 @@
|
|
145 |
int maxOsdWidth, maxOsdHeight;
|
|
146 |
GetMaxOsdSize(maxOsdWidth, maxOsdHeight);
|
|
147 |
|
|
148 |
+#if APIVERSNUM >= 10733
|
|
149 |
+
|
|
150 |
+ // scale to the size and position stored by the last call to cDevice::CanScaleVideo
|
|
151 |
+ m_xineDevice.ScaleVideo(m_xineDevice.GetScaleRect());
|
|
152 |
+
|
|
153 |
+#else
|
|
154 |
#ifdef SET_VIDEO_WINDOW
|
|
155 |
|
|
156 |
m_xineLib.SetVideoWindow(maxOsdWidth, maxOsdHeight, vidWin);
|
|
157 |
|
|
158 |
#endif
|
|
159 |
|
|
160 |
+#endif // APIVERSUM >= 10733
|
|
161 |
+
|
|
162 |
int videoLeft = -1;
|
|
163 |
int videoTop = -1;
|
|
164 |
int videoWidth = -1;
|