summaryrefslogtreecommitdiffstats
path: root/macosx/HBSubtitles.m
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2014-03-30 17:27:18 +0000
committerjstebbins <[email protected]>2014-03-30 17:27:18 +0000
commit05e6e447df6d66307a2cbcf7be19dc6d67676e07 (patch)
tree311923bb6f135f43c71f155008e2036c8e37fe68 /macosx/HBSubtitles.m
parentc02a0dc40464e6d0700ae0514de72d951276b020 (diff)
libhb: enable burn-in of all supported text subtitle formats
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6141 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx/HBSubtitles.m')
-rw-r--r--macosx/HBSubtitles.m187
1 files changed, 80 insertions, 107 deletions
diff --git a/macosx/HBSubtitles.m b/macosx/HBSubtitles.m
index 6760b5d3e..d8474ac09 100644
--- a/macosx/HBSubtitles.m
+++ b/macosx/HBSubtitles.m
@@ -96,20 +96,17 @@
hb_subtitle_t *subtitle;
NSMutableArray *forcedSourceNamesArray = [[NSMutableArray alloc] init];
for (i = 0; i < hb_list_count(fTitle->list_subtitle); i++)
- {
- subtitle = (hb_subtitle_t*)hb_list_item(fTitle->list_subtitle, i);
-
- /* Subtitle source features */
- int canBeBurnedIn = hb_subtitle_can_burn(subtitle->source);
- int supportsForcedFlags = hb_subtitle_can_force(subtitle->source);
- /* Human-readable representation of subtitle->source */
- NSString *bitmapOrText = subtitle->format == PICTURESUB ? @"Bitmap" : @"Text";
- NSString *subSourceName = [NSString stringWithUTF8String:hb_subsource_name(subtitle->source)];
- /* if the subtitle track can be forced, add its source name to the array */
- if (supportsForcedFlags &&
- [forcedSourceNamesArray containsObject:subSourceName] == NO)
- {
- [forcedSourceNamesArray addObject:subSourceName];
+ {
+ subtitle = (hb_subtitle_t*)hb_list_item(fTitle->list_subtitle, i);
+
+ /* Human-readable representation of subtitle->source */
+ NSString *bitmapOrText = subtitle->format == PICTURESUB ? @"Bitmap" : @"Text";
+ NSString *subSourceName = [NSString stringWithUTF8String:hb_subsource_name(subtitle->source)];
+ /* if the subtitle track can be forced, add its source name to the array */
+ if (hb_subtitle_can_force(subtitle->source) &&
+ [forcedSourceNamesArray containsObject:subSourceName] == NO)
+ {
+ [forcedSourceNamesArray addObject:subSourceName];
}
/* create a dictionary of source subtitle information to store in our array */
@@ -117,16 +114,14 @@
/* Subtitle Source track name */
[newSubtitleSourceTrack setObject:[NSString stringWithFormat:@"%d - %@ - (%@) (%@)",
i, [NSString stringWithUTF8String:subtitle->lang],
- bitmapOrText,subSourceName]
- forKey:@"sourceTrackName"];
- /* Subtitle Source track number, type and features */
- [newSubtitleSourceTrack setObject:[NSNumber numberWithInt:i] forKey:@"sourceTrackNum"];
- [newSubtitleSourceTrack setObject:[NSNumber numberWithInt:subtitle->source] forKey:@"sourceTrackType"];
- [newSubtitleSourceTrack setObject:[NSNumber numberWithInt:canBeBurnedIn] forKey:@"sourceTrackCanBeBurnedIn"];
- [newSubtitleSourceTrack setObject:[NSNumber numberWithInt:supportsForcedFlags] forKey:@"sourceTrackSupportsForcedFlags"];
- [subtitleSourceArray addObject:newSubtitleSourceTrack];
- [newSubtitleSourceTrack autorelease];
- }
+ bitmapOrText,subSourceName]
+ forKey:@"sourceTrackName"];
+ /* Subtitle Source track number, type and features */
+ [newSubtitleSourceTrack setObject:[NSNumber numberWithInt:i] forKey:@"sourceTrackNum"];
+ [newSubtitleSourceTrack setObject:[NSNumber numberWithInt:subtitle->source] forKey:@"sourceTrackType"];
+ [subtitleSourceArray addObject:newSubtitleSourceTrack];
+ [newSubtitleSourceTrack autorelease];
+ }
/* now set the name of the Foreign Audio Search track */
if ([forcedSourceNamesArray count])
@@ -185,16 +180,12 @@
/* Subtitle track forced state */
[newSubtitleTrack setObject:[NSNumber numberWithInt:0] forKey:@"subtitleTrackForced"];
/* Subtitle track burned state */
- [newSubtitleTrack setObject:[NSNumber numberWithInt:0] forKey:@"subtitleTrackBurned"];
- /* Subtitle track default state */
- [newSubtitleTrack setObject:[NSNumber numberWithInt:0] forKey:@"subtitleTrackDefault"];
- /* Subtitle Source track canBeBurnedIn */
- [newSubtitleTrack setObject:[NSNumber numberWithInt:0] forKey:@"subtitleSourceTrackCanBeBurnedIn"];
- /* Subtitle Source track supportsForcedFlags */
- [newSubtitleTrack setObject:[NSNumber numberWithInt:0] forKey:@"subtitleSourceTrackSupportsForcedFlags"];
-
- [newSubtitleTrack autorelease];
- return newSubtitleTrack;
+ [newSubtitleTrack setObject:[NSNumber numberWithInt:0] forKey:@"subtitleTrackBurned"];
+ /* Subtitle track default state */
+ [newSubtitleTrack setObject:[NSNumber numberWithInt:0] forKey:@"subtitleTrackDefault"];
+
+ [newSubtitleTrack autorelease];
+ return newSubtitleTrack;
}
- (void)createSubtitleSrtTrack:(NSURL *)fileURL
@@ -209,16 +200,12 @@
[newSubtitleSourceTrack setObject:displayname forKey:@"sourceTrackName"];
/* Subtitle Source track type (VobSub, Srt, etc.) */
[newSubtitleSourceTrack setObject:[NSNumber numberWithInt:SRTSUB] forKey:@"sourceTrackType"];
- [newSubtitleSourceTrack setObject:[NSNumber numberWithInt:SRTSUB] forKey:@"subtitleSourceTrackType"];
- /* Subtitle Source file path */
- [newSubtitleSourceTrack setObject:[fileURL path] forKey:@"sourceSrtFilePath"];
- /* Subtitle Source track canBeBurnedIn */
- [newSubtitleSourceTrack setObject:[NSNumber numberWithInt:0] forKey:@"sourceTrackCanBeBurnedIn"];
- /* Subtitle Source track supportsForcedFlags */
- [newSubtitleSourceTrack setObject:[NSNumber numberWithInt:0] forKey:@"sourceTrackSupportsForcedFlags"];
-
- [subtitleSourceArray addObject:newSubtitleSourceTrack];
- [newSubtitleSourceTrack autorelease];
+ [newSubtitleSourceTrack setObject:[NSNumber numberWithInt:SRTSUB] forKey:@"subtitleSourceTrackType"];
+ /* Subtitle Source file path */
+ [newSubtitleSourceTrack setObject:[fileURL path] forKey:@"sourceSrtFilePath"];
+
+ [subtitleSourceArray addObject:newSubtitleSourceTrack];
+ [newSubtitleSourceTrack autorelease];
/* Now create a new srt subtitle dictionary assuming the user wants to add it to their list
* Note: the subtitle array always has last entry for "None", so we need to replace its
@@ -244,16 +231,12 @@
/* Subtitle track forced state */
[newSubtitleSrtTrack setObject:[NSNumber numberWithInt:0] forKey:@"subtitleTrackForced"];
/* Subtitle track burned state */
- [newSubtitleSrtTrack setObject:[NSNumber numberWithInt:0] forKey:@"subtitleTrackBurned"];
- /* Subtitle track default state */
- [newSubtitleSrtTrack setObject:[NSNumber numberWithInt:0] forKey:@"subtitleTrackDefault"];
- /* Subtitle Source track canBeBurnedIn */
- [newSubtitleSrtTrack setObject:[NSNumber numberWithInt:0] forKey:@"subtitleSourceTrackCanBeBurnedIn"];
- /* Subtitle Source track supportsForcedFlags */
- [newSubtitleSrtTrack setObject:[NSNumber numberWithInt:0] forKey:@"subtitleSourceTrackSupportsForcedFlags"];
-
- /* now the srt only info, Language, Chart Code and offset */
- [newSubtitleSrtTrack setObject:[fileURL path] forKey:@"subtitleSourceSrtFilePath"];
+ [newSubtitleSrtTrack setObject:[NSNumber numberWithInt:0] forKey:@"subtitleTrackBurned"];
+ /* Subtitle track default state */
+ [newSubtitleSrtTrack setObject:[NSNumber numberWithInt:0] forKey:@"subtitleTrackDefault"];
+
+ /* now the srt only info, Language, Chart Code and offset */
+ [newSubtitleSrtTrack setObject:[fileURL path] forKey:@"subtitleSourceSrtFilePath"];
[newSubtitleSrtTrack setObject:[NSNumber numberWithInteger:languagesArrayDefIndex] forKey:@"subtitleTrackSrtLanguageIndex"];
[newSubtitleSrtTrack setObject:[[languagesArray objectAtIndex:languagesArrayDefIndex] objectAtIndex:0] forKey:@"subtitleTrackSrtLanguageLong"];
[newSubtitleSrtTrack setObject:[[languagesArray objectAtIndex:languagesArrayDefIndex] objectAtIndex:1] forKey:@"subtitleTrackSrtLanguageIso3"];
@@ -311,16 +294,12 @@
[newSubtitleSourceTrack setObject:displayname forKey:@"sourceTrackName"];
/* Subtitle Source track type (VobSub, Srt, etc.) */
[newSubtitleSourceTrack setObject:[NSNumber numberWithInt:SRTSUB] forKey:@"sourceTrackType"];
- [newSubtitleSourceTrack setObject:[NSNumber numberWithInt:SRTSUB] forKey:@"subtitleSourceTrackType"];
- /* Subtitle Source file path */
- [newSubtitleSourceTrack setObject:filePath forKey:@"sourceSrtFilePath"];
- /* Subtitle Source track canBeBurnedIn */
- [newSubtitleSourceTrack setObject:[NSNumber numberWithInt:0] forKey:@"sourceTrackCanBeBurnedIn"];
- /* Subtitle Source track supportsForcedFlags */
- [newSubtitleSourceTrack setObject:[NSNumber numberWithInt:0] forKey:@"sourceTrackSupportsForcedFlags"];
-
- [subtitleSourceArray addObject:newSubtitleSourceTrack];
- [newSubtitleSourceTrack autorelease];
+ [newSubtitleSourceTrack setObject:[NSNumber numberWithInt:SRTSUB] forKey:@"subtitleSourceTrackType"];
+ /* Subtitle Source file path */
+ [newSubtitleSourceTrack setObject:filePath forKey:@"sourceSrtFilePath"];
+
+ [subtitleSourceArray addObject:newSubtitleSourceTrack];
+ [newSubtitleSourceTrack autorelease];
/* END replicate the add new srt code above */
}
i++;
@@ -505,14 +484,12 @@
hb_subsource_name(PGSSUB)]].location != NSNotFound)
{
subtitleTrackType = PGSSUB;
- }
- // now set the track type
- [[subtitleArray objectAtIndex:rowIndex] setObject:[NSNumber numberWithInt:subtitleTrackType] forKey:@"subtitleSourceTrackType"];
- [[subtitleArray objectAtIndex:rowIndex] setObject:[NSNumber numberWithInt:1] forKey:@"subtitleSourceTrackCanBeBurnedIn"];
- [[subtitleArray objectAtIndex:rowIndex] setObject:[NSNumber numberWithInt:1] forKey:@"subtitleSourceTrackSupportsForcedFlags"];
- // foreign lang search is most useful when combined w/Forced Only - make it default
- [[subtitleArray objectAtIndex:rowIndex] setObject:[NSNumber numberWithInt:1] forKey:@"subtitleTrackForced"];
- }
+ }
+ // now set the track type
+ [[subtitleArray objectAtIndex:rowIndex] setObject:[NSNumber numberWithInt:subtitleTrackType] forKey:@"subtitleSourceTrackType"];
+ // foreign lang search is most useful when combined w/Forced Only - make it default
+ [[subtitleArray objectAtIndex:rowIndex] setObject:[NSNumber numberWithInt:1] forKey:@"subtitleTrackForced"];
+ }
/* check to see if we are an srt, in which case set our file path and source track type kvp's*/
else if ([[[subtitleSourceArray objectAtIndex:sourceSubtitleIndex] objectForKey:@"sourceTrackType"] intValue] == SRTSUB)
{
@@ -522,25 +499,21 @@
forKey:@"subtitleSourceSrtFilePath"];
}
else
- {
- [[subtitleArray objectAtIndex:rowIndex] setObject:[[subtitleSourceArray objectAtIndex:sourceSubtitleIndex] objectForKey:@"sourceTrackType"]
- forKey:@"subtitleSourceTrackType"];
- [[subtitleArray objectAtIndex:rowIndex] setObject:[[subtitleSourceArray objectAtIndex:sourceSubtitleIndex] objectForKey:@"sourceTrackCanBeBurnedIn"]
- forKey:@"subtitleSourceTrackCanBeBurnedIn"];
- [[subtitleArray objectAtIndex:rowIndex] setObject:[[subtitleSourceArray objectAtIndex:sourceSubtitleIndex] objectForKey:@"sourceTrackSupportsForcedFlags"]
- forKey:@"subtitleSourceTrackSupportsForcedFlags"];
- }
-
- if([[[subtitleArray objectAtIndex:rowIndex] objectForKey:@"subtitleSourceTrackCanBeBurnedIn"] intValue] == 0)
- {
- /* the source track cannot be burned in, so uncheck the widget */
- [[subtitleArray objectAtIndex:rowIndex] setObject:[NSNumber numberWithInt:0] forKey:@"subtitleTrackBurned"];
- }
-
- if([[[subtitleArray objectAtIndex:rowIndex] objectForKey:@"subtitleSourceTrackSupportsForcedFlags"] intValue] == 0)
- {
- /* the source track does not support forced flags, so uncheck the widget */
- [[subtitleArray objectAtIndex:rowIndex] setObject:[NSNumber numberWithInt:0] forKey:@"subtitleTrackForced"];
+ {
+ [[subtitleArray objectAtIndex:rowIndex] setObject:[[subtitleSourceArray objectAtIndex:sourceSubtitleIndex] objectForKey:@"sourceTrackType"]
+ forKey:@"subtitleSourceTrackType"];
+ }
+
+ if (!hb_subtitle_can_burn([[[subtitleArray objectAtIndex:rowIndex] objectForKey:@"subtitleSourceTrackType"] intValue]))
+ {
+ /* the source track cannot be burned in, so uncheck the widget */
+ [[subtitleArray objectAtIndex:rowIndex] setObject:[NSNumber numberWithInt:0] forKey:@"subtitleTrackBurned"];
+ }
+
+ if (!hb_subtitle_can_force([[[subtitleArray objectAtIndex:rowIndex] objectForKey:@"subtitleSourceTrackType"] intValue]))
+ {
+ /* the source track does not support forced flags, so uncheck the widget */
+ [[subtitleArray objectAtIndex:rowIndex] setObject:[NSNumber numberWithInt:0] forKey:@"subtitleTrackForced"];
}
}
}
@@ -715,13 +688,13 @@
if ([[aTableColumn identifier] isEqualToString:@"forced"])
{
- [aCell setState:[[[subtitleArray objectAtIndex:rowIndex] objectForKey:@"subtitleTrackForced"] intValue]];
- /* Disable the "Forced Only" checkbox if a) the track is "None" or b) the subtitle track doesn't support forced flags */
- if (![[[subtitleArray objectAtIndex:rowIndex] objectForKey:@"subtitleSourceTrackNum"] intValue] ||
- ![[[subtitleArray objectAtIndex:rowIndex] objectForKey:@"subtitleSourceTrackSupportsForcedFlags"] intValue])
- {
- [aCell setEnabled:NO];
- }
+ [aCell setState:[[[subtitleArray objectAtIndex:rowIndex] objectForKey:@"subtitleTrackForced"] intValue]];
+ /* Disable the "Forced Only" checkbox if a) the track is "None" or b) the subtitle track doesn't support forced flags */
+ if (![[[subtitleArray objectAtIndex:rowIndex] objectForKey:@"subtitleSourceTrackNum"] intValue] ||
+ !hb_subtitle_can_force([[[subtitleArray objectAtIndex:rowIndex] objectForKey:@"subtitleSourceTrackType"] intValue]))
+ {
+ [aCell setEnabled:NO];
+ }
else
{
[aCell setEnabled:YES];
@@ -733,15 +706,15 @@
/*
* Disable the "Burned In" checkbox if:
* a) the track is "None" OR
- * b) the subtitle track can't be burned in OR
- * c) the subtitle track can't be passed through (e.g. PGS w/MP4)
- */
- if (![[[subtitleArray objectAtIndex:rowIndex] objectForKey:@"subtitleSourceTrackNum"] intValue] ||
- ![[[subtitleArray objectAtIndex:rowIndex] objectForKey:@"subtitleSourceTrackCanBeBurnedIn"] intValue] ||
- !hb_subtitle_can_pass([[[subtitleArray objectAtIndex:rowIndex] objectForKey:@"subtitleSourceTrackType"] intValue], container))
- {
- [aCell setEnabled:NO];
- }
+ * b) the subtitle track can't be burned in OR
+ * c) the subtitle track can't be passed through (e.g. PGS w/MP4)
+ */
+ int subtitleTrackType = [[[subtitleArray objectAtIndex:rowIndex] objectForKey:@"subtitleSourceTrackType"] intValue];
+ if (![[[subtitleArray objectAtIndex:rowIndex] objectForKey:@"subtitleSourceTrackNum"] intValue] ||
+ !hb_subtitle_can_burn(subtitleTrackType) || !hb_subtitle_can_pass(subtitleTrackType, container))
+ {
+ [aCell setEnabled:NO];
+ }
else
{
[aCell setEnabled:YES];