1 /*****************************************************************************
2 * VideoEffects.m: MacOS X interface module
3 *****************************************************************************
4 * Copyright (C) 2011-2012 Felix Paul Kühne
7 * Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #import "CompatibilityFixes.h"
26 #import <vlc_common.h>
27 #import <vlc_modules.h>
28 #import <vlc_charset.h>
29 #import "VideoEffects.h"
32 #pragma mark Initialization & Generic code
34 @implementation VLCVideoEffects
35 static VLCVideoEffects *_o_sharedInstance = nil;
37 + (VLCVideoEffects *)sharedInstance
39 return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
44 if (_o_sharedInstance) {
48 _o_sharedInstance = [super init];
51 return _o_sharedInstance;
54 - (IBAction)toggleWindow:(id)sender
56 if( [o_window isVisible] )
57 [o_window orderOut:sender];
59 [o_window makeKeyAndOrderFront:sender];
64 [o_window setTitle: _NS("Video Effects")];
65 [o_window setExcludedFromWindowsMenu:YES];
67 [o_window setCollectionBehavior: NSWindowCollectionBehaviorFullScreenAuxiliary];
69 [[o_tableView tabViewItemAtIndex:[o_tableView indexOfTabViewItemWithIdentifier:@"basic"]] setLabel:_NS("Basic")];
70 [[o_tableView tabViewItemAtIndex:[o_tableView indexOfTabViewItemWithIdentifier:@"crop"]] setLabel:_NS("Crop")];
71 [[o_tableView tabViewItemAtIndex:[o_tableView indexOfTabViewItemWithIdentifier:@"geometry"]] setLabel:_NS("Geometry")];
72 [[o_tableView tabViewItemAtIndex:[o_tableView indexOfTabViewItemWithIdentifier:@"color"]] setLabel:_NS("Color")];
73 [[o_tableView tabViewItemAtIndex:[o_tableView indexOfTabViewItemWithIdentifier:@"misc"]] setLabel:_NS("Miscellaneous")];
75 [o_adjust_ckb setTitle:_NS("Image Adjust")];
76 [o_adjust_hue_lbl setStringValue:_NS("Hue")];
77 [o_adjust_contrast_lbl setStringValue:_NS("Contrast")];
78 [o_adjust_brightness_lbl setStringValue:_NS("Brightness")];
79 [o_adjust_brightness_ckb setTitle:_NS("Brightness Threshold")];
80 [o_adjust_saturation_lbl setStringValue:_NS("Saturation")];
81 [o_adjust_gamma_lbl setStringValue:_NS("Gamma")];
82 [o_adjust_reset_btn setTitle: _NS("Reset")];
83 [o_sharpen_ckb setTitle:_NS("Sharpen")];
84 [o_sharpen_lbl setStringValue:_NS("Sigma")];
85 [o_banding_ckb setTitle:_NS("Banding removal")];
86 [o_banding_lbl setStringValue:_NS("Radius")];
87 [o_grain_ckb setTitle:_NS("Film Grain")];
88 [o_grain_lbl setStringValue:_NS("Variance")];
89 [o_crop_top_lbl setStringValue:_NS("Top")];
90 [o_crop_left_lbl setStringValue:_NS("Left")];
91 [o_crop_right_lbl setStringValue:_NS("Right")];
92 [o_crop_bottom_lbl setStringValue:_NS("Bottom")];
93 [o_crop_sync_top_bottom_ckb setTitle:_NS("Synchronize top and bottom")];
94 [o_crop_sync_left_right_ckb setTitle:_NS("Synchronize left and right")];
96 [o_transform_ckb setTitle:_NS("Transform")];
97 [o_transform_pop removeAllItems];
98 [o_transform_pop addItemWithTitle: _NS("Rotate by 90 degrees")];
99 [[o_transform_pop lastItem] setTag: 90];
100 [o_transform_pop addItemWithTitle: _NS("Rotate by 180 degrees")];
101 [[o_transform_pop lastItem] setTag: 180];
102 [o_transform_pop addItemWithTitle: _NS("Rotate by 270 degrees")];
103 [[o_transform_pop lastItem] setTag: 270];
104 [o_transform_pop addItemWithTitle: _NS("Flip horizontally")];
105 [[o_transform_pop lastItem] setTag: 1];
106 [o_transform_pop addItemWithTitle: _NS("Flip vertically")];
107 [[o_transform_pop lastItem] setTag: 2];
108 [o_zoom_ckb setTitle:_NS("Magnification/Zoom")];
109 [o_puzzle_ckb setTitle:_NS("Puzzle game")];
110 [o_puzzle_rows_lbl setStringValue:_NS("Rows")];
111 [o_puzzle_columns_lbl setStringValue:_NS("Columns")];
112 [o_puzzle_blackslot_ckb setTitle:_NS("Black Slot")];
114 [o_threshold_ckb setTitle:_NS("Color threshold")];
115 [o_threshold_color_lbl setStringValue:_NS("Color")];
116 [o_threshold_saturation_lbl setStringValue:_NS("Saturation")];
117 [o_threshold_similarity_lbl setStringValue:_NS("Similarity")];
118 [o_sepia_ckb setTitle:_NS("Sepia")];
119 [o_sepia_lbl setStringValue:_NS("Intensity")];
120 [o_noise_ckb setTitle:_NS("Noise")];
121 [o_gradient_ckb setTitle:_NS("Gradient")];
122 [o_gradient_mode_lbl setStringValue:_NS("Mode")];
123 [o_gradient_mode_pop removeAllItems];
124 [o_gradient_mode_pop addItemWithTitle: _NS("Gradient")];
125 [[o_gradient_mode_pop lastItem] setTag: 1];
126 [o_gradient_mode_pop addItemWithTitle: _NS("Edge")];
127 [[o_gradient_mode_pop lastItem] setTag: 2];
128 [o_gradient_mode_pop addItemWithTitle: _NS("Hough")];
129 [[o_gradient_mode_pop lastItem] setTag: 3];
130 [o_gradient_color_ckb setTitle:_NS("Color")];
131 [o_gradient_cartoon_ckb setTitle:_NS("Cartoon")];
132 [o_extract_ckb setTitle:_NS("Color extraction")];
133 [o_extract_lbl setStringValue:_NS("Color")];
134 [o_invert_ckb setTitle:_NS("Invert colors")];
135 [o_posterize_ckb setTitle:_NS("Posterize")];
136 [o_posterize_lbl setStringValue:_NS("Posterize level")];
137 [o_blur_ckb setTitle:_NS("Motion blur")];
138 [o_blur_lbl setStringValue:_NS("Factor")];
139 [o_motiondetect_ckb setTitle:_NS("Motion Detect")];
140 [o_watereffect_ckb setTitle:_NS("Water effect")];
141 [o_waves_ckb setTitle:_NS("Waves")];
142 [o_psychedelic_ckb setTitle:_NS("Psychedelic")];
144 [o_addtext_ckb setTitle:_NS("Add text")];
145 [o_addtext_text_lbl setStringValue:_NS("Text")];
146 [o_addtext_pos_lbl setStringValue:_NS("Position")];
147 [o_addtext_pos_pop removeAllItems];
148 [o_addtext_pos_pop addItemWithTitle: _NS("Center")];
149 [[o_addtext_pos_pop lastItem] setTag: 0];
150 [o_addtext_pos_pop addItemWithTitle: _NS("Left")];
151 [[o_addtext_pos_pop lastItem] setTag: 1];
152 [o_addtext_pos_pop addItemWithTitle: _NS("Right")];
153 [[o_addtext_pos_pop lastItem] setTag: 2];
154 [o_addtext_pos_pop addItemWithTitle: _NS("Top")];
155 [[o_addtext_pos_pop lastItem] setTag: 4];
156 [o_addtext_pos_pop addItemWithTitle: _NS("Bottom")];
157 [[o_addtext_pos_pop lastItem] setTag: 8];
158 [o_addtext_pos_pop addItemWithTitle: _NS("Top-Left")];
159 [[o_addtext_pos_pop lastItem] setTag: 5];
160 [o_addtext_pos_pop addItemWithTitle: _NS("Top-Right")];
161 [[o_addtext_pos_pop lastItem] setTag: 6];
162 [o_addtext_pos_pop addItemWithTitle: _NS("Bottom-Left")];
163 [[o_addtext_pos_pop lastItem] setTag: 9];
164 [o_addtext_pos_pop addItemWithTitle: _NS("Bottom-Right")];
165 [[o_addtext_pos_pop lastItem] setTag: 10];
166 [o_addlogo_ckb setTitle:_NS("Add logo")];
167 [o_addlogo_logo_lbl setStringValue:_NS("Logo")];
168 [o_addlogo_pos_lbl setStringValue:_NS("Position")];
169 [o_addlogo_pos_pop removeAllItems];
170 [o_addlogo_pos_pop addItemWithTitle: _NS("Center")];
171 [[o_addlogo_pos_pop lastItem] setTag: 0];
172 [o_addlogo_pos_pop addItemWithTitle: _NS("Left")];
173 [[o_addlogo_pos_pop lastItem] setTag: 1];
174 [o_addlogo_pos_pop addItemWithTitle: _NS("Right")];
175 [[o_addlogo_pos_pop lastItem] setTag: 2];
176 [o_addlogo_pos_pop addItemWithTitle: _NS("Top")];
177 [[o_addlogo_pos_pop lastItem] setTag: 4];
178 [o_addlogo_pos_pop addItemWithTitle: _NS("Bottom")];
179 [[o_addlogo_pos_pop lastItem] setTag: 8];
180 [o_addlogo_pos_pop addItemWithTitle: _NS("Top-Left")];
181 [[o_addlogo_pos_pop lastItem] setTag: 5];
182 [o_addlogo_pos_pop addItemWithTitle: _NS("Top-Right")];
183 [[o_addlogo_pos_pop lastItem] setTag: 6];
184 [o_addlogo_pos_pop addItemWithTitle: _NS("Bottom-Left")];
185 [[o_addlogo_pos_pop lastItem] setTag: 9];
186 [o_addlogo_pos_pop addItemWithTitle: _NS("Bottom-Right")];
187 [[o_addlogo_pos_pop lastItem] setTag: 10];
188 [o_addlogo_transparency_lbl setStringValue:_NS("Transparency")];
190 [o_tableView selectFirstTabViewItem:self];
201 /* do we have any filter enabled? if yes, show it. */
203 psz_vfilters = config_GetPsz( p_intf, "video-filter" );
205 [o_adjust_ckb setState: (NSInteger)strstr( psz_vfilters, "adjust")];
206 [o_sharpen_ckb setState: (NSInteger)strstr( psz_vfilters, "sharpen")];
207 [o_banding_ckb setState: (NSInteger)strstr( psz_vfilters, "gradfun")];
208 [o_grain_ckb setState: (NSInteger)strstr( psz_vfilters, "grain")];
209 [o_transform_ckb setState: (NSInteger)strstr( psz_vfilters, "transform")];
210 [o_zoom_ckb setState: (NSInteger)strstr( psz_vfilters, "magnify")];
211 [o_puzzle_ckb setState: (NSInteger)strstr( psz_vfilters, "puzzle")];
212 [o_threshold_ckb setState: (NSInteger)strstr( psz_vfilters, "colorthres")];
213 [o_sepia_ckb setState: (NSInteger)strstr( psz_vfilters, "sepia")];
214 [o_noise_ckb setState: (NSInteger)strstr( psz_vfilters, "noise")];
215 [o_gradient_ckb setState: (NSInteger)strstr( psz_vfilters, "gradient")];
216 [o_extract_ckb setState: (NSInteger)strstr( psz_vfilters, "extract")];
217 [o_invert_ckb setState: (NSInteger)strstr( psz_vfilters, "invert")];
218 [o_posterize_ckb setState: (NSInteger)strstr( psz_vfilters, "posterize")];
219 [o_blur_ckb setState: (NSInteger)strstr( psz_vfilters, "motionblur")];
220 [o_motiondetect_ckb setState: (NSInteger)strstr( psz_vfilters, "motiondetect")];
221 [o_watereffect_ckb setState: (NSInteger)strstr( psz_vfilters, "ripple")];
222 [o_waves_ckb setState: (NSInteger)strstr( psz_vfilters, "wave")];
223 [o_psychedelic_ckb setState: (NSInteger)strstr( psz_vfilters, "psychedelic")];
224 free( psz_vfilters );
226 psz_vfilters = config_GetPsz( p_intf, "sub-source" );
228 [o_addtext_ckb setState: (NSInteger)strstr( psz_vfilters, "marq" )];
229 [o_addlogo_ckb setState: (NSInteger)strstr( psz_vfilters, "logo" )];
230 free( psz_vfilters );
233 /* fetch and show the various values */
234 [o_adjust_hue_sld setIntValue: config_GetInt( p_intf, "hue" )];
235 [o_adjust_contrast_sld setFloatValue: config_GetFloat( p_intf, "contrast" )];
236 [o_adjust_brightness_sld setFloatValue: config_GetFloat( p_intf, "brightness" )];
237 [o_adjust_saturation_sld setFloatValue: config_GetFloat( p_intf, "saturation" )];
238 [o_adjust_gamma_sld setFloatValue: config_GetFloat( p_intf, "gamma" )];
239 [o_adjust_brightness_sld setToolTip: [NSString stringWithFormat:@"%0.3f", config_GetFloat( p_intf, "brightness" )]];
240 [o_adjust_contrast_sld setToolTip: [NSString stringWithFormat:@"%0.3f", config_GetFloat( p_intf, "contrast" )]];
241 [o_adjust_gamma_sld setToolTip: [NSString stringWithFormat:@"%0.3f", config_GetFloat( p_intf, "gamma" )]];
242 [o_adjust_hue_sld setToolTip: [NSString stringWithFormat:@"%lli", config_GetInt( p_intf, "hue" )]];
243 [o_adjust_saturation_sld setToolTip: [NSString stringWithFormat:@"%0.3f", config_GetFloat( p_intf, "saturation" )]];
244 b_state = [o_adjust_ckb state];
245 [o_adjust_brightness_sld setEnabled: b_state];
246 [o_adjust_brightness_ckb setEnabled: b_state];
247 [o_adjust_contrast_sld setEnabled: b_state];
248 [o_adjust_gamma_sld setEnabled: b_state];
249 [o_adjust_hue_sld setEnabled: b_state];
250 [o_adjust_saturation_sld setEnabled: b_state];
251 [o_adjust_brightness_lbl setEnabled: b_state];
252 [o_adjust_contrast_lbl setEnabled: b_state];
253 [o_adjust_gamma_lbl setEnabled: b_state];
254 [o_adjust_hue_lbl setEnabled: b_state];
255 [o_adjust_saturation_lbl setEnabled: b_state];
256 [o_adjust_reset_btn setEnabled: b_state];
257 [o_sharpen_sld setFloatValue: config_GetFloat( p_intf, "sharpen-sigma" )];
258 [o_sharpen_sld setToolTip: [NSString stringWithFormat:@"%0.3f", config_GetFloat( p_intf, "sharpen-sigma" )]];
259 [o_sharpen_sld setEnabled: [o_sharpen_ckb state]];
260 [o_sharpen_lbl setEnabled: [o_sharpen_ckb state]];
261 [o_banding_sld setIntValue: config_GetInt( p_intf, "gradfun-radius" )];
262 [o_banding_sld setToolTip: [NSString stringWithFormat:@"%lli", config_GetInt( p_intf, "gradfun-radius" )]];
263 [o_banding_sld setEnabled: [o_banding_ckb state]];
264 [o_banding_lbl setEnabled: [o_banding_ckb state]];
265 [o_grain_sld setFloatValue: config_GetFloat( p_intf, "grain-variance" )];
266 [o_grain_sld setToolTip: [NSString stringWithFormat:@"%0.3f", config_GetFloat( p_intf, "grain-variance" )]];
267 [o_grain_sld setEnabled: [o_grain_ckb state]];
268 [o_grain_lbl setEnabled: [o_grain_ckb state]];
270 [o_crop_top_fld setIntValue: 0];
271 [o_crop_left_fld setIntValue: 0];
272 [o_crop_right_fld setIntValue: 0];
273 [o_crop_bottom_fld setIntValue: 0];
274 [o_crop_sync_top_bottom_ckb setState: NSOffState];
275 [o_crop_sync_left_right_ckb setState: NSOffState];
277 tmpChar = config_GetPsz( p_intf, "transform-type" );
278 tmpString = [NSString stringWithUTF8String: tmpChar];
279 if( [tmpString isEqualToString:@"hflip"] )
280 [o_transform_pop selectItemWithTag: 1];
281 else if( [tmpString isEqualToString:@"vflip"] )
282 [o_transform_pop selectItemWithTag: 2];
284 [o_transform_pop selectItemWithTag:[tmpString intValue]];
286 [o_transform_pop setEnabled: [o_transform_ckb state]];
287 [o_puzzle_rows_fld setIntValue: config_GetInt( p_intf, "puzzle-rows" )];
288 [o_puzzle_columns_fld setIntValue: config_GetInt( p_intf, "puzzle-cols" )];
289 [o_puzzle_blackslot_ckb setState: config_GetInt( p_intf, "puzzle-black-slot" )];
290 b_state = [o_puzzle_ckb state];
291 [o_puzzle_rows_fld setEnabled: b_state];
292 [o_puzzle_rows_lbl setEnabled: b_state];
293 [o_puzzle_columns_fld setEnabled: b_state];
294 [o_puzzle_columns_lbl setEnabled: b_state];
295 [o_puzzle_blackslot_ckb setEnabled: b_state];
297 [o_threshold_color_fld setStringValue: [[NSString stringWithFormat:@"%llx", config_GetInt( p_intf, "colorthres-color" )] uppercaseString]];
298 [o_threshold_saturation_sld setIntValue: config_GetInt( p_intf, "colorthres-saturationthres" )];
299 [o_threshold_saturation_sld setToolTip: [NSString stringWithFormat:@"%lli", config_GetInt( p_intf, "colorthres-saturationthres" )]];
300 [o_threshold_similarity_sld setIntValue: config_GetInt( p_intf, "colorthres-similaritythres" )];
301 [o_threshold_similarity_sld setToolTip: [NSString stringWithFormat:@"%lli", config_GetInt( p_intf, "colorthres-similaritythres" )]];
302 b_state = [o_threshold_ckb state];
303 [o_threshold_color_fld setEnabled: b_state];
304 [o_threshold_color_lbl setEnabled: b_state];
305 [o_threshold_saturation_sld setEnabled: b_state];
306 [o_threshold_saturation_lbl setEnabled: b_state];
307 [o_threshold_similarity_sld setEnabled: b_state];
308 [o_threshold_similarity_lbl setEnabled: b_state];
309 [o_sepia_fld setIntValue: config_GetInt( p_intf, "sepia-intensity" )];
310 [o_sepia_fld setEnabled: [o_sepia_ckb state]];
311 [o_sepia_lbl setEnabled: [o_sepia_ckb state]];
312 tmpChar = config_GetPsz( p_intf, "gradient-mode" );
313 tmpString = [NSString stringWithUTF8String: tmpChar];
314 if( [tmpString isEqualToString:@"hough"] )
315 [o_gradient_mode_pop selectItemWithTag: 3];
316 else if( [tmpString isEqualToString:@"edge"] )
317 [o_gradient_mode_pop selectItemWithTag: 2];
319 [o_gradient_mode_pop selectItemWithTag: 1];
321 [o_gradient_cartoon_ckb setState: config_GetInt( p_intf, "gradient-cartoon" )];
322 [o_gradient_color_ckb setState: config_GetInt( p_intf, "gradient-type" )];
323 b_state = [o_gradient_ckb state];
324 [o_gradient_mode_pop setEnabled: b_state];
325 [o_gradient_mode_lbl setEnabled: b_state];
326 [o_gradient_cartoon_ckb setEnabled: b_state];
327 [o_gradient_color_ckb setEnabled: b_state];
328 [o_extract_fld setStringValue: [[NSString stringWithFormat:@"%llx", config_GetInt( p_intf, "extract-component" )] uppercaseString]];
329 [o_extract_fld setEnabled: [o_extract_ckb state]];
330 [o_extract_lbl setEnabled: [o_extract_ckb state]];
331 [o_posterize_fld setIntValue: config_GetInt( p_intf, "posterize-level" )];
332 [o_posterize_fld setEnabled: [o_posterize_ckb state]];
333 [o_posterize_lbl setEnabled: [o_posterize_ckb state]];
334 [o_blur_sld setIntValue: config_GetInt( p_intf, "blur-factor" )];
335 [o_blur_sld setToolTip: [NSString stringWithFormat:@"%lli", config_GetInt( p_intf, "blur-factor" )]];
336 [o_blur_sld setEnabled: [o_blur_ckb state]];
337 [o_blur_lbl setEnabled: [o_blur_ckb state]];
339 tmpChar = config_GetPsz( p_intf, "marq-marquee" );
342 [o_addtext_text_fld setStringValue: [NSString stringWithUTF8String: tmpChar]];
345 [o_addtext_pos_pop selectItemWithTag: config_GetInt( p_intf, "marq-position" )];
346 b_state = [o_addtext_ckb state];
347 [o_addtext_pos_pop setEnabled: b_state];
348 [o_addtext_pos_lbl setEnabled: b_state];
349 [o_addtext_text_lbl setEnabled: b_state];
350 [o_addtext_text_fld setEnabled: b_state];
352 tmpChar = config_GetPsz( p_intf, "logo-file" );
355 [o_addlogo_logo_fld setStringValue: [NSString stringWithUTF8String: tmpChar]];
358 [o_addlogo_pos_pop selectItemWithTag: config_GetInt( p_intf, "logo-position" )];
359 [o_addlogo_transparency_sld setIntValue: config_GetInt( p_intf, "logo-opacity" )];
360 [o_addlogo_transparency_sld setToolTip: [NSString stringWithFormat:@"%lli", config_GetInt( p_intf, "logo-opacity" )]];
361 b_state = [o_addlogo_ckb state];
362 [o_addlogo_pos_pop setEnabled: b_state];
363 [o_addlogo_pos_lbl setEnabled: b_state];
364 [o_addlogo_logo_fld setEnabled: b_state];
365 [o_addlogo_logo_lbl setEnabled: b_state];
366 [o_addlogo_transparency_sld setEnabled: b_state];
367 [o_addlogo_transparency_lbl setEnabled: b_state];
370 - (void)setVideoFilter: (char *)psz_name on:(BOOL)b_on
372 char *psz_string, *psz_parser;
373 const char *psz_filter_type;
375 module_t *p_obj = module_find( psz_name );
378 msg_Err( p_intf, "Unable to find filter module \"%s\".", psz_name );
381 msg_Dbg( p_intf, "will set filter '%s'", psz_name );
383 if( module_provides( p_obj, "video splitter" ) )
385 psz_filter_type = "video-splitter";
387 else if( module_provides( p_obj, "video filter2" ) )
389 psz_filter_type = "video-filter";
391 else if( module_provides( p_obj, "sub source" ) )
393 psz_filter_type = "sub-source";
395 else if( module_provides( p_obj, "sub filter" ) )
397 psz_filter_type = "sub-filter";
401 msg_Err( p_intf, "Unknown video filter type." );
405 psz_string = config_GetPsz( p_intf, psz_filter_type );
409 psz_string = psz_name;
410 else if( (NSInteger)strstr( psz_string, psz_name ) == NO )
411 psz_string = (char *)[[NSString stringWithFormat: @"%s:%s", psz_string, psz_name] UTF8String];
416 psz_parser = strstr( psz_string, psz_name );
419 if( *( psz_parser + strlen( psz_name ) ) == ':' )
421 memmove( psz_parser, psz_parser + strlen( psz_name ) + 1,
422 strlen( psz_parser + strlen( psz_name ) + 1 ) + 1 );
429 /* Remove trailing : : */
430 if( strlen( psz_string ) > 0 &&
431 *( psz_string + strlen( psz_string ) -1 ) == ':' )
433 *( psz_string + strlen( psz_string ) -1 ) = '\0';
442 config_PutPsz( p_intf, psz_filter_type, psz_string );
444 /* Try to set on the fly */
445 if( !strcmp( psz_filter_type, "video-splitter" ) )
447 playlist_t *p_playlist = pl_Get( p_intf );
448 var_SetString( p_playlist, psz_filter_type, psz_string );
452 vout_thread_t *p_vout = getVout();
455 var_SetString( p_vout, psz_filter_type, psz_string );
456 vlc_object_release( p_vout );
461 - (void)restartFilterIfNeeded: (char *)psz_filter option: (char *)psz_name
463 vout_thread_t *p_vout = getVout();
468 vlc_object_release( p_vout );
470 vlc_object_t *p_filter = vlc_object_find_name( pl_Get(p_intf), psz_filter );
472 i_type = var_Type( p_filter, psz_name );
474 i_type = config_GetType( p_intf, psz_name );
476 if( !(i_type & VLC_VAR_ISCOMMAND) )
478 msg_Warn( p_intf, "Brute-restarting filter '%s', because the last changed option isn't a command", psz_name );
479 [self setVideoFilter: psz_filter on: NO];
480 [self setVideoFilter: psz_filter on: YES];
483 msg_Dbg( p_intf, "restart not needed" );
486 vlc_object_release( p_filter );
489 - (void)setVideoFilterProperty: (char *)psz_name forFilter: (char *)psz_filter integer: (int)i_value
491 vout_thread_t *p_vout = getVout();
492 vlc_object_t *p_filter;
494 if( p_vout == NULL ) {
495 config_PutInt( p_intf , psz_name , i_value );
497 p_filter = vlc_object_find_name( pl_Get(p_intf), psz_filter );
500 msg_Err( p_intf, "we're unable to find the filter '%s'", psz_filter );
501 vlc_object_release( p_vout );
504 var_SetInteger( p_filter, psz_name, i_value );
505 config_PutInt( p_intf, psz_name, i_value );
506 vlc_object_release( p_vout );
507 vlc_object_release( p_filter );
510 [self restartFilterIfNeeded:psz_filter option: psz_name];
513 - (void)setVideoFilterProperty: (char *)psz_name forFilter: (char *)psz_filter float: (float)f_value
515 vout_thread_t *p_vout = getVout();
516 vlc_object_t *p_filter;
518 if( p_vout == NULL ) {
519 config_PutFloat( p_intf , psz_name , f_value );
521 p_filter = vlc_object_find_name( pl_Get(p_intf), psz_filter );
524 msg_Err( p_intf, "we're unable to find the filter '%s'", psz_filter );
525 vlc_object_release( p_vout );
528 var_SetFloat( p_filter, psz_name, f_value );
529 config_PutFloat( p_intf, psz_name, f_value );
530 vlc_object_release( p_vout );
531 vlc_object_release( p_filter );
533 [self restartFilterIfNeeded:psz_filter option: psz_name];
537 - (void)setVideoFilterProperty: (char *)psz_name forFilter: (char *)psz_filter string: (char *)psz_value
539 vout_thread_t *p_vout = getVout();
540 vlc_object_t *p_filter;
542 if( p_vout == NULL ) {
543 config_PutPsz( p_intf, psz_name, EnsureUTF8(psz_value) );
545 p_filter = vlc_object_find_name( pl_Get(p_intf), psz_filter );
548 msg_Err( p_intf, "we're unable to find the filter '%s'", psz_filter );
549 vlc_object_release( p_vout );
552 var_SetString( p_filter, psz_name, EnsureUTF8(psz_value) );
553 config_PutPsz( p_intf, psz_name, EnsureUTF8(psz_value) );
554 vlc_object_release( p_vout );
555 vlc_object_release( p_filter );
557 [self restartFilterIfNeeded:psz_filter option: psz_name];
561 - (void)setVideoFilterProperty: (char *)psz_name forFilter: (char *)psz_filter boolean: (BOOL)b_value
563 vout_thread_t *p_vout = getVout();
564 vlc_object_t *p_filter;
566 if( p_vout == NULL ) {
567 config_PutInt( p_intf, psz_name, b_value );
569 p_filter = vlc_object_find_name( pl_Get(p_intf), psz_filter );
572 msg_Err( p_intf, "we're unable to find the filter '%s'", psz_filter );
573 vlc_object_release( p_vout );
576 var_SetBool( p_filter, psz_name, b_value );
577 config_PutInt( p_intf, psz_name, b_value );
578 vlc_object_release( p_vout );
584 - (IBAction)enableAdjust:(id)sender
586 BOOL b_state = [o_adjust_ckb state];
588 [self setVideoFilter: "adjust" on: b_state];
589 [o_adjust_brightness_sld setEnabled: b_state];
590 [o_adjust_brightness_ckb setEnabled: b_state];
591 [o_adjust_brightness_lbl setEnabled: b_state];
592 [o_adjust_contrast_sld setEnabled: b_state];
593 [o_adjust_contrast_lbl setEnabled: b_state];
594 [o_adjust_gamma_sld setEnabled: b_state];
595 [o_adjust_gamma_lbl setEnabled: b_state];
596 [o_adjust_hue_sld setEnabled: b_state];
597 [o_adjust_hue_lbl setEnabled: b_state];
598 [o_adjust_saturation_sld setEnabled: b_state];
599 [o_adjust_saturation_lbl setEnabled: b_state];
600 [o_adjust_reset_btn setEnabled: b_state];
603 - (IBAction)adjustSliderChanged:(id)sender
605 if( sender == o_adjust_brightness_sld )
606 [self setVideoFilterProperty: "brightness" forFilter: "adjust" float: [o_adjust_brightness_sld floatValue]];
607 else if( sender == o_adjust_contrast_sld )
608 [self setVideoFilterProperty: "contrast" forFilter: "adjust" float: [o_adjust_contrast_sld floatValue]];
609 else if( sender == o_adjust_gamma_sld )
610 [self setVideoFilterProperty: "gamma" forFilter: "adjust" float: [o_adjust_gamma_sld floatValue]];
611 else if( sender == o_adjust_hue_sld )
612 [self setVideoFilterProperty: "hue" forFilter: "adjust" integer: [o_adjust_hue_sld intValue]];
613 else if( sender == o_adjust_saturation_sld )
614 [self setVideoFilterProperty: "saturation" forFilter: "adjust" float: [o_adjust_saturation_sld floatValue]];
616 if( sender == o_adjust_hue_sld )
617 [o_adjust_hue_sld setToolTip: [NSString stringWithFormat:@"%i", [o_adjust_hue_sld intValue]]];
619 [sender setToolTip: [NSString stringWithFormat:@"%0.3f", [sender floatValue]]];
622 - (IBAction)enableAdjustBrightnessThreshold:(id)sender
624 if (sender == o_adjust_reset_btn)
626 [o_adjust_brightness_sld setFloatValue: 1.0];
627 [o_adjust_contrast_sld setFloatValue: 1.0];
628 [o_adjust_gamma_sld setFloatValue: 1.0];
629 [o_adjust_hue_sld setIntValue: 0];
630 [o_adjust_saturation_sld setFloatValue: 1.0];
631 [o_adjust_brightness_sld setToolTip: [NSString stringWithFormat:@"%0.3f", 1.0]];
632 [o_adjust_contrast_sld setToolTip: [NSString stringWithFormat:@"%0.3f", 1.0]];
633 [o_adjust_gamma_sld setToolTip: [NSString stringWithFormat:@"%0.3f", 1.0]];
634 [o_adjust_hue_sld setToolTip: [NSString stringWithFormat:@"%i", 0]];
635 [o_adjust_saturation_sld setToolTip: [NSString stringWithFormat:@"%0.3f", 1.0]];
636 [self setVideoFilterProperty: "brightness" forFilter: "adjust" float: 1.0];
637 [self setVideoFilterProperty: "contrast" forFilter: "adjust" float: 1.0];
638 [self setVideoFilterProperty: "gamma" forFilter: "adjust" float: 1.0];
639 [self setVideoFilterProperty: "hue" forFilter: "adjust" integer: 0.0];
640 [self setVideoFilterProperty: "saturation" forFilter: "adjust" float: 1.0];
643 config_PutInt( p_intf, "brightness-threshold", [o_adjust_brightness_ckb state] );
646 - (IBAction)enableSharpen:(id)sender
648 BOOL b_state = [o_sharpen_ckb state];
650 [self setVideoFilter: "sharpen" on: b_state];
651 [o_sharpen_sld setEnabled: b_state];
652 [o_sharpen_lbl setEnabled: b_state];
655 - (IBAction)sharpenSliderChanged:(id)sender
657 [self setVideoFilterProperty: "sharpen-sigma" forFilter: "sharpen" float: [sender floatValue]];
658 [sender setToolTip: [NSString stringWithFormat:@"%0.3f", [sender floatValue]]];
661 - (IBAction)enableBanding:(id)sender
663 BOOL b_state = [o_banding_ckb state];
665 [self setVideoFilter: "gradfun" on: b_state];
666 [o_banding_sld setEnabled: b_state];
667 [o_banding_lbl setEnabled: b_state];
670 - (IBAction)bandingSliderChanged:(id)sender
672 [self setVideoFilterProperty: "gradfun-radius" forFilter: "gradfun" integer: [sender intValue]];
673 [sender setToolTip: [NSString stringWithFormat:@"%i", [sender intValue]]];
676 - (IBAction)enableGrain:(id)sender
678 BOOL b_state = [o_grain_ckb state];
680 [self setVideoFilter: "grain" on: b_state];
681 [o_grain_sld setEnabled: b_state];
682 [o_grain_lbl setEnabled: b_state];
685 - (IBAction)grainSliderChanged:(id)sender
687 [self setVideoFilterProperty: "grain-variance" forFilter: "grain" float: [sender floatValue]];
688 [sender setToolTip: [NSString stringWithFormat:@"%0.3f", [sender floatValue]]];
695 #define updateopposite( giver, taker ) \
696 if (sender == giver) \
697 [taker setIntValue: [giver intValue]]
699 - (IBAction)cropObjectChanged:(id)sender
701 updateopposite( o_crop_top_fld, o_crop_top_stp );
702 updateopposite( o_crop_top_stp, o_crop_top_fld );
703 updateopposite( o_crop_left_fld, o_crop_left_stp );
704 updateopposite( o_crop_left_stp, o_crop_left_fld );
705 updateopposite( o_crop_right_fld, o_crop_right_stp );
706 updateopposite( o_crop_right_stp, o_crop_right_fld );
707 updateopposite( o_crop_bottom_fld, o_crop_bottom_stp );
708 updateopposite( o_crop_bottom_stp, o_crop_bottom_fld );
710 if( [o_crop_sync_top_bottom_ckb state] ) {
711 if (sender == o_crop_top_fld || sender == o_crop_top_stp ) {
712 [o_crop_bottom_fld setIntValue: [o_crop_top_fld intValue]];
713 [o_crop_bottom_stp setIntValue: [o_crop_top_fld intValue]];
717 [o_crop_top_fld setIntValue: [o_crop_bottom_fld intValue]];
718 [o_crop_top_stp setIntValue: [o_crop_bottom_fld intValue]];
721 if( [o_crop_sync_left_right_ckb state] ) {
722 if (sender == o_crop_left_fld || sender == o_crop_left_stp ) {
723 [o_crop_right_fld setIntValue: [o_crop_left_fld intValue]];
724 [o_crop_right_stp setIntValue: [o_crop_left_fld intValue]];
728 [o_crop_left_fld setIntValue: [o_crop_right_fld intValue]];
729 [o_crop_left_stp setIntValue: [o_crop_right_fld intValue]];
733 vout_thread_t *p_vout = getVout();
735 var_SetInteger( p_vout, "crop-top", [o_crop_top_fld intValue] );
736 var_SetInteger( p_vout, "crop-bottom", [o_crop_bottom_fld intValue] );
737 var_SetInteger( p_vout, "crop-left", [o_crop_left_fld intValue] );
738 var_SetInteger( p_vout, "crop-right", [o_crop_right_fld intValue] );
739 vlc_object_release( p_vout );
743 #undef updateopposite
746 #pragma mark geometry
747 - (IBAction)enableTransform:(id)sender
749 [self setVideoFilter: "transform" on: [o_transform_ckb state]];
750 [o_transform_pop setEnabled: [o_transform_ckb state]];
753 - (IBAction)transformModifierChanged:(id)sender
755 NSInteger tag = [[o_transform_pop selectedItem] tag];
756 char * psz_string = (char *)[[NSString stringWithFormat:@"%li", tag] UTF8String];
758 psz_string = (char *)"hflip";
760 psz_string = (char *)"vflip";
762 [self setVideoFilterProperty: "transform-type" forFilter: "transform" string: psz_string];
765 - (IBAction)enableZoom:(id)sender
767 [self setVideoFilter: "magnify" on: [o_zoom_ckb state]];
770 - (IBAction)enablePuzzle:(id)sender
772 BOOL b_state = [o_puzzle_ckb state];
774 [self setVideoFilter: "puzzle" on: b_state];
775 [o_puzzle_columns_fld setEnabled: b_state];
776 [o_puzzle_columns_lbl setEnabled: b_state];
777 [o_puzzle_rows_fld setEnabled: b_state];
778 [o_puzzle_rows_lbl setEnabled: b_state];
779 [o_puzzle_blackslot_ckb setEnabled: b_state];
782 - (IBAction)puzzleModifierChanged:(id)sender
784 if( sender == o_puzzle_blackslot_ckb )
785 [self setVideoFilterProperty: "puzzle-black-slot" forFilter: "puzzle" boolean: [o_puzzle_blackslot_ckb state]];
786 else if( sender == o_puzzle_columns_fld )
787 [self setVideoFilterProperty: "puzzle-cols" forFilter: "puzzle" integer: [o_puzzle_columns_fld intValue]];
789 [self setVideoFilterProperty: "puzzle-rows" forFilter: "puzzle" integer: [o_puzzle_rows_fld intValue]];
795 - (IBAction)enableThreshold:(id)sender
797 BOOL b_state = [o_threshold_ckb state];
799 [self setVideoFilter: "colorthres" on: b_state];
800 [o_threshold_color_fld setEnabled: b_state];
801 [o_threshold_color_lbl setEnabled: b_state];
802 [o_threshold_saturation_sld setEnabled: b_state];
803 [o_threshold_saturation_lbl setEnabled: b_state];
804 [o_threshold_similarity_sld setEnabled: b_state];
805 [o_threshold_similarity_lbl setEnabled: b_state];
808 - (IBAction)thresholdModifierChanged:(id)sender
810 if( sender == o_threshold_color_fld )
811 [self setVideoFilterProperty: "colorthres-color" forFilter: "colorthres" integer: [o_threshold_color_fld intValue]];
812 else if( sender == o_threshold_saturation_sld )
814 [self setVideoFilterProperty: "colorthres-saturationthres" forFilter: "colorthres" integer: [o_threshold_saturation_sld intValue]];
815 [o_threshold_saturation_sld setToolTip: [NSString stringWithFormat:@"%i", [o_threshold_saturation_sld intValue]]];
819 [self setVideoFilterProperty: "colorthres-similaritythres" forFilter: "colorthres" integer: [o_threshold_similarity_sld intValue]];
820 [o_threshold_similarity_sld setToolTip: [NSString stringWithFormat:@"%i", [o_threshold_similarity_sld intValue]]];
824 - (IBAction)enableSepia:(id)sender
826 BOOL b_state = [o_sepia_ckb state];
828 [self setVideoFilter: "sepia" on: b_state];
829 [o_sepia_fld setEnabled: b_state];
830 [o_sepia_lbl setEnabled: b_state];
833 - (IBAction)sepiaModifierChanged:(id)sender
835 [self setVideoFilterProperty: "sepia-intensity" forFilter: "sepia" integer: [o_sepia_fld intValue]];
838 - (IBAction)enableNoise:(id)sender
840 [self setVideoFilter: "noise" on: [o_noise_ckb state]];
843 - (IBAction)enableGradient:(id)sender
845 BOOL b_state = [o_gradient_ckb state];
847 [self setVideoFilter: "gradient" on: b_state];
848 [o_gradient_mode_pop setEnabled: b_state];
849 [o_gradient_mode_lbl setEnabled: b_state];
850 [o_gradient_color_ckb setEnabled: b_state];
851 [o_gradient_cartoon_ckb setEnabled: b_state];
854 - (IBAction)gradientModifierChanged:(id)sender
856 if( sender == o_gradient_mode_pop ) {
857 if( [[o_gradient_mode_pop selectedItem] tag] == 3 )
858 [self setVideoFilterProperty: "gradient-mode" forFilter: "gradient" string: "hough"];
859 else if( [[o_gradient_mode_pop selectedItem] tag] == 2 )
860 [self setVideoFilterProperty: "gradient-mode" forFilter: "gradient" string: "edge"];
862 [self setVideoFilterProperty: "gradient-mode" forFilter: "gradient" string: "gradient"];
864 else if( sender == o_gradient_color_ckb )
865 [self setVideoFilterProperty: "gradient-type" forFilter: "gradient" integer: [o_gradient_color_ckb state]];
867 [self setVideoFilterProperty: "gradient-cartoon" forFilter: "gradient" boolean: [o_gradient_cartoon_ckb state]];
870 - (IBAction)enableExtract:(id)sender
872 BOOL b_state = [o_extract_ckb state];
873 [self setVideoFilter: "extract" on: b_state];
874 [o_extract_fld setEnabled: b_state];
875 [o_extract_lbl setEnabled: b_state];
878 - (IBAction)extractModifierChanged:(id)sender
880 [self setVideoFilterProperty: "extract-component" forFilter: "extract" integer: [o_extract_fld intValue]];
883 - (IBAction)enableInvert:(id)sender
885 [self setVideoFilter: "invert" on: [o_invert_ckb state]];
888 - (IBAction)enablePosterize:(id)sender
890 BOOL b_state = [o_posterize_ckb state];
892 [self setVideoFilter: "posterize" on: b_state];
893 [o_posterize_fld setEnabled: b_state];
894 [o_posterize_lbl setEnabled: b_state];
897 - (IBAction)posterizeModifierChanged:(id)sender
899 [self setVideoFilterProperty: "posterize-level" forFilter: "posterize" integer: [o_extract_fld intValue]];
902 - (IBAction)enableBlur:(id)sender
904 BOOL b_state = [o_blur_ckb state];
906 [self setVideoFilter: "motionblur" on: b_state];
907 [o_blur_sld setEnabled: b_state];
908 [o_blur_lbl setEnabled: b_state];
911 - (IBAction)blurModifierChanged:(id)sender
913 [self setVideoFilterProperty: "blur-factor" forFilter: "motionblur" integer: [sender intValue]];
914 [sender setToolTip: [NSString stringWithFormat:@"%i", [sender intValue]]];
917 - (IBAction)enableMotionDetect:(id)sender
919 [self setVideoFilter: "motiondetect" on: [o_motiondetect_ckb state]];
922 - (IBAction)enableWaterEffect:(id)sender
924 [self setVideoFilter: "ripple" on: [o_watereffect_ckb state]];
927 - (IBAction)enableWaves:(id)sender
929 [self setVideoFilter: "wave" on: [o_waves_ckb state]];
932 - (IBAction)enablePsychedelic:(id)sender
934 [self setVideoFilter: "psychedelic" on: [o_psychedelic_ckb state]];
939 #pragma mark Miscellaneous
940 - (IBAction)enableAddText:(id)sender
942 BOOL b_state = [o_addtext_ckb state];
944 [o_addtext_pos_pop setEnabled: b_state];
945 [o_addtext_pos_lbl setEnabled: b_state];
946 [o_addtext_text_lbl setEnabled: b_state];
947 [o_addtext_text_fld setEnabled: b_state];
948 [self setVideoFilter: "marq" on: b_state];
949 [self setVideoFilterProperty: "marq-marquee" forFilter: "marq" string: (char *)[[o_addtext_text_fld stringValue] UTF8String]];
950 [self setVideoFilterProperty: "marq-position" forFilter: "marq" integer: [[o_addtext_pos_pop selectedItem] tag]];
953 - (IBAction)addTextModifierChanged:(id)sender
955 if (sender == o_addtext_text_fld)
956 [self setVideoFilterProperty: "marq-marquee" forFilter: "marq" string: (char *)[[o_addtext_text_fld stringValue] UTF8String]];
958 [self setVideoFilterProperty: "marq-position" forFilter: "marq" integer: [[o_addtext_pos_pop selectedItem] tag]];
961 - (IBAction)enableAddLogo:(id)sender
963 BOOL b_state = [o_addlogo_ckb state];
965 [o_addlogo_pos_pop setEnabled: b_state];
966 [o_addlogo_pos_lbl setEnabled: b_state];
967 [o_addlogo_logo_fld setEnabled: b_state];
968 [o_addlogo_logo_lbl setEnabled: b_state];
969 [o_addlogo_transparency_sld setEnabled: b_state];
970 [o_addlogo_transparency_lbl setEnabled: b_state];
971 [self setVideoFilter: "logo" on: b_state];
974 - (IBAction)addLogoModifierChanged:(id)sender
976 if (sender == o_addlogo_logo_fld)
977 [self setVideoFilterProperty: "logo-file" forFilter: "logo" string: (char *)[[o_addlogo_logo_fld stringValue] UTF8String]];
978 else if (sender == o_addlogo_pos_pop)
979 [self setVideoFilterProperty: "logo-position" forFilter: "logo" integer: [[o_addlogo_pos_pop selectedItem] tag]];
982 [self setVideoFilterProperty: "logo-opacity" forFilter: "logo" integer: [o_addlogo_transparency_sld intValue]];
983 [o_addlogo_transparency_sld setToolTip: [NSString stringWithFormat:@"%i", [o_addlogo_transparency_sld intValue]]];