Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

* use ffmpeg-mt in both i386 and ppc.

* remove libswscale dependancy


git-svn-id: http://movist.googlecode.com/svn/trunk@313 9988c26d-9134-0410-b5bb-5778289bb252
  • Loading branch information...
commit 752fb9bbfcd7a95719900291a51370552ab474b3 1 parent 72de450
moosoy authored
View
42 ColorConversions.c
@@ -19,11 +19,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "ColorConversions.h"
#include <QuickTime/QuickTime.h>
#include <Accelerate/Accelerate.h>
-#include "ColorConversions.h"
//#include "Codecprintf.h"
//#include "CommonUtils.h"
+#include <stdio.h>
/*
Converts (without resampling) from ffmpeg pixel formats to the ones QT accepts
@@ -509,9 +510,9 @@ static FASTCALL void ClearY422(UInt8 *baseAddr, int rowBytes, unsigned width, un
OSType ColorConversionDstForPixFmt(enum PixelFormat ffPixFmt)
{
switch (ffPixFmt) {
- case PIX_FMT_RGB555LE:
- case PIX_FMT_RGB555BE:
- return k16BE555PixelFormat;
+ //case PIX_FMT_RGB555LE:
+ //case PIX_FMT_RGB555BE:
+ // return k16BE555PixelFormat;
case PIX_FMT_BGR24:
return k24RGBPixelFormat; //XXX try k24BGRPixelFormat
case PIX_FMT_RGB24:
@@ -564,14 +565,14 @@ int ColorConversionFindFor(ColorConversionFuncs *funcs, enum PixelFormat ffPixFm
funcs->clear = ClearRGB24;
funcs->convert = RGB24toRGB24;
break;
- case PIX_FMT_RGB555LE:
- funcs->clear = ClearRGB16;
- funcs->convert = RGB16LEtoRGB16;
- break;
- case PIX_FMT_RGB555BE:
- funcs->clear = ClearRGB16;
- funcs->convert = RGB16toRGB16;
- break;
+ //case PIX_FMT_RGB555LE:
+ // funcs->clear = ClearRGB16;
+ // funcs->convert = RGB16LEtoRGB16;
+ // break;
+ //case PIX_FMT_RGB555BE:
+ // funcs->clear = ClearRGB16;
+ // funcs->convert = RGB16toRGB16;
+ // break;
case PIX_FMT_YUV410P:
funcs->clear = ClearY422;
funcs->convert = Y410toY422;
@@ -589,4 +590,19 @@ int ColorConversionFindFor(ColorConversionFuncs *funcs, enum PixelFormat ffPixFm
}
return noErr;
-}
+}
+
+int IsAltivecSupported()
+{
+ static int altivec = -1;
+
+ if (altivec == -1) {
+ long response = 0;
+ int err = Gestalt(gestaltPowerPCProcessorFeatures, &response);
+
+ altivec = !err && ((response & (1 << gestaltPowerPCHasVectorInstructions)) != 0);
+ }
+
+ return altivec;
+}
+
View
14 ColorConversions.h
@@ -21,16 +21,12 @@
#include <Carbon/Carbon.h>
-#ifdef __BIG_ENDIAN__
- #include <ffmpeg/avcodec.h>
-#else
- #include <libavcodec/avcodec.h>
-#endif
+#include <libavcodec/avcodec.h>
-#if defined(__i386__) && !defined(__llvm__)
-#define FASTCALL __attribute__((fastcall))
-#else
+#ifndef __i386__
#define FASTCALL
+#else
+#define FASTCALL __attribute__((fastcall))
#endif
typedef void ColorConversionFunc(AVFrame *inPicture, UInt8 *outBaseAddr, int outRowBytes, unsigned outWidth, unsigned outHeight) FASTCALL;
@@ -44,4 +40,4 @@ typedef struct ColorConversionFuncs {
} ColorConversionFuncs;
extern OSType ColorConversionDstForPixFmt(enum PixelFormat ffPixFmt);
-extern int ColorConversionFindFor(ColorConversionFuncs *funcs, enum PixelFormat ffPixFmt, AVFrame *ffPicture, OSType qtPixFmt);
+extern int ColorConversionFindFor(ColorConversionFuncs *funcs, enum PixelFormat ffPixFmt, AVFrame *ffPicture, OSType qtPixFmt);
View
6 FFAudioTrack_Analog.m
@@ -351,15 +351,9 @@ - (void)decodePacket:(AVPacket*)packet
//TRACE(@"dts = %lld * %lf = %lf", packet->dts, PTS_TO_SEC, 1. * packet->dts * PTS_TO_SEC);
while (0 < packetSize) {
dataSize = AVCODEC_MAX_AUDIO_FRAME_SIZE;
-#if 1 // def __BIG_ENDIAN__
- decodedSize = avcodec_decode_audio2(context,
- _audioDataBuf, &dataSize,
- packetPtr, packetSize);
-#else
decodedSize = avcodec_decode_audio3(context,
_audioDataBuf, &dataSize,
packet);
-#endif
if (decodedSize < 0) {
TRACE(@"decodedSize < 0");
break;
View
6 FFAudioTrack_Digital.m
@@ -492,15 +492,9 @@ - (void)putDigitalAudioPacket:(AVPacket*)packet
int dataSize, decodedSize;
while (0 < packetSize) {
dataSize = AVCODEC_MAX_AUDIO_FRAME_SIZE;
-#if 1 // def __BIG_ENDIAN__
- decodedSize = avcodec_decode_audio2(context,
- _audioDataBuf, &dataSize,
- packetPtr, packetSize);
-#else
decodedSize = avcodec_decode_audio3(context,
_audioDataBuf, &dataSize,
packet);
-#endif
if (decodedSize < 0) {
TRACE(@"decodedSize < 0");
break;
View
21 FFIndexer.m
@@ -23,29 +23,11 @@
#import "FFIndexer.h"
#import "MMovie_FFmpeg.h"
-
-#ifdef __BIG_ENDIAN__
- #import <ffmpeg/avio.h>
-#else
- #import <libavformat/avio.h>
-#endif
+#import <libavformat/avio.h>
#import <fcntl.h>
///////////// copied from ffmpeg/libavformat/avformat.h ///////////////////////
-#ifdef __BIG_ENDIAN__
-typedef struct {
- int64_t riff_end;
- int64_t movi_end;
- int64_t fsize;
- offset_t movi_list;
- int index_loaded;
- int is_odml;
- int non_interleaved;
- int stream_index;
- struct DVDemuxContext* dv_demux;
-} AVIContext;
-#else
typedef struct {
int64_t riff_end;
int64_t movi_end;
@@ -58,7 +40,6 @@
int stream_index;
struct DVDemuxContext* dv_demux;
} AVIContext;
-#endif
///////////////////////////////////////////////////////////////////////////////
View
14 FFTrack.h
@@ -26,16 +26,11 @@
#include <CoreVideo/CVOpenGLTexture.h>
#include <CoreVideo/CVOpenGLTextureCache.h>
#include <AudioUnit/AudioUnit.h>
+#include "ColorConversions.h"
-#ifdef __BIG_ENDIAN__
- #import <ffmpeg/avcodec.h>
- #import <ffmpeg/avformat.h>
- #import <ffmpeg/swscale.h>
-#else
- #import <libavcodec/avcodec.h>
- #import <libavformat/avformat.h>
- #import <libswscale/swscale.h>
-#endif
+#import <libavcodec/avcodec.h>
+#import <libavformat/avformat.h>
+//#import <libswscale/swscale.h>
@interface FFContext : NSObject
{
@@ -93,6 +88,7 @@ extern AVPacket s_flushPacket;
PacketQueue* _packetQueue;
AVFrame* _frame; // for decoding
ImageQueue* _imageQueue;
+ ColorConversionFuncs _colorConvFunc;
struct SwsContext* _scalerContext;
CVOpenGLTextureCacheRef _textureCache;
BOOL _needKeyFrame;
View
18 FFTrack.m
@@ -66,23 +66,23 @@ - (BOOL)initContext:(int*)errorCode
context->skip_frame = AVDISCARD_DEFAULT;
context->skip_idct = AVDISCARD_DEFAULT;
context->skip_loop_filter = AVDISCARD_DEFAULT;
-#ifdef __BIG_ENDIAN__
- context->error_resilience = FF_ER_CAREFUL;
-#else
context->error_recognition = FF_ER_CAREFUL;
-#endif
context->error_concealment = 3;
+
+ if (context->codec_type == CODEC_TYPE_VIDEO) {
+ int cpuCount;
+ size_t oldlen = 4;
+ if (sysctlbyname("hw.activecpu", &cpuCount, &oldlen, NULL, 0) == 0) {
+ context->thread_count = cpuCount;
+ avcodec_thread_init(context, cpuCount);
+ }
+ }
if (avcodec_open(context, codec) < 0) {
*errorCode = ERROR_FFMPEG_CODEC_OPEN_FAILED;
return FALSE;
}
- if (context->codec_type == CODEC_TYPE_VIDEO) {
- avcodec_thread_init(context, 2);
- context->thread_count = 2;
- }
-
return TRUE;
}
View
29 FFVideoTrack.m
@@ -24,8 +24,6 @@
#import "FFTrack.h"
#import "MMovie_FFmpeg.h"
-#import "ColorConversions.h"
-
@interface PacketQueue : NSObject
{
AVPacket* _packet;
@@ -116,11 +114,7 @@ - (BOOL)getPacket:(AVPacket*)packet
////////////////////////////////////////////////////////////////////////////////
#pragma mark -
-#ifdef __BIG_ENDIAN__
- #define RGB_PIXEL_FORMAT PIX_FMT_YUV422
-#else
- #define RGB_PIXEL_FORMAT PIX_FMT_YUYV422
-#endif
+#define RGB_PIXEL_FORMAT PIX_FMT_YUYV422
//#undef RGB_PIXEL_FORMAT
//#define RGB_PIXEL_FORMAT PIX_FMT_BGRA // PIX_FMT_ARGB is not supported by ffmpeg
@@ -162,6 +156,7 @@ - (id)initWithCapacity:(unsigned int)capacity width:(int)width height:(int)heigh
bufWidth = 512 + 37;
}
}
+ bufWidth = (bufWidth + 31) / 32 * 32;
int bufSize = avpicture_get_size(RGB_PIXEL_FORMAT, bufWidth , height);
int i, ret;
for (i = 0; i < _capacity; i++) {
@@ -310,6 +305,10 @@ - (BOOL)initTrack:(int*)errorCode videoQueueCapacity:(int)videoQueueCapacity
return FALSE;
}
+#if 1
+ OSType qtPixFmt = ColorConversionDstForPixFmt(_stream->codec->pix_fmt);
+ ColorConversionFindFor(&_colorConvFunc, _stream->codec->pix_fmt, _frame, qtPixFmt);
+#else
// init sw-scaler context
_scalerContext = sws_getContext(width, height, context->pix_fmt,
width, height, RGB_PIXEL_FORMAT,
@@ -319,6 +318,7 @@ - (BOOL)initTrack:(int*)errorCode videoQueueCapacity:(int)videoQueueCapacity
*errorCode = ERROR_FFMPEG_SW_SCALER_INIT_FAILED;
return FALSE;
}
+#endif
// init playback
#ifndef _EXPERIMENTAL_AV_SYNC
@@ -460,13 +460,8 @@ - (double)decodePacket
}
int gotFrame;
-#if 1 // def __BIG_ENDIAN__
- int bytesDecoded = avcodec_decode_video(_stream->codec, _frame,
- &gotFrame, packet->data, packet->size);
-#else
int bytesDecoded = avcodec_decode_video2(_stream->codec, _frame,
&gotFrame, packet);
-#endif
av_free_packet(packet);
if (bytesDecoded < 0) {
TRACE(@"%s error while decoding frame", __PRETTY_FUNCTION__);
@@ -508,11 +503,7 @@ - (BOOL)convertImage:(AVFrame*) frame
#if 1
unsigned width = [_movie encodedSize].width;
unsigned height = [_movie encodedSize].height;
- OSType qtPixFmt = ColorConversionDstForPixFmt(_stream->codec->pix_fmt);
- ColorConversionFuncs f;
- ColorConversionFindFor(&f, _stream->codec->pix_fmt, _frame, qtPixFmt);
-
- f.convert(_frame, frame->data[0], frame->linesize[0], width, height);
+ _colorConvFunc.convert(_frame, frame->data[0], frame->linesize[0], width, height);
#else
// sw-scaler should be used under GPL only!
int ret = sws_scale(_scalerContext,
@@ -655,7 +646,7 @@ - (CVOpenGLTextureRef)nextImage:(double)hostTime
if (ret != kCVReturnSuccess) {
TRACE(@"CVOpenGLTextureCacheCreateTextureFromImage() failed : %d", ret);
}
- //CVOpenGLTextureCacheFlush(_textureCache, 0);
+ CVOpenGLTextureCacheFlush(_textureCache, 0);
#else
*currentTime = [_imageQueue time];
@@ -666,7 +657,7 @@ - (CVOpenGLTextureRef)nextImage:(double)hostTime
if (ret != kCVReturnSuccess) {
TRACE(@"CVOpenGLTextureCacheCreateTextureFromImage() failed : %d", ret);
}
- //CVOpenGLTextureCacheFlush(_textureCache, 0);
+ CVOpenGLTextureCacheFlush(_textureCache, 0);
[_imageQueue dequeue];
#endif
View
8 MMovie.h
@@ -22,13 +22,7 @@
#import <Cocoa/Cocoa.h>
#import <QuartzCore/QuartzCore.h>
-
-#ifdef __BIG_ENDIAN__
- #import <ffmpeg/avformat.h> // for AVFormatContext
-#else
- #import <libavformat/avformat.h> // for AVFormatContext
-#endif
-
+#import <libavformat/avformat.h> // for AVFormatContext
#import "Movist.h"
@class MMovie;
View
9 MMovie_FFMPEG.h
@@ -23,13 +23,8 @@
#import "MMovie.h"
-#ifdef __BIG_ENDIAN__
- #import <ffmpeg/avcodec.h>
- #import <ffmpeg/avformat.h>
-#else
- #import <libavcodec/avcodec.h>
- #import <libavformat/avformat.h>
-#endif
+#import <libavcodec/avcodec.h>
+#import <libavformat/avformat.h>
enum {
COMMAND_NONE,
View
4 Movist.xcodeproj/project.pbxproj
@@ -16,7 +16,6 @@
2CFA586A0DB3496B0084BFB6 /* libavutil.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2CFA58620DB3496B0084BFB6 /* libavutil.a */; };
2CFA586B0DB3496B0084BFB6 /* libfaad.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2CFA58630DB3496B0084BFB6 /* libfaad.a */; };
2CFA586C0DB3496B0084BFB6 /* libpostproc.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2CFA58640DB3496B0084BFB6 /* libpostproc.a */; };
- 2CFA586D0DB3496B0084BFB6 /* libswscale.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2CFA58650DB3496B0084BFB6 /* libswscale.a */; };
8D11072A0486CEB800E47090 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 29B97318FDCFA39411CA2CEA /* MainMenu.nib */; };
8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; };
@@ -269,7 +268,6 @@
2CFA58620DB3496B0084BFB6 /* libavutil.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libavutil.a; path = contrib/lib/libavutil.a; sourceTree = "<group>"; };
2CFA58630DB3496B0084BFB6 /* libfaad.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libfaad.a; path = contrib/lib/libfaad.a; sourceTree = "<group>"; };
2CFA58640DB3496B0084BFB6 /* libpostproc.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libpostproc.a; path = contrib/lib/libpostproc.a; sourceTree = "<group>"; };
- 2CFA58650DB3496B0084BFB6 /* libswscale.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libswscale.a; path = contrib/lib/libswscale.a; sourceTree = "<group>"; };
32CA4F630368D1EE00C91783 /* Movist_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Movist_Prefix.pch; sourceTree = "<group>"; };
8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
8D1107320486CEB800E47090 /* Movist.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Movist.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -592,7 +590,6 @@
2CFA586A0DB3496B0084BFB6 /* libavutil.a in Frameworks */,
2CFA586B0DB3496B0084BFB6 /* libfaad.a in Frameworks */,
2CFA586C0DB3496B0084BFB6 /* libpostproc.a in Frameworks */,
- 2CFA586D0DB3496B0084BFB6 /* libswscale.a in Frameworks */,
AF0247280F137C79007339EB /* libmatroska.a in Frameworks */,
2CB96DA40F1CCF1C00C14189 /* libebml.a in Frameworks */,
);
@@ -725,7 +722,6 @@
2CFA58620DB3496B0084BFB6 /* libavutil.a */,
2CFA58630DB3496B0084BFB6 /* libfaad.a */,
2CFA58640DB3496B0084BFB6 /* libpostproc.a */,
- 2CFA58650DB3496B0084BFB6 /* libswscale.a */,
);
name = FFmpeg;
sourceTree = "<group>";
View
2  build_extlib.sh
@@ -23,7 +23,7 @@ mkdir -p "$BUILDDIR"
cd "$BUILDDIR" && make -f "${CONTRIB_SRC_PATH}Makefile"
# ffmpeg
-cd "$CONTRIB_SRC_PATH" && sh build_ffmpeg.sh
+cd "$CONTRIB_SRC_PATH" && sh build_ffmpeg_mt.sh
# universal
cd "$SRCROOT" && sh make_univlib.sh
View
2  contrib/src/build_ffmpeg_mt.sh
@@ -16,7 +16,7 @@ FFMPEG_CONF_COMMON="$FFMPEG_CONF_COMMON --enable-pthreads"
########## SOURCE ##########
if [ -d "ffmpeg-mt" ]; then
- git pull
+ (cd ffmpeg-mt && git pull)
else
git clone git://gitorious.org/~astrange/ffmpeg/ffmpeg-mt.git
git clone git://git.ffmpeg.org/libswscale/ ffmpeg-mt/libswscale
View
8 spudec.c
@@ -29,9 +29,9 @@
//#include "libvo/video_out.h"
#include "spudec.h"
//#include "avutil.h"
-#ifndef __BIG_ENDIAN__
- #include "libswscale/swscale.h"
-#endif
+//#ifndef __BIG_ENDIAN__
+// #include "libswscale/swscale.h"
+//#endif
#define MIN(a, b) ((a)<(b)?(a):(b))
@@ -1144,4 +1144,4 @@ void spudec_set_hw_spu(void *this, vo_functions_t *hw_spu)
spu->hw_spu = hw_spu;
hw_spu->control(VOCTRL_SET_SPU_PALETTE,spu->global_palette);
}
-*/
+*/
Please sign in to comment.
Something went wrong with that request. Please try again.