Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Schlaile <peter@schlaile.de>2008-06-03 01:35:57 +0400
committerPeter Schlaile <peter@schlaile.de>2008-06-03 01:35:57 +0400
commitca8aa8c901934dc0e3eb1b65618d40bfb65f9111 (patch)
tree72e3ea5d2f5e224a683e064d34f6ee47eff90c59 /source/blender/imbuf
parent8a5f36219214b4a5b8348b8e200ef5aac2297963 (diff)
== RED one (redcode) ==
This adds redcode (the file format of RED one, R3D) support to blender. Seems to work fine with the footage I found on the web, but keep in mind, that because of the unoptimized nature of libopenjpeg, frame decoding isn't that fast. It is also a rather challenging task, to make 4k-float-footage realtime :)
Diffstat (limited to 'source/blender/imbuf')
-rw-r--r--source/blender/imbuf/SConscript8
-rw-r--r--source/blender/imbuf/intern/IMB_anim.h8
-rw-r--r--source/blender/imbuf/intern/anim.c74
-rw-r--r--source/blender/imbuf/intern/util.c18
4 files changed, 107 insertions, 1 deletions
diff --git a/source/blender/imbuf/SConscript b/source/blender/imbuf/SConscript
index f9e46b20d9a..7349f481731 100644
--- a/source/blender/imbuf/SConscript
+++ b/source/blender/imbuf/SConscript
@@ -27,6 +27,14 @@ if env['WITH_BF_FFMPEG'] == 1:
defs.append('WITH_FFMPEG')
incs += ' ' + env['BF_FFMPEG_INC']
+if env['WITH_BF_OPENJPEG'] == 1:
+ defs.append('WITH_OPENJPEG')
+ incs += ' ' + env['BF_OPENJPEG_INC']
+
+if env['WITH_BF_REDCODE'] == 1:
+ defs.append('WITH_REDCODE')
+ incs += ' ' + env['BF_REDCODE_INC']
+
if env['WITH_BF_QUICKTIME']==1:
incs += ' ' + env['BF_QUICKTIME_INC']
defs.append('WITH_QUICKTIME')
diff --git a/source/blender/imbuf/intern/IMB_anim.h b/source/blender/imbuf/intern/IMB_anim.h
index 4948ff11b4a..71d35949833 100644
--- a/source/blender/imbuf/intern/IMB_anim.h
+++ b/source/blender/imbuf/intern/IMB_anim.h
@@ -81,6 +81,10 @@
#include <ffmpeg/swscale.h>
#endif
+#ifdef WITH_REDCODE
+#include <redcode/format.h>
+#endif
+
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
@@ -116,6 +120,7 @@
#define ANIM_AVI (1 << 6)
#define ANIM_QTIME (1 << 7)
#define ANIM_FFMPEG (1 << 8)
+#define ANIM_REDCODE (1 << 9)
#define ANIM5_MMAP 0
#define ANIM5_MALLOC 1
@@ -184,6 +189,9 @@ struct anim {
int videoStream;
#endif
+#ifdef WITH_REDCODE
+ struct redcode_handle * redcodeCtx;
+#endif
};
#endif
diff --git a/source/blender/imbuf/intern/anim.c b/source/blender/imbuf/intern/anim.c
index d2743b680d8..f9c584fba39 100644
--- a/source/blender/imbuf/intern/anim.c
+++ b/source/blender/imbuf/intern/anim.c
@@ -96,6 +96,11 @@
#endif
+#ifdef WITH_REDCODE
+#include <redcode/format.h>
+#include <redcode/codec.h>
+#endif
+
/****/
#ifdef __sgi
@@ -830,6 +835,58 @@ static void free_anim_ffmpeg(struct anim * anim) {
#endif
+#ifdef WITH_REDCODE
+
+static int startredcode(struct anim * anim) {
+ anim->redcodeCtx = redcode_open(anim->name);
+ if (!anim->redcodeCtx) {
+ return -1;
+ }
+ anim->duration = redcode_get_length(anim->redcodeCtx);
+
+ return 0;
+}
+
+static ImBuf * redcode_fetchibuf(struct anim * anim, int position) {
+ struct ImBuf * ibuf;
+ struct redcode_frame * frame;
+ struct redcode_frame_raw * raw_frame;
+
+ if (!anim->redcodeCtx) {
+ return NULL;
+ }
+
+ frame = redcode_read_video_frame(anim->redcodeCtx, position);
+
+ if (!frame) {
+ return NULL;
+ }
+
+ raw_frame = redcode_decode_video_raw(frame, 1);
+
+ redcode_free_frame(frame);
+
+ if (!raw_frame) {
+ return NULL;
+ }
+
+ ibuf = IMB_allocImBuf(raw_frame->width * 2,
+ raw_frame->height * 2, 32, IB_rectfloat, 0);
+
+ redcode_decode_video_float(raw_frame, ibuf->rect_float, 1);
+
+ return ibuf;
+}
+
+static void free_anim_redcode(struct anim * anim) {
+ if (anim->redcodeCtx) {
+ redcode_close(anim->redcodeCtx);
+ anim->redcodeCtx = 0;
+ }
+ anim->duration = 0;
+}
+
+#endif
/* probeer volgende plaatje te lezen */
/* Geen plaatje, probeer dan volgende animatie te openen */
@@ -849,6 +906,10 @@ static struct ImBuf * anim_getnew(struct anim * anim) {
#ifdef WITH_FFMPEG
free_anim_ffmpeg(anim);
#endif
+#ifdef WITH_REDCODE
+ free_anim_redcode(anim);
+#endif
+
if (anim->curtype != 0) return (0);
anim->curtype = imb_get_anim_type(anim->name);
@@ -888,8 +949,13 @@ static struct ImBuf * anim_getnew(struct anim * anim) {
ibuf = IMB_allocImBuf (anim->x, anim->y, 24, 0, 0);
break;
#endif
+#ifdef WITH_REDCODE
+ case ANIM_REDCODE:
+ if (startredcode(anim)) return (0);
+ ibuf = IMB_allocImBuf (8, 8, 32, 0, 0);
+ break;
}
-
+#endif
return(ibuf);
}
@@ -970,6 +1036,12 @@ struct ImBuf * IMB_anim_absolute(struct anim * anim, int position) {
if (ibuf) anim->curposition = position;
break;
#endif
+#ifdef WITH_REDCODE
+ case ANIM_REDCODE:
+ ibuf = redcode_fetchibuf(anim, position);
+ if (ibuf) anim->curposition = position;
+ break;
+#endif
}
if (ibuf) {
diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c
index 632a471ecd0..4f6730db1f1 100644
--- a/source/blender/imbuf/intern/util.c
+++ b/source/blender/imbuf/intern/util.c
@@ -321,6 +321,19 @@ static int isffmpeg (char *filename) {
}
#endif
+#ifdef WITH_REDCODE
+static int isredcode(char * filename)
+{
+ struct redcode_handle * h = redcode_open(filename);
+ if (!h) {
+ return 0;
+ }
+ redcode_close(h);
+ return 1;
+}
+
+#endif
+
int imb_get_anim_type(char * name) {
int type;
struct stat st;
@@ -355,6 +368,9 @@ int imb_get_anim_type(char * name) {
if (isffmpeg(name)) return (ANIM_FFMPEG);
# endif
#endif
+#ifdef WITH_REDCODE
+ if (isredcode(name)) return (ANIM_REDCODE);
+#endif
type = IMB_ispic(name);
if (type == ANIM) return (ANIM_ANIM5);
if (type) return(ANIM_SEQUENCE);
@@ -369,6 +385,7 @@ int IMB_isanim(char *filename) {
if( BLI_testextensie(filename, ".avi")
|| BLI_testextensie(filename, ".flc")
|| BLI_testextensie(filename, ".dv")
+ || BLI_testextensie(filename, ".r3d")
|| BLI_testextensie(filename, ".mov")
|| BLI_testextensie(filename, ".movie")
|| BLI_testextensie(filename, ".mv")) {
@@ -379,6 +396,7 @@ int IMB_isanim(char *filename) {
} else { // no quicktime
if( BLI_testextensie(filename, ".avi")
|| BLI_testextensie(filename, ".dv")
+ || BLI_testextensie(filename, ".r3d")
|| BLI_testextensie(filename, ".mv")) {
type = imb_get_anim_type(filename);
}