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

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

SMPlayer: 0.7.1 trunk update

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