diff options
author | Peter Schlaile <peter@schlaile.de> | 2008-06-03 01:35:57 +0400 |
---|---|---|
committer | Peter Schlaile <peter@schlaile.de> | 2008-06-03 01:35:57 +0400 |
commit | ca8aa8c901934dc0e3eb1b65618d40bfb65f9111 (patch) | |
tree | 72e3ea5d2f5e224a683e064d34f6ee47eff90c59 /source/blender/imbuf/intern/anim.c | |
parent | 8a5f36219214b4a5b8348b8e200ef5aac2297963 (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/intern/anim.c')
-rw-r--r-- | source/blender/imbuf/intern/anim.c | 74 |
1 files changed, 73 insertions, 1 deletions
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) { |