source: smplayer/trunk/src/prefperformance.cpp@ 181

Last change on this file since 181 was 181, checked in by Silvan Scherrer, 9 years ago

smplayer: update trunk to version 16.8.0

  • Property svn:eol-style set to LF
File size: 11.9 KB
Line 
1/* smplayer, GUI front-end for mplayer.
2 Copyright (C) 2006-2016 Ricardo Villalba <rvm@users.sourceforge.net>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17*/
18
19
20#include "prefperformance.h"
21#include "images.h"
22#include "global.h"
23#include "preferences.h"
24#include "playerid.h"
25
26using namespace Global;
27
28PrefPerformance::PrefPerformance(QWidget * parent, Qt::WindowFlags f)
29 : PrefWidget(parent, f )
30{
31 setupUi(this);
32
33 hwdec_combo->addItem(tr("None"), "no");
34 hwdec_combo->addItem(tr("Auto"), "auto");
35 #ifdef Q_OS_LINUX
36 hwdec_combo->addItem("vdpau", "vdpau");
37 hwdec_combo->addItem("vaapi", "vaapi");
38 hwdec_combo->addItem("vaapi-copy", "vaapi-copy");
39 #endif
40 #ifdef Q_OS_OSX
41 hwdec_combo->addItem("vda", "vda");
42 #endif
43 #ifdef Q_OS_WIN
44 hwdec_combo->addItem("dxva2-copy", "dxva2-copy");
45 #endif
46
47#ifndef Q_OS_WIN
48 priority_group->hide();
49#endif
50
51#if SMART_DVD_CHAPTERS
52 fast_chapter_check->hide();
53#endif
54
55#ifndef OBSOLETE_FAST_AUDIO_CHANGE
56 fast_audio_label->hide();
57 fast_audio_combo->hide();
58#endif
59
60#ifndef TV_SUPPORT
61 cachetv_label->hide();
62 cache_tv_spin->hide();
63 cachetv_label2->hide();
64#endif
65
66 retranslateStrings();
67}
68
69PrefPerformance::~PrefPerformance()
70{
71}
72
73QString PrefPerformance::sectionName() {
74 return tr("Performance");
75}
76
77QPixmap PrefPerformance::sectionIcon() {
78 return Images::icon("pref_performance");
79}
80
81
82void PrefPerformance::retranslateStrings() {
83 int priority = priority_combo->currentIndex();
84 int loop_filter = loopfilter_combo->currentIndex();
85
86 retranslateUi(this);
87
88 loopfilter_combo->clear();
89 loopfilter_combo->addItem( tr("Enabled"), Preferences::LoopEnabled );
90 loopfilter_combo->addItem( tr("Skip (always)"), Preferences::LoopDisabled );
91 loopfilter_combo->addItem( tr("Skip only on HD videos"), Preferences::LoopDisabledOnHD );
92
93 priority_combo->setCurrentIndex(priority);
94 loopfilter_combo->setCurrentIndex(loop_filter);
95
96 createHelp();
97}
98
99void PrefPerformance::setData(Preferences * pref) {
100 cache_auto_check->setChecked(pref->cache_auto);
101 setCacheForFiles( pref->cache_for_files );
102 setCacheForStreams( pref->cache_for_streams );
103 setCacheForDVDs( pref->cache_for_dvds );
104 setCacheForAudioCDs( pref->cache_for_audiocds );
105 setCacheForVCDs( pref->cache_for_vcds );
106#ifdef TV_SUPPORT
107 setCacheForTV( pref->cache_for_tv );
108#endif
109
110#ifdef Q_OS_WIN
111 setPriority( pref->priority );
112#endif
113 setFrameDrop( pref->frame_drop );
114 setHardFrameDrop( pref->hard_frame_drop );
115 setCoreavcUsage( pref->coreavc );
116 setSkipLoop( pref->h264_skip_loop_filter );
117#if !SMART_DVD_CHAPTERS
118 setFastChapterSeeking( pref->fast_chapter_change );
119#endif
120#ifdef OBSOLETE_FAST_AUDIO_CHANGE
121 setFastAudioSwitching( pref->fast_audio_change );
122#endif
123 setThreads( pref->threads );
124 setHwdec( pref->hwdec );
125}
126
127void PrefPerformance::getData(Preferences * pref) {
128 requires_restart = false;
129
130 TEST_AND_SET(pref->cache_auto, cache_auto_check->isChecked());
131 TEST_AND_SET(pref->cache_for_files, cacheForFiles());
132 TEST_AND_SET(pref->cache_for_streams, cacheForStreams());
133 TEST_AND_SET(pref->cache_for_dvds, cacheForDVDs());
134 TEST_AND_SET(pref->cache_for_audiocds, cacheForAudioCDs());
135 TEST_AND_SET(pref->cache_for_vcds, cacheForVCDs());
136#ifdef TV_SUPPORT
137 TEST_AND_SET(pref->cache_for_tv, cacheForTV());
138#endif
139
140#ifdef Q_OS_WIN
141 TEST_AND_SET(pref->priority, priority());
142#endif
143 TEST_AND_SET(pref->frame_drop, frameDrop());
144 TEST_AND_SET(pref->hard_frame_drop, hardFrameDrop());
145 TEST_AND_SET(pref->coreavc, coreavcUsage())
146 TEST_AND_SET(pref->h264_skip_loop_filter, skipLoop());
147#if !SMART_DVD_CHAPTERS
148 TEST_AND_SET(pref->fast_chapter_change, fastChapterSeeking());
149#endif
150#ifdef OBSOLETE_FAST_AUDIO_CHANGE
151 pref->fast_audio_change = fastAudioSwitching();
152#endif
153 TEST_AND_SET(pref->threads, threads());
154 TEST_AND_SET(pref->hwdec, hwdec());
155}
156
157void PrefPerformance::setCacheForFiles(int n) {
158 cache_files_spin->setValue(n);
159}
160
161int PrefPerformance::cacheForFiles() {
162 return cache_files_spin->value();
163}
164
165void PrefPerformance::setCacheForStreams(int n) {
166 cache_streams_spin->setValue(n);
167}
168
169int PrefPerformance::cacheForStreams() {
170 return cache_streams_spin->value();
171}
172
173void PrefPerformance::setCacheForDVDs(int n) {
174 cache_dvds_spin->setValue(n);
175}
176
177int PrefPerformance::cacheForDVDs() {
178 return cache_dvds_spin->value();
179}
180
181void PrefPerformance::setCacheForAudioCDs(int n) {
182 cache_cds_spin->setValue(n);
183}
184
185int PrefPerformance::cacheForAudioCDs() {
186 return cache_cds_spin->value();
187}
188
189void PrefPerformance::setCacheForVCDs(int n) {
190 cache_vcds_spin->setValue(n);
191}
192
193int PrefPerformance::cacheForVCDs() {
194 return cache_vcds_spin->value();
195}
196
197#ifdef TV_SUPPORT
198void PrefPerformance::setCacheForTV(int n) {
199 cache_tv_spin->setValue(n);
200}
201
202int PrefPerformance::cacheForTV() {
203 return cache_tv_spin->value();
204}
205#endif
206
207#ifdef Q_OS_WIN
208void PrefPerformance::setPriority(int n) {
209 priority_combo->setCurrentIndex(n);
210}
211
212int PrefPerformance::priority() {
213 return priority_combo->currentIndex();
214}
215#endif
216
217void PrefPerformance::setFrameDrop(bool b) {
218 framedrop_check->setChecked(b);
219}
220
221bool PrefPerformance::frameDrop() {
222 return framedrop_check->isChecked();
223}
224
225void PrefPerformance::setHardFrameDrop(bool b) {
226 hardframedrop_check->setChecked(b);
227}
228
229bool PrefPerformance::hardFrameDrop() {
230 return hardframedrop_check->isChecked();
231}
232
233void PrefPerformance::setCoreavcUsage(bool b) {
234 coreavc_check->setChecked(b);
235}
236
237bool PrefPerformance::coreavcUsage() {
238 return coreavc_check->isChecked();
239}
240
241void PrefPerformance::setSkipLoop(Preferences::H264LoopFilter value) {
242 loopfilter_combo->setCurrentIndex(loopfilter_combo->findData(value));
243}
244
245Preferences::H264LoopFilter PrefPerformance::skipLoop() {
246 return (Preferences::H264LoopFilter) loopfilter_combo->itemData(loopfilter_combo->currentIndex()).toInt();
247}
248
249#if !SMART_DVD_CHAPTERS
250void PrefPerformance::setFastChapterSeeking(bool b) {
251 fast_chapter_check->setChecked(b);
252}
253
254bool PrefPerformance::fastChapterSeeking() {
255 return fast_chapter_check->isChecked();
256}
257#endif
258
259#ifdef OBSOLETE_FAST_AUDIO_CHANGE
260void PrefPerformance::setFastAudioSwitching(Preferences::OptionState value) {
261 fast_audio_combo->setState(value);
262}
263
264Preferences::OptionState PrefPerformance::fastAudioSwitching() {
265 return fast_audio_combo->state();
266}
267#endif
268
269void PrefPerformance::setThreads(int v) {
270 threads_spin->setValue(v);
271}
272
273int PrefPerformance::threads() {
274 return threads_spin->value();
275}
276
277void PrefPerformance::setHwdec(const QString & v) {
278 int idx = hwdec_combo->findData(v);
279 if (idx < 0) idx = 0;
280 hwdec_combo->setCurrentIndex(idx);
281}
282
283QString PrefPerformance::hwdec() {
284 int idx = hwdec_combo->currentIndex();
285 return hwdec_combo->itemData(idx).toString();
286}
287
288void PrefPerformance::createHelp() {
289 clearHelp();
290
291 addSectionTitle(tr("Performance"));
292
293 // Performance tab
294#ifdef Q_OS_WIN
295 setWhatsThis(priority_combo, tr("Priority"),
296 tr("Set process priority for %1 according to the predefined "
297 "priorities available under Windows.<br>"
298 "<b>Warning:</b> Using realtime priority can cause system lockup.").arg(PLAYER_NAME));
299#endif
300
301 setWhatsThis(framedrop_check, tr("Allow frame drop"),
302 tr("Skip displaying some frames to maintain A/V sync on slow systems." ) );
303
304 setWhatsThis(hardframedrop_check, tr("Allow hard frame drop"),
305 tr("More intense frame dropping (breaks decoding). "
306 "Leads to image distortion!") );
307
308 setWhatsThis(threads_spin, tr("Threads for decoding"),
309 tr("Sets the number of threads to use for decoding. Only for "
310 "MPEG-1/2 and H.264") );
311
312 setWhatsThis(hwdec_combo, tr("Hardware decoding"),
313 tr("Sets the hardware video decoding API. "
314 "If hardware decoding is not possible, software decoding will be used instead.") + " " +
315 tr("Available options:") +
316 "<ul>"
317 "<li>" + tr("None: only software decoding will be used.") + "</li>"
318 "<li>" + tr("Auto: it tries to automatically enable hardware decoding using the first available method.") + "</li>"
319 #ifdef Q_OS_LINUX
320 "<li>" + tr("vdpau: for the vdpau and opengl video outputs.") + "</li>"
321 "<li>" + tr("vaapi: for the opengl and vaapi video outputs. For Intel GPUs only.") + "</li>"
322 "<li>" + tr("vaapi-copy: it copies video back into system RAM. For Intel GPUs only.") + "</li>"
323 #endif
324 #ifdef Q_OS_WIN
325 "<li>" + tr("dxva2-copy: it copies video back to system RAM. Experimental.") + "</li>"
326 #endif
327 "</ul>"
328 #ifdef MPLAYER_SUPPORT
329 + tr("This option only works with mpv.")
330 #endif
331 );
332
333 setWhatsThis(loopfilter_combo, tr("Skip loop filter"),
334 tr("This option allows to skips the loop filter (AKA deblocking) "
335 "during H.264 decoding. "
336 "Since the filtered frame is supposed to be used as reference "
337 "for decoding dependent frames this has a worse effect on quality "
338 "than not doing deblocking on e.g. MPEG-2 video. But at least for "
339 "high bitrate HDTV this provides a big speedup with no visible "
340 "quality loss.") +"<br>"+
341 tr("Possible values:") +"<br>" +
342 tr("<b>Enabled</b>: the loop filter is not skipped")+"<br>"+
343 tr("<b>Skip (always)</b>: the loop filter is skipped no matter the "
344 "resolution of the video")+"<br>"+
345 tr("<b>Skip only on HD videos</b>: the loop filter will be "
346 "skipped only on videos which height is %1 or "
347 "greater.").arg(pref->HD_height) +"<br>" );
348
349 setWhatsThis(coreavc_check, tr("Use CoreAVC if no other codec specified"),
350 tr("Try to use the non-free CoreAVC codec when no other codec is specified "
351 "and a non-VDPAU video output is selected.") +" "+
352 tr("Requires a %1 build with CoreAVC support.").arg(PLAYER_NAME));
353
354#ifdef OBSOLETE_FAST_AUDIO_CHANGE
355 setWhatsThis(fast_audio_combo, tr("Fast audio track switching"),
356 tr("Possible values:<br> "
357 "<b>Yes</b>: it will try the fastest method "
358 "to switch the audio track (it might not work with some formats).<br> "
359 "<b>No</b>: the MPlayer process will be restarted whenever you "
360 "change the audio track.<br> "
361 "<b>Auto</b>: SMPlayer will decide what to do according to the "
362 "MPlayer version." ) );
363#endif
364
365#if !SMART_DVD_CHAPTERS
366 setWhatsThis(fast_chapter_check, tr("Fast seek to chapters in dvds"),
367 tr("If checked, it will try the fastest method to seek to chapters "
368 "but it might not work with some discs.") );
369#endif
370
371 addSectionTitle(tr("Cache"));
372
373 setWhatsThis(cache_auto_check, tr("Auto"),
374 tr("Usually this option will enable the cache when it's necessary."));
375
376 setWhatsThis(cache_files_spin, tr("Cache for files"),
377 tr("This option specifies how much memory (in kBytes) to use when "
378 "precaching a file.") );
379
380 setWhatsThis(cache_streams_spin, tr("Cache for streams"),
381 tr("This option specifies how much memory (in kBytes) to use when "
382 "precaching a URL.") );
383
384 setWhatsThis(cache_dvds_spin, tr("Cache for DVDs"),
385 tr("This option specifies how much memory (in kBytes) to use when "
386 "precaching a DVD.<br><b>Warning:</b> Seeking might not work "
387 "properly (including chapter switching) when using a cache for DVDs.") );
388
389 setWhatsThis(cache_cds_spin, tr("Cache for audio CDs"),
390 tr("This option specifies how much memory (in kBytes) to use when "
391 "precaching an audio CD.") );
392
393 setWhatsThis(cache_vcds_spin, tr("Cache for VCDs"),
394 tr("This option specifies how much memory (in kBytes) to use when "
395 "precaching a VCD.") );
396}
397
398#include "moc_prefperformance.cpp"
Note: See TracBrowser for help on using the repository browser.