diff options
Diffstat (limited to 'source/blender/imbuf/intern')
-rw-r--r-- | source/blender/imbuf/intern/IMB_anim.h | 8 | ||||
-rw-r--r-- | source/blender/imbuf/intern/anim.c | 74 | ||||
-rw-r--r-- | source/blender/imbuf/intern/util.c | 18 |
3 files changed, 99 insertions, 1 deletions
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); } |