Skip to content

Commit

Permalink
Update to build with latest FFMPEG
Browse files Browse the repository at this point in the history
- Updated to build against 53b15348a4284a73269399e59fe2a7f1eacd4121
  of astrange's FFMPEG-MT
- Update various constants to new names (Codec type and packet flags).
- Remove avcodec_thread_init as it's deprecated. Deprecation comment
  says we just need to set the thread count before we open the codec
  which we were already.
- Put more parens around more assignments used in conditionals.
  • Loading branch information
samiamwork committed Jun 10, 2011
1 parent 55403da commit 3a9ada4
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 24 deletions.
8 changes: 4 additions & 4 deletions FFIndexer.m
Expand Up @@ -59,8 +59,8 @@ - (id)initWithMovie:(MMovie_FFmpeg*)movie
return 0;
}

if (self = [super initWithAVStream:_indexContext->streams[streamIndex]
index:streamIndex]) {
if ((self = [super initWithAVStream:_indexContext->streams[streamIndex]
index:streamIndex])) {
_movie = [movie retain];
_formatContext = formatContext;
_frameReadMutex = [frameReadMutex retain];
Expand Down Expand Up @@ -113,10 +113,10 @@ - (void)makeIndex
[_frameReadMutex lock];
av_add_index_entry(_formatContext->streams[packet.stream_index],
packet.pos - 8, packet.dts, packet.size, 0,
(packet.flags & PKT_FLAG_KEY) ? AVINDEX_KEYFRAME : 0);
(packet.flags & AV_PKT_FLAG_KEY) ? AVINDEX_KEYFRAME : 0);
[_frameReadMutex unlock];
if (packet.stream_index == [self streamIndex]) {
if (packet.flags & PKT_FLAG_KEY) {
if (packet.flags & AV_PKT_FLAG_KEY) {
AVStream* stream = _formatContext->streams[packet.stream_index];
_indexingTime = packet.dts * av_q2d(stream->time_base);
TRACE(@"current %f", packet.dts * av_q2d(stream->time_base));
Expand Down
7 changes: 4 additions & 3 deletions FFTrack.m
Expand Up @@ -23,6 +23,8 @@

#import "FFTrack.h"
#import "MMovie_FFmpeg.h"
#include <sys/types.h>
#include <sys/sysctl.h>

@implementation FFContext

Expand All @@ -33,7 +35,7 @@ + (id)contextWithAVStream:(AVStream*)stream index:(int)index

- (id)initWithAVStream:(AVStream*)stream index:(int)index
{
if (self = [super init]) {
if ((self = [super init])) {
_streamIndex = index;
_stream = stream;
}
Expand Down Expand Up @@ -72,13 +74,12 @@ - (BOOL)initContext:(int*)errorCode
context->error_recognition = FF_ER_CAREFUL;
context->error_concealment = 3;

if (context->codec_type == CODEC_TYPE_VIDEO) {
if (context->codec_type == AVMEDIA_TYPE_VIDEO) {
int cpuCount;
size_t oldlen = 4;
if (sysctlbyname("hw.activecpu", &cpuCount, &oldlen, NULL, 0) == 0) {
if (1 < cpuCount) {
context->thread_count = 2;
avcodec_thread_init(context, context->thread_count);
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions MMovie.m
Expand Up @@ -32,7 +32,7 @@ + (id)trackWithImpl:(id)impl

- (id)initWithImpl:(id)impl
{
if (self = [super init]) {
if ((self = [super init])) {
_impl = [impl retain];
_codecId = MCODEC_ETC_;
}
Expand Down Expand Up @@ -247,7 +247,7 @@ + (void)setNamesForTracks:(NSArray*)tracks defaultName:(NSString*)defaultName
MTrack* track;
int number = 1;
NSEnumerator* enumerator = [tracks objectEnumerator];
while (track = [enumerator nextObject]) {
while ((track = [enumerator nextObject])) {
[track setName:[defaultName stringByAppendingFormat:@" %d", number++]];
}
}
Expand Down Expand Up @@ -288,14 +288,14 @@ + (BOOL)getMovieInfo:(MMovieInfo*)info forMovieURL:(NSURL*)url error:(NSError**)
NSMutableArray* audioTracks = [NSMutableArray arrayWithCapacity:1];
for (i = 0; i < formatContext->nb_streams; i++) {
stream = formatContext->streams[i];
if (stream->codec->codec_type == CODEC_TYPE_VIDEO) {
if (stream->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
track = [self videoTrackWithAVStream:stream streamIndex:i];
[videoTracks addObject:track];
if (!fps && 0 < [track fps]) {
fps = [track fps];
}
}
else if (stream->codec->codec_type == CODEC_TYPE_AUDIO) {
else if (stream->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
track = [self audioTrackWithAVStream:stream streamIndex:i];
[audioTracks addObject:track];
if ([track codecId] == MCODEC_AC3) {
Expand Down Expand Up @@ -346,7 +346,7 @@ - (id)initWithURL:(NSURL*)url movieInfo:(MMovieInfo*)movieInfo
if (![MMovie checkMovieURL:url error:error]) {
return nil;
}
if (self = [super init]) {
if ((self = [super init])) {
_url = [url retain];
_videoTracks = [movieInfo->videoTracks retain];
_audioTracks = [movieInfo->audioTracks retain];
Expand Down
2 changes: 0 additions & 2 deletions MMovie_Codec.m
Expand Up @@ -109,7 +109,6 @@ + (int)videoCodecIdFromFFmpegCodecId:(int)ffmpegCodecId fourCC:(NSString*)fourCC
CASE_FFCODEC_______(QDRAW);
CASE_FFCODEC_______(VIXL);
CASE_FFCODEC_______(QPEG);
CASE_FFCODEC_MCODEC(XVID, XVID);
CASE_FFCODEC_______(PNG);
CASE_FFCODEC_______(PPM);
CASE_FFCODEC_______(PBM);
Expand Down Expand Up @@ -174,7 +173,6 @@ + (int)videoCodecIdFromFFmpegCodecId:(int)ffmpegCodecId fourCC:(NSString*)fourCC
else IF_FFCODEC_MCODEC(@"DIV6", DIV6);
else IF_FFCODEC_MCODEC(@"DIVX", DIVX);
else IF_FFCODEC_MCODEC(@"DX50", DX50);
else IF_FFCODEC_MCODEC(@"XVID", XVID);
else IF_FFCODEC_MCODEC(@"mp4v", MP4V);
else IF_FFCODEC_MCODEC(@"MPG4", MPG4);
else IF_FFCODEC_MCODEC(@"MP42", MP42);
Expand Down
2 changes: 1 addition & 1 deletion MMovie_FFMPEG.m
Expand Up @@ -87,7 +87,7 @@ void traceAVFormatContext(AVFormatContext* formatContext)
avcodec_string(buf, sizeof(buf), stream->codec, 1);
[s appendFormat:@": %s", buf];

if (stream->codec->codec_type == CODEC_TYPE_VIDEO) {
if (stream->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if (stream->r_frame_rate.den && stream->r_frame_rate.num) {
[s appendFormat:@", %5.2f fps(r)", av_q2d(stream->r_frame_rate)];
}
Expand Down
2 changes: 1 addition & 1 deletion MMovie_QuickTime.m
Expand Up @@ -260,7 +260,7 @@ - (id)initWithURL:(NSURL*)url movieInfo:(MMovieInfo*)movieInfo
QTTrack* qtTrack;
int vi = 0, ai = 0;
NSEnumerator* enumerator = [[_qtMovie tracks] objectEnumerator];
while (qtTrack = [enumerator nextObject]) {
while ((qtTrack = [enumerator nextObject])) {
mediaType = [qtTrack attributeForKey:QTTrackMediaTypeAttribute];
if ([mediaType isEqualToString:QTMediaTypeVideo] ||
[mediaType isEqualToString:QTMediaTypeMPEG]/* ||
Expand Down
2 changes: 1 addition & 1 deletion Movist.h
Expand Up @@ -270,7 +270,7 @@ enum {
MCODEC_DIV6, // DivX MPEG-4 V3.x
MCODEC_DIVX, // DivX MPEG-4 V4.x
MCODEC_DX50, // DivX MPEG-4 V5.x
MCODEC_XVID = 120, // Xvid MPEG-4
//MCODEC_XVID = 120, // Xvid MPEG-4 (removed from FFMPEG)
MCODEC_MP4V = 130, // Apple MPEG-4
MCODEC_MPG4 = 140, // Microsoft MPEG-4 V1
MCODEC_MP42, // Microsoft MPEG-4 V2
Expand Down
5 changes: 2 additions & 3 deletions Movist.m
Expand Up @@ -143,7 +143,7 @@ BOOL checkMovieSeries(NSString* filename1, NSString* filename2)

NSString* filename;
NSEnumerator* e = [filenames objectEnumerator];
while (filename = [e nextObject]) {
while ((filename = [e nextObject])) {
[URLs addObject:[NSURL fileURLWithPath:filename]];
}
return URLs;
Expand All @@ -170,7 +170,6 @@ BOOL checkMovieSeries(NSString* filename1, NSString* filename2)
CASE_CODEC_STRING(DIV6);
CASE_CODEC_STRING(DIVX);
CASE_CODEC_STRING(DX50);
CASE_CODEC_STRING(XVID);
CASE_CODEC_STRING(MP4V);
CASE_CODEC_STRING(MPG4);
CASE_CODEC_STRING(MP42);
Expand Down Expand Up @@ -288,7 +287,7 @@ unsigned int dragActionFromPasteboard(NSPasteboard* pboard, BOOL defaultPlay)
NSArray* subtitleExts = [MSubtitle fileExtensions];
NSString* filename;
NSEnumerator* e = [filenames objectEnumerator];
while (filename = [e nextObject]) {
while ((filename = [e nextObject])) {
if (![filename hasAnyExtension:subtitleExts]) {
break;
}
Expand Down
4 changes: 2 additions & 2 deletions PreferenceController_Advanced_Codec.m
Expand Up @@ -36,7 +36,7 @@ - (void)initCodecBinding
MCODEC_ID(MPEG1),MCODEC_ID(MPEG2),MCODEC_ID(MPEG4),
MCODEC_ID(DIV1), MCODEC_ID(DIV2), MCODEC_ID(DIV3), MCODEC_ID(DIV4),
MCODEC_ID(DIV5), MCODEC_ID(DIV6), MCODEC_ID(DIVX), MCODEC_ID(DX50),
MCODEC_ID(XVID), MCODEC_ID(MP4V), MCODEC_ID(MPG4), MCODEC_ID(MP42),
MCODEC_ID(MP4V), MCODEC_ID(MPG4), MCODEC_ID(MP42),
MCODEC_ID(MP43), MCODEC_ID(MP4S), MCODEC_ID(M4S2), MCODEC_ID(AP41),
MCODEC_ID(RMP4), MCODEC_ID(SEDG), MCODEC_ID(FMP4), MCODEC_ID(BLZ0),
MCODEC_ID(H263), MCODEC_ID(H264), MCODEC_ID(AVC1), MCODEC_ID(X264),
Expand Down Expand Up @@ -142,7 +142,7 @@ - (IBAction)codecBindingActions:(id)sender
NSNumber* num;
NSDictionary* dict = [_defaults dictionaryForKey:MDefaultCodecBindingKey];
NSEnumerator* enumerator = [[dict allKeys] objectEnumerator];
while (num = [enumerator nextObject]) {
while ((num = [enumerator nextObject])) {
if ([num intValue] / MCODEC_MPEG4 == 1) { // all MPEG4s are in 100 ~ 199.
[set addIndex:[num intValue]];
}
Expand Down
3 changes: 1 addition & 2 deletions UserDefaults.m
Expand Up @@ -272,7 +272,6 @@ - (NSDictionary*)defaultCodecBinding
CODEC_BINDING(DECODER_FFMPEG, MCODEC_DIV6),
CODEC_BINDING(DECODER_FFMPEG, MCODEC_DIVX),
CODEC_BINDING(DECODER_FFMPEG, MCODEC_DX50),
CODEC_BINDING(DECODER_FFMPEG, MCODEC_XVID),
CODEC_BINDING(DECODER_QUICKTIME,MCODEC_MP4V),
CODEC_BINDING(DECODER_FFMPEG, MCODEC_MPG4),
CODEC_BINDING(DECODER_FFMPEG, MCODEC_MP42),
Expand Down Expand Up @@ -337,7 +336,7 @@ - (void)setDefaultDecoder:(int)decoder forCodecId:(int)codecId
TRACE(@"codecId=%d ==> default-decoder=%d", codecId, decoder);
id key;
NSEnumerator* enumerator = [[dict allKeys] objectEnumerator];
while (key = [enumerator nextObject]) {
while ((key = [enumerator nextObject])) {
[dict setObject:object forKey:key];
}
}
Expand Down

0 comments on commit 3a9ada4

Please sign in to comment.