[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24631] trunk/blender: Quicktime for Cocoa : import part
Damien Plisson
damien.plisson at yahoo.fr
Wed Nov 18 10:49:43 CET 2009
Revision: 24631
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24631
Author: damien78
Date: 2009-11-18 10:49:42 +0100 (Wed, 18 Nov 2009)
Log Message:
-----------
Quicktime for Cocoa : import part
This makes quicktime import (.mov & quicktime handled image files such as .gif) available also for 64bit OSX
Unfortunately, Apple currently incomplete implementation of QTKit has much lower performance than old Carbon Quicktime.
FYI, it spawns a 32bit process "QTKitserver" to place calls to Quicktime 7.
So this is mostly meant as a "backup" for 64bit OSX builds, until Apple releases full Quicktime X.
Export part will come just after.
CMake scripts updated: set WITH_QUICKTIME and USE_QTKIT to ON
Modified Paths:
--------------
trunk/blender/CMakeLists.txt
trunk/blender/source/blender/imbuf/intern/util.c
trunk/blender/source/blender/quicktime/CMakeLists.txt
trunk/blender/source/blender/quicktime/apple/quicktime_import.c
trunk/blender/source/blender/quicktime/quicktime_import.h
Added Paths:
-----------
trunk/blender/source/blender/quicktime/apple/qtkit_export.m
trunk/blender/source/blender/quicktime/apple/qtkit_import.m
Modified: trunk/blender/CMakeLists.txt
===================================================================
--- trunk/blender/CMakeLists.txt 2009-11-18 08:50:09 UTC (rev 24630)
+++ trunk/blender/CMakeLists.txt 2009-11-18 09:49:42 UTC (rev 24631)
@@ -84,6 +84,7 @@
IF (APPLE)
OPTION(WITH_COCOA "Use Cocoa framework instead of deprecated Carbon" ON)
+OPTION(USE_QTKIT "Use QtKit instead of Carbon quicktime (needed for having partial quicktime for 64bit)" OFF)
OPTION(WITH_LIBS10.5 "Use 10.5 libs (needed for 64bit builds)" OFF)
ENDIF (APPLE)
@@ -525,7 +526,15 @@
IF (WITH_COCOA)
SET(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing -DGHOST_COCOA")
- SET(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Cocoa -framework Carbon -framework AudioUnit -framework AudioToolbox -framework CoreAudio -framework QuickTime")
+ SET(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Cocoa -framework Carbon -framework AudioUnit -framework AudioToolbox -framework CoreAudio")
+ IF(USE_QTKIT)
+ SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DUSE_QTKIT")
+ SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QTKit")
+ ELSE(USE_QTKIT)
+ IF(WITH_QUICKTIME)
+ SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime")
+ ENDIF(WITH_QUICKTIME)
+ ENDIF(USE_QTKIT)
ELSE (WITH_COCOA)
SET(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
SET(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Carbon -framework AGL -framework AudioUnit -framework AudioToolbox -framework CoreAudio -framework QuickTime")
Modified: trunk/blender/source/blender/imbuf/intern/util.c
===================================================================
--- trunk/blender/source/blender/imbuf/intern/util.c 2009-11-18 08:50:09 UTC (rev 24630)
+++ trunk/blender/source/blender/imbuf/intern/util.c 2009-11-18 09:49:42 UTC (rev 24631)
@@ -384,6 +384,9 @@
if(UTIL_DEBUG) printf("in getanimtype: %s\n", name);
#ifndef _WIN32
+# ifdef WITH_QUICKTIME
+ if (isqtime(name)) return (ANIM_QTIME);
+# endif
# ifdef WITH_FFMPEG
/* stat test below fails on large files > 4GB */
if (isffmpeg(name)) return (ANIM_FFMPEG);
@@ -394,9 +397,6 @@
if (isavi(name)) return (ANIM_AVI);
if (ismovie(name)) return (ANIM_MOVIE);
-# ifdef WITH_QUICKTIME
- if (isqtime(name)) return (ANIM_QTIME);
-# endif
#else
if (ib_stat(name,&st) == -1) return(0);
if (((st.st_mode) & S_IFMT) != S_IFREG) return(0);
Modified: trunk/blender/source/blender/quicktime/CMakeLists.txt
===================================================================
--- trunk/blender/source/blender/quicktime/CMakeLists.txt 2009-11-18 08:50:09 UTC (rev 24630)
+++ trunk/blender/source/blender/quicktime/CMakeLists.txt 2009-11-18 09:49:42 UTC (rev 24631)
@@ -24,7 +24,11 @@
#
# ***** END GPL LICENSE BLOCK *****
-SET(SRC apple/quicktime_import.c apple/quicktime_export.c)
+IF(USE_QTKIT)
+ SET(SRC apple/qtkit_import.m apple/qtkit_export.m)
+ELSE(USE_QTKIT)
+ SET(SRC apple/quicktime_import.c apple/quicktime_export.c)
+ENDIF(USE_QTKIT)
SET(INC
.
Added: trunk/blender/source/blender/quicktime/apple/qtkit_export.m
===================================================================
--- trunk/blender/source/blender/quicktime/apple/qtkit_export.m (rev 0)
+++ trunk/blender/source/blender/quicktime/apple/qtkit_export.m 2009-11-18 09:49:42 UTC (rev 24631)
@@ -0,0 +1,665 @@
+/**
+ * $Id: qtkit_export.m 24424 2009-11-09 17:06:48Z damien78 $
+ *
+ * qtkit_export.m
+ *
+ * Code to create QuickTime Movies with Blender
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ *
+ * The Original Code is written by Rob Haarsma (phase)
+ *
+ * Contributor(s): Stefan Gartner (sgefant)
+ * Damien Plisson 11/2009
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifdef WITH_QUICKTIME
+#if defined(_WIN32) || defined(__APPLE__)
+
+#include "DNA_scene_types.h"
+
+#include "BKE_global.h"
+#include "BKE_scene.h"
+
+#include "BLI_blenlib.h"
+
+#include "BLO_sys_types.h"
+
+#include "IMB_imbuf.h"
+#include "IMB_imbuf_types.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "quicktime_import.h"
+#include "quicktime_export.h"
+
+
+#ifdef __APPLE__
+/* evil */
+#ifndef __AIFF__
+#define __AIFF__
+#endif
+#endif /* __APPLE__ */
+
+#define kMyCreatorType FOUR_CHAR_CODE('TVOD')
+#define kTrackStart 0
+#define kMediaStart 0
+
+//static void QT_StartAddVideoSamplesToMedia (const Rect *trackFrame, int rectx, int recty);
+static void QT_DoAddVideoSamplesToMedia (int frame, int *pixels, int rectx, int recty);
+static void QT_EndAddVideoSamplesToMedia (void);
+static void QT_CreateMyVideoTrack (int rectx, int recty);
+static void QT_EndCreateMyVideoTrack (void);
+static void check_renderbutton_framerate(struct RenderData *rd);
+
+typedef struct QuicktimeExport {
+
+ /*FSSpec theSpec;
+ short resRefNum;
+ Str255 qtfilename;
+
+ Media theMedia;
+ Movie theMovie;
+ Track theTrack;
+
+ GWorldPtr theGWorld;
+ PixMapHandle thePixMap;
+ ImageDescription **anImageDescription;*/
+
+ ImBuf *ibuf; //imagedata for Quicktime's Gworld
+ ImBuf *ibuf2; //copy of renderdata, to be Y-flipped
+
+} QuicktimeExport;
+
+typedef struct QuicktimeComponentData {
+
+ /*ComponentInstance theComponent;
+ SCTemporalSettings gTemporalSettings;
+ SCSpatialSettings gSpatialSettings;
+ SCDataRateSettings aDataRateSetting;
+ TimeValue duration;
+ long kVideoTimeScale;*/
+
+} QuicktimeComponentData;
+
+static struct QuicktimeExport *qtexport;
+static struct QuicktimeComponentData *qtdata;
+
+static int sframe;
+
+#if 0
+
+static OSErr QT_SaveCodecSettingsToScene(RenderData *rd)
+{
+ QTAtomContainer myContainer = NULL;
+ ComponentResult myErr = noErr;
+ Ptr myPtr;
+ long mySize = 0;
+
+ CodecInfo ci;
+ char str[255];
+
+ QuicktimeCodecData *qcd = rd->qtcodecdata;
+
+ // check if current scene already has qtcodec settings, and clear them
+ if (qcd) {
+ free_qtcodecdata(qcd);
+ } else {
+ qcd = rd->qtcodecdata = MEM_callocN(sizeof(QuicktimeCodecData), "QuicktimeCodecData");
+ }
+
+ // obtain all current codec settings
+ SCSetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings);
+ SCSetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings);
+ SCSetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting);
+
+ // retreive codecdata from quicktime in a atomcontainer
+ myErr = SCGetSettingsAsAtomContainer(qtdata->theComponent, &myContainer);
+ if (myErr != noErr) {
+ printf("Quicktime: SCGetSettingsAsAtomContainer failed\n");
+ goto bail;
+ }
+
+ // get the size of the atomcontainer
+ mySize = GetHandleSize((Handle)myContainer);
+
+ // lock and convert the atomcontainer to a *valid* pointer
+ QTLockContainer(myContainer);
+ myPtr = *(Handle)myContainer;
+
+ // copy the Quicktime data into the blender qtcodecdata struct
+ if (myPtr) {
+ qcd->cdParms = MEM_mallocN(mySize, "qt.cdParms");
+ memcpy(qcd->cdParms, myPtr, mySize);
+ qcd->cdSize = mySize;
+
+ GetCodecInfo (&ci, qtdata->gSpatialSettings.codecType, 0);
+ CopyPascalStringToC(ci.typeName, str);
+ sprintf(qcd->qtcodecname, "Codec: %s", str);
+ } else {
+ printf("Quicktime: QT_SaveCodecSettingsToScene failed\n");
+ }
+
+ QTUnlockContainer(myContainer);
+
+bail:
+ if (myContainer != NULL)
+ QTDisposeAtomContainer(myContainer);
+
+ return((OSErr)myErr);
+}
+
+
+static OSErr QT_GetCodecSettingsFromScene(RenderData *rd)
+{
+ Handle myHandle = NULL;
+ ComponentResult myErr = noErr;
+// CodecInfo ci;
+// char str[255];
+
+ QuicktimeCodecData *qcd = rd->qtcodecdata;
+
+ // if there is codecdata in the blendfile, convert it to a Quicktime handle
+ if (qcd) {
+ myHandle = NewHandle(qcd->cdSize);
+ PtrToHand( qcd->cdParms, &myHandle, qcd->cdSize);
+ }
+
+ // restore codecsettings to the quicktime component
+ if(qcd->cdParms && qcd->cdSize) {
+ myErr = SCSetSettingsFromAtomContainer((GraphicsExportComponent)qtdata->theComponent, (QTAtomContainer)myHandle);
+ if (myErr != noErr) {
+ printf("Quicktime: SCSetSettingsFromAtomContainer failed\n");
+ goto bail;
+ }
+
+ // update runtime codecsettings for use with the codec dialog
+ SCGetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting);
+ SCGetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings);
+ SCGetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings);
+
+// GetCodecInfo (&ci, qtdata->gSpatialSettings.codecType, 0);
+// CopyPascalStringToC(ci.typeName, str);
+// printf("restored Codec: %s\n", str);
+ } else {
+ printf("Quicktime: QT_GetCodecSettingsFromScene failed\n");
+ }
+bail:
+ if (myHandle != NULL)
+ DisposeHandle(myHandle);
+
+ return((OSErr)myErr);
+}
+
+
+static OSErr QT_AddUserDataTextToMovie (Movie theMovie, char *theText, OSType theType)
+{
+ UserData myUserData = NULL;
+ Handle myHandle = NULL;
+ long myLength = strlen(theText);
+ OSErr myErr = noErr;
+
+ // get the movie's user data list
+ myUserData = GetMovieUserData(theMovie);
+ if (myUserData == NULL)
+ return(paramErr);
+
+ // copy the specified text into a new handle
+ myHandle = NewHandleClear(myLength);
+ if (myHandle == NULL)
+ return(MemError());
+
+ BlockMoveData(theText, *myHandle, myLength);
+
+ // add the data to the movie's user data
+ myErr = AddUserDataText(myUserData, myHandle, theType, 1, (short)GetScriptManagerVariable(smRegionCode));
+
+ // clean up
+ DisposeHandle(myHandle);
+ return(myErr);
+}
+
+
+static void QT_CreateMyVideoTrack(int rectx, int recty)
+{
+ OSErr err = noErr;
+ Rect trackFrame;
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list