diff options
Diffstat (limited to 'macosx/HBJob+HBJobConversion.m')
-rw-r--r-- | macosx/HBJob+HBJobConversion.m | 135 |
1 files changed, 64 insertions, 71 deletions
diff --git a/macosx/HBJob+HBJobConversion.m b/macosx/HBJob+HBJobConversion.m index b194e86d8..4ed4e4390 100644 --- a/macosx/HBJob+HBJobConversion.m +++ b/macosx/HBJob+HBJobConversion.m @@ -9,6 +9,8 @@ #import "HBAudioDefaults.h" #import "HBAudioTrack.h" +#import "HBSubtitlesTrack.h" + #import "HBChapter.h" #import "HBTitlePrivate.h" @@ -220,93 +222,84 @@ // Map the settings in the dictionaries for the SubtitleList array to match title->list_subtitle BOOL one_burned = NO; - for (NSDictionary *subtitleDict in self.subtitles.tracks) + for (HBSubtitlesTrack *subTrack in self.subtitles.tracks) { - int subtitle = [subtitleDict[keySubTrackIndex] intValue]; - BOOL force = [subtitleDict[keySubTrackForced] boolValue]; - BOOL burned = [subtitleDict[keySubTrackBurned] boolValue]; - BOOL def = [subtitleDict[keySubTrackDefault] boolValue]; - - // Skip the "None" track. - if (subtitle == -2) - { - continue; - } - - // we need to check for the "Foreign Audio Search" which would be keySubTrackIndex of -1 - if (subtitle == -1) + if (subTrack.isEnabled) { - job->indepth_scan = 1; + // Shift the source index by 2 to componsate + // for the none and foreign audio search tracks. + int sourceIdx = ((int)subTrack.sourceTrackIdx) - 2; - if (burned != 1) + // we need to check for the "Foreign Audio Search" which would be have an index of -1 + if (sourceIdx == -1) { - job->select_subtitle_config.dest = PASSTHRUSUB; - } - else - { - job->select_subtitle_config.dest = RENDERSUB; - } + job->indepth_scan = 1; - job->select_subtitle_config.force = force; - job->select_subtitle_config.default_track = def; - } - else - { - // if we are getting the subtitles from an external srt file - if ([subtitleDict[keySubTrackType] intValue] == SRTSUB) - { - hb_subtitle_config_t sub_config; - - sub_config.offset = [subtitleDict[keySubTrackSrtOffset] intValue]; - - // we need to strncpy file name and codeset - strncpy(sub_config.src_filename, [subtitleDict[keySubTrackSrtFilePath] UTF8String], 255); - sub_config.src_filename[255] = 0; - strncpy(sub_config.src_codeset, [subtitleDict[keySubTrackSrtCharCode] UTF8String], 39); - sub_config.src_codeset[39] = 0; - - if (!burned && hb_subtitle_can_pass(SRTSUB, job->mux)) + if (subTrack.burnedIn) { - sub_config.dest = PASSTHRUSUB; + job->select_subtitle_config.dest = RENDERSUB; } - else if (hb_subtitle_can_burn(SRTSUB)) + else { - // Only allow one subtitle to be burned into the video - if (one_burned) - continue; - one_burned = YES; - sub_config.dest = RENDERSUB; + job->select_subtitle_config.dest = PASSTHRUSUB; } - sub_config.force = 0; - sub_config.default_track = def; - hb_srt_add( job, &sub_config, [subtitleDict[keySubTrackLanguageIsoCode] UTF8String]); - continue; + job->select_subtitle_config.force = subTrack.forcedOnly; + job->select_subtitle_config.default_track = subTrack.def; } - - // We are setting a source subtitle so access the source subtitle info - hb_subtitle_t * subt = (hb_subtitle_t *) hb_list_item(title->list_subtitle, subtitle); - - if (subt != NULL) + else { - hb_subtitle_config_t sub_config = subt->config; - - if (!burned && hb_subtitle_can_pass(subt->source, job->mux)) + // if we are getting the subtitles from an external srt file + if (subTrack.type == SRTSUB) { - sub_config.dest = PASSTHRUSUB; + hb_subtitle_config_t sub_config; + + sub_config.offset = subTrack.offset; + + // we need to strncpy file name and codeset + strncpy(sub_config.src_filename, subTrack.fileURL.path.fileSystemRepresentation, 255); + sub_config.src_filename[255] = 0; + strncpy(sub_config.src_codeset, subTrack.charCode.UTF8String, 39); + sub_config.src_codeset[39] = 0; + + if (!subTrack.burnedIn && hb_subtitle_can_pass(SRTSUB, job->mux)) + { + sub_config.dest = PASSTHRUSUB; + } + else if (hb_subtitle_can_burn(SRTSUB)) + { + one_burned = YES; + sub_config.dest = RENDERSUB; + } + + sub_config.force = 0; + sub_config.default_track = subTrack.def; + hb_srt_add( job, &sub_config, subTrack.isoLanguage.UTF8String); } - else if (hb_subtitle_can_burn(subt->source)) + else { - // Only allow one subtitle to be burned into the video - if (one_burned) - continue; - one_burned = YES; - sub_config.dest = RENDERSUB; + // We are setting a source subtitle so access the source subtitle info + hb_subtitle_t * subt = (hb_subtitle_t *) hb_list_item(title->list_subtitle, sourceIdx); + + if (subt != NULL) + { + hb_subtitle_config_t sub_config = subt->config; + + if (!subTrack.burnedIn && hb_subtitle_can_pass(subt->source, job->mux)) + { + sub_config.dest = PASSTHRUSUB; + } + else if (hb_subtitle_can_burn(subt->source)) + { + one_burned = YES; + sub_config.dest = RENDERSUB; + } + + sub_config.force = subTrack.forcedOnly; + sub_config.default_track = subTrack.def; + hb_subtitle_add(job, &sub_config, sourceIdx); + } } - - sub_config.force = force; - sub_config.default_track = def; - hb_subtitle_add(job, &sub_config, subtitle); } } } |