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

Last change on this file since 112 was 112, checked in by Silvan Scherrer, 15 years ago

Smplayer: eol-style

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