This commit is contained in:
Damiano Galassi committed 2013-11-03 17:10:49 +01:00
1 parent 077f0ff2f6
commit 05cf06cfa9
31 files changed
+528 -102

No files matched your search

+1 -1
View File
@@ -7,7 +7,7 @@
//
#import "MP42AACImporter.h"
#import "SBLanguages.h"
#import "MP42Languages.h"
#import "MP42File.h"
@implementation MP42AACImporter
+1 -1
View File
@@ -7,7 +7,7 @@
//
#import "MP42AC3Importer.h"
#import "SBLanguages.h"
#import "MP42Languages.h"
#import "MP42File.h"
#import "MP42Utilities.h"
#import "MP42Fifo.h"
+1 -1
View File
@@ -9,7 +9,7 @@
#if __MAC_OS_X_VERSION_MAX_ALLOWED > 1060
#import "MP42AVFImporter.h"
#import "SBLanguages.h"
#import "MP42Languages.h"
#import "MP42File.h"
#import "MP42Image.h"
+1 -1
View File
@@ -8,7 +8,7 @@
#import "MP42CCImporter.h"
#import "MP42SubUtilities.h"
#import "SBLanguages.h"
#import "MP42Languages.h"
#import "MP42File.h"
#import "RegexKitLite.h"
+5
View File
@@ -12,12 +12,17 @@
@interface MP42ChapterTrack : MP42Track <NSCoding> {
NSMutableArray *chapters;
BOOL _areChaptersEdited;
}
- (instancetype)initWithSourceURL:(NSURL *)URL trackID:(NSInteger)trackID fileHandle:(MP42FileHandle)fileHandle;
+ (instancetype)chapterTrackFromFile:(NSURL *)URL;
- (void)addChapter:(NSString *)title duration:(uint64_t)timestamp;
- (void)addChapter:(NSString *)title image:(MP42Image *)image duration:(uint64_t)timestamp;
- (void)removeChapterAtIndex:(NSUInteger)index;
- (void)removeChaptersAtIndexes:(NSIndexSet *)indexes;
- (void)setTimestamp:(MP42Duration)timestamp forChapter:(MP42TextSample *)chapterSample;
- (void)setTitle:(NSString*)title forChapter:(MP42TextSample *)chapterSample;
+26 -2
View File
@@ -85,6 +85,7 @@
_muxed = NO;
_enabled = NO;
_mediaType = MP42MediaTypeText;
_areChaptersEdited = YES;
chapters = [[NSMutableArray alloc] init];
LoadChaptersFromPath([_sourceURL path], chapters);
@@ -106,6 +107,21 @@
newChapter.timestamp = timestamp;
_isEdited = YES;
_areChaptersEdited = YES;
[chapters addObject:newChapter];
[chapters sortUsingSelector:@selector(compare:)];
[newChapter release];
}
- (void)addChapter:(NSString *)title image:(MP42Image *)image duration:(uint64_t)timestamp {
MP42TextSample *newChapter = [[MP42TextSample alloc] init];
newChapter.title = title;
newChapter.image = image;
newChapter.timestamp = timestamp;
_isEdited = YES;
_areChaptersEdited = YES;
[chapters addObject:newChapter];
[chapters sortUsingSelector:@selector(compare:)];
@@ -113,14 +129,21 @@
}
- (void)removeChapterAtIndex:(NSUInteger)index
{
[self removeChaptersAtIndexes:[NSIndexSet indexSetWithIndex:index]];
}
- (void)removeChaptersAtIndexes:(NSIndexSet *)indexes
{
_isEdited = YES;
[chapters removeObjectAtIndex:index];
_areChaptersEdited = YES;
[chapters removeObjectsAtIndexes:indexes];
}
- (void)setTimestamp:(MP4Duration)timestamp forChapter:(MP42TextSample *)chapterSample
{
_isEdited = YES;
_areChaptersEdited = YES;
[chapterSample setTimestamp:timestamp];
[chapters sortUsingSelector:@selector(compare:)];
}
@@ -128,6 +151,7 @@
- (void)setTitle:(NSString *)title forChapter:(MP42TextSample *)chapterSample
{
_isEdited = YES;
_areChaptersEdited = YES;
[chapterSample setTitle:title];
}
@@ -140,7 +164,7 @@
{
BOOL success = YES;
if (_isEdited) {
if (_isEdited && _areChaptersEdited) {
MP4Chapter_t * fileChapters = 0;
MP4Duration refTrackDuration;
uint32_t chapterCount = 0;
+1 -1
View File
@@ -8,7 +8,7 @@
#import "MP42ClosedCaptionTrack.h"
#import "MP42MediaFormat.h"
#import "SBLanguages.h"
#import "MP42Languages.h"
@implementation MP42ClosedCaptionTrack
+4 -3
View File
@@ -18,9 +18,10 @@
#import "MP42MediaFormat.h"
extern NSString * const MP42Create64BitData;
extern NSString * const MP42Create64BitTime;
extern NSString * const MP42CreateChaptersPreviewTrack;
extern NSString * const MP4264BitData;
extern NSString * const MP4264BitTime;
extern NSString * const MP42GenerateChaptersPreviewTrack;
extern NSString * const MP42CustomChaptersPreviewTrack;
extern NSString * const MP42OrganizeAlternateGroups;
@protocol MP42FileDelegate
+165 -9
View File
@@ -11,7 +11,7 @@
#import "MP42Muxer.h"
#import "MP42SubUtilities.h"
#import "MP42Utilities.h"
#import "SBLanguages.h"
#import "MP42Languages.h"
#import <QTKit/QTKit.h>
@@ -21,9 +21,10 @@
#import "mp4v2.h"
NSString * const MP42Create64BitData = @"MP4264BitData";
NSString * const MP42Create64BitTime = @"MP4264BitTime";
NSString * const MP42CreateChaptersPreviewTrack = @"MP42ChaptersPreview";
NSString * const MP4264BitData = @"MP4264BitData";
NSString * const MP4264BitTime = @"MP4264BitTime";
NSString * const MP42GenerateChaptersPreviewTrack = @"MP42ChaptersPreview";
NSString * const MP42CustomChaptersPreviewTrack = @"MP42CustomChaptersPreview";
NSString * const MP42OrganizeAlternateGroups = @"MP42AlternateGroups";
@interface MP42File () <MP42MuxerDelegate> {
@@ -106,10 +107,11 @@ NSString * const MP42OrganizeAlternateGroups = @"MP42AlternateGroups";
_hasFileRepresentation = YES;
_tracks = [[NSMutableArray alloc] init];
int i, tracksCount = MP4GetNumberOfTracks(_fileHandle, 0, 0);
uint32_t tracksCount = MP4GetNumberOfTracks(_fileHandle, 0, 0);
MP4TrackId chapterId = findChapterTrackId(_fileHandle);
MP4TrackId previewsId = 0; //findChapterPreviewTrackId(_fileHandle);
for (i=0; i< tracksCount; i++) {
for (int i = 0; i< tracksCount; i++) {
id track;
MP4TrackId trackId = MP4FindTrackId(_fileHandle, i, 0, 0);
const char* type = MP4GetTrackType(_fileHandle, trackId);
@@ -140,6 +142,12 @@ NSString * const MP42OrganizeAlternateGroups = @"MP42AlternateGroups";
[self reconnectReferences];
for (MP42Track *track in _tracks)
if ([track.format isEqualToString:MP42VideoFormatJPEG])
previewsId = track.Id;
[self loadPreviewsFromTrackID:previewsId];
_tracksToBeDeleted = [[NSMutableArray alloc] init];
_metadata = [[MP42Metadata alloc] initWithSourceURL:_fileURL fileHandle:_fileHandle];
_importers = [[NSMutableDictionary alloc] init];
@@ -166,6 +174,39 @@ NSString * const MP42OrganizeAlternateGroups = @"MP42AlternateGroups";
}
}
- (void)loadPreviewsFromTrackID:(MP4TrackId) trackID {
MP42Track *track = [self trackWithTrackID:trackID];
if (track) {
MP4SampleId sampleNum = MP4GetTrackNumberOfSamples(_fileHandle, track.Id);
for (MP4SampleId currentSampleNum = 1; currentSampleNum <= sampleNum; currentSampleNum++) {
uint8_t *pBytes = NULL;
uint32_t numBytes = 0;
MP4Duration duration;
MP4Duration renderingOffset;
MP4Timestamp pStartTime;
bool isSyncSample;
if (!MP4ReadSample(_fileHandle,
track.Id,
currentSampleNum,
&pBytes, &numBytes,
&pStartTime, &duration, &renderingOffset,
&isSyncSample)) {
break;
}
NSData *frameData = [[NSData alloc] initWithBytes:pBytes length:numBytes];
MP42Image *frame = [[MP42Image alloc] initWithData:frameData type:MP42_ART_JPEG];
[[self chapters] chapterAtIndex:currentSampleNum - 1].image = frame;
[frame release];
free(pBytes);
}
}
}
- (NSUInteger)duration
{
NSUInteger duration = 0;
@@ -406,10 +447,10 @@ NSString * const MP42OrganizeAlternateGroups = @"MP42AlternateGroups";
uint32_t supportedBrandsCount = 0;
uint32_t flags = 0;
if ([[attributes valueForKey:MP42Create64BitData] boolValue])
if ([[attributes valueForKey:MP4264BitData] boolValue])
flags += 0x01;
if ([[attributes valueForKey:MP42Create64BitTime] boolValue])
if ([[attributes valueForKey:MP4264BitTime] boolValue])
flags += 0x02;
if ([fileExtension isEqualToString:MP42FileTypeM4V]) {
@@ -545,8 +586,11 @@ NSString * const MP42OrganizeAlternateGroups = @"MP42AlternateGroups";
}
// Generate previews images for chapters
if ([[attributes valueForKey:MP42CreateChaptersPreviewTrack] boolValue] && [_tracks count])
if ([[attributes valueForKey:MP42GenerateChaptersPreviewTrack] boolValue] && [_tracks count]) {
[self createChaptersPreview];
} else if ([[attributes valueForKey:MP42CustomChaptersPreviewTrack] boolValue] && [_tracks count]) {
[self customChaptersPreview];
}
if ([_delegate respondsToSelector:@selector(endSave:)])
[_delegate performSelector:@selector(endSave:) withObject:self];
@@ -719,6 +763,118 @@ NSString * const MP42OrganizeAlternateGroups = @"MP42AlternateGroups";
return [images autorelease];
}
- (BOOL)muxChaptersPreviewTrackId:(MP4TrackId)jpegTrack withChapterTrack:(MP42ChapterTrack *)chapterTrack andRefTrack:(MP42VideoTrack *)videoTrack {
// Reopen the mp4v2 fileHandle
_fileHandle = MP4Modify([[_fileURL path] UTF8String], 0);
if (_fileHandle == MP4_INVALID_FILE_HANDLE)
return NO;
CGFloat maxWidth = 640;
NSSize imageSize = NSMakeSize(videoTrack.trackWidth, videoTrack.trackHeight);
if (imageSize.width > maxWidth) {
imageSize.height = maxWidth / imageSize.width * imageSize.height;
imageSize.width = maxWidth;
}
NSRect rect = NSMakeRect(0.0, 0.0, imageSize.width, imageSize.height);
if (jpegTrack ) {
MP4DeleteTrack(_fileHandle, jpegTrack);
}
jpegTrack = MP4AddJpegVideoTrack(_fileHandle, MP4GetTrackTimeScale(_fileHandle, [chapterTrack Id]),
MP4_INVALID_DURATION, imageSize.width, imageSize.height);
MP4SetTrackLanguage(_fileHandle, jpegTrack, lang_for_english([videoTrack.language UTF8String])->iso639_2);
MP4SetTrackIntegerProperty(_fileHandle, jpegTrack, "tkhd.layer", 1);
MP4SetTrackDisabled(_fileHandle, jpegTrack);
NSUInteger idx = 0;
MP4Duration duration = 0;
for (MP42TextSample *chapterT in [chapterTrack chapters]) {
duration = MP4GetSampleDuration(_fileHandle, chapterTrack.Id, idx + 1);
NSData *imageData = chapterT.image.data;
if (!imageData) {
// Scale the image.
NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
pixelsWide:rect.size.width
pixelsHigh:rect.size.height
bitsPerSample:8
samplesPerPixel:4
hasAlpha:YES
isPlanar:NO
colorSpaceName:NSCalibratedRGBColorSpace
bitmapFormat:NSAlphaFirstBitmapFormat
bytesPerRow:0
bitsPerPixel:32];
[NSGraphicsContext saveGraphicsState];
[NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithBitmapImageRep:bitmap]];
[[NSColor blackColor] set];
NSRectFill(rect);
if (chapterT.image.image)
[[chapterT image].image drawInRect:rect fromRect:NSZeroRect operation:NSCompositeCopy fraction:1.0];
[NSGraphicsContext restoreGraphicsState];
imageData = [bitmap representationUsingType:NSJPEGFileType properties:nil];
[bitmap release];
}
MP4WriteSample(_fileHandle,
jpegTrack,
[imageData bytes],
[imageData length],
duration,
0,
true);
idx++;
}
MP4RemoveAllTrackReferences(_fileHandle, "tref.chap", videoTrack.Id);
MP4AddTrackReference(_fileHandle, "tref.chap", chapterTrack.Id, videoTrack.Id);
MP4AddTrackReference(_fileHandle, "tref.chap", jpegTrack, videoTrack.Id);
copyTrackEditLists(_fileHandle, chapterTrack.Id, jpegTrack);
MP4Close(_fileHandle, 0);
return YES;
}
- (BOOL)customChaptersPreview {
NSInteger decodable = 1;
MP42ChapterTrack *chapterTrack = nil;
MP42VideoTrack *refTrack = nil;
MP4TrackId jpegTrack = 0;
for (MP42Track *track in _tracks) {
if ([track isMemberOfClass:[MP42ChapterTrack class]] && !chapterTrack)
chapterTrack = (MP42ChapterTrack *)track;
if ([track isMemberOfClass:[MP42VideoTrack class]] &&
![track.format isEqualToString:MP42VideoFormatJPEG]
&& !refTrack)
refTrack = (MP42VideoTrack *)track;
if ([track.format isEqualToString:MP42VideoFormatJPEG] && !jpegTrack)
jpegTrack = track.Id;
if ([track.format isEqualToString:MP42VideoFormatH264])
if ((((MP42VideoTrack *)track).origProfile) == 110)
decodable = 0;
}
if (!refTrack)
refTrack = [_tracks objectAtIndex:0];
[self muxChaptersPreviewTrackId:jpegTrack withChapterTrack:chapterTrack andRefTrack:refTrack];
return YES;
}
- (BOOL)createChaptersPreview {
NSInteger decodable = 1;
MP42ChapterTrack *chapterTrack = nil;
+3 -3
View File
@@ -39,8 +39,8 @@
- (instancetype)initWithURL:(NSURL *)fileURL error:(NSError **)outError;
- (BOOL)containsTrack:(MP42Track*)track;
- (MP42Track *)inputTrackWithTrackID:(MP4TrackId)trackId;
- (BOOL)containsTrack:(MP42Track *)track;
- (MP42Track *)inputTrackWithTrackID:(MP42TrackId)trackId;
- (NSUInteger)timescaleForTrack:(MP42Track *)track;
- (NSSize)sizeForTrack:(MP42Track *)track;
@@ -59,7 +59,7 @@
- (BOOL)done;
- (void)setDone:(BOOL)status;
- (BOOL)cleanUp:(MP4FileHandle) fileHandle;
- (BOOL)cleanUp:(MP42FileHandle) fileHandle;
@property(readwrite, retain) MP42Metadata *metadata;
@property(readonly) NSMutableArray *tracks;
+1 -1
View File
@@ -7,7 +7,7 @@
//
#import "MP42H264Importer.h"
#import "SBLanguages.h"
#import "MP42Languages.h"
#import "MP42File.h"
#include <sys/stat.h>
+4 -4
View File
@@ -1,5 +1,5 @@
//
// SBLanguages.h
// MP42Languages.h
// Subler
//
// Created by Damiano Galassi on 13/08/12.
@@ -28,7 +28,7 @@ extern "C" {
/* find language associated with ISO-639-2 language code */
iso639_lang_t * lang_for_code2( const char *code2 );
/* find language associated with qt language code */
iso639_lang_t * lang_for_qtcode( short code );
@@ -40,9 +40,9 @@ extern "C" {
}
#endif
@interface SBLanguages : NSObject
@interface MP42Languages : NSObject
+ (SBLanguages *)defaultManager;
+ (MP42Languages *)defaultManager;
- (NSArray *)languages;
+ (NSString *)iso6391CodeFor:(NSString *)aLanguage;
+5 -5
View File
@@ -1,12 +1,12 @@
//
// SBLanguages.m
// MP42Languages.m
// Subler
//
// Created by Damiano Galassi on 13/08/12.
//
//
#import "SBLanguages.h"
#import "MP42Languages.h"
#include <string.h>
#include <ctype.h>
@@ -600,12 +600,12 @@ iso639_lang_t * lang_for_english( const char * english )
return (iso639_lang_t*) languages;
}
@implementation SBLanguages
@implementation MP42Languages
+ (SBLanguages *)defaultManager
+ (MP42Languages *)defaultManager
{
static dispatch_once_t pred;
static SBLanguages *sharedLanguagesManager = nil;
static MP42Languages *sharedLanguagesManager = nil;
dispatch_once(&pred, ^{ sharedLanguagesManager = [[self alloc] init]; });
return sharedLanguagesManager;
+5 -5
View File
@@ -11,7 +11,7 @@
#import "MP42XMLReader.h"
#import "MP42Image.h"
#import "RegexKitLite.h"
#import "SBRatings.h"
#import "MP42Ratings.h"
typedef struct mediaKind_t
{
@@ -939,7 +939,7 @@ static const genreType_t genreType_strings[] = {
else
ratingiTunesCode = nil;
[tagsDict setObject:[NSNumber numberWithUnsignedInteger:[[SBRatings defaultManager] ratingIndexForiTunesCode:ratingiTunesCode]] forKey:@"Rating"];
[tagsDict setObject:[NSNumber numberWithUnsignedInteger:[[MP42Ratings defaultManager] ratingIndexForiTunesCode:ratingiTunesCode]] forKey:@"Rating"];
if ([ratingItems count] >= 4)
[tagsDict setObject:[ratingItems objectAtIndex:3] forKey:@"Rating Annotation"];
}
@@ -1280,12 +1280,12 @@ static const genreType_t genreType_strings[] = {
MP4ItmfData* data = &newItem->dataList.elements[0];
if (![[tagsDict valueForKey:@"Rating"] isKindOfClass:[NSNumber class]] ||
[[tagsDict valueForKey:@"Rating"] unsignedIntegerValue] == [[SBRatings defaultManager] unknownIndex]) {
[[tagsDict valueForKey:@"Rating"] unsignedIntegerValue] == [[MP42Ratings defaultManager] unknownIndex]) {
if (!ratingiTunesCode) {
ratingiTunesCode = [[[SBRatings defaultManager] iTunesCodes] objectAtIndex:[[SBRatings defaultManager] unknownIndex]];
ratingiTunesCode = [[[MP42Ratings defaultManager] iTunesCodes] objectAtIndex:[[MP42Ratings defaultManager] unknownIndex]];
}
} else {
ratingiTunesCode = [[[SBRatings defaultManager] iTunesCodes] objectAtIndex:[[tagsDict valueForKey:@"Rating"] unsignedIntegerValue]];
ratingiTunesCode = [[[MP42Ratings defaultManager] iTunesCodes] objectAtIndex:[[tagsDict valueForKey:@"Rating"] unsignedIntegerValue]];
}
NSString *ratingString = ratingiTunesCode;
if ([[tagsDict valueForKey:@"Rating Annotation"] length] && [ratingString length]) {
+1 -1
View File
@@ -10,7 +10,7 @@
#import "MP42File.h"
#import "MP42SubUtilities.h"
#import "SBLanguages.h"
#import "MP42Languages.h"
#import "MatroskaParser.h"
#import "MatroskaFile.h"
+1 -1
View File
@@ -7,7 +7,7 @@
//
#import "MP42Mp4Importer.h"
#import "SBLanguages.h"
#import "MP42Languages.h"
#import "MP42Sample.h"
@interface MP4DemuxkHelper : NSObject {
+1 -1
View File
@@ -7,7 +7,7 @@
//
#import "MP42OCRWrapper.h"
#import "SBLanguages.h"
#import "MP42Languages.h"
// Tesseract OCR
#include "baseapi.h"
+1 -1
View File
@@ -12,7 +12,7 @@
#import "MP42Image.h"
#import <AudioToolbox/AudioToolbox.h>
#import <QuickTime/QuickTime.h>
#import "SBLanguages.h"
#import "MP42Languages.h"
#import "QTKitDecrap.h"
#include "avcodec.h"
+3 -3
View File
@@ -1,5 +1,5 @@
//
// SBRatings.h
// MP42Ratings.h
// Subler
//
// Created by Douglas Stebila on 2013-06-02.
@@ -8,7 +8,7 @@
#import <Foundation/Foundation.h>
@interface SBRatings : NSObject {
@interface MP42Ratings : NSObject {
NSMutableArray *ratingsDictionary;
NSMutableArray *ratings;
NSMutableArray *iTunesCodes;
@@ -17,7 +17,7 @@
@property(readonly) NSMutableArray *ratings;
@property(readonly) NSMutableArray *iTunesCodes;
+ (SBRatings *) defaultManager;
+ (MP42Ratings *) defaultManager;
- (void)updateRatingsCountry;
- (NSArray *) ratingsCountries;
+6 -6
View File
@@ -1,30 +1,30 @@
//
// SBRatings.m
// MP42Ratings.m
// Subler
//
// Created by Douglas Stebila on 2013-06-02.
//
//
#import "SBRatings.h"
#import "MP42Ratings.h"
#import "JSONKit.h"
@implementation SBRatings
@implementation MP42Ratings
@synthesize ratings;
@synthesize iTunesCodes;
+ (SBRatings *) defaultManager {
+ (MP42Ratings *) defaultManager {
static dispatch_once_t sharedRatingsPred;
static SBRatings *sharedRatingsManager = nil;
static MP42Ratings *sharedRatingsManager = nil;
dispatch_once(&sharedRatingsPred, ^{ sharedRatingsManager = [[self alloc] init]; });
return sharedRatingsManager;
}
- (id) init {
if (self = [super init]) {
NSString* ratingsJSON = [[NSBundle mainBundle] pathForResource:@"Ratings" ofType:@"json"];
NSString* ratingsJSON = [[NSBundle bundleForClass:[MP42Ratings class]] pathForResource:@"Ratings" ofType:@"json"];
if (!ratingsJSON) {
[self release];
return nil;
+1 -1
View File
@@ -10,7 +10,7 @@
#import "MP42File.h"
#import "MP42SubUtilities.h"
#import "SBLanguages.h"
#import "MP42Languages.h"
@implementation MP42SrtImporter
+1 -1
View File
@@ -10,7 +10,7 @@
#import "MP42Utilities.h"
#import "MP42MediaFormat.h"
#import "MP42HtmlParser.h"
#import "SBLanguages.h"
#import "MP42Languages.h"
@implementation MP42SubtitleTrack
+3
View File
@@ -8,13 +8,16 @@
#import <Foundation/Foundation.h>
#import "MP42MediaFormat.h"
#import "MP42Image.h"
@interface MP42TextSample : NSObject <NSCoding> {
MP42Duration timestamp;
MP42Image *image;
NSString *title;
}
@property(readwrite, retain) NSString *title;
@property(readwrite, retain) MP42Image *image;
@property(readwrite) MP42Duration timestamp;
@end
+2
View File
@@ -24,12 +24,14 @@
-(void) dealloc
{
[image release];
[title release];
[super dealloc];
}
@synthesize timestamp;
@synthesize title;
@synthesize image;
- (void)encodeWithCoder:(NSCoder *)coder
{
+1 -1
View File
@@ -11,7 +11,7 @@
#import "MP42FileImporter.h"
#import "MP42Sample.h"
#import "MP42Fifo.h"
#import "SBLanguages.h"
#import "MP42Languages.h"
#import "MP42Track_Muxer.h"
+2
View File
@@ -36,6 +36,8 @@ uint64_t getTrackSize(MP4FileHandle fileHandle, MP4TrackId trackId);
int isHdVideo(uint64_t width, uint64_t height);
MP4TrackId findChapterTrackId(MP4FileHandle fileHandle);
MP4TrackId findChapterPreviewTrackId(MP4FileHandle fileHandle);
void removeAllChapterTrackReferences(MP4FileHandle fileHandle);
MP4TrackId findFirstVideoTrack(MP4FileHandle fileHandle);
+21 -1
View File
@@ -13,7 +13,7 @@
#include <zlib.h>
#include <bzlib.h>
#import "SBLanguages.h"
#import "MP42Languages.h"
#import "MP42MediaFormat.h"
#include "intreadwrite.h"
#include "avcodec.h"
@@ -150,6 +150,26 @@ MP4TrackId findChapterTrackId(MP4FileHandle fileHandle)
return (MP4TrackId) trackRef;
}
}
return 0;
}
MP4TrackId findChapterPreviewTrackId(MP4FileHandle fileHandle)
{
MP4TrackId trackId = 0;
uint64_t trackRef = 0;
unsigned int i;
for (i = 0; i< MP4GetNumberOfTracks( fileHandle, 0, 0); i++ ) {
trackId = MP4FindTrackId(fileHandle, i, 0, 0);
if (MP4HaveTrackAtom(fileHandle, trackId, "tref.chap")) {
uint64_t entryCount = 0;
MP4GetTrackIntegerProperty(fileHandle, trackId, "tref.chap.entryCount", &entryCount);
if (entryCount > 1 && MP4GetTrackIntegerProperty(fileHandle, trackId, "tref.chap.entries.trackId[1]", &trackRef))
if (trackRef > 0)
return (MP4TrackId) trackRef;
}
}
return 0;
}
+1 -1
View File
@@ -8,7 +8,7 @@
#import "MP42VobSubImporter.h"
#import "MP42SubUtilities.h"
#import "SBLanguages.h"
#import "MP42Languages.h"
#import "MP42File.h"
+209
View File
@@ -0,0 +1,209 @@
[
{
"country" : "Unknown",
"ratings" : [
{ "media" : "movie & TV", "prefix" : "mpaa", "itunes-code" : "Unrated", "itunes-value" : "???", "description" : "Unknown" }
]
},
{
"country" : "USA",
"ratings" : [
{ "media" : "movie", "prefix" : "mpaa", "itunes-code" : "NR", "itunes-value" : "000", "description" : "NR" },
{ "media" : "movie", "prefix" : "mpaa", "itunes-code" : "G", "itunes-value" : "100", "description" : "G" },
{ "media" : "movie", "prefix" : "mpaa", "itunes-code" : "PG", "itunes-value" : "200", "description" : "PG" },
{ "media" : "movie", "prefix" : "mpaa", "itunes-code" : "PG-13", "itunes-value" : "300", "description" : "PG-13" },
{ "media" : "movie", "prefix" : "mpaa", "itunes-code" : "R", "itunes-value" : "400", "description" : "R" },
{ "media" : "movie", "prefix" : "mpaa", "itunes-code" : "NC-17", "itunes-value" : "500", "description" : "NC-17" },
{ "media" : "movie", "prefix" : "mpaa", "itunes-code" : "Unrated", "itunes-value" : "???", "description" : "Unrated" },
{ "media" : "TV", "prefix" : "us-tv", "itunes-code" : "TV-Y", "itunes-value" : "100", "description" : "TV-Y" },
{ "media" : "TV", "prefix" : "us-tv", "itunes-code" : "TV-Y7", "itunes-value" : "200", "description" : "TV-Y7" },
{ "media" : "TV", "prefix" : "us-tv", "itunes-code" : "TV-G", "itunes-value" : "300", "description" : "TV-G" },
{ "media" : "TV", "prefix" : "us-tv", "itunes-code" : "TV-PG", "itunes-value" : "400", "description" : "TV-PG" },
{ "media" : "TV", "prefix" : "us-tv", "itunes-code" : "TV-14", "itunes-value" : "500", "description" : "TV-14" },
{ "media" : "TV", "prefix" : "us-tv", "itunes-code" : "TV-MA", "itunes-value" : "600", "description" : "TV-MA" },
{ "media" : "TV", "prefix" : "us-tv", "itunes-code" : "Unrated", "itunes-value" : "???", "description" : "Unrated" }
]
},
{
"country" : "Australia",
"ratings" : [
{ "media" : "movie", "prefix" : "au-movie", "itunes-code" : "G", "itunes-value" : "100", "description" : "G" },
{ "media" : "movie", "prefix" : "au-movie", "itunes-code" : "PG", "itunes-value" : "200", "description" : "PG" },
{ "media" : "movie", "prefix" : "au-movie", "itunes-code" : "M", "itunes-value" : "350", "description" : "M" },
{ "media" : "movie", "prefix" : "au-movie", "itunes-code" : "MA15+", "itunes-value" : "375", "description" : "MA15+" },
{ "media" : "movie", "prefix" : "au-movie", "itunes-code" : "R18+", "itunes-value" : "400", "description" : "R18+" },
{ "media" : "movie", "prefix" : "au-movie", "itunes-code" : "Not Rated","itunes-value" : "???", "description" : "Not Rated" },
{ "media" : "TV", "prefix" : "au-tv", "itunes-code" : "P", "itunes-value" : "100", "description" : "P" },
{ "media" : "TV", "prefix" : "au-tv", "itunes-code" : "C", "itunes-value" : "200", "description" : "C" },
{ "media" : "TV", "prefix" : "au-tv", "itunes-code" : "G", "itunes-value" : "300", "description" : "G" },
{ "media" : "TV", "prefix" : "au-tv", "itunes-code" : "PG", "itunes-value" : "400", "description" : "PG" },
{ "media" : "TV", "prefix" : "au-tv", "itunes-code" : "M", "itunes-value" : "500", "description" : "M" },
{ "media" : "TV", "prefix" : "au-tv", "itunes-code" : "MA15+", "itunes-value" : "550", "description" : "MA15+" },
{ "media" : "TV", "prefix" : "au-tv", "itunes-code" : "AV15+", "itunes-value" : "575", "description" : "AV15+" },
{ "media" : "TV", "prefix" : "au-tv", "itunes-code" : "R18+", "itunes-value" : "160", "description" : "R18+" }
]
},
{
"country" : "Brasil",
"ratings" : [
{ "media" : "movie", "prefix" : "br-movie", "itunes-code" : "L", "itunes-value" : "000", "description" : "L" },
{ "media" : "movie", "prefix" : "br-movie", "itunes-code" : "12", "itunes-value" : "100", "description" : "12" },
{ "media" : "movie", "prefix" : "br-movie", "itunes-code" : "14", "itunes-value" : "300", "description" : "14" },
{ "media" : "movie", "prefix" : "br-movie", "itunes-code" : "16", "itunes-value" : "350", "description" : "16" },
{ "media" : "movie", "prefix" : "br-movie", "itunes-code" : "18", "itunes-value" : "400", "description" : "18" }
]
},
{
"country" : "Canada",
"ratings" : [
{ "media" : "movie", "prefix" : "ca-movie", "itunes-code" : "G", "itunes-value" : "100", "description" : "G" },
{ "media" : "movie", "prefix" : "ca-movie", "itunes-code" : "PG", "itunes-value" : "200", "description" : "PG" },
{ "media" : "movie", "prefix" : "ca-movie", "itunes-code" : "14A", "itunes-value" : "300", "description" : "14A" },
{ "media" : "movie", "prefix" : "ca-movie", "itunes-code" : "18A", "itunes-value" : "350", "description" : "18A" },
{ "media" : "movie", "prefix" : "ca-movie", "itunes-code" : "R", "itunes-value" : "400", "description" : "R" },
{ "media" : "movie", "prefix" : "ca-movie", "itunes-code" : "A", "itunes-value" : "500", "description" : "A" },
{ "media" : "movie", "prefix" : "ca-movie", "itunes-code" : "Unrated", "itunes-value" : "???", "description" : "Unrated" },
{ "media" : "movie", "prefix" : "ca-movie", "itunes-code" : "Unrated", "itunes-value" : "???", "description" : "Not Rated" },
{ "media" : "TV", "prefix" : "ca-tv", "itunes-code" : "E", "itunes-value" : "000", "description" : "E" },
{ "media" : "TV", "prefix" : "ca-tv", "itunes-code" : "C", "itunes-value" : "050", "description" : "C" },
{ "media" : "TV", "prefix" : "ca-tv", "itunes-code" : "C8", "itunes-value" : "075", "description" : "C8" },
{ "media" : "TV", "prefix" : "ca-tv", "itunes-code" : "G", "itunes-value" : "100", "description" : "G" },
{ "media" : "TV", "prefix" : "ca-tv", "itunes-code" : "PG", "itunes-value" : "200", "description" : "PG" },
{ "media" : "TV", "prefix" : "ca-tv", "itunes-code" : "14+", "itunes-value" : "300", "description" : "14+" },
{ "media" : "TV", "prefix" : "ca-tv", "itunes-code" : "18+", "itunes-value" : "350", "description" : "18+" },
{ "media" : "TV", "prefix" : "ca-tv", "itunes-code" : "21+", "itunes-value" : "500", "description" : "21+" }
]
},
{
"country" : "Deutschland",
"ratings" : [
{ "media" : "movie", "prefix" : "de-movie", "itunes-code" : "Ab 0 Jahren", "itunes-value" : "075", "description" : "Ab 0 Jahren" },
{ "media" : "movie", "prefix" : "de-movie", "itunes-code" : "Ab 6 Jahren", "itunes-value" : "100", "description" : "Ab 6 Jahren" },
{ "media" : "movie", "prefix" : "de-movie", "itunes-code" : "Ab 12 Jahren", "itunes-value" : "200", "description" : "Ab 12 Jahren" },
{ "media" : "movie", "prefix" : "de-movie", "itunes-code" : "Ab 16 Jahren", "itunes-value" : "500", "description" : "Ab 16 Jahren" },
{ "media" : "movie", "prefix" : "de-movie", "itunes-code" : "Ab 18 Jahren", "itunes-value" : "600", "description" : "Ab 18 Jahren" },
{ "media" : "TV", "prefix" : "de-tv", "itunes-code" : "Ab 0 Jahren", "itunes-value" : "075", "description" : "Ab 0 Jahren" },
{ "media" : "TV", "prefix" : "de-tv", "itunes-code" : "Ab 6 Jahren", "itunes-value" : "100", "description" : "Ab 6 Jahren" },
{ "media" : "TV", "prefix" : "de-tv", "itunes-code" : "Ab 12 Jahren", "itunes-value" : "200", "description" : "Ab 12 Jahren" },
{ "media" : "TV", "prefix" : "de-tv", "itunes-code" : "Ab 16 Jahren", "itunes-value" : "500", "description" : "Ab 16 Jahren" },
{ "media" : "TV", "prefix" : "de-tv", "itunes-code" : "Ab 18 Jahren", "itunes-value" : "600", "description" : "Ab 18 Jahren" }
]
},
{
"country" : "France",
"ratings" : [
{ "media" : "movie & TV", "prefix" : "fr-movie", "itunes-code" : "Tout public", "itunes-value" : "000", "description" : "Tout public" },
{ "media" : "movie & TV", "prefix" : "fr-movie", "itunes-code" : "-10", "itunes-value" : "100", "description" : "-10" },
{ "media" : "movie & TV", "prefix" : "fr-movie", "itunes-code" : "-12", "itunes-value" : "300", "description" : "-12" },
{ "media" : "movie & TV", "prefix" : "fr-movie", "itunes-code" : "-16", "itunes-value" : "375", "description" : "-16" },
{ "media" : "movie & TV", "prefix" : "fr-movie", "itunes-code" : "-18", "itunes-value" : "400", "description" : "-18" },
{ "media" : "movie & TV", "prefix" : "fr-movie", "itunes-code" : "Unrated", "itunes-value" : "???", "description" : "Unrated" }
]
},
{
"country" : "Italia",
"ratings" : [
{ "media" : "movie", "prefix" : "it-movie", "itunes-code" : "T", "itunes-value" : "100", "description" : "T" },
{ "media" : "movie", "prefix" : "it-movie", "itunes-code" : "VPA", "itunes-value" : "125", "description" : "VPA" },
{ "media" : "movie", "prefix" : "it-movie", "itunes-code" : "VM10", "itunes-value" : "150", "description" : "VM10" },
{ "media" : "movie", "prefix" : "it-movie", "itunes-code" : "VM12", "itunes-value" : "200", "description" : "VM12" },
{ "media" : "movie", "prefix" : "it-movie", "itunes-code" : "VM14", "itunes-value" : "325", "description" : "VM14" },
{ "media" : "movie", "prefix" : "it-movie", "itunes-code" : "VM18", "itunes-value" : "400", "description" : "VM18" }
]
},
{
"country" : "日本",
"ratings" : [
{ "media" : "movie", "prefix" : "jp-movie", "itunes-code" : "G", "itunes-value" : "100", "description" : "G" },
{ "media" : "movie", "prefix" : "jp-movie", "itunes-code" : "PG12", "itunes-value" : "200", "description" : "PG12" },
{ "media" : "movie", "prefix" : "jp-movie", "itunes-code" : "R15+", "itunes-value" : "300", "description" : "R15+" },
{ "media" : "movie", "prefix" : "jp-movie", "itunes-code" : "R18+", "itunes-value" : "400", "description" : "R18+" },
{ "media" : "movie", "prefix" : "jp-movie", "itunes-code" : "Unrated", "itunes-value" : "???", "description" : "未審査" }
]
},
{
"country" : "Nederland",
"ratings" : [
{ "media" : "movie & TV", "prefix" : "nl-movie", "itunes-code" : "AL/G", "itunes-value" : "000", "description" : "AL/G" },
{ "media" : "movie & TV", "prefix" : "nl-movie", "itunes-code" : "6", "itunes-value" : "100", "description" : "6" },
{ "media" : "movie & TV", "prefix" : "nl-movie", "itunes-code" : "9", "itunes-value" : "200", "description" : "9" },
{ "media" : "movie & TV", "prefix" : "nl-movie", "itunes-code" : "12", "itunes-value" : "300", "description" : "12" },
{ "media" : "movie & TV", "prefix" : "nl-movie", "itunes-code" : "16", "itunes-value" : "500", "description" : "16" },
{ "media" : "movie & TV", "prefix" : "nl-movie", "itunes-code" : "18", "itunes-value" : "600", "description" : "18" }
]
},
{
"country" : "New Zealand",
"ratings" : [
{ "media" : "movie & TV", "prefix" : "nz-movie", "itunes-code" : "G", "itunes-value" : "100", "description" : "G" },
{ "media" : "movie & TV", "prefix" : "nz-movie", "itunes-code" : "PG", "itunes-value" : "200", "description" : "PG" },
{ "media" : "movie & TV", "prefix" : "nz-movie", "itunes-code" : "M", "itunes-value" : "300", "description" : "M" },
{ "media" : "movie & TV", "prefix" : "nz-movie", "itunes-code" : "R13", "itunes-value" : "325", "description" : "R13" },
{ "media" : "movie & TV", "prefix" : "nz-movie", "itunes-code" : "RP13", "itunes-value" : "325", "description" : "RP13" },
{ "media" : "movie & TV", "prefix" : "nz-movie", "itunes-code" : "R15", "itunes-value" : "350", "description" : "R15" },
{ "media" : "movie & TV", "prefix" : "nz-movie", "itunes-code" : "R16", "itunes-value" : "375", "description" : "R16" },
{ "media" : "movie & TV", "prefix" : "nz-movie", "itunes-code" : "RP16", "itunes-value" : "375", "description" : "RP16" },
{ "media" : "movie & TV", "prefix" : "nz-movie", "itunes-code" : "R18", "itunes-value" : "400", "description" : "R18" },
{ "media" : "movie & TV", "prefix" : "nz-movie", "itunes-code" : "R", "itunes-value" : "500", "description" : "R" },
{ "media" : "movie & TV", "prefix" : "nz-movie", "itunes-code" : "U", "itunes-value" : "900", "description" : "U" },
{ "media" : "movie & TV", "prefix" : "nz-movie", "itunes-code" : "Not Rated","itunes-value" : "???", "description" : "Not Rated" }
]
},
{
"country" : "Sverige",
"ratings" : [
{ "media" : "movie & TV", "prefix" : "se-movie", "itunes-code" : "A", "itunes-value" : "000", "description" : "Barntillåten" },
{ "media" : "movie & TV", "prefix" : "se-movie", "itunes-code" : "7", "itunes-value" : "125", "description" : "Från 7 år" },
{ "media" : "movie & TV", "prefix" : "se-movie", "itunes-code" : "11", "itunes-value" : "225", "description" : "Från 11 år" },
{ "media" : "movie & TV", "prefix" : "se-movie", "itunes-code" : "15", "itunes-value" : "400", "description" : "Från 15 år" },
{ "media" : "movie & TV", "prefix" : "se-movie", "itunes-code" : "Unrated", "itunes-value" : "???", "description" : "Ocensurerad" },
{ "media" : "movie & TV", "prefix" : "se-movie", "itunes-code" : "Unrated", "itunes-value" : "???", "description" : "Inte klassificerad" }
]
},
{
"country" : "Schweiz",
"ratings" : [
{ "media" : "movie", "prefix" : "ch-movie", "itunes-code" : "0", "itunes-value" : "050", "description" : "0" },
{ "media" : "movie", "prefix" : "ch-movie", "itunes-code" : "6", "itunes-value" : "075", "description" : "6" },
{ "media" : "movie", "prefix" : "ch-movie", "itunes-code" : "7", "itunes-value" : "125", "description" : "7" },
{ "media" : "movie", "prefix" : "ch-movie", "itunes-code" : "10", "itunes-value" : "150", "description" : "10" },
{ "media" : "movie", "prefix" : "ch-movie", "itunes-code" : "12", "itunes-value" : "200", "description" : "12" },
{ "media" : "movie", "prefix" : "ch-movie", "itunes-code" : "14", "itunes-value" : "325", "description" : "14" },
{ "media" : "movie", "prefix" : "ch-movie", "itunes-code" : "16", "itunes-value" : "375", "description" : "16" },
{ "media" : "movie", "prefix" : "ch-movie", "itunes-code" : "18", "itunes-value" : "400", "description" : "18" },
{ "media" : "movie", "prefix" : "ch-movie", "itunes-code" : "Unrated", "itunes-value" : "???", "description" : "keine alterseinstufung" }
]
},
{
"country" : "Suisse",
"ratings" : [
{ "media" : "movie", "prefix" : "ch-movie", "itunes-code" : "0", "itunes-value" : "050", "description" : "0" },
{ "media" : "movie", "prefix" : "ch-movie", "itunes-code" : "6", "itunes-value" : "075", "description" : "6" },
{ "media" : "movie", "prefix" : "ch-movie", "itunes-code" : "7", "itunes-value" : "125", "description" : "7" },
{ "media" : "movie", "prefix" : "ch-movie", "itunes-code" : "10", "itunes-value" : "150", "description" : "10" },
{ "media" : "movie", "prefix" : "ch-movie", "itunes-code" : "12", "itunes-value" : "200", "description" : "12" },
{ "media" : "movie", "prefix" : "ch-movie", "itunes-code" : "14", "itunes-value" : "325", "description" : "14" },
{ "media" : "movie", "prefix" : "ch-movie", "itunes-code" : "16", "itunes-value" : "375", "description" : "16" },
{ "media" : "movie", "prefix" : "ch-movie", "itunes-code" : "18", "itunes-value" : "400", "description" : "18" },
{ "media" : "movie", "prefix" : "ch-movie", "itunes-code" : "Unrated", "itunes-value" : "???", "description" : "keine alterseinstufung" }
]
},
{
"country" : "UK",
"ratings" : [
{ "media" : "movie & TV", "prefix" : "uk-movie", "itunes-code" : "NR", "itunes-value" : "000", "description" : "Not Rated" },
{ "media" : "movie & TV", "prefix" : "uk-movie", "itunes-code" : "U", "itunes-value" : "100", "description" : "U" },
{ "media" : "movie & TV", "prefix" : "uk-movie", "itunes-code" : "Uc", "itunes-value" : "150", "description" : "Uc" },
{ "media" : "movie & TV", "prefix" : "uk-movie", "itunes-code" : "PG", "itunes-value" : "200", "description" : "PG" },
{ "media" : "movie & TV", "prefix" : "uk-movie", "itunes-code" : "12", "itunes-value" : "300", "description" : "12" },
{ "media" : "movie & TV", "prefix" : "uk-movie", "itunes-code" : "12A", "itunes-value" : "325", "description" : "12A" },
{ "media" : "movie & TV", "prefix" : "uk-movie", "itunes-code" : "15", "itunes-value" : "350", "description" : "15" },
{ "media" : "movie & TV", "prefix" : "uk-movie", "itunes-code" : "18", "itunes-value" : "400", "description" : "18" },
{ "media" : "TV", "prefix" : "uk-tv", "itunes-code" : "Caution", "itunes-value" : "500", "description" : "Caution" },
{ "media" : "movie & TV", "prefix" : "uk-movie", "itunes-code" : "R18", "itunes-value" : "600", "description" : "R18" },
{ "media" : "movie & TV", "prefix" : "uk-movie", "itunes-code" : "E", "itunes-value" : "0", "description" : "Exempt" },
{ "media" : "movie & TV", "prefix" : "uk-movie", "itunes-code" : "Unrated", "itunes-value" : "???", "description" : "Unrated" },
{ "media" : "movie & TV", "prefix" : "uk-movie", "itunes-code" : "Unrated", "itunes-value" : "???", "description" : "TBC" }
]
}
]