1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
/* HBPicture+UIAdditions.m $
This file is part of the HandBrake source code.
Homepage: <http://handbrake.fr/>.
It may be used under the terms of the GNU General Public License. */
#import "HBPicture+UIAdditions.h"
#import "HBTitle.h"
#include "hb.h"
@implementation HBPicture (UIAdditions)
@dynamic maxHeight;
@dynamic maxWidth;
@dynamic maxTopCrop;
@dynamic maxBottomCrop;
@dynamic maxLeftCrop;
@dynamic maxRightCrop;
#pragma mark - Editable state
+ (NSSet<NSString *> *)keyPathsForValuesAffectingKeepDisplayAspectEditable
{
return [NSSet setWithObjects:@"anamorphicMode", nil];
}
- (BOOL)isKeepDisplayAspectEditable
{
if (self.anamorphicMode == HB_ANAMORPHIC_AUTO ||
self.anamorphicMode == HB_ANAMORPHIC_LOOSE)
{
return NO;
}
else
{
return YES;
}
}
+ (NSSet<NSString *> *)keyPathsForValuesAffectingCustomAnamorphicEnabled
{
return [NSSet setWithObjects:@"anamorphicMode", nil];
}
- (BOOL)isCustomAnamorphicEnabled
{
return self.anamorphicMode == HB_ANAMORPHIC_CUSTOM;
}
+ (NSSet<NSString *> *)keyPathsForValuesAffectingInfo
{
return [NSSet setWithObjects:@"parWidth", @"parHeight", @"displayWidth", @"width", @"height",@"anamorphicMode", @"cropTop", @"cropBottom", @"cropLeft", @"cropRight", nil];
}
- (NSString *)info
{
NSString *sizeInfo = @"";
sizeInfo = [NSString stringWithFormat:
@"Source: %dx%d, ",
self.sourceWidth, self.sourceHeight];
if (self.anamorphicMode == HB_ANAMORPHIC_AUTO)
{
sizeInfo = [NSString stringWithFormat:
@"%@Output: %dx%d, Anamorphic: %dx%d Auto",
sizeInfo, self.width, self.height, self.displayWidth, self.height];
}
else if (self.anamorphicMode == HB_ANAMORPHIC_LOOSE) // Loose Anamorphic
{
sizeInfo = [NSString stringWithFormat:
@"%@Output: %dx%d, Anamorphic: %dx%d Loose",
sizeInfo, self.width, self.height, self.displayWidth, self.height];
}
else if (self.anamorphicMode == HB_ANAMORPHIC_CUSTOM) // Custom Anamorphic
{
sizeInfo = [NSString stringWithFormat:
@"%@Output: %dx%d, Anamorphic: %dx%d Custom",
sizeInfo, self.width, self.height, self.displayWidth, self.height];
}
else // No Anamorphic
{
sizeInfo = [NSString stringWithFormat:
@"%@Output: %dx%d",
sizeInfo, self.width, self.height];
}
return sizeInfo;
}
- (NSString *)shortInfo
{
return [NSString stringWithFormat:NSLocalizedString(@"%dx%d Storage, %dx%d Display\n %d : %d PAR, %@ DAR", nil),
self.width, self.height, self.displayWidth, self.height,
self.parWidth, self.parHeight, [self displayAspectInfo]];
}
- (NSString *)displayAspectInfo
{
int dar_width, dar_height;
NSString *str;
hb_reduce(&dar_width, &dar_height, self.displayWidth, self.height);
int iaspect = dar_width * 9 / dar_height;
if (dar_width > 2 * dar_height)
{
str = [NSString stringWithFormat:@"%.2g : 1", (double)dar_width / dar_height];
}
else if (iaspect <= 16 && iaspect >= 15)
{
str = [NSString stringWithFormat:@"%.2g : 9", (double)dar_width * 9 / dar_height];
}
else if (iaspect <= 12 && iaspect >= 11)
{
str = [NSString stringWithFormat:@"%.2g : 3", (double)dar_width * 3 / dar_height];
}
else
{
str = [NSString stringWithFormat:@"%d : %d", dar_width, dar_height];
}
return str;
}
- (NSString *)sourceInfo
{
NSString *sizeInfo = @"";
sizeInfo = [NSString stringWithFormat:@"%d x %d", self.sourceWidth, self.sourceHeight];
if (self.sourceWidth != self.sourceDisplayWidth)
{
sizeInfo = [NSString stringWithFormat:@"%d x %d, Anamorphic: %d x %d", self.sourceWidth, self.sourceHeight, self.sourceDisplayWidth, self.sourceHeight];
}
return sizeInfo;
}
+ (NSSet<NSString *> *)keyPathsForValuesAffectingSummary
{
return [NSSet setWithObjects:@"parWidth", @"parHeight", @"displayWidth", @"width", @"height",@"anamorphicMode", @"cropTop", @"cropBottom", @"cropLeft", @"cropRight", nil];
}
- (NSString *)summary
{
NSMutableString *summary = [NSMutableString stringWithString:@""];
[summary appendString:self.info];
[summary appendFormat:@", Modulus: %d", self.modulus];
[summary appendFormat:@", Crop: %s %d/%d/%d/%d",
self.autocrop ? "Auto" : "Custom",
self.cropTop, self.cropBottom,
self.cropLeft, self.cropRight];
return [summary copy];
}
@end
|