[112] | 1 | /* smplayer, GUI front-end for mplayer.
|
---|
[188] | 2 | Copyright (C) 2006-2017 Ricardo Villalba <rvm@users.sourceforge.net>
|
---|
[112] | 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"
|
---|
[176] | 24 | #include "playerid.h"
|
---|
[112] | 25 |
|
---|
| 26 | using namespace Global;
|
---|
| 27 |
|
---|
| 28 | PrefPerformance::PrefPerformance(QWidget * parent, Qt::WindowFlags f)
|
---|
| 29 | : PrefWidget(parent, f )
|
---|
| 30 | {
|
---|
| 31 | setupUi(this);
|
---|
| 32 |
|
---|
[176] | 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 |
|
---|
[112] | 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 |
|
---|
[176] | 55 | #ifndef OBSOLETE_FAST_AUDIO_CHANGE
|
---|
| 56 | fast_audio_label->hide();
|
---|
| 57 | fast_audio_combo->hide();
|
---|
[124] | 58 | #endif
|
---|
| 59 |
|
---|
[181] | 60 | #ifndef TV_SUPPORT
|
---|
| 61 | cachetv_label->hide();
|
---|
| 62 | cache_tv_spin->hide();
|
---|
| 63 | cachetv_label2->hide();
|
---|
| 64 | #endif
|
---|
| 65 |
|
---|
[112] | 66 | retranslateStrings();
|
---|
| 67 | }
|
---|
| 68 |
|
---|
| 69 | PrefPerformance::~PrefPerformance()
|
---|
| 70 | {
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | QString PrefPerformance::sectionName() {
|
---|
| 74 | return tr("Performance");
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | QPixmap PrefPerformance::sectionIcon() {
|
---|
[181] | 78 | return Images::icon("pref_performance");
|
---|
[112] | 79 | }
|
---|
| 80 |
|
---|
| 81 |
|
---|
| 82 | void 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 |
|
---|
| 99 | void PrefPerformance::setData(Preferences * pref) {
|
---|
[181] | 100 | cache_auto_check->setChecked(pref->cache_auto);
|
---|
[112] | 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 );
|
---|
[181] | 106 | #ifdef TV_SUPPORT
|
---|
[112] | 107 | setCacheForTV( pref->cache_for_tv );
|
---|
[181] | 108 | #endif
|
---|
[112] | 109 |
|
---|
[181] | 110 | #ifdef Q_OS_WIN
|
---|
[112] | 111 | setPriority( pref->priority );
|
---|
[181] | 112 | #endif
|
---|
[112] | 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
|
---|
[176] | 120 | #ifdef OBSOLETE_FAST_AUDIO_CHANGE
|
---|
[112] | 121 | setFastAudioSwitching( pref->fast_audio_change );
|
---|
[176] | 122 | #endif
|
---|
[112] | 123 | setThreads( pref->threads );
|
---|
[176] | 124 | setHwdec( pref->hwdec );
|
---|
[112] | 125 | }
|
---|
| 126 |
|
---|
| 127 | void PrefPerformance::getData(Preferences * pref) {
|
---|
| 128 | requires_restart = false;
|
---|
| 129 |
|
---|
[181] | 130 | TEST_AND_SET(pref->cache_auto, cache_auto_check->isChecked());
|
---|
[112] | 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());
|
---|
[181] | 136 | #ifdef TV_SUPPORT
|
---|
[112] | 137 | TEST_AND_SET(pref->cache_for_tv, cacheForTV());
|
---|
[181] | 138 | #endif
|
---|
[112] | 139 |
|
---|
[181] | 140 | #ifdef Q_OS_WIN
|
---|
[112] | 141 | TEST_AND_SET(pref->priority, priority());
|
---|
[181] | 142 | #endif
|
---|
[112] | 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
|
---|
[176] | 150 | #ifdef OBSOLETE_FAST_AUDIO_CHANGE
|
---|
[112] | 151 | pref->fast_audio_change = fastAudioSwitching();
|
---|
[176] | 152 | #endif
|
---|
[112] | 153 | TEST_AND_SET(pref->threads, threads());
|
---|
[176] | 154 | TEST_AND_SET(pref->hwdec, hwdec());
|
---|
[112] | 155 | }
|
---|
| 156 |
|
---|
| 157 | void PrefPerformance::setCacheForFiles(int n) {
|
---|
| 158 | cache_files_spin->setValue(n);
|
---|
| 159 | }
|
---|
| 160 |
|
---|
| 161 | int PrefPerformance::cacheForFiles() {
|
---|
| 162 | return cache_files_spin->value();
|
---|
| 163 | }
|
---|
| 164 |
|
---|
| 165 | void PrefPerformance::setCacheForStreams(int n) {
|
---|
| 166 | cache_streams_spin->setValue(n);
|
---|
| 167 | }
|
---|
| 168 |
|
---|
| 169 | int PrefPerformance::cacheForStreams() {
|
---|
| 170 | return cache_streams_spin->value();
|
---|
| 171 | }
|
---|
| 172 |
|
---|
| 173 | void PrefPerformance::setCacheForDVDs(int n) {
|
---|
| 174 | cache_dvds_spin->setValue(n);
|
---|
| 175 | }
|
---|
| 176 |
|
---|
| 177 | int PrefPerformance::cacheForDVDs() {
|
---|
| 178 | return cache_dvds_spin->value();
|
---|
| 179 | }
|
---|
| 180 |
|
---|
| 181 | void PrefPerformance::setCacheForAudioCDs(int n) {
|
---|
| 182 | cache_cds_spin->setValue(n);
|
---|
| 183 | }
|
---|
| 184 |
|
---|
| 185 | int PrefPerformance::cacheForAudioCDs() {
|
---|
| 186 | return cache_cds_spin->value();
|
---|
| 187 | }
|
---|
| 188 |
|
---|
| 189 | void PrefPerformance::setCacheForVCDs(int n) {
|
---|
| 190 | cache_vcds_spin->setValue(n);
|
---|
| 191 | }
|
---|
| 192 |
|
---|
| 193 | int PrefPerformance::cacheForVCDs() {
|
---|
| 194 | return cache_vcds_spin->value();
|
---|
| 195 | }
|
---|
| 196 |
|
---|
[181] | 197 | #ifdef TV_SUPPORT
|
---|
[112] | 198 | void PrefPerformance::setCacheForTV(int n) {
|
---|
| 199 | cache_tv_spin->setValue(n);
|
---|
| 200 | }
|
---|
| 201 |
|
---|
| 202 | int PrefPerformance::cacheForTV() {
|
---|
| 203 | return cache_tv_spin->value();
|
---|
| 204 | }
|
---|
[181] | 205 | #endif
|
---|
[112] | 206 |
|
---|
[181] | 207 | #ifdef Q_OS_WIN
|
---|
[112] | 208 | void PrefPerformance::setPriority(int n) {
|
---|
| 209 | priority_combo->setCurrentIndex(n);
|
---|
| 210 | }
|
---|
| 211 |
|
---|
| 212 | int PrefPerformance::priority() {
|
---|
| 213 | return priority_combo->currentIndex();
|
---|
| 214 | }
|
---|
[181] | 215 | #endif
|
---|
[112] | 216 |
|
---|
| 217 | void PrefPerformance::setFrameDrop(bool b) {
|
---|
| 218 | framedrop_check->setChecked(b);
|
---|
| 219 | }
|
---|
| 220 |
|
---|
| 221 | bool PrefPerformance::frameDrop() {
|
---|
| 222 | return framedrop_check->isChecked();
|
---|
| 223 | }
|
---|
| 224 |
|
---|
| 225 | void PrefPerformance::setHardFrameDrop(bool b) {
|
---|
| 226 | hardframedrop_check->setChecked(b);
|
---|
| 227 | }
|
---|
| 228 |
|
---|
| 229 | bool PrefPerformance::hardFrameDrop() {
|
---|
| 230 | return hardframedrop_check->isChecked();
|
---|
| 231 | }
|
---|
| 232 |
|
---|
| 233 | void PrefPerformance::setCoreavcUsage(bool b) {
|
---|
| 234 | coreavc_check->setChecked(b);
|
---|
| 235 | }
|
---|
| 236 |
|
---|
| 237 | bool PrefPerformance::coreavcUsage() {
|
---|
| 238 | return coreavc_check->isChecked();
|
---|
| 239 | }
|
---|
| 240 |
|
---|
| 241 | void PrefPerformance::setSkipLoop(Preferences::H264LoopFilter value) {
|
---|
| 242 | loopfilter_combo->setCurrentIndex(loopfilter_combo->findData(value));
|
---|
| 243 | }
|
---|
| 244 |
|
---|
| 245 | Preferences::H264LoopFilter PrefPerformance::skipLoop() {
|
---|
| 246 | return (Preferences::H264LoopFilter) loopfilter_combo->itemData(loopfilter_combo->currentIndex()).toInt();
|
---|
| 247 | }
|
---|
| 248 |
|
---|
| 249 | #if !SMART_DVD_CHAPTERS
|
---|
| 250 | void PrefPerformance::setFastChapterSeeking(bool b) {
|
---|
| 251 | fast_chapter_check->setChecked(b);
|
---|
| 252 | }
|
---|
| 253 |
|
---|
| 254 | bool PrefPerformance::fastChapterSeeking() {
|
---|
| 255 | return fast_chapter_check->isChecked();
|
---|
| 256 | }
|
---|
| 257 | #endif
|
---|
| 258 |
|
---|
[176] | 259 | #ifdef OBSOLETE_FAST_AUDIO_CHANGE
|
---|
[112] | 260 | void PrefPerformance::setFastAudioSwitching(Preferences::OptionState value) {
|
---|
| 261 | fast_audio_combo->setState(value);
|
---|
| 262 | }
|
---|
| 263 |
|
---|
| 264 | Preferences::OptionState PrefPerformance::fastAudioSwitching() {
|
---|
| 265 | return fast_audio_combo->state();
|
---|
| 266 | }
|
---|
[176] | 267 | #endif
|
---|
[112] | 268 |
|
---|
| 269 | void PrefPerformance::setThreads(int v) {
|
---|
| 270 | threads_spin->setValue(v);
|
---|
| 271 | }
|
---|
| 272 |
|
---|
| 273 | int PrefPerformance::threads() {
|
---|
| 274 | return threads_spin->value();
|
---|
| 275 | }
|
---|
| 276 |
|
---|
[176] | 277 | void PrefPerformance::setHwdec(const QString & v) {
|
---|
| 278 | int idx = hwdec_combo->findData(v);
|
---|
| 279 | if (idx < 0) idx = 0;
|
---|
| 280 | hwdec_combo->setCurrentIndex(idx);
|
---|
[124] | 281 | }
|
---|
| 282 |
|
---|
[176] | 283 | QString PrefPerformance::hwdec() {
|
---|
| 284 | int idx = hwdec_combo->currentIndex();
|
---|
| 285 | return hwdec_combo->itemData(idx).toString();
|
---|
[124] | 286 | }
|
---|
| 287 |
|
---|
[112] | 288 | void PrefPerformance::createHelp() {
|
---|
| 289 | clearHelp();
|
---|
| 290 |
|
---|
| 291 | addSectionTitle(tr("Performance"));
|
---|
| 292 |
|
---|
| 293 | // Performance tab
|
---|
| 294 | #ifdef Q_OS_WIN
|
---|
| 295 | setWhatsThis(priority_combo, tr("Priority"),
|
---|
[176] | 296 | tr("Set process priority for %1 according to the predefined "
|
---|
[112] | 297 | "priorities available under Windows.<br>"
|
---|
[176] | 298 | "<b>Warning:</b> Using realtime priority can cause system lockup.").arg(PLAYER_NAME));
|
---|
[112] | 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 |
|
---|
[176] | 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 | );
|
---|
[112] | 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 |
|
---|
[176] | 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
|
---|
[112] | 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." ) );
|
---|
[176] | 363 | #endif
|
---|
[112] | 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 |
|
---|
[181] | 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"),
|
---|
[112] | 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"
|
---|