summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Stebbins <[email protected]>2016-02-25 12:44:33 -0700
committerJohn Stebbins <[email protected]>2016-03-09 13:10:10 -0700
commitb7f4685f8d765d7a5c1335bf4ddc957bf9417433 (patch)
treec505afc5f4b1b0e0456497f6615c05cde1ba72bd
parenta44ccb49f182d4eeb122fbe675b28deb5c36b793 (diff)
macui support for filter dict settings
-rw-r--r--macosx/HBFilters.m22
-rw-r--r--macosx/HBJob+HBJobConversion.m72
2 files changed, 41 insertions, 53 deletions
diff --git a/macosx/HBFilters.m b/macosx/HBFilters.m
index e0352868a..0ab4e924d 100644
--- a/macosx/HBFilters.m
+++ b/macosx/HBFilters.m
@@ -6,6 +6,7 @@
#import "HBFilters.h"
#import "HBCodingUtilities.h"
+#import "NSDictionary+HBAdditions.h"
#include "hb.h"
NSString * const HBFiltersChangedNotification = @"HBFiltersChangedNotification";
@@ -135,7 +136,7 @@ NSString * const HBFiltersChangedNotification = @"HBFiltersChangedNotification";
filter_id = HB_FILTER_DEINTERLACE;
}
- if (hb_validate_filter_preset(filter_id, self.deinterlacePreset.UTF8String, NULL))
+ if (hb_validate_filter_preset(filter_id, self.deinterlacePreset.UTF8String, NULL, NULL))
{
_deinterlacePreset = @"default";
}
@@ -412,7 +413,7 @@ NSString * const HBFiltersChangedNotification = @"HBFiltersChangedNotification";
preset[@"PictureDeblock"] = @(self.deblock);
preset[@"VideoGrayScale"] = @(self.grayscale);
- preset[@"PictureRotate"] = [NSString stringWithFormat:@"%d:%d", self.rotate, self.flip];
+ preset[@"PictureRotate"] = [NSString stringWithFormat:@"angle=%d:hflip=%d", self.rotate, self.flip];
}
- (void)applyPreset:(HBPreset *)preset
@@ -445,17 +446,12 @@ NSString * const HBFiltersChangedNotification = @"HBFiltersChangedNotification";
NSString *rotate = preset[@"PictureRotate"];
if ([rotate isKindOfClass:[NSString class]])
{
- NSArray<NSString *> *components = [rotate componentsSeparatedByString:@":"];
- if (components.count == 2)
- {
- self.rotate = [components[0] intValue];
- self.flip = [components[1] boolValue];
- }
- else
- {
- self.rotate = 0;
- self.flip = NO;
- }
+ hb_dict_t * hbdict = hb_parse_filter_settings(rotate.UTF8String);
+ NSDictionary * dict = [[NSDictionary alloc] initWithHBDict:hbdict];
+ hb_value_free(&hbdict);
+
+ self.rotate = [dict[@"angle"] intValue];
+ self.flip = [dict[@"hflip"] boolValue];
}
}
diff --git a/macosx/HBJob+HBJobConversion.m b/macosx/HBJob+HBJobConversion.m
index 5de06eb5c..07d2be599 100644
--- a/macosx/HBJob+HBJobConversion.m
+++ b/macosx/HBJob+HBJobConversion.m
@@ -304,14 +304,6 @@
}
}
- if (one_burned)
- {
- hb_filter_object_t *filter = hb_filter_init( HB_FILTER_RENDER_SUB );
- hb_add_filter(job, filter, [NSString stringWithFormat:@"%d:%d:%d:%d",
- self.picture.cropTop, self.picture.cropBottom,
- self.picture.cropLeft, self.picture.cropRight].UTF8String);
- }
-
// Audio Defaults
job->acodec_copy_mask = 0;
@@ -413,11 +405,13 @@
if (![self.filters.detelecine isEqualToString:@"off"])
{
int filter_id = HB_FILTER_DETELECINE;
- const char *filter_str = hb_generate_filter_settings(filter_id,
+ hb_dict_t *filter_dict = hb_generate_filter_settings(filter_id,
self.filters.detelecine.UTF8String,
+ NULL,
self.filters.detelecineCustomString.UTF8String);
filter = hb_filter_init(filter_id);
- hb_add_filter(job, filter, filter_str);
+ hb_add_filter_dict(job, filter, filter_dict);
+ hb_value_free(&filter_dict);
}
// Deinterlace
@@ -429,11 +423,13 @@
filter_id = HB_FILTER_DEINTERLACE;
}
- const char *filter_str = hb_generate_filter_settings(filter_id,
- self.filters.deinterlacePreset.UTF8String,
- self.filters.deinterlaceCustomString.UTF8String);
+ hb_dict_t *filter_dict = hb_generate_filter_settings(filter_id,
+ self.filters.deinterlacePreset.UTF8String,
+ NULL,
+ self.filters.deinterlaceCustomString.UTF8String);
filter = hb_filter_init(filter_id);
- hb_add_filter(job, filter, filter_str);
+ hb_add_filter_dict(job, filter, filter_dict);
+ hb_value_free(&filter_dict);
}
// Denoise
@@ -441,39 +437,34 @@
{
int filter_id = HB_FILTER_HQDN3D;
if ([self.filters.denoise isEqualToString:@"nlmeans"])
- filter_id = HB_FILTER_NLMEANS;
-
- if ([self.filters.denoisePreset isEqualToString:@"custom"])
{
- const char *filter_str;
- filter_str = self.filters.denoiseCustomString.UTF8String;
- filter = hb_filter_init(filter_id);
- hb_add_filter(job, filter, filter_str);
- }
- else
- {
- const char *filter_str, *preset, *tune;
- preset = self.filters.denoisePreset.UTF8String;
- tune = self.filters.denoiseTune.UTF8String;
- filter_str = hb_generate_filter_settings(filter_id, preset, tune);
- filter = hb_filter_init(filter_id);
- hb_add_filter(job, filter, filter_str);
+ filter_id = HB_FILTER_NLMEANS;
}
+
+ hb_dict_t *filter_dict = hb_generate_filter_settings(filter_id,
+ self.filters.denoisePreset.UTF8String,
+ self.filters.denoiseTune.UTF8String,
+ self.filters.denoiseCustomString.UTF8String);
+ filter = hb_filter_init(filter_id);
+ hb_add_filter_dict(job, filter, filter_dict);
+ hb_dict_free(&filter_dict);
}
// Deblock (uses pp7 default)
if (self.filters.deblock)
{
filter = hb_filter_init(HB_FILTER_DEBLOCK);
- hb_add_filter(job, filter, [NSString stringWithFormat:@"%d", self.filters.deblock].UTF8String);
+ hb_add_filter(job, filter, [NSString stringWithFormat:@"qp=%d", self.filters.deblock].UTF8String);
}
// Add Crop/Scale filter
filter = hb_filter_init(HB_FILTER_CROP_SCALE);
- hb_add_filter( job, filter, [NSString stringWithFormat:@"%d:%d:%d:%d:%d:%d",
- self.picture.width, self.picture.height,
- self.picture.cropTop, self.picture.cropBottom,
- self.picture.cropLeft, self.picture.cropRight].UTF8String);
+ hb_add_filter( job, filter,
+ [NSString stringWithFormat:
+ @"width=%d:height=%d:crop-top=%d:crop-bottom=%d:crop-left=%d:crop-right=%d",
+ self.picture.width, self.picture.height,
+ self.picture.cropTop, self.picture.cropBottom,
+ self.picture.cropLeft, self.picture.cropRight].UTF8String);
// Add grayscale filter
if (self.filters.grayscale)
@@ -486,17 +477,18 @@
if (self.filters.rotate || self.filters.flip)
{
int filter_id = HB_FILTER_ROTATE;
- const char *filter_str = hb_generate_filter_settings(filter_id,
- [NSString stringWithFormat:@"%d:%d", self.filters.rotate, self.filters.flip].UTF8String,
- NULL);
+ hb_dict_t *filter_dict = hb_generate_filter_settings(filter_id,
+ NULL, NULL,
+ [NSString stringWithFormat:@"angle=%d:hflip=%d", self.filters.rotate, self.filters.flip].UTF8String);
filter = hb_filter_init(filter_id);
- hb_add_filter(job, filter, filter_str);
+ hb_add_filter_dict(job, filter, filter_dict);
+ hb_dict_free(&filter_dict);
}
// Add framerate shaping filter
filter = hb_filter_init(HB_FILTER_VFR);
- hb_add_filter(job, filter, [[NSString stringWithFormat:@"%d:%d:%d",
+ hb_add_filter(job, filter, [[NSString stringWithFormat:@"mode=%d:rate=%d/%d",
fps_mode, fps_num, fps_den] UTF8String]);
return job;