Ticket #4653: 25_skiploop_option.dpatch

File 25_skiploop_option.dpatch, 13.8 KB (added by laga@…, 16 years ago)

Updated the patch to work if you only have one playback thread. Thanks to janneg for pointing this out

Line 
1#! /bin/sh /usr/share/dpatch/dpatch-run
2## 25_skiploop_option.dpatch by Michael Haas <laga@laga.ath.cx>
3##
4## All lines beginning with `## DP:' are a description of the patch.
5## DP: Add a checkbox to disable the deblocking loop filter for h.264 ffmpeg.
6## DP: Enable this checkbox to reduce CPU usage when playing h.264 content.
7## DP: Original patch by reidjr_at_lineone_net, updated by Robert Mcnamara
8
9@DPATCH@
10
11===================================================================
12--- a/libs/libmythtv/avformatdecoder.cpp        (revision 16446)
13+++ b/libs/libmythtv/avformatdecoder.cpp        (working copy)
14@@ -1487,6 +1487,7 @@
15                 vdp.SetInput(QSize(width, height));
16                 QString dec = vdp.GetDecoder();
17                 uint thread_count = vdp.GetMaxCPUs();
18+                bool skip_loop_filter = vdp.IsSkipLoopEnabled();
19                 VERBOSE(VB_PLAYBACK, QString("Using %1 CPUs for decoding")
20                         .arg(ENABLE_THREADS ? thread_count : 1));
21
22@@ -1500,6 +1501,12 @@
23                     enc->thread_count = thread_count;
24                 }
25
26+                if  (!skip_loop_filter)
27+                {
28+                    enc->skip_loop_filter = AVDISCARD_ALL;
29+                }
30+
31+
32                 bool handled = false;
33 #ifdef USING_XVMC
34                 if (!using_null_videoout && mpeg_version(enc->codec_id))
35
36 
37Index: libs/libmythtv/videodisplayprofile.h
38===================================================================
39--- a/libs/libmythtv/videodisplayprofile.h      (revision 16446)
40+++ b/libs/libmythtv/videodisplayprofile.h      (working copy)
41@@ -84,6 +84,9 @@
42     uint GetMaxCPUs(void) const
43         { return GetPreference("pref_max_cpus").toUInt(); }
44 
45+    bool IsSkipLoopEnabled(void) const
46+        { return GetPreference("pref_skiploop").toInt(); }
47+   
48     QString GetVideoRenderer(void) const
49         { return GetPreference("pref_videorenderer"); }
50 
51@@ -125,7 +128,7 @@
52         uint grpid, uint priority,
53         QString cmp0, uint width0, uint height0,
54         QString cmp1, uint width1, uint height1,
55-        QString decoder, uint max_cpus, QString videorenderer,
56+        QString decoder, uint max_cpus, bool skiploop, QString videorenderer,
57         QString osdrenderer, bool osdfade,
58         QString deint0, QString deint1, QString filters);
59 
60Index: libs/libmythtv/videodisplayprofile.cpp
61===================================================================
62--- a/libs/libmythtv/videodisplayprofile.cpp    (revision 16446)
63+++ b/libs/libmythtv/videodisplayprofile.cpp    (working copy)
64@@ -170,6 +170,7 @@
65     QString cmp1      = Get("pref_cmp1");
66     QString decoder   = Get("pref_decoder");
67     uint    max_cpus  = Get("pref_max_cpus").toUInt();
68+    bool    skiploop  = Get("pref_skiploop").toInt();
69     QString renderer  = Get("pref_videorenderer");
70     QString osd       = Get("pref_osdrenderer");
71     QString deint0    = Get("pref_deint0");
72@@ -177,9 +178,9 @@
73     QString filter    = Get("pref_filters");
74     bool    osdfade   = Get("pref_osdfade").toInt();
75 
76-    QString str =  QString("cmp(%1%2) dec(%3) cpus(%4) rend(%5) ")
77+    QString str =  QString("cmp(%1%2) dec(%3) cpus(%4) skiploop(%5) rend(%6) ")
78         .arg(cmp0).arg(QString(cmp1.isEmpty() ? "" : ",") + cmp1)
79-        .arg(decoder).arg(max_cpus).arg(renderer);
80+        .arg(decoder).arg(max_cpus).arg((skiploop) ? "enabled" : "disabled").arg(renderer);
81     str += QString("osd(%1) osdfade(%2) deint(%3,%4) filt(%5)")
82         .arg(osd).arg((osdfade) ? "enabled" : "disabled")
83         .arg(deint0).arg(deint1).arg(filter);
84@@ -799,7 +800,7 @@
85     uint groupid, uint priority,
86     QString cmp0, uint width0, uint height0,
87     QString cmp1, uint width1, uint height1,
88-    QString decoder, uint max_cpus, QString videorenderer,
89+    QString decoder, uint max_cpus, bool skiploop, QString videorenderer,
90     QString osdrenderer, bool osdfade,
91     QString deint0, QString deint1, QString filters)
92 {
93@@ -845,6 +846,9 @@
94     queryValue += "pref_max_cpus";
95     queryData  += QString::number(max_cpus);
96 
97+    queryValue += "pref_skiploop";
98+    queryData  += (skiploop) ? "1" : "0";
99+
100     queryValue += "pref_videorenderer";
101     queryData  += videorenderer;
102 
103@@ -958,48 +962,48 @@
104     DeleteProfileGroup("CPU++", hostname);
105     uint groupid = CreateProfileGroup("CPU++", hostname);
106     CreateProfile(groupid, 1, ">", 0, 0, "", 0, 0,
107-                  "ffmpeg", 1, "xv-blit", "softblend", true,
108+                  "ffmpeg", 1, true, "xv-blit", "softblend", true,
109                   "bobdeint", "linearblend", "");
110     CreateProfile(groupid, 2, ">", 0, 0, "", 0, 0,
111-                  "ffmpeg", 1, "quartz-blit", "softblend", true,
112+                  "ffmpeg", 1, true, "quartz-blit", "softblend", true,     
113                   "linearblend", "linearblend", "");
114 
115     (void) QObject::tr("CPU+", "Sample: Hardware assist HD only");
116     DeleteProfileGroup("CPU+", hostname);
117     groupid = CreateProfileGroup("CPU+", hostname);
118     CreateProfile(groupid, 1, "<=", 720, 576, ">", 0, 0,
119-                  "ffmpeg", 1, "xv-blit", "softblend", true,
120+                  "ffmpeg", 1, true, "xv-blit", "softblend", true,
121                   "bobdeint", "linearblend", "");
122     CreateProfile(groupid, 2, "<=", 1280, 720, ">", 720, 576,
123-                  "xvmc", 1, "xvmc-blit", "opengl", true,
124+                  "xvmc", 1, true, "xvmc-blit", "opengl", true,
125                   "bobdeint", "onefield", "");
126     CreateProfile(groupid, 3, "<=", 1280, 720, ">", 720, 576,
127-                  "libmpeg2", 1, "xv-blit", "softblend", true,
128+                  "libmpeg2", 1, true, "xv-blit", "softblend", true,
129                   "bobdeint", "onefield", "");
130     CreateProfile(groupid, 4, ">", 0, 0, "", 0, 0,
131-                  "xvmc", 1, "xvmc-blit", "ia44blend", false,
132+                  "xvmc", 1, true, "xvmc-blit", "ia44blend", false,
133                   "bobdeint", "onefield", "");
134     CreateProfile(groupid, 5, ">", 0, 0, "", 0, 0,
135-                  "libmpeg2", 1, "xv-blit", "chromakey", false,
136+                  "libmpeg2", 1, true, "xv-blit", "chromakey", false,
137                   "bobdeint", "onefield", "");
138 
139     (void) QObject::tr("CPU--", "Sample: Hardware assist all");
140     DeleteProfileGroup("CPU--", hostname);
141     groupid = CreateProfileGroup("CPU--", hostname);
142     CreateProfile(groupid, 1, "<=", 720, 576, ">", 0, 0,
143-                  "ivtv", 1, "ivtv", "ivtv", true,
144+                  "ivtv", 1, true, "ivtv", "ivtv", true,
145                   "none", "none", "");
146     CreateProfile(groupid, 2, "<=", 720, 576, ">", 0, 0,
147-                  "xvmc", 1, "xvmc-blit", "ia44blend", false,
148+                  "xvmc", 1, true, "xvmc-blit", "ia44blend", false,
149                   "bobdeint", "onefield", "");
150     CreateProfile(groupid, 3, "<=", 1280, 720, ">", 720, 576,
151-                  "xvmc", 1, "xvmc-blit", "ia44blend", false,
152+                  "xvmc", 1, true, "xvmc-blit", "ia44blend", false,
153                   "bobdeint", "onefield", "");
154     CreateProfile(groupid, 4, ">", 0, 0, "", 0, 0,
155-                  "xvmc", 1, "xvmc-blit", "ia44blend", false,
156+                  "xvmc", 1, true, "xvmc-blit", "ia44blend", false,
157                   "bobdeint", "onefield", "");
158     CreateProfile(groupid, 5, ">", 0, 0, "", 0, 0,
159-                  "libmpeg2", 1, "xv-blit", "chromakey", false,
160+                  "libmpeg2", 1, true, "xv-blit", "chromakey", false,
161                   "none", "none", "");
162 }
163 
164@@ -1009,48 +1013,48 @@
165     DeleteProfileGroup("High Quality", hostname);
166     uint groupid = CreateProfileGroup("High Quality", hostname);
167     CreateProfile(groupid, 1, ">=", 1920, 1080, "", 0, 0,
168-                  "ffmpeg", 2, "xv-blit", "softblend", true,
169+                  "ffmpeg", 2, true, "xv-blit", "softblend", true,
170                   "linearblend", "linearblend", "");
171     CreateProfile(groupid, 2, ">", 0, 0, "", 0, 0,
172-                  "ffmpeg", 1, "xv-blit", "softblend", true,
173+                  "ffmpeg", 1, true, "xv-blit", "softblend", true,
174                   "yadifdoubleprocessdeint", "yadifdeint", "");
175     CreateProfile(groupid, 3, ">=", 1920, 1080, "", 0, 0,
176-                  "ffmpeg", 2, "quartz-blit", "softblend", true,
177+                  "ffmpeg", 2, true, "quartz-blit", "softblend", true,
178                   "linearblend", "linearblend", "");
179     CreateProfile(groupid, 4, ">", 0, 0, "", 0, 0,
180-                  "ffmpeg", 1, "quartz-blit", "softblend", true,
181+                  "ffmpeg", 1, true, "quartz-blit", "softblend", true,
182                   "yadifdoubleprocessdeint", "yadifdeint", "");
183 
184     (void) QObject::tr("Normal", "Sample: average quality");
185     DeleteProfileGroup("Normal", hostname);
186     groupid = CreateProfileGroup("Normal", hostname);
187     CreateProfile(groupid, 1, ">=", 1280, 720, "", 0, 0,
188-                  "ffmpeg", 1, "xv-blit", "softblend", false,
189+                  "ffmpeg", 1, true, "xv-blit", "softblend", false,
190                   "linearblend", "linearblend", "");
191     CreateProfile(groupid, 2, ">", 0, 0, "", 0, 0,
192-                  "ffmpeg", 1, "xv-blit", "softblend", true,
193+                  "ffmpeg", 1, true, "xv-blit", "softblend", true,
194                   "greedyhdoubleprocessdeint", "kerneldeint", "");
195     CreateProfile(groupid, 3, ">=", 1280, 720, "", 0, 0,
196-                  "ffmpeg", 1, "quartz-blit", "softblend", false,
197+                  "ffmpeg", 1, true, "quartz-blit", "softblend", false,
198                   "linearblend", "linearblend", "");
199     CreateProfile(groupid, 4, ">", 0, 0, "", 0, 0,
200-                  "ffmpeg", 1, "quartz-blit", "softblend", true,
201+                  "ffmpeg", 1, true, "quartz-blit", "softblend", true,
202                   "greedyhdoubleprocessdeint", "kerneldeint", "");
203 
204     (void) QObject::tr("Slim", "Sample: low CPU usage");
205     DeleteProfileGroup("Slim", hostname);
206     groupid = CreateProfileGroup("Slim", hostname);
207     CreateProfile(groupid, 1, ">=", 1280, 720, "", 0, 0,
208-                  "ffmpeg", 1, "xv-blit", "softblend", false,
209+                  "ffmpeg", 1, true, "xv-blit", "softblend", false,
210                   "onefield", "onefield", "");
211     CreateProfile(groupid, 2, ">", 0, 0, "", 0, 0,
212-                  "ffmpeg", 1, "xv-blit", "softblend", true,
213+                  "ffmpeg", 1, true, "xv-blit", "softblend", true,
214                   "linearblend", "linearblend", "");
215     CreateProfile(groupid, 3, ">=", 1280, 720, "", 0, 0,
216-                  "ffmpeg", 1, "quartz-blit", "softblend", false,
217+                  "ffmpeg", 1, true, "quartz-blit", "softblend", false,
218                   "onefield", "onefield", "");
219     CreateProfile(groupid, 4, ">", 0, 0, "", 0, 0,
220-                  "ffmpeg", 1, "quartz-blit", "softblend", true,
221+                  "ffmpeg", 1, true, "quartz-blit", "softblend", true,
222                   "linearblend", "linearblend", "");
223 }
224 
225Index: programs/mythfrontend/globalsettings.cpp
226===================================================================
227--- a/programs/mythfrontend/globalsettings.cpp  (revision 16446)
228+++ b/programs/mythfrontend/globalsettings.cpp  (working copy)
229@@ -846,6 +846,7 @@
230     height[1] = new TransSpinBoxSetting(0, 1088, 64, true);
231     decoder   = new TransComboBoxSetting();
232     max_cpus  = new TransSpinBoxSetting(1, ENABLE_THREADS ? 4 : 1, 1, true);
233+    skiploop  = new TransCheckBoxSetting();
234     vidrend   = new TransComboBoxSetting();
235     osdrend   = new TransComboBoxSetting();
236     osdfade   = new TransCheckBoxSetting();
237@@ -877,6 +878,7 @@
238 
239     decoder->setLabel(tr("Decoder"));
240     max_cpus->setLabel(tr("Max CPUs"));
241+    skiploop->setLabel(tr("Loopfilter"));
242     vidrend->setLabel(tr("Video Renderer"));
243     osdrend->setLabel(tr("OSD Renderer"));
244     osdfade->setLabel(tr("OSD Fade"));
245@@ -894,6 +896,12 @@
246     filters->setHelpText(
247         QObject::tr("Example Custom filter list: 'ivtc,denoise3d'"));
248 
249+    skiploop->setHelpText(
250+        tr("When unchecked the deblocking loopfilter will be disabled "
251+           "for h264 decoding.") + "\n" +
252+        tr("Disabling will significantly reduce the load on the CPU "
253+           "when watching HD h264."));
254+
255     osdfade->setHelpText(
256         tr("When unchecked the OSD will not fade away but instead "
257            "will disappear abruptly.") + "\n" +
258@@ -902,7 +910,7 @@
259 
260     vid_row->addChild(decoder);
261     vid_row->addChild(max_cpus);
262-
263+    vid_row->addChild(skiploop);
264     osd_row->addChild(vidrend);
265     osd_row->addChild(osdrend);
266     osd_row->addChild(osdfade);
267@@ -955,6 +963,7 @@
268 
269     QString pdecoder  = item.Get("pref_decoder");
270     QString pmax_cpus = item.Get("pref_max_cpus");
271+    QString pskiploop  = item.Get("pref_skiploop");
272     QString prenderer = item.Get("pref_videorenderer");
273     QString posd      = item.Get("pref_osdrenderer");
274     QString posdfade  = item.Get("pref_osdfade");
275@@ -982,6 +991,9 @@
276 
277     if (!pmax_cpus.isEmpty())
278         max_cpus->setValue(pmax_cpus.toUInt());
279+
280+    skiploop->setValue((!pskiploop.isEmpty()) ? (bool) pskiploop.toInt() : true);
281+
282     if (!prenderer.isEmpty())
283         vidrend->setValue(prenderer);
284     if (!posd.isEmpty())
285@@ -1015,6 +1027,7 @@
286 
287     item.Set("pref_decoder",       decoder->getValue());
288     item.Set("pref_max_cpus",      max_cpus->getValue());
289+    item.Set("pref_skiploop",       (skiploop->boolValue()) ? "1" : "0");
290     item.Set("pref_videorenderer", vidrend->getValue());
291     item.Set("pref_osdrenderer",   osdrend->getValue());
292     item.Set("pref_osdfade",       (osdfade->boolValue()) ? "1" : "0");
293Index: programs/mythfrontend/globalsettings.h
294===================================================================
295--- a/programs/mythfrontend/globalsettings.h    (revision 16446)
296+++ b/programs/mythfrontend/globalsettings.h    (working copy)
297@@ -87,6 +87,7 @@
298     TransSpinBoxSetting  *height[2];
299     TransComboBoxSetting *decoder;
300     TransSpinBoxSetting  *max_cpus;
301+    TransCheckBoxSetting *skiploop;
302     TransComboBoxSetting *vidrend;
303     TransComboBoxSetting *osdrend;
304     TransCheckBoxSetting *osdfade;