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 "VideoEffects.h"
31 #pragma mark Initialization & Generic code
33 @implementation VLCVideoEffects
34 static VLCVideoEffects *_o_sharedInstance = nil;
36 + (VLCVideoEffects *)sharedInstance
38 return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
43 if (_o_sharedInstance) {
47 _o_sharedInstance = [super init];
50 return _o_sharedInstance;
53 - (IBAction)toggleWindow:(id)sender
55 if( [o_window isVisible] )
56 [o_window orderOut:sender];
58 [o_window makeKeyAndOrderFront:sender];
63 [o_window setTitle: _NS("Video Effects")];
64 [o_window setExcludedFromWindowsMenu:YES];
66 [o_window setCollectionBehavior: NSWindowCollectionBehaviorFullScreenAuxiliary];
68 [[o_tableView tabViewItemAtIndex:[o_tableView indexOfTabViewItemWithIdentifier:@"basic"]] setLabel:_NS("Basic")];
69 [[o_tableView tabViewItemAtIndex:[o_tableView indexOfTabViewItemWithIdentifier:@"crop"]] setLabel:_NS("Crop")];
70 [[o_tableView tabViewItemAtIndex:[o_tableView indexOfTabViewItemWithIdentifier:@"geometry"]] setLabel:_NS("Geometry")];
71 [[o_tableView tabViewItemAtIndex:[o_tableView indexOfTabViewItemWithIdentifier:@"color"]] setLabel:_NS("Color")];
72 [[o_tableView tabViewItemAtIndex:[o_tableView indexOfTabViewItemWithIdentifier:@"misc"]] setLabel:_NS("Miscellaneous")];
74 [o_adjust_ckb setTitle:_NS("Image Adjust")];
75 [o_adjust_hue_lbl setStringValue:_NS("Hue")];
76 [o_adjust_contrast_lbl setStringValue:_NS("Contrast")];
77 [o_adjust_brightness_lbl setStringValue:_NS("Brightness")];
78 [o_adjust_brightness_ckb setTitle:_NS("Brightness Threshold")];
79 [o_adjust_saturation_lbl setStringValue:_NS("Saturation")];
80 [o_adjust_gamma_lbl setStringValue:_NS("Gamma")];
81 [o_adjust_reset_btn setTitle: _NS("Reset")];
82 [o_sharpen_ckb setTitle:_NS("Sharpen")];
83 [o_sharpen_lbl setStringValue:_NS("Sigma")];
84 [o_banding_ckb setTitle:_NS("Banding removal")];
85 [o_banding_lbl setStringValue:_NS("Radius")];
86 [o_grain_ckb setTitle:_NS("Film Grain")];
87 [o_grain_lbl setStringValue:_NS("Variance")];
88 [o_crop_top_lbl setStringValue:_NS("Top")];
89 [o_crop_left_lbl setStringValue:_NS("Left")];
90 [o_crop_right_lbl setStringValue:_NS("Right")];
91 [o_crop_bottom_lbl setStringValue:_NS("Bottom")];
92 [o_crop_sync_top_bottom_ckb setTitle:_NS("Synchronize top and bottom")];
93 [o_crop_sync_left_right_ckb setTitle:_NS("Synchronize left and right")];
95 [o_transform_ckb setTitle:_NS("Transform")];
96 [o_transform_pop removeAllItems];
97 [o_transform_pop addItemWithTitle: _NS("Rotate by 90 degrees")];
98 [[o_transform_pop lastItem] setTag: 90];
99 [o_transform_pop addItemWithTitle: _NS("Rotate by 180 degrees")];
100 [[o_transform_pop lastItem] setTag: 180];
101 [o_transform_pop addItemWithTitle: _NS("Rotate by 270 degrees")];
102 [[o_transform_pop lastItem] setTag: 270];
103 [o_transform_pop addItemWithTitle: _NS("Flip horizontally")];
104 [[o_transform_pop lastItem] setTag: 1];
105 [o_transform_pop addItemWithTitle: _NS("Flip vertically")];
106 [[o_transform_pop lastItem] setTag: 2];
107 [o_zoom_ckb setTitle:_NS("Magnification/Zoom")];
108 [o_puzzle_ckb setTitle:_NS("Puzzle game")];
109 [o_puzzle_rows_lbl setStringValue:_NS("Rows")];
110 [o_puzzle_columns_lbl setStringValue:_NS("Columns")];
111 [o_puzzle_blackslot_ckb setTitle:_NS("Black Slot")];
113 [o_threshold_ckb setTitle:_NS("Color threshold")];
114 [o_threshold_color_lbl setStringValue:_NS("Color")];
115 [o_threshold_saturation_lbl setStringValue:_NS("Saturation")];
116 [o_threshold_similarity_lbl setStringValue:_NS("Similarity")];
117 [o_sepia_ckb setTitle:_NS("Sepia")];
118 [o_sepia_lbl setStringValue:_NS("Intensity")];
119 [o_noise_ckb setTitle:_NS("Noise")];
120 [o_gradient_ckb setTitle:_NS("Gradient")];
121 [o_gradient_mode_lbl setStringValue:_NS("Mode")];
122 [o_gradient_mode_pop removeAllItems];
123 [o_gradient_mode_pop addItemWithTitle: _NS("Gradient")];
124 [[o_gradient_mode_pop lastItem] setTag: 1];
125 [o_gradient_mode_pop addItemWithTitle: _NS("Edge")];
126 [[o_gradient_mode_pop lastItem] setTag: 2];
127 [o_gradient_mode_pop addItemWithTitle: _NS("Hough")];
128 [[o_gradient_mode_pop lastItem] setTag: 3];
129 [o_gradient_color_ckb setTitle:_NS("Color")];
130 [o_gradient_cartoon_ckb setTitle:_NS("Cartoon")];
131 [o_extract_ckb setTitle:_NS("Color extraction")];
132 [o_extract_lbl setStringValue:_NS("Color")];
133 [o_invert_ckb setTitle:_NS("Invert colors")];
134 [o_posterize_ckb setTitle:_NS("Posterize")];
135 [o_posterize_lbl setStringValue:_NS("Posterize level")];
136 [o_blur_ckb setTitle:_NS("Motion blur")];
137 [o_blur_lbl setStringValue:_NS("Factor")];
138 [o_motiondetect_ckb setTitle:_NS("Motion Detect")];
139 [o_watereffect_ckb setTitle:_NS("Water effect")];
140 [o_waves_ckb setTitle:_NS("Waves")];
141 [o_psychedelic_ckb setTitle:_NS("Psychedelic")];
143 [o_addtext_ckb setTitle:_NS("Add text")];
144 [o_addtext_text_lbl setStringValue:_NS("Text")];
145 [o_addtext_pos_lbl setStringValue:_NS("Position")];
146 [o_addtext_pos_pop removeAllItems];
147 [o_addtext_pos_pop addItemWithTitle: _NS("Center")];
148 [[o_addtext_pos_pop lastItem] setTag: 0];
149 [o_addtext_pos_pop addItemWithTitle: _NS("Left")];
150 [[o_addtext_pos_pop lastItem] setTag: 1];
151 [o_addtext_pos_pop addItemWithTitle: _NS("Right")];
152 [[o_addtext_pos_pop lastItem] setTag: 2];
153 [o_addtext_pos_pop addItemWithTitle: _NS("Top")];
154 [[o_addtext_pos_pop lastItem] setTag: 4];
155 [o_addtext_pos_pop addItemWithTitle: _NS("Bottom")];
156 [[o_addtext_pos_pop lastItem] setTag: 8];
157 [o_addtext_pos_pop addItemWithTitle: _NS("Top-Left")];
158 [[o_addtext_pos_pop lastItem] setTag: 5];
159 [o_addtext_pos_pop addItemWithTitle: _NS("Top-Right")];
160 [[o_addtext_pos_pop lastItem] setTag: 6];
161 [o_addtext_pos_pop addItemWithTitle: _NS("Bottom-Left")];
162 [[o_addtext_pos_pop lastItem] setTag: 9];
163 [o_addtext_pos_pop addItemWithTitle: _NS("Bottom-Right")];
164 [[o_addtext_pos_pop lastItem] setTag: 10];
165 [o_addlogo_ckb setTitle:_NS("Add logo")];
166 [o_addlogo_logo_lbl setStringValue:_NS("Logo")];
167 [o_addlogo_pos_lbl setStringValue:_NS("Position")];
168 [o_addlogo_pos_pop removeAllItems];
169 [o_addlogo_pos_pop addItemWithTitle: _NS("Center")];
170 [[o_addlogo_pos_pop lastItem] setTag: 0];
171 [o_addlogo_pos_pop addItemWithTitle: _NS("Left")];
172 [[o_addlogo_pos_pop lastItem] setTag: 1];
173 [o_addlogo_pos_pop addItemWithTitle: _NS("Right")];
174 [[o_addlogo_pos_pop lastItem] setTag: 2];
175 [o_addlogo_pos_pop addItemWithTitle: _NS("Top")];
176 [[o_addlogo_pos_pop lastItem] setTag: 4];
177 [o_addlogo_pos_pop addItemWithTitle: _NS("Bottom")];
178 [[o_addlogo_pos_pop lastItem] setTag: 8];
179 [o_addlogo_pos_pop addItemWithTitle: _NS("Top-Left")];
180 [[o_addlogo_pos_pop lastItem] setTag: 5];
181 [o_addlogo_pos_pop addItemWithTitle: _NS("Top-Right")];
182 [[o_addlogo_pos_pop lastItem] setTag: 6];
183 [o_addlogo_pos_pop addItemWithTitle: _NS("Bottom-Left")];
184 [[o_addlogo_pos_pop lastItem] setTag: 9];
185 [o_addlogo_pos_pop addItemWithTitle: _NS("Bottom-Right")];
186 [[o_addlogo_pos_pop lastItem] setTag: 10];
187 [o_addlogo_transparency_lbl setStringValue:_NS("Transparency")];
189 [o_tableView selectFirstTabViewItem:self];
200 /* do we have any filter enabled? if yes, show it. */
202 psz_vfilters = config_GetPsz( p_intf, "video-filter" );
204 [o_adjust_ckb setState: (NSInteger)strstr( psz_vfilters, "adjust")];
205 [o_sharpen_ckb setState: (NSInteger)strstr( psz_vfilters, "sharpen")];
206 [o_banding_ckb setState: (NSInteger)strstr( psz_vfilters, "gradfun")];
207 [o_grain_ckb setState: (NSInteger)strstr( psz_vfilters, "grain")];
208 [o_transform_ckb setState: (NSInteger)strstr( psz_vfilters, "transform")];
209 [o_zoom_ckb setState: (NSInteger)strstr( psz_vfilters, "magnify")];
210 [o_puzzle_ckb setState: (NSInteger)strstr( psz_vfilters, "puzzle")];
211 [o_threshold_ckb setState: (NSInteger)strstr( psz_vfilters, "colorthres")];
212 [o_sepia_ckb setState: (NSInteger)strstr( psz_vfilters, "sepia")];
213 [o_noise_ckb setState: (NSInteger)strstr( psz_vfilters, "noise")];
214 [o_gradient_ckb setState: (NSInteger)strstr( psz_vfilters, "gradient")];
215 [o_extract_ckb setState: (NSInteger)strstr( psz_vfilters, "extract")];
216 [o_invert_ckb setState: (NSInteger)strstr( psz_vfilters, "invert")];
217 [o_posterize_ckb setState: (NSInteger)strstr( psz_vfilters, "posterize")];
218 [o_blur_ckb setState: (NSInteger)strstr( psz_vfilters, "motionblur")];
219 [o_motiondetect_ckb setState: (NSInteger)strstr( psz_vfilters, "motiondetect")];
220 [o_watereffect_ckb setState: (NSInteger)strstr( psz_vfilters, "ripple")];
221 [o_waves_ckb setState: (NSInteger)strstr( psz_vfilters, "wave")];
222 [o_psychedelic_ckb setState: (NSInteger)strstr( psz_vfilters, "psychedelic")];
223 free( psz_vfilters );
225 psz_vfilters = config_GetPsz( p_intf, "sub-source" );
227 [o_addtext_ckb setState: (NSInteger)strstr( psz_vfilters, "marq" )];
228 [o_addlogo_ckb setState: (NSInteger)strstr( psz_vfilters, "logo" )];
229 free( psz_vfilters );
232 /* fetch and show the various values */
233 [o_adjust_hue_sld setIntValue: config_GetInt( p_intf, "hue" )];
234 [o_adjust_contrast_sld setFloatValue: config_GetFloat( p_intf, "contrast" )];
235 [o_adjust_brightness_sld setFloatValue: config_GetFloat( p_intf, "brightness" )];
236 [o_adjust_saturation_sld setFloatValue: config_GetFloat( p_intf, "saturation" )];
237 [o_adjust_gamma_sld setFloatValue: config_GetFloat( p_intf, "gamma" )];
238 [o_adjust_brightness_sld setToolTip: [NSString stringWithFormat:@"%0.3f", config_GetFloat( p_intf, "brightness" )]];
239 [o_adjust_contrast_sld setToolTip: [NSString stringWithFormat:@"%0.3f", config_GetFloat( p_intf, "contrast" )]];
240 [o_adjust_gamma_sld setToolTip: [NSString stringWithFormat:@"%0.3f", config_GetFloat( p_intf, "gamma" )]];
241 [o_adjust_hue_sld setToolTip: [NSString stringWithFormat:@"%i", config_GetInt( p_intf, "hue" )]];
242 [o_adjust_saturation_sld setToolTip: [NSString stringWithFormat:@"%0.3f", config_GetFloat( p_intf, "saturation" )]];
243 b_state = [o_adjust_ckb state];
244 [o_adjust_brightness_sld setEnabled: b_state];
245 [o_adjust_brightness_ckb setEnabled: b_state];
246 [o_adjust_contrast_sld setEnabled: b_state];
247 [o_adjust_gamma_sld setEnabled: b_state];
248 [o_adjust_hue_sld setEnabled: b_state];
249 [o_adjust_saturation_sld setEnabled: b_state];
250 [o_adjust_brightness_lbl setEnabled: b_state];
251 [o_adjust_contrast_lbl setEnabled: b_state];
252 [o_adjust_gamma_lbl setEnabled: b_state];
253 [o_adjust_hue_lbl setEnabled: b_state];
254 [o_adjust_saturation_lbl setEnabled: b_state];
255 [o_adjust_reset_btn setEnabled: b_state];
256 [o_sharpen_sld setFloatValue: config_GetFloat( p_intf, "sharpen-sigma" )];
257 [o_sharpen_sld setToolTip: [NSString stringWithFormat:@"%0.3f", config_GetFloat( p_intf, "sharpen-sigma" )]];
258 [o_sharpen_sld setEnabled: [o_sharpen_ckb state]];
259 [o_sharpen_lbl setEnabled: [o_sharpen_ckb state]];
260 [o_banding_sld setIntValue: config_GetInt( p_intf, "gradfun-radius" )];
261 [o_banding_sld setToolTip: [NSString stringWithFormat:@"%i", config_GetInt( p_intf, "gradfun-radius" )]];
262 [o_banding_sld setEnabled: [o_banding_ckb state]];
263 [o_banding_lbl setEnabled: [o_banding_ckb state]];
264 [o_grain_sld setFloatValue: config_GetFloat( p_intf, "grain-variance" )];
265 [o_grain_sld setToolTip: [NSString stringWithFormat:@"%0.3f", config_GetFloat( p_intf, "grain-variance" )]];
266 [o_grain_sld setEnabled: [o_grain_ckb state]];
267 [o_grain_lbl setEnabled: [o_grain_ckb state]];
269 [o_crop_top_fld setIntValue: 0];
270 [o_crop_left_fld setIntValue: 0];
271 [o_crop_right_fld setIntValue: 0];
272 [o_crop_bottom_fld setIntValue: 0];
273 [o_crop_sync_top_bottom_ckb setState: NSOffState];
274 [o_crop_sync_left_right_ckb setState: NSOffState];
276 tmpChar = config_GetPsz( p_intf, "transform-type" );
277 tmpString = [NSString stringWithUTF8String: tmpChar];
278 if( [tmpString isEqualToString:@"hflip"] )
279 [o_transform_pop selectItemWithTag: 1];
280 else if( [tmpString isEqualToString:@"vflip"] )
281 [o_transform_pop selectItemWithTag: 2];
283 [o_transform_pop selectItemWithTag:[tmpString intValue]];
285 [o_transform_pop setEnabled: [o_transform_ckb state]];
286 [o_puzzle_rows_fld setIntValue: config_GetInt( p_intf, "puzzle-rows" )];
287 [o_puzzle_columns_fld setIntValue: config_GetInt( p_intf, "puzzle-cols" )];
288 [o_puzzle_blackslot_ckb setState: config_GetInt( p_intf, "puzzle-black-slot" )];
289 b_state = [o_puzzle_ckb state];
290 [o_puzzle_rows_fld setEnabled: b_state];
291 [o_puzzle_rows_lbl setEnabled: b_state];
292 [o_puzzle_columns_fld setEnabled: b_state];
293 [o_puzzle_columns_lbl setEnabled: b_state];
294 [o_puzzle_blackslot_ckb setEnabled: b_state];
296 [o_threshold_color_fld setStringValue: [[NSString stringWithFormat:@"%x", config_GetInt( p_intf, "colorthres-color" )] uppercaseString]];
297 [o_threshold_saturation_sld setIntValue: config_GetInt( p_intf, "colorthres-saturationthres" )];
298 [o_threshold_saturation_sld setToolTip: [NSString stringWithFormat:@"%i", config_GetInt( p_intf, "colorthres-saturationthres" )]];
299 [o_threshold_similarity_sld setIntValue: config_GetInt( p_intf, "colorthres-similaritythres" )];
300 [o_threshold_similarity_sld setToolTip: [NSString stringWithFormat:@"%i", config_GetInt( p_intf, "colorthres-similaritythres" )]];
301 b_state = [o_threshold_ckb state];
302 [o_threshold_color_fld setEnabled: b_state];
303 [o_threshold_color_lbl setEnabled: b_state];
304 [o_threshold_saturation_sld setEnabled: b_state];
305 [o_threshold_saturation_lbl setEnabled: b_state];
306 [o_threshold_similarity_sld setEnabled: b_state];
307 [o_threshold_similarity_lbl setEnabled: b_state];
308 [o_sepia_fld setIntValue: config_GetInt( p_intf, "sepia-intensity" )];
309 [o_sepia_fld setEnabled: [o_sepia_ckb state]];
310 [o_sepia_lbl setEnabled: [o_sepia_ckb state]];
311 tmpChar = config_GetPsz( p_intf, "gradient-mode" );
312 tmpString = [NSString stringWithUTF8String: tmpChar];
313 if( [tmpString isEqualToString:@"hough"] )
314 [o_gradient_mode_pop selectItemWithTag: 3];
315 else if( [tmpString isEqualToString:@"edge"] )
316 [o_gradient_mode_pop selectItemWithTag: 2];
318 [o_gradient_mode_pop selectItemWithTag: 1];
320 [o_gradient_cartoon_ckb setState: config_GetInt( p_intf, "gradient-cartoon" )];
321 [o_gradient_color_ckb setState: config_GetInt( p_intf, "gradient-type" )];
322 b_state = [o_gradient_ckb state];
323 [o_gradient_mode_pop setEnabled: b_state];
324 [o_gradient_mode_lbl setEnabled: b_state];
325 [o_gradient_cartoon_ckb setEnabled: b_state];
326 [o_gradient_color_ckb setEnabled: b_state];
327 [o_extract_fld setStringValue: [[NSString stringWithFormat:@"%x", config_GetInt( p_intf, "extract-component" )] uppercaseString]];
328 [o_extract_fld setEnabled: [o_extract_ckb state]];
329 [o_extract_lbl setEnabled: [o_extract_ckb state]];
330 [o_posterize_fld setIntValue: config_GetInt( p_intf, "posterize-level" )];
331 [o_posterize_fld setEnabled: [o_posterize_ckb state]];
332 [o_posterize_lbl setEnabled: [o_posterize_ckb state]];
333 [o_blur_sld setIntValue: config_GetInt( p_intf, "blur-factor" )];
334 [o_blur_sld setToolTip: [NSString stringWithFormat:@"%i", config_GetInt( p_intf, "blur-factor" )]];
335 [o_blur_sld setEnabled: [o_blur_ckb state]];
336 [o_blur_lbl setEnabled: [o_blur_ckb state]];
338 tmpChar = config_GetPsz( p_intf, "marq-marquee" );
341 [o_addtext_text_fld setStringValue: [NSString stringWithUTF8String: tmpChar]];
344 [o_addtext_pos_pop selectItemWithTag: config_GetInt( p_intf, "marq-position" )];
345 b_state = [o_addtext_ckb state];
346 [o_addtext_pos_pop setEnabled: b_state];
347 [o_addtext_pos_lbl setEnabled: b_state];
348 [o_addtext_text_lbl setEnabled: b_state];
349 [o_addtext_text_fld setEnabled: b_state];
351 tmpChar = config_GetPsz( p_intf, "logo-file" );
354 [o_addlogo_logo_fld setStringValue: [NSString stringWithUTF8String: tmpChar]];
357 [o_addlogo_pos_pop selectItemWithTag: config_GetInt( p_intf, "logo-position" )];
358 [o_addlogo_transparency_sld setIntValue: config_GetInt( p_intf, "logo-opacity" )];
359 [o_addlogo_transparency_sld setToolTip: [NSString stringWithFormat:@"%i", config_GetInt( p_intf, "logo-opacity" )]];
360 b_state = [o_addlogo_ckb state];
361 [o_addlogo_pos_pop setEnabled: b_state];
362 [o_addlogo_pos_lbl setEnabled: b_state];
363 [o_addlogo_logo_fld setEnabled: b_state];
364 [o_addlogo_logo_lbl setEnabled: b_state];
365 [o_addlogo_transparency_sld setEnabled: b_state];
366 [o_addlogo_transparency_lbl setEnabled: b_state];
369 - (void)setVideoFilter: (char *)psz_name on:(BOOL)b_on
371 char *psz_string, *psz_parser;
372 const char *psz_filter_type;
374 module_t *p_obj = module_find( psz_name );
377 msg_Err( p_intf, "Unable to find filter module \"%s\".", psz_name );
380 msg_Dbg( p_intf, "will set filter '%s'", psz_name );
382 if( module_provides( p_obj, "video splitter" ) )
384 psz_filter_type = "video-splitter";
386 else if( module_provides( p_obj, "video filter2" ) )
388 psz_filter_type = "video-filter";
390 else if( module_provides( p_obj, "sub source" ) )
392 psz_filter_type = "sub-source";
394 else if( module_provides( p_obj, "sub filter" ) )
396 psz_filter_type = "sub-filter";
400 msg_Err( p_intf, "Unknown video filter type." );
404 psz_string = config_GetPsz( p_intf, psz_filter_type );
408 psz_string = psz_name;
409 else if( (NSInteger)strstr( psz_string, psz_name ) == NO )
410 psz_string = (char *)[[NSString stringWithFormat: @"%s:%s", psz_string, psz_name] UTF8String];
412 psz_parser = strstr( psz_string, psz_name );
415 if( *( psz_parser + strlen( psz_name ) ) == ':' )
417 memmove( psz_parser, psz_parser + strlen( psz_name ) + 1,
418 strlen( psz_parser + strlen( psz_name ) + 1 ) + 1 );
425 /* Remove trailing : : */
426 if( strlen( psz_string ) > 0 &&
427 *( psz_string + strlen( psz_string ) -1 ) == ':' )
429 *( psz_string + strlen( psz_string ) -1 ) = '\0';
438 config_PutPsz( p_intf, psz_filter_type, psz_string );
440 /* Try to set on the fly */
441 if( !strcmp( psz_filter_type, "video-splitter" ) )
443 playlist_t *p_playlist = pl_Get( p_intf );
444 var_SetString( p_playlist, psz_filter_type, psz_string );
448 vout_thread_t *p_vout = getVout();
451 var_SetString( p_vout, psz_filter_type, psz_string );
452 vlc_object_release( p_vout );
457 - (void)restartFilterIfNeeded: (char *)psz_filter option: (char *)psz_name
459 vout_thread_t *p_vout = getVout();
464 vlc_object_release( p_vout );
466 vlc_object_t *p_filter = vlc_object_find_name( pl_Get(p_intf), psz_filter );
468 i_type = var_Type( p_filter, psz_name );
470 i_type = config_GetType( p_intf, psz_name );
472 if( !(i_type & VLC_VAR_ISCOMMAND) )
474 msg_Warn( p_intf, "Brute-restarting filter '%s', because the last changed option isn't a command", psz_name );
475 [self setVideoFilter: psz_filter on: NO];
476 [self setVideoFilter: psz_filter on: YES];
479 msg_Dbg( p_intf, "restart not needed" );
482 vlc_object_release( p_filter );
485 - (void)setVideoFilterProperty: (char *)psz_name forFilter: (char *)psz_filter integer: (int)i_value
487 vout_thread_t *p_vout = getVout();
488 vlc_object_t *p_filter;
490 if( p_vout == NULL ) {
491 config_PutInt( p_intf , psz_name , i_value );
493 p_filter = vlc_object_find_name( pl_Get(p_intf), psz_filter );
496 msg_Err( p_intf, "we're unable to find the filter '%s'", psz_filter );
497 vlc_object_release( p_vout );
500 var_SetInteger( p_filter, psz_name, i_value );
501 config_PutInt( p_intf, psz_name, i_value );
502 vlc_object_release( p_vout );
503 vlc_object_release( p_filter );
506 [self restartFilterIfNeeded:psz_filter option: psz_name];
509 - (void)setVideoFilterProperty: (char *)psz_name forFilter: (char *)psz_filter float: (float)f_value
511 vout_thread_t *p_vout = getVout();
512 vlc_object_t *p_filter;
514 if( p_vout == NULL ) {
515 config_PutFloat( p_intf , psz_name , f_value );
517 p_filter = vlc_object_find_name( pl_Get(p_intf), psz_filter );
520 msg_Err( p_intf, "we're unable to find the filter '%s'", psz_filter );
521 vlc_object_release( p_vout );
524 var_SetFloat( p_filter, psz_name, f_value );
525 config_PutFloat( p_intf, psz_name, f_value );
526 vlc_object_release( p_vout );
527 vlc_object_release( p_filter );
529 [self restartFilterIfNeeded:psz_filter option: psz_name];
533 - (void)setVideoFilterProperty: (char *)psz_name forFilter: (char *)psz_filter string: (char *)psz_value
535 vout_thread_t *p_vout = getVout();
536 vlc_object_t *p_filter;
538 if( p_vout == NULL ) {
539 config_PutPsz( p_intf, psz_name, psz_value );
541 p_filter = vlc_object_find_name( pl_Get(p_intf), psz_filter );
544 msg_Err( p_intf, "we're unable to find the filter '%s'", psz_filter );
545 vlc_object_release( p_vout );
548 var_SetString( p_filter, psz_name, psz_value );
549 config_PutPsz( p_intf, psz_name, psz_value );
550 vlc_object_release( p_vout );
551 vlc_object_release( p_filter );
553 [self restartFilterIfNeeded:psz_filter option: psz_name];
557 - (void)setVideoFilterProperty: (char *)psz_name forFilter: (char *)psz_filter boolean: (BOOL)b_value
559 vout_thread_t *p_vout = getVout();
560 vlc_object_t *p_filter;
562 if( p_vout == NULL ) {
563 config_PutInt( p_intf, psz_name, b_value );
565 p_filter = vlc_object_find_name( pl_Get(p_intf), psz_filter );
568 msg_Err( p_intf, "we're unable to find the filter '%s'", psz_filter );
569 vlc_object_release( p_vout );
572 var_SetBool( p_filter, psz_name, b_value );
573 config_PutInt( p_intf, psz_name, b_value );
574 vlc_object_release( p_vout );
580 - (IBAction)enableAdjust:(id)sender
582 BOOL b_state = [o_adjust_ckb state];
584 [self setVideoFilter: "adjust" on: b_state];
585 [o_adjust_brightness_sld setEnabled: b_state];
586 [o_adjust_brightness_ckb setEnabled: b_state];
587 [o_adjust_brightness_lbl setEnabled: b_state];
588 [o_adjust_contrast_sld setEnabled: b_state];
589 [o_adjust_contrast_lbl setEnabled: b_state];
590 [o_adjust_gamma_sld setEnabled: b_state];
591 [o_adjust_gamma_lbl setEnabled: b_state];
592 [o_adjust_hue_sld setEnabled: b_state];
593 [o_adjust_hue_lbl setEnabled: b_state];
594 [o_adjust_saturation_sld setEnabled: b_state];
595 [o_adjust_saturation_lbl setEnabled: b_state];
596 [o_adjust_reset_btn setEnabled: b_state];
599 - (IBAction)adjustSliderChanged:(id)sender
601 if( sender == o_adjust_brightness_sld )
602 [self setVideoFilterProperty: "brightness" forFilter: "adjust" float: [o_adjust_brightness_sld floatValue]];
603 else if( sender == o_adjust_contrast_sld )
604 [self setVideoFilterProperty: "contrast" forFilter: "adjust" float: [o_adjust_contrast_sld floatValue]];
605 else if( sender == o_adjust_gamma_sld )
606 [self setVideoFilterProperty: "gamma" forFilter: "adjust" float: [o_adjust_gamma_sld floatValue]];
607 else if( sender == o_adjust_hue_sld )
608 [self setVideoFilterProperty: "hue" forFilter: "adjust" integer: [o_adjust_hue_sld intValue]];
609 else if( sender == o_adjust_saturation_sld )
610 [self setVideoFilterProperty: "saturation" forFilter: "adjust" float: [o_adjust_saturation_sld floatValue]];
612 if( sender == o_adjust_hue_sld )
613 [o_adjust_hue_sld setToolTip: [NSString stringWithFormat:@"%i", [o_adjust_hue_sld intValue]]];
615 [sender setToolTip: [NSString stringWithFormat:@"%0.3f", [sender floatValue]]];
618 - (IBAction)enableAdjustBrightnessThreshold:(id)sender
620 if (sender == o_adjust_reset_btn)
622 [o_adjust_brightness_sld setFloatValue: 1.0];
623 [o_adjust_contrast_sld setFloatValue: 1.0];
624 [o_adjust_gamma_sld setFloatValue: 1.0];
625 [o_adjust_hue_sld setIntValue: 0];
626 [o_adjust_saturation_sld setFloatValue: 1.0];
627 [o_adjust_brightness_sld setToolTip: [NSString stringWithFormat:@"%0.3f", 1.0]];
628 [o_adjust_contrast_sld setToolTip: [NSString stringWithFormat:@"%0.3f", 1.0]];
629 [o_adjust_gamma_sld setToolTip: [NSString stringWithFormat:@"%0.3f", 1.0]];
630 [o_adjust_hue_sld setToolTip: [NSString stringWithFormat:@"%i", 0]];
631 [o_adjust_saturation_sld setToolTip: [NSString stringWithFormat:@"%0.3f", 1.0]];
632 [self setVideoFilterProperty: "brightness" forFilter: "adjust" float: 1.0];
633 [self setVideoFilterProperty: "contrast" forFilter: "adjust" float: 1.0];
634 [self setVideoFilterProperty: "gamma" forFilter: "adjust" float: 1.0];
635 [self setVideoFilterProperty: "hue" forFilter: "adjust" integer: 0.0];
636 [self setVideoFilterProperty: "saturation" forFilter: "adjust" float: 1.0];
639 config_PutInt( p_intf, "brightness-threshold", [o_adjust_brightness_ckb state] );
642 - (IBAction)enableSharpen:(id)sender
644 BOOL b_state = [o_sharpen_ckb state];
646 [self setVideoFilter: "sharpen" on: b_state];
647 [o_sharpen_sld setEnabled: b_state];
648 [o_sharpen_lbl setEnabled: b_state];
651 - (IBAction)sharpenSliderChanged:(id)sender
653 [self setVideoFilterProperty: "sharpen-sigma" forFilter: "sharpen" float: [sender floatValue]];
654 [sender setToolTip: [NSString stringWithFormat:@"%0.3f", [sender floatValue]]];
657 - (IBAction)enableBanding:(id)sender
659 BOOL b_state = [o_banding_ckb state];
661 [self setVideoFilter: "gradfun" on: b_state];
662 [o_banding_sld setEnabled: b_state];
663 [o_banding_lbl setEnabled: b_state];
666 - (IBAction)bandingSliderChanged:(id)sender
668 [self setVideoFilterProperty: "gradfun-radius" forFilter: "gradfun" integer: [sender intValue]];
669 [sender setToolTip: [NSString stringWithFormat:@"%i", [sender intValue]]];
672 - (IBAction)enableGrain:(id)sender
674 BOOL b_state = [o_grain_ckb state];
676 [self setVideoFilter: "grain" on: b_state];
677 [o_grain_sld setEnabled: b_state];
678 [o_grain_lbl setEnabled: b_state];
681 - (IBAction)grainSliderChanged:(id)sender
683 [self setVideoFilterProperty: "grain-variance" forFilter: "grain" float: [sender floatValue]];
684 [sender setToolTip: [NSString stringWithFormat:@"%0.3f", [sender floatValue]]];
691 #define updateopposite( giver, taker ) \
692 if (sender == giver) \
693 [taker setIntValue: [giver intValue]]
695 - (IBAction)cropObjectChanged:(id)sender
697 updateopposite( o_crop_top_fld, o_crop_top_stp );
698 updateopposite( o_crop_top_stp, o_crop_top_fld );
699 updateopposite( o_crop_left_fld, o_crop_left_stp );
700 updateopposite( o_crop_left_stp, o_crop_left_fld );
701 updateopposite( o_crop_right_fld, o_crop_right_stp );
702 updateopposite( o_crop_right_stp, o_crop_right_fld );
703 updateopposite( o_crop_bottom_fld, o_crop_bottom_stp );
704 updateopposite( o_crop_bottom_stp, o_crop_bottom_fld );
706 if( [o_crop_sync_top_bottom_ckb state] ) {
707 if (sender == o_crop_top_fld || sender == o_crop_top_stp ) {
708 [o_crop_bottom_fld setIntValue: [o_crop_top_fld intValue]];
709 [o_crop_bottom_stp setIntValue: [o_crop_top_fld intValue]];
713 [o_crop_top_fld setIntValue: [o_crop_bottom_fld intValue]];
714 [o_crop_top_stp setIntValue: [o_crop_bottom_fld intValue]];
717 if( [o_crop_sync_left_right_ckb state] ) {
718 if (sender == o_crop_left_fld || sender == o_crop_left_stp ) {
719 [o_crop_right_fld setIntValue: [o_crop_left_fld intValue]];
720 [o_crop_right_stp setIntValue: [o_crop_left_fld intValue]];
724 [o_crop_left_fld setIntValue: [o_crop_right_fld intValue]];
725 [o_crop_left_stp setIntValue: [o_crop_right_fld intValue]];
729 vout_thread_t *p_vout = getVout();
731 var_SetInteger( p_vout, "crop-top", [o_crop_top_fld intValue] );
732 var_SetInteger( p_vout, "crop-bottom", [o_crop_bottom_fld intValue] );
733 var_SetInteger( p_vout, "crop-left", [o_crop_left_fld intValue] );
734 var_SetInteger( p_vout, "crop-right", [o_crop_right_fld intValue] );
735 vlc_object_release( p_vout );
739 #undef updateopposite
742 #pragma mark geometry
743 - (IBAction)enableTransform:(id)sender
745 [self setVideoFilter: "transform" on: [o_transform_ckb state]];
746 [o_transform_pop setEnabled: [o_transform_ckb state]];
749 - (IBAction)transformModifierChanged:(id)sender
751 NSInteger tag = [[o_transform_pop selectedItem] tag];
752 char * psz_string = (char *)[[NSString stringWithFormat:@"%i", tag] UTF8String];
754 psz_string = (char *)"hflip";
756 psz_string = (char *)"vflip";
758 [self setVideoFilterProperty: "transform-type" forFilter: "transform" string: psz_string];
761 - (IBAction)enableZoom:(id)sender
763 [self setVideoFilter: "magnify" on: [o_zoom_ckb state]];
766 - (IBAction)enablePuzzle:(id)sender
768 BOOL b_state = [o_puzzle_ckb state];
770 [self setVideoFilter: "puzzle" on: b_state];
771 [o_puzzle_columns_fld setEnabled: b_state];
772 [o_puzzle_columns_lbl setEnabled: b_state];
773 [o_puzzle_rows_fld setEnabled: b_state];
774 [o_puzzle_rows_lbl setEnabled: b_state];
775 [o_puzzle_blackslot_ckb setEnabled: b_state];
778 - (IBAction)puzzleModifierChanged:(id)sender
780 if( sender == o_puzzle_blackslot_ckb )
781 [self setVideoFilterProperty: "puzzle-black-slot" forFilter: "puzzle" boolean: [o_puzzle_blackslot_ckb state]];
782 else if( sender == o_puzzle_columns_fld )
783 [self setVideoFilterProperty: "puzzle-cols" forFilter: "puzzle" integer: [o_puzzle_columns_fld intValue]];
785 [self setVideoFilterProperty: "puzzle-rows" forFilter: "puzzle" integer: [o_puzzle_rows_fld intValue]];
791 - (IBAction)enableThreshold:(id)sender
793 BOOL b_state = [o_threshold_ckb state];
795 [self setVideoFilter: "colorthres" on: b_state];
796 [o_threshold_color_fld setEnabled: b_state];
797 [o_threshold_color_lbl setEnabled: b_state];
798 [o_threshold_saturation_sld setEnabled: b_state];
799 [o_threshold_saturation_lbl setEnabled: b_state];
800 [o_threshold_similarity_sld setEnabled: b_state];
801 [o_threshold_similarity_lbl setEnabled: b_state];
804 - (IBAction)thresholdModifierChanged:(id)sender
806 if( sender == o_threshold_color_fld )
807 [self setVideoFilterProperty: "colorthres-color" forFilter: "colorthres" integer: [o_threshold_color_fld intValue]];
808 else if( sender == o_threshold_saturation_sld )
810 [self setVideoFilterProperty: "colorthres-saturationthres" forFilter: "colorthres" integer: [o_threshold_saturation_sld intValue]];
811 [o_threshold_saturation_sld setToolTip: [NSString stringWithFormat:@"%i", [o_threshold_saturation_sld intValue]]];
815 [self setVideoFilterProperty: "colorthres-similaritythres" forFilter: "colorthres" integer: [o_threshold_similarity_sld intValue]];
816 [o_threshold_similarity_sld setToolTip: [NSString stringWithFormat:@"%i", [o_threshold_similarity_sld intValue]]];
820 - (IBAction)enableSepia:(id)sender
822 BOOL b_state = [o_sepia_ckb state];
824 [self setVideoFilter: "sepia" on: b_state];
825 [o_sepia_fld setEnabled: b_state];
826 [o_sepia_lbl setEnabled: b_state];
829 - (IBAction)sepiaModifierChanged:(id)sender
831 [self setVideoFilterProperty: "sepia-intensity" forFilter: "sepia" integer: [o_sepia_fld intValue]];
834 - (IBAction)enableNoise:(id)sender
836 [self setVideoFilter: "noise" on: [o_noise_ckb state]];
839 - (IBAction)enableGradient:(id)sender
841 BOOL b_state = [o_gradient_ckb state];
843 [self setVideoFilter: "gradient" on: b_state];
844 [o_gradient_mode_pop setEnabled: b_state];
845 [o_gradient_mode_lbl setEnabled: b_state];
846 [o_gradient_color_ckb setEnabled: b_state];
847 [o_gradient_cartoon_ckb setEnabled: b_state];
850 - (IBAction)gradientModifierChanged:(id)sender
852 if( sender == o_gradient_mode_pop ) {
853 if( [[o_gradient_mode_pop selectedItem] tag] == 3 )
854 [self setVideoFilterProperty: "gradient-mode" forFilter: "gradient" string: "hough"];
855 else if( [[o_gradient_mode_pop selectedItem] tag] == 2 )
856 [self setVideoFilterProperty: "gradient-mode" forFilter: "gradient" string: "edge"];
858 [self setVideoFilterProperty: "gradient-mode" forFilter: "gradient" string: "gradient"];
860 else if( sender == o_gradient_color_ckb )
861 [self setVideoFilterProperty: "gradient-type" forFilter: "gradient" integer: [o_gradient_color_ckb state]];
863 [self setVideoFilterProperty: "gradient-cartoon" forFilter: "gradient" boolean: [o_gradient_cartoon_ckb state]];
866 - (IBAction)enableExtract:(id)sender
868 BOOL b_state = [o_extract_ckb state];
869 [self setVideoFilter: "extract" on: b_state];
870 [o_extract_fld setEnabled: b_state];
871 [o_extract_lbl setEnabled: b_state];
874 - (IBAction)extractModifierChanged:(id)sender
876 [self setVideoFilterProperty: "extract-component" forFilter: "extract" integer: [o_extract_fld intValue]];
879 - (IBAction)enableInvert:(id)sender
881 [self setVideoFilter: "invert" on: [o_invert_ckb state]];
884 - (IBAction)enablePosterize:(id)sender
886 BOOL b_state = [o_posterize_ckb state];
888 [self setVideoFilter: "posterize" on: b_state];
889 [o_posterize_fld setEnabled: b_state];
890 [o_posterize_lbl setEnabled: b_state];
893 - (IBAction)posterizeModifierChanged:(id)sender
895 [self setVideoFilterProperty: "posterize-level" forFilter: "posterize" integer: [o_extract_fld intValue]];
898 - (IBAction)enableBlur:(id)sender
900 BOOL b_state = [o_blur_ckb state];
902 [self setVideoFilter: "motionblur" on: b_state];
903 [o_blur_sld setEnabled: b_state];
904 [o_blur_lbl setEnabled: b_state];
907 - (IBAction)blurModifierChanged:(id)sender
909 [self setVideoFilterProperty: "blur-factor" forFilter: "motionblur" integer: [sender intValue]];
910 [sender setToolTip: [NSString stringWithFormat:@"%i", [sender intValue]]];
913 - (IBAction)enableMotionDetect:(id)sender
915 [self setVideoFilter: "motiondetect" on: [o_motiondetect_ckb state]];
918 - (IBAction)enableWaterEffect:(id)sender
920 [self setVideoFilter: "ripple" on: [o_watereffect_ckb state]];
923 - (IBAction)enableWaves:(id)sender
925 [self setVideoFilter: "wave" on: [o_waves_ckb state]];
928 - (IBAction)enablePsychedelic:(id)sender
930 [self setVideoFilter: "psychedelic" on: [o_psychedelic_ckb state]];
935 #pragma mark Miscellaneous
936 - (IBAction)enableAddText:(id)sender
938 BOOL b_state = [o_addtext_ckb state];
940 [o_addtext_pos_pop setEnabled: b_state];
941 [o_addtext_pos_lbl setEnabled: b_state];
942 [o_addtext_text_lbl setEnabled: b_state];
943 [o_addtext_text_fld setEnabled: b_state];
944 [self setVideoFilter: "marq" on: b_state];
947 - (IBAction)addTextModifierChanged:(id)sender
949 if (sender == o_addtext_text_fld)
950 [self setVideoFilterProperty: "marq-marquee" forFilter: "marq" string: (char *)[[o_addtext_text_fld stringValue] UTF8String]];
952 [self setVideoFilterProperty: "marq-position" forFilter: "marq" integer: [[o_addtext_pos_pop selectedItem] tag]];
955 - (IBAction)enableAddLogo:(id)sender
957 BOOL b_state = [o_addlogo_ckb state];
959 [o_addlogo_pos_pop setEnabled: b_state];
960 [o_addlogo_pos_lbl setEnabled: b_state];
961 [o_addlogo_logo_fld setEnabled: b_state];
962 [o_addlogo_logo_lbl setEnabled: b_state];
963 [o_addlogo_transparency_sld setEnabled: b_state];
964 [o_addlogo_transparency_lbl setEnabled: b_state];
965 [self setVideoFilter: "logo" on: b_state];
968 - (IBAction)addLogoModifierChanged:(id)sender
970 if (sender == o_addlogo_logo_fld)
971 [self setVideoFilterProperty: "logo-file" forFilter: "logo" string: (char *)[[o_addlogo_logo_fld stringValue] UTF8String]];
972 else if (sender == o_addlogo_pos_pop)
973 [self setVideoFilterProperty: "logo-position" forFilter: "logo" integer: [[o_addlogo_pos_pop selectedItem] tag]];
976 [self setVideoFilterProperty: "logo-opacity" forFilter: "logo" integer: [o_addlogo_transparency_sld intValue]];
977 [o_addlogo_transparency_sld setToolTip: [NSString stringWithFormat:@"%i", [o_addlogo_transparency_sld intValue]]];