diff --git a/trunk/blender/config/linux2-config.py b/trunk/blender/config/linux2-config.py index edc7f26..bd323e4 100644 --- a/trunk/blender/config/linux2-config.py +++ b/trunk/blender/config/linux2-config.py @@ -119,7 +119,7 @@ WITH_BF_FFMPEG = 'false' # -DWITH_FFMPEG BF_FFMPEG = '/usr' BF_FFMPEG_INC = '${BF_FFMPEG}/include' BF_FFMPEG_LIBPATH='${BF_FFMPEG}/lib' -BF_FFMPEG_LIB = 'avformat avcodec avutil' +BF_FFMPEG_LIB = 'avformat avcodec avutil swscale' # Mesa Libs should go here if your using them as well.... WITH_BF_STATICOPENGL = 'false' diff --git a/trunk/blender/source/blender/blenkernel/intern/writeffmpeg.c b/trunk/blender/source/blender/blenkernel/intern/writeffmpeg.c index 703f280..8576f59 100644 --- a/trunk/blender/source/blender/blenkernel/intern/writeffmpeg.c +++ b/trunk/blender/source/blender/blenkernel/intern/writeffmpeg.c @@ -32,6 +32,7 @@ #include #include #include +#include #if LIBAVFORMAT_VERSION_INT < (49 << 16) #define FFMPEG_OLD_FRAME_RATE 1 @@ -258,6 +259,7 @@ static void write_video_frame(AVFrame* frame) static AVFrame* generate_video_frame(uint8_t* pixels) { uint8_t* rendered_frame; + static struct SwsContext *img_convert_ctx; AVCodecContext* c = get_codec_from_stream(video_stream); int width = c->width; @@ -317,8 +319,18 @@ static AVFrame* generate_video_frame(uint8_t* pixels) } if (c->pix_fmt != PIX_FMT_RGBA32) { - img_convert((AVPicture*)current_frame, c->pix_fmt, - (AVPicture*)rgb_frame, PIX_FMT_RGBA32, width, height); + if (img_convert_ctx == NULL) + img_convert_ctx = sws_getContext(c->width, c->height, + PIX_FMT_RGBA32, + c->width, c->height, + c->pix_fmt, + SWS_BICUBIC, + NULL, NULL, NULL); + sws_scale(img_convert_ctx, rgb_frame->data, + rgb_frame->linesize, 0, c->height, + current_frame->data, current_frame->linesize); +// img_convert((AVPicture*)current_frame, c->pix_fmt, +// (AVPicture*)rgb_frame, PIX_FMT_RGBA32, width, height); delete_picture(rgb_frame); } return current_frame; diff --git a/trunk/blender/source/blender/imbuf/intern/anim.c b/trunk/blender/source/blender/imbuf/intern/anim.c index 5b185a4..5cdb651 100644 --- a/trunk/blender/source/blender/imbuf/intern/anim.c +++ b/trunk/blender/source/blender/imbuf/intern/anim.c @@ -89,6 +89,7 @@ #include #include #include +#include #if LIBAVFORMAT_VERSION_INT < (49 << 16) #define FFMPEG_OLD_FRAME_RATE 1 @@ -619,6 +620,7 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position) { AVPacket packet; int64_t pts_to_search = 0; int pos_found = 1; + static struct SwsContext *img_convert_ctx; if (anim == 0) return (0); @@ -706,12 +708,32 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position) { unsigned char * p =(unsigned char*) ibuf->rect; unsigned char * e = p + anim->x * anim->y * 4; - img_convert((AVPicture *)anim->pFrameRGB, - PIX_FMT_RGBA32, - (AVPicture*)anim->pFrame, - anim->pCodecCtx->pix_fmt, - anim->pCodecCtx->width, - anim->pCodecCtx->height); +// img_convert((AVPicture *)anim->pFrameRGB, +// PIX_FMT_RGBA32, +// (AVPicture*)anim->pFrame, +// anim->pCodecCtx->pix_fmt, +// anim->pCodecCtx->width, +// anim->pCodecCtx->height); + if (img_convert_ctx == NULL) { + img_convert_ctx = sws_getContext( + anim->pCodecCtx->width, + anim->pCodecCtx->height, + anim->pCodecCtx->pix_fmt, + anim->pCodecCtx->width, + anim->pCodecCtx->height, + PIX_FMT_RGBA32, + SWS_BICUBIC, + NULL, NULL, NULL); + } + sws_scale(img_convert_ctx, + anim->pFrame->data, + anim->pFrame->linesize, + 0, + anim->pCodecCtx->height, + anim->pFrameRGB->data, + anim->pFrameRGB->linesize); + + IMB_flipy(ibuf); if (G.order == L_ENDIAN) { /* BGRA -> RGBA */