]> granicus.if.org Git - handbrake/commitdiff
MacGui: remove HBPicture dependency on HBTitle.
authorritsuka <damiog@gmail.com>
Fri, 17 Apr 2015 13:21:30 +0000 (13:21 +0000)
committerritsuka <damiog@gmail.com>
Fri, 17 Apr 2015 13:21:30 +0000 (13:21 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7091 b64f7644-9d1e-0410-96f1-a4d463321fa5

macosx/HBJob.m
macosx/HBPicture+UIAdditions.m
macosx/HBPicture.h
macosx/HBPicture.m

index 574fd375e0c3f2d9f9c3c6bdde1e492f477cfd80..1607cca8edfa4b9f85a4f56beb4b6e9b59e64c5f 100644 (file)
@@ -113,7 +113,6 @@ NSString *HBChaptersChangedNotification  = @"HBChaptersChangedNotification";
 {
     _title = title;
     self.range.title = title;
-    self.picture.title = title;
 }
 
 - (void)setChaptersEnabled:(BOOL)chaptersEnabled
index 8dfd019cd9953b2259aca1834d2e55e3574b2477..06ea316ee1615aab2da4ee66ff20b7a93da81a34 100644 (file)
 {
     NSString *sizeInfo = @"";
 
-    if (self.title)
-    {
-        hb_title_t *title = self.title.hb_title;
-        sizeInfo = [NSString stringWithFormat:
-                    @"Source: %dx%d, ",
-                    title->geometry.width, title->geometry.height];
-    }
+    sizeInfo = [NSString stringWithFormat:
+                @"Source: %dx%d, ",
+                self.sourceWidth, self.sourceHeight];
 
     if (self.anamorphicMode == HB_ANAMORPHIC_STRICT) // Original PAR Implementation
     {
index bf2f6ec5c8037e482595d7749bc27b9591aea2c1..6bd281eaafd6e2240c9158a2273f49a5f12e5537 100644 (file)
@@ -41,7 +41,11 @@ extern NSString * const HBPictureChangedNotification;
 @property (nonatomic, readwrite) int cropLeft;
 @property (nonatomic, readwrite) int cropRight;
 
-@property (nonatomic, readwrite, unsafe_unretained) HBTitle *title;
+/**
+ *  Source size
+ */
+@property (nonatomic, readonly) int sourceWidth;
+@property (nonatomic, readonly) int sourceHeight;
 
 @end
 
index 0da6af2d6440ea4b2362a22890280eb556f0137c..d713f631f498cb9f246be2acc8915f53e2d23e8d 100644 (file)
@@ -21,6 +21,14 @@ NSString * const HBPictureChangedNotification = @"HBPictureChangedNotification";
 @property (nonatomic, readwrite) int keep;
 @property (nonatomic, readwrite) BOOL darUpdated;
 
+@property (nonatomic, readonly) int sourceParNum;
+@property (nonatomic, readonly) int sourceParDen;
+
+@property (nonatomic, readonly) int autoCropTop;
+@property (nonatomic, readonly) int autoCropBottom;
+@property (nonatomic, readonly) int autoCropLeft;
+@property (nonatomic, readonly) int autoCropRight;
+
 @end
 
 @implementation HBPicture
@@ -33,9 +41,17 @@ NSString * const HBPictureChangedNotification = @"HBPictureChangedNotification";
         // Set some values if we ever need a fake instance
         _width = 1280;
         _height = 720;
+
+        _sourceWidth = 1280;
+        _sourceHeight = 720;
+
         _anamorphicMode = HB_ANAMORPHIC_NONE;
+
         _parWidth = 1;
         _parHeight = 1;
+        _sourceParNum = 1;
+        _sourceParDen = 1;
+
     }
     return self;
 }
@@ -45,10 +61,15 @@ NSString * const HBPictureChangedNotification = @"HBPictureChangedNotification";
     self = [self init];
     if (self)
     {
-        _title = title;
         _width = title.hb_title->geometry.width;
         _height = title.hb_title->geometry.height;
 
+        _sourceWidth = title.hb_title->geometry.width;
+        _sourceHeight = title.hb_title->geometry.height;
+
+        _sourceParNum = title.hb_title->geometry.par.num;
+        _sourceParDen = title.hb_title->geometry.par.den;
+
         [self validateSettings];
 
         _notificationsEnabled = YES;
@@ -250,15 +271,14 @@ NSString * const HBPictureChangedNotification = @"HBPictureChangedNotification";
 - (void)setAutocrop:(BOOL)autocrop
 {
     _autocrop = autocrop;
-    if (self.title && autocrop && !self.isValidating)
+    if (autocrop && !self.isValidating)
     {
-        hb_title_t *title = self.title.hb_title;
         self.validating = YES;
         // Reset the crop values to those determined right after scan
-        self.cropTop    = title->crop[0];
-        self.cropBottom = title->crop[1];
-        self.cropLeft   = title->crop[2];
-        self.cropRight  = title->crop[3];
+        self.cropTop    = self.autoCropTop;
+        self.cropBottom = self.autoCropBottom;
+        self.cropLeft   = self.autoCropLeft;
+        self.cropRight  = self.autoCropRight;
         self.validating = NO;
         [self validateSettings];
     }
@@ -302,34 +322,22 @@ NSString * const HBPictureChangedNotification = @"HBPictureChangedNotification";
 
 - (int)maxWidth
 {
-    if (self.title)
-        return self.title.hb_title->geometry.width - self.cropRight - self.cropLeft;
-
-    return 0;
+    return self.sourceWidth - self.cropRight - self.cropLeft;
 }
 
 - (int)maxHeight
 {
-    if (self.title)
-        return self.title.hb_title->geometry.height - self.cropTop - self.cropBottom;
-
-    return 0;
+    return self.sourceHeight - self.cropTop - self.cropBottom;
 }
 
 - (int)maxVerticalCrop
 {
-    if (self.title)
-        return self.title.hb_title->geometry.height / 2 - 2;
-
-    return 0;
+    return self.sourceHeight / 2 - 2;
 }
 
 - (int)maxHorizontalCrop
 {
-    if (self.title)
-        return self.title.hb_title->geometry.width / 2 - 2;
-
-    return 0;
+    return self.sourceWidth / 2 - 2;
 }
 
 + (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key
@@ -381,16 +389,15 @@ NSString * const HBPictureChangedNotification = @"HBPictureChangedNotification";
 {
     self.validating = YES;
 
-    hb_title_t *title = self.title.hb_title;
-
     self.keep |= self.keepDisplayAspect * HB_KEEP_DISPLAY_ASPECT;
 
     hb_geometry_t srcGeo, resultGeo;
     hb_geometry_settings_t uiGeo;
 
-    srcGeo.width = title->geometry.width;
-    srcGeo.height = title->geometry.height;
-    srcGeo.par = title->geometry.par;
+    srcGeo.width = self.sourceWidth;
+    srcGeo.height = self.sourceHeight;
+    srcGeo.par.num = self.sourceParNum;
+    srcGeo.par.den = self.sourceParDen;
 
     uiGeo.mode = self.anamorphicMode;
     uiGeo.keep = self.keep;
@@ -403,8 +410,8 @@ NSString * const HBPictureChangedNotification = @"HBPictureChangedNotification";
     uiGeo.geometry.height =  self.height;
     // Modulus added to maxWidth/maxHeight to allow a small amount of
     // upscaling to the next mod boundary.
-    uiGeo.maxWidth = title->geometry.width - crop[2] - crop[3] + self.modulus - 1;
-    uiGeo.maxHeight = title->geometry.height - crop[0] - crop[1] + self.modulus - 1;
+    uiGeo.maxWidth = self.sourceWidth - crop[2] - crop[3] + self.modulus - 1;
+    uiGeo.maxHeight = self.sourceHeight - crop[0] - crop[1] + self.modulus - 1;
 
     hb_rational_t par = {self.parWidth, self.parHeight};
     uiGeo.geometry.par = par;
@@ -484,6 +491,16 @@ NSString * const HBPictureChangedNotification = @"HBPictureChangedNotification";
     encodeInt(_cropBottom);
     encodeInt(_cropLeft);
     encodeInt(_cropRight);
+
+    encodeInt(_autoCropTop);
+    encodeInt(_autoCropBottom);
+    encodeInt(_autoCropLeft);
+    encodeInt(_autoCropRight);
+
+    encodeInt(_sourceWidth);
+    encodeInt(_sourceHeight);
+    encodeInt(_sourceParNum);
+    encodeInt(_sourceParDen);
 }
 
 - (instancetype)initWithCoder:(NSCoder *)decoder
@@ -507,6 +524,16 @@ NSString * const HBPictureChangedNotification = @"HBPictureChangedNotification";
     decodeInt(_cropLeft);
     decodeInt(_cropRight);
 
+    decodeInt(_autoCropTop);
+    decodeInt(_autoCropBottom);
+    decodeInt(_autoCropLeft);
+    decodeInt(_autoCropRight);
+
+    decodeInt(_sourceWidth);
+    decodeInt(_sourceHeight);
+    decodeInt(_sourceParNum);
+    decodeInt(_sourceParDen);
+
     _notificationsEnabled = YES;
     
     return self;
@@ -533,14 +560,13 @@ NSString * const HBPictureChangedNotification = @"HBPictureChangedNotification";
 {
     self.validating = YES;
     self.notificationsEnabled = NO;
-    hb_title_t *title = self.title.hb_title;
 
     /* Note: objectForKey:@"UsesPictureSettings" refers to picture size, which encompasses:
      * height, width, keep ar, anamorphic and crop settings.
      * picture filters are handled separately below.
      */
-    int maxWidth = title->geometry.width - self.cropLeft - self.cropRight;
-    int maxHeight = title->geometry.height - self.cropTop - self.cropBottom;
+    int maxWidth = self.sourceWidth - self.cropLeft - self.cropRight;
+    int maxHeight = self.sourceHeight - self.cropTop - self.cropBottom;
     int jobMaxWidth = 0, jobMaxHeight = 0;
 
     /* Check to see if the objectForKey:@"UsesPictureSettings is greater than 0, as 0 means use picture sizing "None"
@@ -565,15 +591,15 @@ NSString * const HBPictureChangedNotification = @"HBPictureChangedNotification";
         {
             self.autocrop = YES;
             /* Here we use the auto crop values determined right after scan */
-            self.cropTop    = title->crop[0];
-            self.cropBottom = title->crop[1];
-            self.cropLeft   = title->crop[2];
-            self.cropRight  = title->crop[3];
+            self.cropTop    = self.autoCropTop;
+            self.cropBottom = self.autoCropBottom;
+            self.cropLeft   = self.autoCropLeft;
+            self.cropRight  = self.autoCropRight;
         }
 
         // crop may have changed, reset maxWidth/maxHeight
-        maxWidth = title->geometry.width - self.cropLeft - self.cropRight;
-        maxHeight = title->geometry.height - self.cropTop - self.cropBottom;
+        maxWidth = self.sourceWidth - self.cropLeft - self.cropRight;
+        maxHeight = self.sourceHeight - self.cropTop - self.cropBottom;
 
         // Set modulus
         if (preset[@"PictureModulus"])
@@ -588,8 +614,8 @@ NSString * const HBPictureChangedNotification = @"HBPictureChangedNotification";
         // Assume max picture settings initially.
         self.keepDisplayAspect = [preset[@"PictureKeepRatio"] intValue];
         self.anamorphicMode = [preset[@"PicturePAR"] intValue];
-        self.width = title->geometry.width - self.cropLeft - self.cropRight;
-        self.height = title->geometry.height - self.cropTop - self.cropBottom;
+        self.width = self.sourceWidth - self.cropLeft - self.cropRight;
+        self.height = self.sourceHeight - self.cropTop - self.cropBottom;
 
         // Check to see if the objectForKey:@"UsesPictureSettings" is 2,
         // which means "Use max. picture size for source"
@@ -627,9 +653,10 @@ NSString * const HBPictureChangedNotification = @"HBPictureChangedNotification";
     hb_geometry_t srcGeo, resultGeo;
     hb_geometry_settings_t uiGeo;
 
-    srcGeo.width = title->geometry.width;
-    srcGeo.height = title->geometry.height;
-    srcGeo.par = title->geometry.par;
+    srcGeo.width = self.sourceWidth;
+    srcGeo.height = self.sourceHeight;
+    srcGeo.par.num = self.sourceParNum;
+    srcGeo.par.den = self.sourceParDen;
 
     uiGeo.mode = self.anamorphicMode;
     uiGeo.keep = self.keepDisplayAspect * HB_KEEP_DISPLAY_ASPECT;