| 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 |
|
|---|
| 26 | using namespace Global;
|
|---|
| 27 |
|
|---|
| 28 | PrefPerformance::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 | // Priority is only for windows, so we disable for other systems
|
|---|
| 48 | #ifndef Q_OS_WIN
|
|---|
| 49 | priority_group->hide();
|
|---|
| 50 | #endif
|
|---|
| 51 |
|
|---|
| 52 | #if SMART_DVD_CHAPTERS
|
|---|
| 53 | fast_chapter_check->hide();
|
|---|
| 54 | #endif
|
|---|
| 55 |
|
|---|
| 56 | #ifndef OBSOLETE_FAST_AUDIO_CHANGE
|
|---|
| 57 | fast_audio_label->hide();
|
|---|
| 58 | fast_audio_combo->hide();
|
|---|
| 59 | #endif
|
|---|
| 60 |
|
|---|
| 61 | retranslateStrings();
|
|---|
| 62 | }
|
|---|
| 63 |
|
|---|
| 64 | PrefPerformance::~PrefPerformance()
|
|---|
| 65 | {
|
|---|
| 66 | }
|
|---|
| 67 |
|
|---|
| 68 | QString PrefPerformance::sectionName() {
|
|---|
| 69 | return tr("Performance");
|
|---|
| 70 | }
|
|---|
| 71 |
|
|---|
| 72 | QPixmap PrefPerformance::sectionIcon() {
|
|---|
| 73 | return Images::icon("pref_performance", 22);
|
|---|
| 74 | }
|
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 | void PrefPerformance::retranslateStrings() {
|
|---|
| 78 | int priority = priority_combo->currentIndex();
|
|---|
| 79 | int loop_filter = loopfilter_combo->currentIndex();
|
|---|
| 80 |
|
|---|
| 81 | retranslateUi(this);
|
|---|
| 82 |
|
|---|
| 83 | loopfilter_combo->clear();
|
|---|
| 84 | loopfilter_combo->addItem( tr("Enabled"), Preferences::LoopEnabled );
|
|---|
| 85 | loopfilter_combo->addItem( tr("Skip (always)"), Preferences::LoopDisabled );
|
|---|
| 86 | loopfilter_combo->addItem( tr("Skip only on HD videos"), Preferences::LoopDisabledOnHD );
|
|---|
| 87 |
|
|---|
| 88 | priority_combo->setCurrentIndex(priority);
|
|---|
| 89 | loopfilter_combo->setCurrentIndex(loop_filter);
|
|---|
| 90 |
|
|---|
| 91 | createHelp();
|
|---|
| 92 | }
|
|---|
| 93 |
|
|---|
| 94 | void PrefPerformance::setData(Preferences * pref) {
|
|---|
| 95 | setCacheForFiles( pref->cache_for_files );
|
|---|
| 96 | setCacheForStreams( pref->cache_for_streams );
|
|---|
| 97 | setCacheForDVDs( pref->cache_for_dvds );
|
|---|
| 98 | setCacheForAudioCDs( pref->cache_for_audiocds );
|
|---|
| 99 | setCacheForVCDs( pref->cache_for_vcds );
|
|---|
| 100 | setCacheForTV( pref->cache_for_tv );
|
|---|
| 101 |
|
|---|
| 102 | setPriority( pref->priority );
|
|---|
| 103 | setFrameDrop( pref->frame_drop );
|
|---|
| 104 | setHardFrameDrop( pref->hard_frame_drop );
|
|---|
| 105 | setCoreavcUsage( pref->coreavc );
|
|---|
| 106 | setSkipLoop( pref->h264_skip_loop_filter );
|
|---|
| 107 | #if !SMART_DVD_CHAPTERS
|
|---|
| 108 | setFastChapterSeeking( pref->fast_chapter_change );
|
|---|
| 109 | #endif
|
|---|
| 110 | #ifdef OBSOLETE_FAST_AUDIO_CHANGE
|
|---|
| 111 | setFastAudioSwitching( pref->fast_audio_change );
|
|---|
| 112 | #endif
|
|---|
| 113 | setThreads( pref->threads );
|
|---|
| 114 | setHwdec( pref->hwdec );
|
|---|
| 115 | }
|
|---|
| 116 |
|
|---|
| 117 | void PrefPerformance::getData(Preferences * pref) {
|
|---|
| 118 | requires_restart = false;
|
|---|
| 119 |
|
|---|
| 120 | TEST_AND_SET(pref->cache_for_files, cacheForFiles());
|
|---|
| 121 | TEST_AND_SET(pref->cache_for_streams, cacheForStreams());
|
|---|
| 122 | TEST_AND_SET(pref->cache_for_dvds, cacheForDVDs());
|
|---|
| 123 | TEST_AND_SET(pref->cache_for_audiocds, cacheForAudioCDs());
|
|---|
| 124 | TEST_AND_SET(pref->cache_for_vcds, cacheForVCDs());
|
|---|
| 125 | TEST_AND_SET(pref->cache_for_tv, cacheForTV());
|
|---|
| 126 |
|
|---|
| 127 | TEST_AND_SET(pref->priority, priority());
|
|---|
| 128 | TEST_AND_SET(pref->frame_drop, frameDrop());
|
|---|
| 129 | TEST_AND_SET(pref->hard_frame_drop, hardFrameDrop());
|
|---|
| 130 | TEST_AND_SET(pref->coreavc, coreavcUsage())
|
|---|
| 131 | TEST_AND_SET(pref->h264_skip_loop_filter, skipLoop());
|
|---|
| 132 | #if !SMART_DVD_CHAPTERS
|
|---|
| 133 | TEST_AND_SET(pref->fast_chapter_change, fastChapterSeeking());
|
|---|
| 134 | #endif
|
|---|
| 135 | #ifdef OBSOLETE_FAST_AUDIO_CHANGE
|
|---|
| 136 | pref->fast_audio_change = fastAudioSwitching();
|
|---|
| 137 | #endif
|
|---|
| 138 | TEST_AND_SET(pref->threads, threads());
|
|---|
| 139 | TEST_AND_SET(pref->hwdec, hwdec());
|
|---|
| 140 | }
|
|---|
| 141 |
|
|---|
| 142 | void PrefPerformance::setCacheForFiles(int n) {
|
|---|
| 143 | cache_files_spin->setValue(n);
|
|---|
| 144 | }
|
|---|
| 145 |
|
|---|
| 146 | int PrefPerformance::cacheForFiles() {
|
|---|
| 147 | return cache_files_spin->value();
|
|---|
| 148 | }
|
|---|
| 149 |
|
|---|
| 150 | void PrefPerformance::setCacheForStreams(int n) {
|
|---|
| 151 | cache_streams_spin->setValue(n);
|
|---|
| 152 | }
|
|---|
| 153 |
|
|---|
| 154 | int PrefPerformance::cacheForStreams() {
|
|---|
| 155 | return cache_streams_spin->value();
|
|---|
| 156 | }
|
|---|
| 157 |
|
|---|
| 158 | void PrefPerformance::setCacheForDVDs(int n) {
|
|---|
| 159 | cache_dvds_spin->setValue(n);
|
|---|
| 160 | }
|
|---|
| 161 |
|
|---|
| 162 | int PrefPerformance::cacheForDVDs() {
|
|---|
| 163 | return cache_dvds_spin->value();
|
|---|
| 164 | }
|
|---|
| 165 |
|
|---|
| 166 | void PrefPerformance::setCacheForAudioCDs(int n) {
|
|---|
| 167 | cache_cds_spin->setValue(n);
|
|---|
| 168 | }
|
|---|
| 169 |
|
|---|
| 170 | int PrefPerformance::cacheForAudioCDs() {
|
|---|
| 171 | return cache_cds_spin->value();
|
|---|
| 172 | }
|
|---|
| 173 |
|
|---|
| 174 | void PrefPerformance::setCacheForVCDs(int n) {
|
|---|
| 175 | cache_vcds_spin->setValue(n);
|
|---|
| 176 | }
|
|---|
| 177 |
|
|---|
| 178 | int PrefPerformance::cacheForVCDs() {
|
|---|
| 179 | return cache_vcds_spin->value();
|
|---|
| 180 | }
|
|---|
| 181 |
|
|---|
| 182 | void PrefPerformance::setCacheForTV(int n) {
|
|---|
| 183 | cache_tv_spin->setValue(n);
|
|---|
| 184 | }
|
|---|
| 185 |
|
|---|
| 186 | int PrefPerformance::cacheForTV() {
|
|---|
| 187 | return cache_tv_spin->value();
|
|---|
| 188 | }
|
|---|
| 189 |
|
|---|
| 190 | void PrefPerformance::setPriority(int n) {
|
|---|
| 191 | priority_combo->setCurrentIndex(n);
|
|---|
| 192 | }
|
|---|
| 193 |
|
|---|
| 194 | int PrefPerformance::priority() {
|
|---|
| 195 | return priority_combo->currentIndex();
|
|---|
| 196 | }
|
|---|
| 197 |
|
|---|
| 198 | void PrefPerformance::setFrameDrop(bool b) {
|
|---|
| 199 | framedrop_check->setChecked(b);
|
|---|
| 200 | }
|
|---|
| 201 |
|
|---|
| 202 | bool PrefPerformance::frameDrop() {
|
|---|
| 203 | return framedrop_check->isChecked();
|
|---|
| 204 | }
|
|---|
| 205 |
|
|---|
| 206 | void PrefPerformance::setHardFrameDrop(bool b) {
|
|---|
| 207 | hardframedrop_check->setChecked(b);
|
|---|
| 208 | }
|
|---|
| 209 |
|
|---|
| 210 | bool PrefPerformance::hardFrameDrop() {
|
|---|
| 211 | return hardframedrop_check->isChecked();
|
|---|
| 212 | }
|
|---|
| 213 |
|
|---|
| 214 | void PrefPerformance::setCoreavcUsage(bool b) {
|
|---|
| 215 | coreavc_check->setChecked(b);
|
|---|
| 216 | }
|
|---|
| 217 |
|
|---|
| 218 | bool PrefPerformance::coreavcUsage() {
|
|---|
| 219 | return coreavc_check->isChecked();
|
|---|
| 220 | }
|
|---|
| 221 |
|
|---|
| 222 | void PrefPerformance::setSkipLoop(Preferences::H264LoopFilter value) {
|
|---|
| 223 | loopfilter_combo->setCurrentIndex(loopfilter_combo->findData(value));
|
|---|
| 224 | }
|
|---|
| 225 |
|
|---|
| 226 | Preferences::H264LoopFilter PrefPerformance::skipLoop() {
|
|---|
| 227 | return (Preferences::H264LoopFilter) loopfilter_combo->itemData(loopfilter_combo->currentIndex()).toInt();
|
|---|
| 228 | }
|
|---|
| 229 |
|
|---|
| 230 | #if !SMART_DVD_CHAPTERS
|
|---|
| 231 | void PrefPerformance::setFastChapterSeeking(bool b) {
|
|---|
| 232 | fast_chapter_check->setChecked(b);
|
|---|
| 233 | }
|
|---|
| 234 |
|
|---|
| 235 | bool PrefPerformance::fastChapterSeeking() {
|
|---|
| 236 | return fast_chapter_check->isChecked();
|
|---|
| 237 | }
|
|---|
| 238 | #endif
|
|---|
| 239 |
|
|---|
| 240 | #ifdef OBSOLETE_FAST_AUDIO_CHANGE
|
|---|
| 241 | void PrefPerformance::setFastAudioSwitching(Preferences::OptionState value) {
|
|---|
| 242 | fast_audio_combo->setState(value);
|
|---|
| 243 | }
|
|---|
| 244 |
|
|---|
| 245 | Preferences::OptionState PrefPerformance::fastAudioSwitching() {
|
|---|
| 246 | return fast_audio_combo->state();
|
|---|
| 247 | }
|
|---|
| 248 | #endif
|
|---|
| 249 |
|
|---|
| 250 | void PrefPerformance::setThreads(int v) {
|
|---|
| 251 | threads_spin->setValue(v);
|
|---|
| 252 | }
|
|---|
| 253 |
|
|---|
| 254 | int PrefPerformance::threads() {
|
|---|
| 255 | return threads_spin->value();
|
|---|
| 256 | }
|
|---|
| 257 |
|
|---|
| 258 | void PrefPerformance::setHwdec(const QString & v) {
|
|---|
| 259 | int idx = hwdec_combo->findData(v);
|
|---|
| 260 | if (idx < 0) idx = 0;
|
|---|
| 261 | hwdec_combo->setCurrentIndex(idx);
|
|---|
| 262 | }
|
|---|
| 263 |
|
|---|
| 264 | QString PrefPerformance::hwdec() {
|
|---|
| 265 | int idx = hwdec_combo->currentIndex();
|
|---|
| 266 | return hwdec_combo->itemData(idx).toString();
|
|---|
| 267 | }
|
|---|
| 268 |
|
|---|
| 269 | void PrefPerformance::createHelp() {
|
|---|
| 270 | clearHelp();
|
|---|
| 271 |
|
|---|
| 272 | addSectionTitle(tr("Performance"));
|
|---|
| 273 |
|
|---|
| 274 | // Performance tab
|
|---|
| 275 | #ifdef Q_OS_WIN
|
|---|
| 276 | setWhatsThis(priority_combo, tr("Priority"),
|
|---|
| 277 | tr("Set process priority for %1 according to the predefined "
|
|---|
| 278 | "priorities available under Windows.<br>"
|
|---|
| 279 | "<b>Warning:</b> Using realtime priority can cause system lockup.").arg(PLAYER_NAME));
|
|---|
| 280 | #endif
|
|---|
| 281 |
|
|---|
| 282 | setWhatsThis(framedrop_check, tr("Allow frame drop"),
|
|---|
| 283 | tr("Skip displaying some frames to maintain A/V sync on slow systems." ) );
|
|---|
| 284 |
|
|---|
| 285 | setWhatsThis(hardframedrop_check, tr("Allow hard frame drop"),
|
|---|
| 286 | tr("More intense frame dropping (breaks decoding). "
|
|---|
| 287 | "Leads to image distortion!") );
|
|---|
| 288 |
|
|---|
| 289 | setWhatsThis(threads_spin, tr("Threads for decoding"),
|
|---|
| 290 | tr("Sets the number of threads to use for decoding. Only for "
|
|---|
| 291 | "MPEG-1/2 and H.264") );
|
|---|
| 292 |
|
|---|
| 293 | setWhatsThis(hwdec_combo, tr("Hardware decoding"),
|
|---|
| 294 | tr("Sets the hardware video decoding API. "
|
|---|
| 295 | "If hardware decoding is not possible, software decoding will be used instead.") + " " +
|
|---|
| 296 | tr("Available options:") +
|
|---|
| 297 | "<ul>"
|
|---|
| 298 | "<li>" + tr("None: only software decoding will be used.") + "</li>"
|
|---|
| 299 | "<li>" + tr("Auto: it tries to automatically enable hardware decoding using the first available method.") + "</li>"
|
|---|
| 300 | #ifdef Q_OS_LINUX
|
|---|
| 301 | "<li>" + tr("vdpau: for the vdpau and opengl video outputs.") + "</li>"
|
|---|
| 302 | "<li>" + tr("vaapi: for the opengl and vaapi video outputs. For Intel GPUs only.") + "</li>"
|
|---|
| 303 | "<li>" + tr("vaapi-copy: it copies video back into system RAM. For Intel GPUs only.") + "</li>"
|
|---|
| 304 | #endif
|
|---|
| 305 | #ifdef Q_OS_WIN
|
|---|
| 306 | "<li>" + tr("dxva2-copy: it copies video back to system RAM. Experimental.") + "</li>"
|
|---|
| 307 | #endif
|
|---|
| 308 | "</ul>"
|
|---|
| 309 | #ifdef MPLAYER_SUPPORT
|
|---|
| 310 | + tr("This option only works with mpv.")
|
|---|
| 311 | #endif
|
|---|
| 312 | );
|
|---|
| 313 |
|
|---|
| 314 | setWhatsThis(loopfilter_combo, tr("Skip loop filter"),
|
|---|
| 315 | tr("This option allows to skips the loop filter (AKA deblocking) "
|
|---|
| 316 | "during H.264 decoding. "
|
|---|
| 317 | "Since the filtered frame is supposed to be used as reference "
|
|---|
| 318 | "for decoding dependent frames this has a worse effect on quality "
|
|---|
| 319 | "than not doing deblocking on e.g. MPEG-2 video. But at least for "
|
|---|
| 320 | "high bitrate HDTV this provides a big speedup with no visible "
|
|---|
| 321 | "quality loss.") +"<br>"+
|
|---|
| 322 | tr("Possible values:") +"<br>" +
|
|---|
| 323 | tr("<b>Enabled</b>: the loop filter is not skipped")+"<br>"+
|
|---|
| 324 | tr("<b>Skip (always)</b>: the loop filter is skipped no matter the "
|
|---|
| 325 | "resolution of the video")+"<br>"+
|
|---|
| 326 | tr("<b>Skip only on HD videos</b>: the loop filter will be "
|
|---|
| 327 | "skipped only on videos which height is %1 or "
|
|---|
| 328 | "greater.").arg(pref->HD_height) +"<br>" );
|
|---|
| 329 |
|
|---|
| 330 | setWhatsThis(coreavc_check, tr("Use CoreAVC if no other codec specified"),
|
|---|
| 331 | tr("Try to use the non-free CoreAVC codec when no other codec is specified "
|
|---|
| 332 | "and a non-VDPAU video output is selected.") +" "+
|
|---|
| 333 | tr("Requires a %1 build with CoreAVC support.").arg(PLAYER_NAME));
|
|---|
| 334 |
|
|---|
| 335 | #ifdef OBSOLETE_FAST_AUDIO_CHANGE
|
|---|
| 336 | setWhatsThis(fast_audio_combo, tr("Fast audio track switching"),
|
|---|
| 337 | tr("Possible values:<br> "
|
|---|
| 338 | "<b>Yes</b>: it will try the fastest method "
|
|---|
| 339 | "to switch the audio track (it might not work with some formats).<br> "
|
|---|
| 340 | "<b>No</b>: the MPlayer process will be restarted whenever you "
|
|---|
| 341 | "change the audio track.<br> "
|
|---|
| 342 | "<b>Auto</b>: SMPlayer will decide what to do according to the "
|
|---|
| 343 | "MPlayer version." ) );
|
|---|
| 344 | #endif
|
|---|
| 345 |
|
|---|
| 346 | #if !SMART_DVD_CHAPTERS
|
|---|
| 347 | setWhatsThis(fast_chapter_check, tr("Fast seek to chapters in dvds"),
|
|---|
| 348 | tr("If checked, it will try the fastest method to seek to chapters "
|
|---|
| 349 | "but it might not work with some discs.") );
|
|---|
| 350 | #endif
|
|---|
| 351 |
|
|---|
| 352 | addSectionTitle(tr("Cache"));
|
|---|
| 353 |
|
|---|
| 354 | setWhatsThis(cache_files_spin, tr("Cache for files"),
|
|---|
| 355 | tr("This option specifies how much memory (in kBytes) to use when "
|
|---|
| 356 | "precaching a file.") );
|
|---|
| 357 |
|
|---|
| 358 | setWhatsThis(cache_streams_spin, tr("Cache for streams"),
|
|---|
| 359 | tr("This option specifies how much memory (in kBytes) to use when "
|
|---|
| 360 | "precaching a URL.") );
|
|---|
| 361 |
|
|---|
| 362 | setWhatsThis(cache_dvds_spin, tr("Cache for DVDs"),
|
|---|
| 363 | tr("This option specifies how much memory (in kBytes) to use when "
|
|---|
| 364 | "precaching a DVD.<br><b>Warning:</b> Seeking might not work "
|
|---|
| 365 | "properly (including chapter switching) when using a cache for DVDs.") );
|
|---|
| 366 |
|
|---|
| 367 | setWhatsThis(cache_cds_spin, tr("Cache for audio CDs"),
|
|---|
| 368 | tr("This option specifies how much memory (in kBytes) to use when "
|
|---|
| 369 | "precaching an audio CD.") );
|
|---|
| 370 |
|
|---|
| 371 | setWhatsThis(cache_vcds_spin, tr("Cache for VCDs"),
|
|---|
| 372 | tr("This option specifies how much memory (in kBytes) to use when "
|
|---|
| 373 | "precaching a VCD.") );
|
|---|
| 374 | }
|
|---|
| 375 |
|
|---|
| 376 | #include "moc_prefperformance.cpp"
|
|---|