[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [25069] trunk/blender/source/blender: Quicktime : make dna codecType data store the quicktime codecType value instead of a proxy value
Damien Plisson
damien.plisson at yahoo.fr
Wed Dec 2 12:23:11 CET 2009
Revision: 25069
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=25069
Author: damien78
Date: 2009-12-02 12:23:11 +0100 (Wed, 02 Dec 2009)
Log Message:
-----------
Quicktime : make dna codecType data store the quicktime codecType value instead of a proxy value
Quicktime codecType data is a 32 bit value (4 chars coded).
Implemented RNA set/get functions for codecType enum to cope with RNA enum values 24bit precision limitation
Implemented dynamic codecType enum list creation
Carbon quicktime now stores codec settings in "clear" in the QuicktimeCodecSettings dna struct (in addition to the closed atom container in QuicktimeCodecData) to be compatible with the QTKit version
+fixed some warnings
Modified Paths:
--------------
trunk/blender/source/blender/makesrna/intern/rna_scene.c
trunk/blender/source/blender/quicktime/apple/qtkit_export.m
trunk/blender/source/blender/quicktime/apple/qtkit_import.m
trunk/blender/source/blender/quicktime/apple/quicktime_export.c
trunk/blender/source/blender/quicktime/quicktime_export.h
Modified: trunk/blender/source/blender/makesrna/intern/rna_scene.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_scene.c 2009-12-02 10:32:39 UTC (rev 25068)
+++ trunk/blender/source/blender/makesrna/intern/rna_scene.c 2009-12-02 11:23:11 UTC (rev 25069)
@@ -410,6 +410,48 @@
}
#endif
+#ifdef WITH_QUICKTIME
+static int rna_SceneRenderData_qtcodecsettings_codecType_get(PointerRNA *ptr)
+{
+ RenderData *rd= (RenderData*)ptr->data;
+
+ return quicktime_rnatmpvalue_from_codectype(rd->qtcodecsettings.codecType);
+}
+
+static void rna_SceneRenderData_qtcodecsettings_codecType_set(PointerRNA *ptr, int value)
+{
+ RenderData *rd= (RenderData*)ptr->data;
+
+ rd->qtcodecsettings.codecType = quicktime_codecType_from_rnatmpvalue(value);
+}
+
+static EnumPropertyItem *rna_SceneRenderData_qtcodecsettings_codecType_itemf(bContext *C, PointerRNA *ptr, int *free)
+{
+ EnumPropertyItem *item= NULL;
+ EnumPropertyItem tmp = {0, "", 0, "", ""};
+ QuicktimeCodecTypeDesc *codecTypeDesc;
+ int i=1, totitem= 0;
+ char id[5];
+
+ for(i=0;i<quicktime_get_num_codecs();i++) {
+ codecTypeDesc = quicktime_get_codecType_desc(i);
+ if (!codecTypeDesc) break;
+
+ tmp.value= codecTypeDesc->rnatmpvalue;
+ *((int*)id) = codecTypeDesc->codecType;
+ id[4] = 0;
+ tmp.identifier= id;
+ tmp.name= codecTypeDesc->codecName;
+ RNA_enum_item_add(&item, &totitem, &tmp);
+ }
+
+ RNA_enum_item_end(&item, &totitem);
+ *free= 1;
+
+ return item;
+}
+#endif
+
static int rna_SceneRenderData_active_layer_index_get(PointerRNA *ptr)
{
RenderData *rd= (RenderData*)ptr->data;
@@ -1457,7 +1499,7 @@
# ifdef USE_QTKIT
{R_QUICKTIME, "QUICKTIME_QTKIT", ICON_FILE_MOVIE, "QuickTime", ""},
# else
- {R_QUICKTIME, "QUICKTIME", ICON_FILE_MOVIE, "QuickTime", ""},
+ {R_QUICKTIME, "QUICKTIME_CARBON", ICON_FILE_MOVIE, "QuickTime", ""},
# endif
#endif
#ifdef __sgi
@@ -1508,18 +1550,7 @@
#ifdef WITH_QUICKTIME
static EnumPropertyItem quicktime_codec_type_items[] = {
- {QT_CODECTYPE_RAW, "RAW", 0, "Uncompressed", ""},
- {QT_CODECTYPE_JPEG, "JPEG", 0, "JPEG", ""},
- {QT_CODECTYPE_MJPEGA, "MJPEG_A", 0, "M-JPEG A", ""},
- {QT_CODECTYPE_MJPEGB, "MJPEG_B", 0, "M-JPEG B", ""},
- {QT_CODECTYPE_DVCPAL, "DVCPAL", 0, "DV PAL", ""},
- {QT_CODECTYPE_DVCNTSC, "DVCNTSC", 0, "DV/DVCPRO NTSC", ""},
- {QT_CODECTYPE_DVCPROHD720p, "DVCPROHD720P", 0, "DVCPRO HD 720p"},
- {QT_CODECTYPE_DVCPROHD1080i50, "DVCPROHD1080I50", 0, "DVCPRO HD 1080i50"},
- {QT_CODECTYPE_DVCPROHD1080i60, "DVCPROHD1080I60", 0, "DVCPRO HD 1080i60"},
- {QT_CODECTYPE_MPEG4, "MPEG4", 0, "MPEG4", ""},
- {QT_CODECTYPE_H263, "H263", 0, "H.263", ""},
- {QT_CODECTYPE_H264, "H264", 0, "H.264", ""},
+ {0, "codec", 0, "codec", ""},
{0, NULL, 0, NULL, NULL}};
#endif
@@ -1718,6 +1749,9 @@
prop= RNA_def_property(srna, "quicktime_codec_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "qtcodecsettings.codecType");
RNA_def_property_enum_items(prop, quicktime_codec_type_items);
+ RNA_def_property_enum_funcs(prop, "rna_SceneRenderData_qtcodecsettings_codecType_get",
+ "rna_SceneRenderData_qtcodecsettings_codecType_set",
+ "rna_SceneRenderData_qtcodecsettings_codecType_itemf");
RNA_def_property_ui_text(prop, "Codec", "QuickTime codec type");
RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
Modified: trunk/blender/source/blender/quicktime/apple/qtkit_export.m
===================================================================
--- trunk/blender/source/blender/quicktime/apple/qtkit_export.m 2009-12-02 10:32:39 UTC (rev 25068)
+++ trunk/blender/source/blender/quicktime/apple/qtkit_export.m 2009-12-02 11:23:11 UTC (rev 25069)
@@ -49,10 +49,6 @@
#include "MEM_guardedalloc.h"
-#include "quicktime_import.h"
-#include "quicktime_export.h"
-
-
#ifdef __APPLE__
/* evil */
#ifndef __AIFF__
@@ -65,6 +61,9 @@
#error OSX 10.5 minimum is needed for QTKit
#endif
+#include "quicktime_import.h"
+#include "quicktime_export.h"
+
#endif /* __APPLE__ */
typedef struct QuicktimeExport {
@@ -78,38 +77,67 @@
static struct QuicktimeExport *qtexport;
+#pragma mark rna helper functions
-static NSString *stringWithCodecType(int codecType) {
- switch (codecType) {
- case QT_CODECTYPE_RAW:
- return @"raw ";
- case QT_CODECTYPE_MJPEGA:
- return @"mjpa";
- case QT_CODECTYPE_MJPEGB:
- return @"mjpb";
- case QT_CODECTYPE_DVCPAL:
- return @"dvcp";
- case QT_CODECTYPE_DVCNTSC:
- return @"dvc ";
- case QT_CODECTYPE_MPEG4:
- return @"mp4v";
- case QT_CODECTYPE_H263:
- return @"h263";
- case QT_CODECTYPE_H264:
- return @"avc1";
- case QT_CODECTYPE_DVCPROHD720p:
- return @"dvhp";
- case QT_CODECTYPE_DVCPROHD1080i50:
- return @"dvh5";
- case QT_CODECTYPE_DVCPROHD1080i60:
- return @"dvh6";
-
- case QT_CODECTYPE_JPEG:
- default:
- return @"jpeg";
+
+static QuicktimeCodecTypeDesc qtCodecList[] = {
+ {kRawCodecType, 1, "Uncompressed"},
+ {kJPEGCodecType, 2, "JPEG"},
+ {kMotionJPEGACodecType, 3, "M-JPEG A"},
+ {kMotionJPEGBCodecType, 4, "M-JPEG B"},
+ {kDVCPALCodecType, 5, "DV PAL"},
+ {kDVCNTSCCodecType, 6, "DV/DVCPRO NTSC"},
+ {kDVCPROHD720pCodecType, 7, "DVCPRO HD 720p"},
+ {kDVCPROHD1080i50CodecType, 8, "DVCPRO HD 1080i50"},
+ {kDVCPROHD1080i60CodecType, 9, "DVCPRO HD 1080i60"},
+ {kMPEG4VisualCodecType, 10, "MPEG4"},
+ {kH263CodecType, 11, "H.263"},
+ {kH264CodecType, 12, "H.264"},
+ {0,0,NULL}};
+
+static int qtCodecCount = 12;
+
+int quicktime_get_num_codecs() {
+ return qtCodecCount;
+}
+
+QuicktimeCodecTypeDesc* quicktime_get_codecType_desc(int indexValue) {
+ if ((indexValue>=0) && (indexValue < qtCodecCount))
+ return &qtCodecList[indexValue];
+ else
+ return NULL;
+}
+
+int quicktime_rnatmpvalue_from_codectype(int codecType) {
+ int i;
+ for (i=0;i<qtCodecCount;i++) {
+ if (qtCodecList[i].codecType == codecType)
+ return qtCodecList[i].rnatmpvalue;
}
+
+ return 0;
}
+int quicktime_codecType_from_rnatmpvalue(int rnatmpvalue) {
+ int i;
+ for (i=0;i<qtCodecCount;i++) {
+ if (qtCodecList[i].rnatmpvalue == rnatmpvalue)
+ return qtCodecList[i].codecType;
+ }
+
+ return 0;
+}
+
+
+static NSString *stringWithCodecType(int codecType) {
+ char str[5];
+
+ *((int*)str) = EndianU32_NtoB(codecType);
+ str[4] = 0;
+
+ return [NSString stringWithCString:str encoding:NSASCIIStringEncoding];
+}
+
void makeqtstring (RenderData *rd, char *string) {
char txt[64];
@@ -124,6 +152,7 @@
}
}
+#pragma mark export functions
void start_qt(struct Scene *scene, struct RenderData *rd, int rectx, int recty)
{
@@ -264,7 +293,7 @@
(rd->qtcodecsettings.codecSpatialQuality <0) ||
(rd->qtcodecsettings.codecSpatialQuality > 100)) {
- rd->qtcodecsettings.codecType = QT_CODECTYPE_JPEG;
+ rd->qtcodecsettings.codecType = kJPEGCodecType;
rd->qtcodecsettings.codecSpatialQuality = (codecHighQuality*100)/codecLosslessQuality;
}
}
Modified: trunk/blender/source/blender/quicktime/apple/qtkit_import.m
===================================================================
--- trunk/blender/source/blender/quicktime/apple/qtkit_import.m 2009-12-02 10:32:39 UTC (rev 25068)
+++ trunk/blender/source/blender/quicktime/apple/qtkit_import.m 2009-12-02 11:23:11 UTC (rev 25069)
@@ -137,7 +137,7 @@
uchar *toIBuf = NULL;
int x, y, to_i, from_i;
NSSize bitmapSize;
- NSBitmapImageRep *blBitmapFormatImageRGB,*blBitmapFormatImageRGBA,*bitmapImage;
+ NSBitmapImageRep *blBitmapFormatImageRGB,*blBitmapFormatImageRGBA,*bitmapImage=nil;
NSEnumerator *enumerator;
NSImageRep *representation;
@@ -150,12 +150,13 @@
/*Get the bitmap of the image*/
enumerator = [[sourceImage representations] objectEnumerator];
- while (representation = [enumerator nextObject]) {
+ while ((representation = [enumerator nextObject])) {
if ([representation isKindOfClass:[NSBitmapImageRep class]]) {
bitmapImage = (NSBitmapImageRep *)representation;
break;
}
}
+ if (bitmapImage == nil) return NULL;
if (([bitmapImage bitsPerPixel] == 32) && (([bitmapImage bitmapFormat] & 0x5) == 0)
&& ![bitmapImage isPlanar]) {
Modified: trunk/blender/source/blender/quicktime/apple/quicktime_export.c
===================================================================
--- trunk/blender/source/blender/quicktime/apple/quicktime_export.c 2009-12-02 10:32:39 UTC (rev 25068)
+++ trunk/blender/source/blender/quicktime/apple/quicktime_export.c 2009-12-02 11:23:11 UTC (rev 25069)
@@ -77,6 +77,7 @@
static void QT_CreateMyVideoTrack (int rectx, int recty);
static void QT_EndCreateMyVideoTrack (void);
static void check_renderbutton_framerate(struct RenderData *rd);
+static int get_qtcodec_settings(struct RenderData *rd);
typedef struct QuicktimeExport {
@@ -113,7 +114,58 @@
static int sframe;
+/* RNA functions */
+static QuicktimeCodecTypeDesc qtCodecList[] = {
+ {kRawCodecType, 1, "Uncompressed"},
+ {kJPEGCodecType, 2, "JPEG"},
+ {kMotionJPEGACodecType, 3, "M-JPEG A"},
+ {kMotionJPEGBCodecType, 4, "M-JPEG B"},
+ {kDVCPALCodecType, 5, "DV PAL"},
+ {kDVCNTSCCodecType, 6, "DV/DVCPRO NTSC"},
+ {kDVCPROHD720pCodecType, 7, "DVCPRO HD 720p"},
+ {kDVCPROHD1080i50CodecType, 8, "DVCPRO HD 1080i50"},
+ {kDVCPROHD1080i60CodecType, 9, "DVCPRO HD 1080i60"},
+ {kMPEG4VisualCodecType, 10, "MPEG4"},
+ {kH263CodecType, 11, "H.263"},
+ {kH264CodecType, 12, "H.264"},
+ {0,0,NULL}};
+
+static int qtCodecCount = 12;
+
+int quicktime_get_num_codecs() {
+ return qtCodecCount;
+}
+
+QuicktimeCodecTypeDesc* quicktime_get_codecType_desc(int indexValue) {
+ if ((indexValue>=0) && (indexValue < qtCodecCount))
+ return &qtCodecList[indexValue];
+ else
+ return NULL;
+}
+
+int quicktime_rnatmpvalue_from_codectype(int codecType) {
+ int i;
+ for (i=0;i<qtCodecCount;i++) {
+ if (qtCodecList[i].codecType == codecType)
+ return qtCodecList[i].rnatmpvalue;
+ }
+
+ return 0;
+}
+
+int quicktime_codecType_from_rnatmpvalue(int rnatmpvalue) {
+ int i;
+ for (i=0;i<qtCodecCount;i++) {
+ if (qtCodecList[i].rnatmpvalue == rnatmpvalue)
+ return qtCodecList[i].codecType;
+ }
+
+ return 0;
+}
+
+
+
static void CheckError(OSErr err, char *msg)
{
if(err != noErr) printf("%s: %d\n", msg, err);
@@ -128,10 +180,9 @@
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);
@@ -183,8 +234,6 @@
{
Handle myHandle = NULL;
ComponentResult myErr = noErr;
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list