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

Last change on this file since 128 was 128, checked in by Silvan Scherrer, 13 years ago

SMPlayer: trunk update to latest svn

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