From bed344976b3757dd3b6ac4fa4e7b3589b0f9f6cb Mon Sep 17 00:00:00 2001 From: ritsuka Date: Tue, 17 Feb 2015 17:30:34 +0000 Subject: MacGui: add Burn-In options to subtitle defaults hopefully similar to the LinGui. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6916 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- macosx/English.lproj/SubtitlesDefaults.xib | 101 ++++++++++++++++++++++++----- macosx/HBSubtitles.m | 61 +++++++++++++++-- macosx/HBSubtitlesDefaults.h | 11 ++++ macosx/HBSubtitlesDefaults.m | 58 ++++++++++++++++- 4 files changed, 210 insertions(+), 21 deletions(-) diff --git a/macosx/English.lproj/SubtitlesDefaults.xib b/macosx/English.lproj/SubtitlesDefaults.xib index dcf8fc835..b6c1b3c7b 100644 --- a/macosx/English.lproj/SubtitlesDefaults.xib +++ b/macosx/English.lproj/SubtitlesDefaults.xib @@ -1,8 +1,8 @@ - + - + @@ -17,16 +17,16 @@ - + - + - + @@ -35,7 +35,7 @@ - + @@ -44,7 +44,7 @@ - + @@ -53,7 +53,7 @@ - + @@ -66,12 +66,13 @@ + - + @@ -103,7 +104,7 @@ - + @@ -156,7 +157,7 @@ + + + + Set the behavior of subtitle "Burn-in" + +Burned-In subtitles are part of the video and can not be disabled during playback. +Only one subtitle track can be burned. Since conflics can occur, the first chosen wins. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + diff --git a/macosx/HBSubtitles.m b/macosx/HBSubtitles.m index 82eceb963..a8fed1cae 100644 --- a/macosx/HBSubtitles.m +++ b/macosx/HBSubtitles.m @@ -306,9 +306,63 @@ NSString *keySubTrackLanguageIndex = @"keySubTrackLanguageIndex"; } } + // Set the burn key for the appropriate track. + if (self.defaults.burnInBehavior != HBSubtitleTrackBurnInBehaviorNone && self.tracks.count) + { + if (self.defaults.burnInBehavior == HBSubtitleTrackBurnInBehaviorFirst) + { + if ([self.tracks.firstObject[keySubTrackIndex] integerValue] != -1) + { + self.tracks.firstObject[keySubTrackBurned] = @YES; + } + else if (self.tracks.count > 1) + { + self.tracks[1][keySubTrackBurned] = @YES; + } + } + else if (self.defaults.burnInBehavior == HBSubtitleTrackBurnInBehaviorForeignAudio) + { + if ([self.tracks.firstObject[keySubTrackIndex] integerValue] == -1) + { + self.tracks.firstObject[keySubTrackBurned] = @YES; + } + } + else if (self.defaults.burnInBehavior == HBSubtitleTrackBurnInBehaviorForeignAudioThenFirst) + { + self.tracks.firstObject[keySubTrackBurned] = @YES; + } + } + + // Burn-in the first dvd or bluray track and remove the others. + if (self.defaults.burnInDVDSubtitles || self.defaults.burnInBluraySubtitles) + { + // Ugly settings for ugly players + BOOL bitmapSubtitlesFound = NO; + + NSMutableArray *tracksToDelete = [[NSMutableArray alloc] init]; + for (NSMutableDictionary *track in self.tracks) + { + if ([track[keySubTrackIndex] integerValue] != -1) + { + if ((([track[keySubTrackType] intValue] == VOBSUB && self.defaults.burnInDVDSubtitles) || + ([track[keySubTrackType] intValue] == PGSSUB && self.defaults.burnInBluraySubtitles)) && + !bitmapSubtitlesFound) + { + track[keySubTrackBurned] = @YES; + bitmapSubtitlesFound = YES; + } + else if ([track[keySubTrackType] intValue] == VOBSUB || [track[keySubTrackType] intValue] == PGSSUB) + { + [tracksToDelete addObject:track]; + } + } + } + [self.tracks removeObjectsInArray:tracksToDelete]; + [tracksToDelete release]; + } + // Add an empty track [self insertObject:[self createSubtitleTrack] inTracksAtIndex:[self countOfTracks]]; - [self validatePassthru]; } @@ -318,7 +372,6 @@ NSString *keySubTrackLanguageIndex = @"keySubTrackLanguageIndex"; */ - (void)validatePassthru { - int subtitleTrackType; BOOL convertToBurnInUsed = NO; NSMutableArray *tracksToDelete = [[NSMutableArray alloc] init]; @@ -330,7 +383,7 @@ NSString *keySubTrackLanguageIndex = @"keySubTrackLanguageIndex"; continue; } - subtitleTrackType = [track[keySubTrackType] intValue]; + int subtitleTrackType = [track[keySubTrackType] intValue]; if (!hb_subtitle_can_pass(subtitleTrackType, self.container)) { if (convertToBurnInUsed == NO) @@ -356,7 +409,7 @@ NSString *keySubTrackLanguageIndex = @"keySubTrackLanguageIndex"; continue; } - subtitleTrackType = [track[keySubTrackType] intValue]; + int subtitleTrackType = [track[keySubTrackType] intValue]; if (hb_subtitle_can_pass(subtitleTrackType, self.container)) { track[keySubTrackBurned] = @0; diff --git a/macosx/HBSubtitlesDefaults.h b/macosx/HBSubtitlesDefaults.h index ab65a20b3..793e31d3a 100644 --- a/macosx/HBSubtitlesDefaults.h +++ b/macosx/HBSubtitlesDefaults.h @@ -13,6 +13,13 @@ typedef NS_ENUM(NSUInteger, HBSubtitleTrackSelectionBehavior) { HBSubtitleTrackSelectionBehaviorAll, }; +typedef NS_ENUM(NSUInteger, HBSubtitleTrackBurnInBehavior) { + HBSubtitleTrackBurnInBehaviorNone, + HBSubtitleTrackBurnInBehaviorForeignAudio, + HBSubtitleTrackBurnInBehaviorFirst, + HBSubtitleTrackBurnInBehaviorForeignAudioThenFirst, +}; + @interface HBSubtitlesDefaults : NSObject @property (nonatomic, readwrite) HBSubtitleTrackSelectionBehavior trackSelectionBehavior; @@ -22,4 +29,8 @@ typedef NS_ENUM(NSUInteger, HBSubtitleTrackSelectionBehavior) { @property (nonatomic, readwrite) BOOL addForeignAudioSubtitle; @property (nonatomic, readwrite) BOOL addCC; +@property (nonatomic, readwrite) HBSubtitleTrackBurnInBehavior burnInBehavior; +@property (nonatomic, readwrite) BOOL burnInDVDSubtitles; +@property (nonatomic, readwrite) BOOL burnInBluraySubtitles; + @end diff --git a/macosx/HBSubtitlesDefaults.m b/macosx/HBSubtitlesDefaults.m index 359b19ea2..02d9cc345 100644 --- a/macosx/HBSubtitlesDefaults.m +++ b/macosx/HBSubtitlesDefaults.m @@ -37,6 +37,28 @@ self.addCC = [preset[@"SubtitleAddCC"] boolValue]; self.addForeignAudioSearch = [preset[@"SubtitleAddForeignAudioSearch"] boolValue]; self.addForeignAudioSubtitle = [preset[@"SubtitleAddForeignAudioSubtitle"] boolValue]; + + NSString *burnInBehavior = preset[@"SubtitleBurnBehavior"]; + + if ([burnInBehavior isEqualToString:@"foreign"]) + { + self.burnInBehavior = HBSubtitleTrackBurnInBehaviorForeignAudio; + } + else if ([burnInBehavior isEqualToString:@"fist"]) + { + self.burnInBehavior = HBSubtitleTrackBurnInBehaviorFirst; + } + else if ([burnInBehavior isEqualToString:@"foreign_first"]) + { + self.burnInBehavior = HBSubtitleTrackBurnInBehaviorForeignAudioThenFirst; + } + else + { + self.burnInBehavior = HBSubtitleTrackBurnInBehaviorNone; + } + + self.burnInDVDSubtitles = [preset[@"SubtitleBurnDVDSub"] boolValue]; + self.burnInBluraySubtitles = [preset[@"SubtitleBurnBDSub"] boolValue]; } - (void)writeToPreset:(NSMutableDictionary *)preset @@ -58,6 +80,26 @@ preset[@"SubtitleAddCC"] = @(self.addCC); preset[@"SubtitleAddForeignAudioSearch"] = @(self.addForeignAudioSearch); preset[@"SubtitleAddForeignAudioSubtitle"] = @(self.addForeignAudioSubtitle); + + if (self.burnInBehavior == HBSubtitleTrackBurnInBehaviorForeignAudio) + { + preset[@"SubtitleBurnBehavior"] = @"foreign"; + } + else if (self.burnInBehavior == HBSubtitleTrackBurnInBehaviorFirst) + { + preset[@"SubtitleBurnBehavior"] = @"fist"; + } + else if (self.burnInBehavior == HBSubtitleTrackBurnInBehaviorForeignAudioThenFirst) + { + preset[@"SubtitleBurnBehavior"] = @"foreign_first"; + } + else + { + preset[@"SubtitleBurnBehavior"] = @"none"; + } + + preset[@"SubtitleBurnDVDSub"] = @(self.burnInDVDSubtitles); + preset[@"SubtitleBurnBDSub"] = @(self.burnInBluraySubtitles); } #pragma mark - NSCopying @@ -75,8 +117,12 @@ copy->_addForeignAudioSearch = _addForeignAudioSearch; copy->_addForeignAudioSubtitle = _addForeignAudioSubtitle; copy->_addCC = _addCC; + + copy->_burnInBehavior = _burnInBehavior; + copy->_burnInDVDSubtitles = _burnInDVDSubtitles; + copy->_burnInBluraySubtitles = _burnInBluraySubtitles; } - + return copy; } @@ -84,7 +130,7 @@ - (void)encodeWithCoder:(NSCoder *)coder { - [coder encodeInt:1 forKey:@"HBAudioDefaultsVersion"]; + [coder encodeInt:1 forKey:@"HBSubtitlesDefaultsVersion"]; encodeInteger(_trackSelectionBehavior); encodeObject(_trackSelectionLanguages); @@ -92,6 +138,10 @@ encodeBool(_addForeignAudioSearch); encodeBool(_addForeignAudioSubtitle); encodeBool(_addCC); + + encodeInteger(_burnInBehavior); + encodeBool(_burnInDVDSubtitles); + encodeBool(_burnInBluraySubtitles); } - (id)initWithCoder:(NSCoder *)decoder @@ -105,6 +155,10 @@ decodeBool(_addForeignAudioSubtitle); decodeBool(_addCC); + decodeInteger(_burnInBehavior); + decodeBool(_burnInDVDSubtitles); + decodeBool(_burnInBluraySubtitles); + return self; } -- cgit v1.2.3