source: smplayer/trunk/src/mediasettings.cpp@ 142

Last change on this file since 142 was 142, checked in by Silvan Scherrer, 12 years ago

SMPlayer: update trunk to 0.8.5

  • Property svn:eol-style set to LF
File size: 16.8 KB
Line 
1/* smplayer, GUI front-end for mplayer.
2 Copyright (C) 2006-2013 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#include "mediasettings.h"
20#include "preferences.h"
21#include "global.h"
22#include <QSettings>
23
24using namespace Global;
25
26MediaSettings::MediaSettings() {
27 reset();
28}
29
30MediaSettings::~MediaSettings() {
31}
32
33void MediaSettings::reset() {
34 current_sec = 0;
35 //current_sub_id = SubNone;
36 current_sub_id = NoneSelected;
37#if PROGRAM_SWITCH
38 current_program_id = NoneSelected;
39#endif
40 current_video_id = NoneSelected;
41 current_audio_id = NoneSelected;
42 current_title_id = NoneSelected;
43 current_chapter_id = NoneSelected;
44 current_angle_id = NoneSelected;
45
46 aspect_ratio_id = AspectAuto;
47
48 //fullscreen = FALSE;
49 volume = pref->initial_volume;
50 mute = false;
51 external_subtitles = "";
52 external_subtitles_fps = SFPS_None;
53 external_audio = "";
54 sub_delay=0;
55 audio_delay=0;
56 sub_pos = pref->initial_sub_pos; // 100% by default
57 sub_scale = pref->initial_sub_scale;
58 sub_scale_ass = pref->initial_sub_scale_ass;
59
60 closed_caption_channel = 0; // disabled
61
62 brightness = pref->initial_brightness;
63 contrast = pref->initial_contrast;
64 gamma = pref->initial_gamma;
65 hue = pref->initial_hue;
66 saturation = pref->initial_saturation;
67
68 audio_equalizer = pref->initial_audio_equalizer;
69
70 speed = 1.0;
71
72 phase_filter = false;
73 deblock_filter = false;
74 dering_filter = false;
75 gradfun_filter = false;
76 noise_filter = false;
77 postprocessing_filter = pref->initial_postprocessing;
78 upscaling_filter = false;
79 current_denoiser = NoDenoise;
80 current_unsharp = 0;
81
82 //current_deinterlacer = NoDeinterlace;
83 current_deinterlacer = pref->initial_deinterlace;
84
85 add_letterbox = false;
86
87 karaoke_filter = false;
88 extrastereo_filter = false;
89 volnorm_filter = pref->initial_volnorm;
90
91 audio_use_channels = pref->initial_audio_channels; //ChDefault; // (0)
92 stereo_mode = pref->initial_stereo_mode; //Stereo; // (0)
93
94 zoom_factor = pref->initial_zoom_factor; // 1.0;
95
96#if USE_MPLAYER_PANSCAN
97 panscan_factor = 0;
98#endif
99
100 starting_time = -1; // Not set yet.
101
102 rotate = NoRotate;
103 flip = false;
104 mirror = false;
105
106 loop = false;
107 A_marker = -1;
108 B_marker = -1;
109
110 is264andHD = false;
111
112 forced_demuxer="";
113 forced_video_codec="";
114 forced_audio_codec="";
115
116 original_demuxer="";
117 original_video_codec="";
118 original_audio_codec="";
119
120 mplayer_additional_options="";
121 mplayer_additional_video_filters="";
122 mplayer_additional_audio_filters="";
123
124 win_width=400;
125 win_height=300;
126}
127
128double MediaSettings::win_aspect() {
129 return (double) win_width / win_height;
130}
131
132double MediaSettings::aspectToNum(Aspect aspect) {
133 double asp;
134
135 switch (aspect) {
136 case MediaSettings::AspectNone: asp = 0; break;
137 case MediaSettings::Aspect43: asp = (double) 4 / 3; break;
138 case MediaSettings::Aspect169: asp = (double) 16 / 9; break;
139 case MediaSettings::Aspect149: asp = (double) 14 / 9; break;
140 case MediaSettings::Aspect1610: asp = (double) 16 / 10; break;
141 case MediaSettings::Aspect54: asp = (double) 5 / 4; break;
142 case MediaSettings::Aspect235: asp = 2.35; break;
143 case MediaSettings::Aspect11: asp = 1; break;
144 case MediaSettings::Aspect32: asp = (double) 3 / 2; break;
145 case MediaSettings::Aspect1410: asp = (double) 14 / 10; break;
146 case MediaSettings::AspectAuto: asp = win_aspect(); break;
147 default: asp = win_aspect();
148 qWarning("MediaSettings::aspectToNum: invalid aspect: %d", aspect);
149 }
150
151 return asp;
152}
153
154QString MediaSettings::aspectToString(Aspect aspect) {
155 QString asp_name;
156
157 switch (aspect) {
158 case MediaSettings::AspectNone: asp_name = QObject::tr("disabled", "aspect_ratio"); break;
159 case MediaSettings::Aspect43: asp_name = "4:3"; break;
160 case MediaSettings::Aspect169: asp_name = "16:9"; break;
161 case MediaSettings::Aspect149: asp_name = "14:9"; break;
162 case MediaSettings::Aspect1610: asp_name = "16:10"; break;
163 case MediaSettings::Aspect54: asp_name = "5:4"; break;
164 case MediaSettings::Aspect235: asp_name = "2.35:1"; break;
165 case MediaSettings::Aspect11: asp_name = "1:1"; break;
166 case MediaSettings::Aspect32: asp_name = "3:2"; break;
167 case MediaSettings::Aspect1410: asp_name = "14:10"; break;
168 case MediaSettings::AspectAuto: asp_name = QObject::tr("auto", "aspect_ratio"); break;
169 default: asp_name = QObject::tr("unknown", "aspect_ratio");
170 }
171
172 return asp_name;
173}
174
175void MediaSettings::list() {
176 qDebug("MediaSettings::list");
177
178 qDebug(" current_sec: %f", current_sec);
179 qDebug(" current_sub_id: %d", current_sub_id);
180#if PROGRAM_SWITCH
181 qDebug(" current_program_id: %d", current_program_id);
182#endif
183 qDebug(" current_video_id: %d", current_video_id);
184 qDebug(" current_audio_id: %d", current_audio_id);
185 qDebug(" current_title_id: %d", current_title_id);
186 qDebug(" current_chapter_id: %d", current_chapter_id);
187 qDebug(" current_angle_id: %d", current_angle_id);
188
189 qDebug(" aspect_ratio_id: %d", aspect_ratio_id);
190 //qDebug(" fullscreen: %d", fullscreen);
191 qDebug(" volume: %d", volume);
192 qDebug(" mute: %d", mute);
193 qDebug(" external_subtitles: '%s'", external_subtitles.toUtf8().data());
194 qDebug(" external_subtitles_fps: '%d'", external_subtitles_fps);
195 qDebug(" external_audio: '%s'", external_audio.toUtf8().data());
196 qDebug(" sub_delay: %d", sub_delay);
197 qDebug(" audio_delay: %d", sub_delay);
198 qDebug(" sub_pos: %d", sub_pos);
199 qDebug(" sub_scale: %f", sub_scale);
200 qDebug(" sub_scale_ass: %f", sub_scale_ass);
201
202 qDebug(" closed_caption_channel: %d", closed_caption_channel);
203
204 qDebug(" brightness: %d", brightness);
205 qDebug(" contrast: %d", contrast);
206 qDebug(" gamma: %d", gamma);
207 qDebug(" hue: %d", hue);
208 qDebug(" saturation: %d", saturation);
209
210 qDebug(" speed: %f", speed);
211
212 qDebug(" phase_filter: %d", phase_filter);
213 qDebug(" deblock_filter: %d", deblock_filter);
214 qDebug(" dering_filter: %d", dering_filter);
215 qDebug(" gradfun_filter: %d", gradfun_filter);
216 qDebug(" noise_filter: %d", noise_filter);
217 qDebug(" postprocessing_filter: %d", postprocessing_filter);
218 qDebug(" upscaling_filter: %d", upscaling_filter);
219 qDebug(" current_denoiser: %d", current_denoiser);
220 qDebug(" current_unsharp: %d", current_unsharp);
221
222 qDebug(" current_deinterlacer: %d", current_deinterlacer);
223
224 qDebug(" add_letterbox: %d", add_letterbox);
225
226 qDebug(" karaoke_filter: %d", karaoke_filter);
227 qDebug(" extrastereo_filter: %d", extrastereo_filter);
228 qDebug(" volnorm_filter: %d", volnorm_filter);
229
230 qDebug(" audio_use_channels: %d", audio_use_channels);
231 qDebug(" stereo_mode: %d", stereo_mode);
232
233 qDebug(" zoom_factor: %f", zoom_factor);
234
235#if USE_MPLAYER_PANSCAN
236 qDebug(" panscan_factor: %f", zoom_factor);
237#endif
238
239 qDebug(" rotate: %d", rotate);
240 qDebug(" flip: %d", flip);
241 qDebug(" mirror: %d", mirror);
242
243 qDebug(" loop: %d", loop);
244 qDebug(" A_marker: %d", A_marker);
245 qDebug(" B_marker: %d", B_marker);
246
247 qDebug(" forced_demuxer: '%s'", forced_demuxer.toUtf8().data());
248 qDebug(" forced_video_codec: '%s'", forced_video_codec.toUtf8().data());
249 qDebug(" forced_audio_codec: '%s'", forced_video_codec.toUtf8().data());
250
251 qDebug(" original_demuxer: '%s'", original_demuxer.toUtf8().data());
252 qDebug(" original_video_codec: '%s'", original_video_codec.toUtf8().data());
253 qDebug(" original_audio_codec: '%s'", original_video_codec.toUtf8().data());
254
255 qDebug(" mplayer_additional_options: '%s'", mplayer_additional_options.toUtf8().data());
256 qDebug(" mplayer_additional_video_filters: '%s'", mplayer_additional_video_filters.toUtf8().data());
257 qDebug(" mplayer_additional_audio_filters: '%s'", mplayer_additional_audio_filters.toUtf8().data());
258
259 qDebug(" win_width: %d", win_width);
260 qDebug(" win_height: %d", win_height);
261 qDebug(" win_aspect(): %f", win_aspect());
262
263 qDebug(" starting_time: %f", starting_time);
264 qDebug(" is264andHD: %d", is264andHD);
265}
266
267#ifndef NO_USE_INI_FILES
268void MediaSettings::save(QSettings * set) {
269 qDebug("MediaSettings::save");
270
271 //QSettings * set = settings;
272
273 /*set->beginGroup( "mediasettings" );*/
274
275 set->setValue( "current_sec", current_sec );
276 set->setValue( "current_sub_id", current_sub_id );
277#if PROGRAM_SWITCH
278 set->setValue( "current_program_id", current_program_id );
279#endif
280 set->setValue( "current_video_id", current_video_id );
281 set->setValue( "current_audio_id", current_audio_id );
282 set->setValue( "current_title_id", current_title_id );
283 set->setValue( "current_chapter_id", current_chapter_id );
284 set->setValue( "current_angle_id", current_angle_id );
285
286 set->setValue( "aspect_ratio", aspect_ratio_id );
287 //set->setValue( "fullscreen", fullscreen );
288 set->setValue( "volume", volume );
289 set->setValue( "mute", mute );
290 set->setValue( "external_subtitles", external_subtitles );
291 set->setValue( "external_subtitles_fps", external_subtitles_fps );
292 set->setValue( "external_audio", external_audio );
293 set->setValue( "sub_delay", sub_delay);
294 set->setValue( "audio_delay", audio_delay);
295 set->setValue( "sub_pos", sub_pos);
296 set->setValue( "sub_scale", sub_scale);
297 set->setValue( "sub_scale_ass", sub_scale_ass);
298
299 set->setValue( "closed_caption_channel", closed_caption_channel);
300
301 set->setValue( "brightness", brightness);
302 set->setValue( "contrast", contrast);
303 set->setValue( "gamma", gamma);
304 set->setValue( "hue", hue);
305 set->setValue( "saturation", saturation);
306
307 set->setValue("audio_equalizer", audio_equalizer );
308
309 set->setValue( "speed", speed);
310
311 set->setValue( "phase_filter", phase_filter);
312 set->setValue( "deblock_filter", deblock_filter);
313 set->setValue( "dering_filter", dering_filter);
314 set->setValue( "gradfun_filter", gradfun_filter);
315 set->setValue( "noise_filter", noise_filter);
316 set->setValue( "postprocessing_filter", postprocessing_filter);
317 set->setValue( "upscaling_filter", upscaling_filter);
318 set->setValue( "current_denoiser", current_denoiser);
319 set->setValue( "current_unsharp", current_unsharp);
320
321 set->setValue( "current_deinterlacer", current_deinterlacer);
322
323 set->setValue( "add_letterbox", add_letterbox );
324
325 set->setValue( "karaoke_filter", karaoke_filter);
326 set->setValue( "extrastereo_filter", extrastereo_filter);
327 set->setValue( "volnorm_filter", volnorm_filter);
328
329 set->setValue( "audio_use_channels", audio_use_channels);
330 set->setValue( "stereo_mode", stereo_mode);
331
332 set->setValue( "zoom_factor", zoom_factor);
333
334#if USE_MPLAYER_PANSCAN
335 set->setValue( "panscan_factor", zoom_factor);
336#endif
337
338 set->setValue( "rotate", rotate );
339 set->setValue( "flip", flip);
340 set->setValue( "mirror", mirror);
341
342 set->setValue( "loop", loop);
343 set->setValue( "A_marker", A_marker);
344 set->setValue( "B_marker", B_marker);
345
346 set->setValue( "forced_demuxer", forced_demuxer);
347 set->setValue( "forced_video_codec", forced_video_codec);
348 set->setValue( "forced_audio_codec", forced_audio_codec);
349
350 set->setValue( "original_demuxer", original_demuxer);
351 set->setValue( "original_video_codec", original_video_codec);
352 set->setValue( "original_audio_codec", original_audio_codec);
353
354 set->setValue( "mplayer_additional_options", mplayer_additional_options);
355 set->setValue( "mplayer_additional_video_filters", mplayer_additional_video_filters);
356 set->setValue( "mplayer_additional_audio_filters", mplayer_additional_audio_filters);
357
358 set->setValue( "win_width", win_width );
359 set->setValue( "win_height", win_height );
360
361 set->setValue( "starting_time", starting_time );
362
363 set->setValue( "is264andHD", is264andHD );
364
365 /*set->endGroup();*/
366}
367
368void MediaSettings::load(QSettings * set) {
369 qDebug("MediaSettings::load");
370
371 //QSettings * set = settings;
372
373 /*set->beginGroup( "mediasettings" );*/
374
375 current_sec = set->value( "current_sec", current_sec).toDouble();
376 current_sub_id = set->value( "current_sub_id", current_sub_id ).toInt();
377#if PROGRAM_SWITCH
378 current_program_id = set->value( "current_program_id", current_program_id ).toInt();
379#endif
380 current_video_id = set->value( "current_video_id", current_video_id ).toInt();
381 current_audio_id = set->value( "current_audio_id", current_audio_id ).toInt();
382 current_title_id = set->value( "current_title_id", current_title_id ).toInt();
383 current_chapter_id = set->value( "current_chapter_id", current_chapter_id ).toInt();
384 current_angle_id = set->value( "current_angle_id", current_angle_id ).toInt();
385
386 aspect_ratio_id = set->value( "aspect_ratio", aspect_ratio_id ).toInt();
387 //fullscreen = set->value( "fullscreen", fullscreen ).toBool();
388 volume = set->value( "volume", volume ).toInt();
389 mute = set->value( "mute", mute ).toBool();
390 external_subtitles = set->value( "external_subtitles", external_subtitles ).toString();
391 external_subtitles_fps = set->value( "external_subtitles_fps", external_subtitles_fps ).toInt();
392 external_audio = set->value( "external_audio", external_audio ).toString();
393 sub_delay = set->value( "sub_delay", sub_delay).toInt();
394 audio_delay = set->value( "audio_delay", audio_delay).toInt();
395 sub_pos = set->value( "sub_pos", sub_pos).toInt();
396 sub_scale = set->value( "sub_scale", sub_scale).toDouble();
397 sub_scale_ass = set->value( "sub_scale_ass", sub_scale_ass).toDouble();
398
399 closed_caption_channel = set->value( "closed_caption_channel", closed_caption_channel).toInt();
400
401 brightness = set->value( "brightness", brightness).toInt();
402 contrast = set->value( "contrast", contrast).toInt();
403 gamma = set->value( "gamma", gamma).toInt();
404 hue = set->value( "hue", hue).toInt();
405 saturation = set->value( "saturation", saturation).toInt();
406
407 audio_equalizer = set->value("audio_equalizer", audio_equalizer ).toList();
408
409 speed = set->value( "speed", speed ).toDouble();
410
411 phase_filter = set->value( "phase_filter", phase_filter ).toBool();
412 deblock_filter = set->value( "deblock_filter", deblock_filter).toBool();
413 dering_filter = set->value( "dering_filter", dering_filter).toBool();
414 gradfun_filter = set->value( "gradfun_filter", gradfun_filter).toBool();
415 noise_filter = set->value( "noise_filter", noise_filter).toBool();
416 postprocessing_filter = set->value( "postprocessing_filter", postprocessing_filter).toBool();
417 upscaling_filter = set->value( "upscaling_filter", upscaling_filter).toBool();
418 current_denoiser = set->value( "current_denoiser", current_denoiser).toInt();
419 current_unsharp = set->value( "current_unsharp", current_unsharp).toInt();
420
421 current_deinterlacer = set->value( "current_deinterlacer", current_deinterlacer ).toInt();
422
423 add_letterbox = set->value( "add_letterbox", add_letterbox ).toBool();
424
425 karaoke_filter = set->value( "karaoke_filter", karaoke_filter).toBool();
426 extrastereo_filter = set->value( "extrastereo_filter", extrastereo_filter).toBool();
427 volnorm_filter = set->value( "volnorm_filter", volnorm_filter).toBool();
428
429 audio_use_channels = set->value( "audio_use_channels", audio_use_channels).toInt();
430 stereo_mode = set->value( "stereo_mode", stereo_mode).toInt();
431
432 zoom_factor = set->value( "zoom_factor", zoom_factor).toDouble();
433
434#if USE_MPLAYER_PANSCAN
435 panscan_factor = set->value( "panscan_factor", panscan_factor).toDouble();
436#endif
437
438 rotate = set->value( "rotate", rotate).toInt();
439 flip = set->value( "flip", flip).toBool();
440 mirror = set->value( "mirror", mirror).toBool();
441
442 loop = set->value( "loop", loop).toBool();
443 A_marker = set->value( "A_marker", A_marker).toInt();
444 B_marker = set->value( "B_marker", B_marker).toInt();
445
446 forced_demuxer = set->value( "forced_demuxer", forced_demuxer).toString();
447 forced_video_codec = set->value( "forced_video_codec", forced_video_codec).toString();
448 forced_audio_codec = set->value( "forced_audio_codec", forced_audio_codec).toString();
449
450 original_demuxer = set->value( "original_demuxer", original_demuxer).toString();
451 original_video_codec = set->value( "original_video_codec", original_video_codec).toString();
452 original_audio_codec = set->value( "original_audio_codec", original_audio_codec).toString();
453
454 mplayer_additional_options = set->value( "mplayer_additional_options", mplayer_additional_options).toString();
455 mplayer_additional_video_filters = set->value( "mplayer_additional_video_filters", mplayer_additional_video_filters).toString();
456 mplayer_additional_audio_filters = set->value( "mplayer_additional_audio_filters", mplayer_additional_audio_filters).toString();
457
458 win_width = set->value( "win_width", win_width ).toInt();
459 win_height = set->value( "win_height", win_height ).toInt();
460
461 starting_time = set->value( "starting_time", starting_time ).toDouble();
462
463 is264andHD = set->value( "is264andHD", is264andHD ).toBool();
464
465 /*set->endGroup();*/
466
467 // ChDefault not used anymore
468 if (audio_use_channels == ChDefault) audio_use_channels = ChStereo;
469}
470
471#endif // NO_USE_INI_FILES
Note: See TracBrowser for help on using the repository browser.