| 1 | /* smplayer, GUI front-end for mplayer.
|
|---|
| 2 | Copyright (C) 2006-2012 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 |
|
|---|
| 25 | #ifdef YOUTUBE_SUPPORT
|
|---|
| 26 | #include "retrieveyoutubeurl.h"
|
|---|
| 27 | #endif
|
|---|
| 28 |
|
|---|
| 29 | using namespace Global;
|
|---|
| 30 |
|
|---|
| 31 | PrefPerformance::PrefPerformance(QWidget * parent, Qt::WindowFlags f)
|
|---|
| 32 | : PrefWidget(parent, f )
|
|---|
| 33 | {
|
|---|
| 34 | setupUi(this);
|
|---|
| 35 |
|
|---|
| 36 | // Priority is only for windows, so we disable for other systems
|
|---|
| 37 | #ifndef Q_OS_WIN
|
|---|
| 38 | priority_group->hide();
|
|---|
| 39 | #endif
|
|---|
| 40 |
|
|---|
| 41 | #if SMART_DVD_CHAPTERS
|
|---|
| 42 | fast_chapter_check->hide();
|
|---|
| 43 | #endif
|
|---|
| 44 |
|
|---|
| 45 | #ifdef YOUTUBE_SUPPORT
|
|---|
| 46 | yt_quality_combo->addItem( "240p (flv)", RetrieveYoutubeUrl::FLV_240p );
|
|---|
| 47 |
|
|---|
| 48 | yt_quality_combo->addItem( "360p (flv)", RetrieveYoutubeUrl::FLV_360p );
|
|---|
| 49 | yt_quality_combo->addItem( "360p (mp4)", RetrieveYoutubeUrl::MP4_360p );
|
|---|
| 50 | yt_quality_combo->addItem( "360p (webm)", RetrieveYoutubeUrl::WEBM_360p );
|
|---|
| 51 |
|
|---|
| 52 | yt_quality_combo->addItem( "480p (flv)", RetrieveYoutubeUrl::FLV_480p );
|
|---|
| 53 | yt_quality_combo->addItem( "480p (webm)", RetrieveYoutubeUrl::WEBM_480p );
|
|---|
| 54 |
|
|---|
| 55 | yt_quality_combo->addItem( "720p (mp4)", RetrieveYoutubeUrl::MP4_720p );
|
|---|
| 56 | yt_quality_combo->addItem( "720p (webm)", RetrieveYoutubeUrl::WEBM_720p );
|
|---|
| 57 |
|
|---|
| 58 | yt_quality_combo->addItem( "1080p (mp4)", RetrieveYoutubeUrl::MP4_1080p );
|
|---|
| 59 | yt_quality_combo->addItem( "1080p (webm)", RetrieveYoutubeUrl::WEBM_1080p );
|
|---|
| 60 | #else
|
|---|
| 61 | yt_label->hide();
|
|---|
| 62 | yt_quality_combo->hide();
|
|---|
| 63 | yt_line->hide();
|
|---|
| 64 | #endif
|
|---|
| 65 |
|
|---|
| 66 | retranslateStrings();
|
|---|
| 67 | }
|
|---|
| 68 |
|
|---|
| 69 | PrefPerformance::~PrefPerformance()
|
|---|
| 70 | {
|
|---|
| 71 | }
|
|---|
| 72 |
|
|---|
| 73 | QString PrefPerformance::sectionName() {
|
|---|
| 74 | return tr("Performance");
|
|---|
| 75 | }
|
|---|
| 76 |
|
|---|
| 77 | QPixmap PrefPerformance::sectionIcon() {
|
|---|
| 78 | return Images::icon("pref_performance", 22);
|
|---|
| 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) {
|
|---|
| 100 | setCacheForFiles( pref->cache_for_files );
|
|---|
| 101 | setCacheForStreams( pref->cache_for_streams );
|
|---|
| 102 | setCacheForDVDs( pref->cache_for_dvds );
|
|---|
| 103 | setCacheForAudioCDs( pref->cache_for_audiocds );
|
|---|
| 104 | setCacheForVCDs( pref->cache_for_vcds );
|
|---|
| 105 | setCacheForTV( pref->cache_for_tv );
|
|---|
| 106 |
|
|---|
| 107 | setPriority( pref->priority );
|
|---|
| 108 | setFrameDrop( pref->frame_drop );
|
|---|
| 109 | setHardFrameDrop( pref->hard_frame_drop );
|
|---|
| 110 | setCoreavcUsage( pref->coreavc );
|
|---|
| 111 | setSkipLoop( pref->h264_skip_loop_filter );
|
|---|
| 112 | #if !SMART_DVD_CHAPTERS
|
|---|
| 113 | setFastChapterSeeking( pref->fast_chapter_change );
|
|---|
| 114 | #endif
|
|---|
| 115 | setFastAudioSwitching( pref->fast_audio_change );
|
|---|
| 116 | setThreads( pref->threads );
|
|---|
| 117 |
|
|---|
| 118 | #ifdef YOUTUBE_SUPPORT
|
|---|
| 119 | setYTQuality( pref->yt_quality );
|
|---|
| 120 | #endif
|
|---|
| 121 | }
|
|---|
| 122 |
|
|---|
| 123 | void PrefPerformance::getData(Preferences * pref) {
|
|---|
| 124 | requires_restart = false;
|
|---|
| 125 |
|
|---|
| 126 | TEST_AND_SET(pref->cache_for_files, cacheForFiles());
|
|---|
| 127 | TEST_AND_SET(pref->cache_for_streams, cacheForStreams());
|
|---|
| 128 | TEST_AND_SET(pref->cache_for_dvds, cacheForDVDs());
|
|---|
| 129 | TEST_AND_SET(pref->cache_for_audiocds, cacheForAudioCDs());
|
|---|
| 130 | TEST_AND_SET(pref->cache_for_vcds, cacheForVCDs());
|
|---|
| 131 | TEST_AND_SET(pref->cache_for_tv, cacheForTV());
|
|---|
| 132 |
|
|---|
| 133 | TEST_AND_SET(pref->priority, priority());
|
|---|
| 134 | TEST_AND_SET(pref->frame_drop, frameDrop());
|
|---|
| 135 | TEST_AND_SET(pref->hard_frame_drop, hardFrameDrop());
|
|---|
| 136 | TEST_AND_SET(pref->coreavc, coreavcUsage())
|
|---|
| 137 | TEST_AND_SET(pref->h264_skip_loop_filter, skipLoop());
|
|---|
| 138 | #if !SMART_DVD_CHAPTERS
|
|---|
| 139 | TEST_AND_SET(pref->fast_chapter_change, fastChapterSeeking());
|
|---|
| 140 | #endif
|
|---|
| 141 | pref->fast_audio_change = fastAudioSwitching();
|
|---|
| 142 | TEST_AND_SET(pref->threads, threads());
|
|---|
| 143 |
|
|---|
| 144 | #ifdef YOUTUBE_SUPPORT
|
|---|
| 145 | pref->yt_quality = YTQuality();
|
|---|
| 146 | #endif
|
|---|
| 147 | }
|
|---|
| 148 |
|
|---|
| 149 | void PrefPerformance::setCacheForFiles(int n) {
|
|---|
| 150 | cache_files_spin->setValue(n);
|
|---|
| 151 | }
|
|---|
| 152 |
|
|---|
| 153 | int PrefPerformance::cacheForFiles() {
|
|---|
| 154 | return cache_files_spin->value();
|
|---|
| 155 | }
|
|---|
| 156 |
|
|---|
| 157 | void PrefPerformance::setCacheForStreams(int n) {
|
|---|
| 158 | cache_streams_spin->setValue(n);
|
|---|
| 159 | }
|
|---|
| 160 |
|
|---|
| 161 | int PrefPerformance::cacheForStreams() {
|
|---|
| 162 | return cache_streams_spin->value();
|
|---|
| 163 | }
|
|---|
| 164 |
|
|---|
| 165 | void PrefPerformance::setCacheForDVDs(int n) {
|
|---|
| 166 | cache_dvds_spin->setValue(n);
|
|---|
| 167 | }
|
|---|
| 168 |
|
|---|
| 169 | int PrefPerformance::cacheForDVDs() {
|
|---|
| 170 | return cache_dvds_spin->value();
|
|---|
| 171 | }
|
|---|
| 172 |
|
|---|
| 173 | void PrefPerformance::setCacheForAudioCDs(int n) {
|
|---|
| 174 | cache_cds_spin->setValue(n);
|
|---|
| 175 | }
|
|---|
| 176 |
|
|---|
| 177 | int PrefPerformance::cacheForAudioCDs() {
|
|---|
| 178 | return cache_cds_spin->value();
|
|---|
| 179 | }
|
|---|
| 180 |
|
|---|
| 181 | void PrefPerformance::setCacheForVCDs(int n) {
|
|---|
| 182 | cache_vcds_spin->setValue(n);
|
|---|
| 183 | }
|
|---|
| 184 |
|
|---|
| 185 | int PrefPerformance::cacheForVCDs() {
|
|---|
| 186 | return cache_vcds_spin->value();
|
|---|
| 187 | }
|
|---|
| 188 |
|
|---|
| 189 | void PrefPerformance::setCacheForTV(int n) {
|
|---|
| 190 | cache_tv_spin->setValue(n);
|
|---|
| 191 | }
|
|---|
| 192 |
|
|---|
| 193 | int PrefPerformance::cacheForTV() {
|
|---|
| 194 | return cache_tv_spin->value();
|
|---|
| 195 | }
|
|---|
| 196 |
|
|---|
| 197 | void PrefPerformance::setPriority(int n) {
|
|---|
| 198 | priority_combo->setCurrentIndex(n);
|
|---|
| 199 | }
|
|---|
| 200 |
|
|---|
| 201 | int PrefPerformance::priority() {
|
|---|
| 202 | return priority_combo->currentIndex();
|
|---|
| 203 | }
|
|---|
| 204 |
|
|---|
| 205 | void PrefPerformance::setFrameDrop(bool b) {
|
|---|
| 206 | framedrop_check->setChecked(b);
|
|---|
| 207 | }
|
|---|
| 208 |
|
|---|
| 209 | bool PrefPerformance::frameDrop() {
|
|---|
| 210 | return framedrop_check->isChecked();
|
|---|
| 211 | }
|
|---|
| 212 |
|
|---|
| 213 | void PrefPerformance::setHardFrameDrop(bool b) {
|
|---|
| 214 | hardframedrop_check->setChecked(b);
|
|---|
| 215 | }
|
|---|
| 216 |
|
|---|
| 217 | bool PrefPerformance::hardFrameDrop() {
|
|---|
| 218 | return hardframedrop_check->isChecked();
|
|---|
| 219 | }
|
|---|
| 220 |
|
|---|
| 221 | void PrefPerformance::setCoreavcUsage(bool b) {
|
|---|
| 222 | coreavc_check->setChecked(b);
|
|---|
| 223 | }
|
|---|
| 224 |
|
|---|
| 225 | bool PrefPerformance::coreavcUsage() {
|
|---|
| 226 | return coreavc_check->isChecked();
|
|---|
| 227 | }
|
|---|
| 228 |
|
|---|
| 229 | void PrefPerformance::setSkipLoop(Preferences::H264LoopFilter value) {
|
|---|
| 230 | loopfilter_combo->setCurrentIndex(loopfilter_combo->findData(value));
|
|---|
| 231 | }
|
|---|
| 232 |
|
|---|
| 233 | Preferences::H264LoopFilter PrefPerformance::skipLoop() {
|
|---|
| 234 | return (Preferences::H264LoopFilter) loopfilter_combo->itemData(loopfilter_combo->currentIndex()).toInt();
|
|---|
| 235 | }
|
|---|
| 236 |
|
|---|
| 237 | #if !SMART_DVD_CHAPTERS
|
|---|
| 238 | void PrefPerformance::setFastChapterSeeking(bool b) {
|
|---|
| 239 | fast_chapter_check->setChecked(b);
|
|---|
| 240 | }
|
|---|
| 241 |
|
|---|
| 242 | bool PrefPerformance::fastChapterSeeking() {
|
|---|
| 243 | return fast_chapter_check->isChecked();
|
|---|
| 244 | }
|
|---|
| 245 | #endif
|
|---|
| 246 |
|
|---|
| 247 | void PrefPerformance::setFastAudioSwitching(Preferences::OptionState value) {
|
|---|
| 248 | fast_audio_combo->setState(value);
|
|---|
| 249 | }
|
|---|
| 250 |
|
|---|
| 251 | Preferences::OptionState PrefPerformance::fastAudioSwitching() {
|
|---|
| 252 | return fast_audio_combo->state();
|
|---|
| 253 | }
|
|---|
| 254 |
|
|---|
| 255 | void PrefPerformance::setThreads(int v) {
|
|---|
| 256 | threads_spin->setValue(v);
|
|---|
| 257 | }
|
|---|
| 258 |
|
|---|
| 259 | int PrefPerformance::threads() {
|
|---|
| 260 | return threads_spin->value();
|
|---|
| 261 | }
|
|---|
| 262 |
|
|---|
| 263 | #ifdef YOUTUBE_SUPPORT
|
|---|
| 264 | void PrefPerformance::setYTQuality(int q) {
|
|---|
| 265 | yt_quality_combo->setCurrentIndex(yt_quality_combo->findData(q));
|
|---|
| 266 | }
|
|---|
| 267 |
|
|---|
| 268 | int PrefPerformance::YTQuality() {
|
|---|
| 269 | int index = yt_quality_combo->currentIndex();
|
|---|
| 270 | return yt_quality_combo->itemData(index).toInt();
|
|---|
| 271 | }
|
|---|
| 272 | #endif
|
|---|
| 273 |
|
|---|
| 274 | void PrefPerformance::createHelp() {
|
|---|
| 275 | clearHelp();
|
|---|
| 276 |
|
|---|
| 277 | addSectionTitle(tr("Performance"));
|
|---|
| 278 |
|
|---|
| 279 | // Performance tab
|
|---|
| 280 | #ifdef Q_OS_WIN
|
|---|
| 281 | setWhatsThis(priority_combo, tr("Priority"),
|
|---|
| 282 | tr("Set process priority for mplayer according to the predefined "
|
|---|
| 283 | "priorities available under Windows.<br>"
|
|---|
| 284 | "<b>Warning:</b> Using realtime priority can cause system lockup."));
|
|---|
| 285 | #endif
|
|---|
| 286 |
|
|---|
| 287 | setWhatsThis(framedrop_check, tr("Allow frame drop"),
|
|---|
| 288 | tr("Skip displaying some frames to maintain A/V sync on slow systems." ) );
|
|---|
| 289 |
|
|---|
| 290 | setWhatsThis(hardframedrop_check, tr("Allow hard frame drop"),
|
|---|
| 291 | tr("More intense frame dropping (breaks decoding). "
|
|---|
| 292 | "Leads to image distortion!") );
|
|---|
| 293 |
|
|---|
| 294 | setWhatsThis(threads_spin, tr("Threads for decoding"),
|
|---|
| 295 | tr("Sets the number of threads to use for decoding. Only for "
|
|---|
| 296 | "MPEG-1/2 and H.264") );
|
|---|
| 297 |
|
|---|
| 298 | setWhatsThis(coreavc_check, tr("Use CoreAVC if no other codec specified"),
|
|---|
| 299 | tr("Try to use non-free CoreAVC codec with no other codec is specified and non-VDPAU video output selected. Requires MPlayer build with CoreAVC support."));
|
|---|
| 300 |
|
|---|
| 301 | setWhatsThis(loopfilter_combo, tr("Skip loop filter"),
|
|---|
| 302 | tr("This option allows to skips the loop filter (AKA deblocking) "
|
|---|
| 303 | "during H.264 decoding. "
|
|---|
| 304 | "Since the filtered frame is supposed to be used as reference "
|
|---|
| 305 | "for decoding dependent frames this has a worse effect on quality "
|
|---|
| 306 | "than not doing deblocking on e.g. MPEG-2 video. But at least for "
|
|---|
| 307 | "high bitrate HDTV this provides a big speedup with no visible "
|
|---|
| 308 | "quality loss.") +"<br>"+
|
|---|
| 309 | tr("Possible values:") +"<br>" +
|
|---|
| 310 | tr("<b>Enabled</b>: the loop filter is not skipped")+"<br>"+
|
|---|
| 311 | tr("<b>Skip (always)</b>: the loop filter is skipped no matter the "
|
|---|
| 312 | "resolution of the video")+"<br>"+
|
|---|
| 313 | tr("<b>Skip only on HD videos</b>: the loop filter will be "
|
|---|
| 314 | "skipped only on videos which height is %1 or "
|
|---|
| 315 | "greater.").arg(pref->HD_height) +"<br>" );
|
|---|
| 316 |
|
|---|
| 317 | setWhatsThis(fast_audio_combo, tr("Fast audio track switching"),
|
|---|
| 318 | tr("Possible values:<br> "
|
|---|
| 319 | "<b>Yes</b>: it will try the fastest method "
|
|---|
| 320 | "to switch the audio track (it might not work with some formats).<br> "
|
|---|
| 321 | "<b>No</b>: the MPlayer process will be restarted whenever you "
|
|---|
| 322 | "change the audio track.<br> "
|
|---|
| 323 | "<b>Auto</b>: SMPlayer will decide what to do according to the "
|
|---|
| 324 | "MPlayer version." ) );
|
|---|
| 325 |
|
|---|
| 326 | #if !SMART_DVD_CHAPTERS
|
|---|
| 327 | setWhatsThis(fast_chapter_check, tr("Fast seek to chapters in dvds"),
|
|---|
| 328 | tr("If checked, it will try the fastest method to seek to chapters "
|
|---|
| 329 | "but it might not work with some discs.") );
|
|---|
| 330 | #endif
|
|---|
| 331 |
|
|---|
| 332 | #ifdef YOUTUBE_SUPPORT
|
|---|
| 333 | setWhatsThis(yt_quality_combo, tr("Youtube quality"),
|
|---|
| 334 | tr("Select the preferred quality for youtube videos.") );
|
|---|
| 335 | #endif
|
|---|
| 336 |
|
|---|
| 337 | addSectionTitle(tr("Cache"));
|
|---|
| 338 |
|
|---|
| 339 | setWhatsThis(cache_files_spin, tr("Cache for files"),
|
|---|
| 340 | tr("This option specifies how much memory (in kBytes) to use when "
|
|---|
| 341 | "precaching a file.") );
|
|---|
| 342 |
|
|---|
| 343 | setWhatsThis(cache_streams_spin, tr("Cache for streams"),
|
|---|
| 344 | tr("This option specifies how much memory (in kBytes) to use when "
|
|---|
| 345 | "precaching a URL.") );
|
|---|
| 346 |
|
|---|
| 347 | setWhatsThis(cache_dvds_spin, tr("Cache for DVDs"),
|
|---|
| 348 | tr("This option specifies how much memory (in kBytes) to use when "
|
|---|
| 349 | "precaching a DVD.<br><b>Warning:</b> Seeking might not work "
|
|---|
| 350 | "properly (including chapter switching) when using a cache for DVDs.") );
|
|---|
| 351 |
|
|---|
| 352 | setWhatsThis(cache_cds_spin, tr("Cache for audio CDs"),
|
|---|
| 353 | tr("This option specifies how much memory (in kBytes) to use when "
|
|---|
| 354 | "precaching an audio CD.") );
|
|---|
| 355 |
|
|---|
| 356 | setWhatsThis(cache_vcds_spin, tr("Cache for VCDs"),
|
|---|
| 357 | tr("This option specifies how much memory (in kBytes) to use when "
|
|---|
| 358 | "precaching a VCD.") );
|
|---|
| 359 | }
|
|---|
| 360 |
|
|---|
| 361 | #include "moc_prefperformance.cpp"
|
|---|