Moved some functions to the public MP42Utilities.

This commit is contained in:
Damiano Galassi committed 2013-11-16 14:01:14 +01:00
1 parent 08e32323ce
commit 7611af9ce4
5 files changed
+92 -97

No files matched your search

-83
View File
@@ -41,42 +41,6 @@ NSString* SRTStringFromTime( long long time, long timeScale , const char separat
return SRT_string;
}
NSString* SMPTEStringFromTime( long long time, long timeScale )
{
NSString *SMPTE_string;
int hour, minute, second, frame;
long long result;
result = time / timeScale; // second
frame = (time % timeScale) / 10;
second = result % 60;
result = result / 60; // minute
minute = result % 60;
result = result / 60; // hour
hour = result % 24;
SMPTE_string = [NSString stringWithFormat:@"%d:%02d:%02d:%02d", hour, minute, second, frame]; // h:mm:ss:ff
return SMPTE_string;
}
MP4Duration TimeFromSMPTEString( NSString* SMPTE_string, MP4Duration timeScale )
{
int hour, minute, second, frame;
MP4Duration timeval;
sscanf([SMPTE_string UTF8String], "%d:%02d:%02d:%02d",&hour, &minute, &second, &frame);
timeval = hour * 60 * 60 + minute * 60 + second;
timeval = timeScale * timeval + ( frame * 10 );
return timeval;
}
int MP4SetTrackEnabled(MP4FileHandle fileHandle, MP4TrackId trackId)
{
return MP4SetTrackIntegerProperty(fileHandle, trackId, "tkhd.flags", (TRACK_ENABLED | TRACK_IN_MOVIE));
@@ -127,16 +91,6 @@ uint64_t getTrackSize(MP4FileHandle fileHandle, MP4TrackId trackId)
return dataLength;
}
int isHdVideo(uint64_t width, uint64_t height)
{
if ((width > 1280) || (height > 720))
return 2;
else if (((width >= 960) && (height >= 720)) || width >= 1280)
return 1;
return 0;
}
MP4TrackId findChapterTrackId(MP4FileHandle fileHandle)
{
MP4TrackId trackId = 0;
@@ -695,43 +649,6 @@ int readAC3Config(uint64_t acmod, uint64_t lfeon, UInt32 *channelsCount, UInt32
return 1;
}
BOOL isTrackMuxable(NSString * formatName)
{
NSArray* supportedFormats = [NSArray arrayWithObjects:MP42VideoFormatH264, MP42VideoFormatMPEG4Visual, MP42AudioFormatAAC, MP42AudioFormatALAC, MP42AudioFormatAC3, MP42AudioFormatDTS, MP42SubtitleFormatTx3g, MP42SubtitleFormatText, MP42ClosedCaptionFormatCEA608, MP42VideoFormatJPEG, MP42SubtitleFormatVobSub, nil];
for (NSString* type in supportedFormats)
if ([formatName isEqualToString:type])
return YES;
return NO;
}
BOOL trackNeedConversion(NSString * formatName) {
NSArray* supportedConversionFormats = [NSArray arrayWithObjects:MP42AudioFormatVorbis, MP42AudioFormatFLAC, MP42AudioFormatMP3, MP42AudioFormatTrueHD, MP42SubtitleFormatSSA, MP42SubtitleFormatText, MP42SubtitleFormatPGS, nil];
for (NSString* type in supportedConversionFormats)
if ([formatName isEqualToString:type])
return YES;
return NO;
}
NSArray *supportedFileFormat()
{
return [NSArray arrayWithObjects:@"scc", @"smi", @"txt", @"m4v", @"mp4", @"m4a", @"m4a", @"mov", @"mts", @"m2ts",
@"mkv", @"mka", @"mks", @"h264", @"264", @"idx", @"aac", @"ac3", @"srt", nil];
}
BOOL isFileFormatSupported(NSString * fileExt) {
NSArray *supportedFormat = supportedFileFormat();
for (NSString *type in supportedFormat)
if ([fileExt caseInsensitiveCompare:type] == NSOrderedSame)
return YES;
return NO;
}
int64_t getTrackStartOffset(MP4FileHandle fileHandle, MP4TrackId Id)
{
int64_t offset = 0;