+@@ -293,13 +298,81 @@
+ av_free(m_frameDeinterlaced);
+ m_frameDeinterlaced = NULL;
+ MEM_freeN(m_frameRGB->data[0]);
+- av_free(m_frameRGB);
++ av_frame_free(&m_frameRGB);
+ m_frameRGB = NULL;
+ return -1;
+ }
+ return 0;
+ }
+
++void VideoFFmpeg::delete_filter_graph(VideoFFmpeg* video) {
++ if (video->filter_graph) {
++ av_frame_free(&video->filter_frame);
++ avfilter_graph_free(&video->filter_graph);
++ }
++}
++
++int VideoFFmpeg::init_filter_graph(VideoFFmpeg* video, enum AVPixelFormat pixfmt, int width, int height) {
++ AVFilterInOut *inputs = NULL, *outputs = NULL;
++ char args[512];
++ int res;
++
++ delete_filter_graph(video);
++ video->filter_graph = avfilter_graph_alloc();
++ snprintf(args, sizeof(args),
++ "buffer=video_size=%dx%d:pix_fmt=%d:time_base=1/1:pixel_aspect=0/1[in];"
++ "[in]yadif[out];"
++ "[out]buffersink",
++ width, height, pixfmt);
++ res = avfilter_graph_parse2(video->filter_graph, args, &inputs, &outputs);
++ if (res < 0)
++ return res;
++ if(inputs || outputs)
++ return -1;
++ res = avfilter_graph_config(video->filter_graph, NULL);
++ if (res < 0)
++ return res;
++
++ video->buffersrc_ctx = avfilter_graph_get_filter(video->filter_graph, "Parsed_buffer_0");
++ video->buffersink_ctx = avfilter_graph_get_filter(video->filter_graph, "Parsed_buffersink_2");
++ if (!video->buffersrc_ctx || !video->buffersink_ctx)
++ return -1;
++ video->filter_frame = av_frame_alloc();
++ video->last_width = width;
++ video->last_height = height;
++ video->last_pixfmt = pixfmt;
++
++ return 0;
++}
++
++int VideoFFmpeg::process_filter_graph(VideoFFmpeg* video, AVPicture *dst, const AVPicture *src,
++ enum AVPixelFormat pixfmt, int width, int height) {
++ int res;
++
++ if (!video->filter_graph || width != video->last_width ||
++ height != video->last_height || pixfmt != video->last_pixfmt) {
++ res = init_filter_graph(video, pixfmt, width, height);
++ if (res < 0)
++ return res;
++ }
++
++ memcpy(video->filter_frame->data, src->data, sizeof(src->data));
++ memcpy(video->filter_frame->linesize, src->linesize, sizeof(src->linesize));
++ video->filter_frame->width = width;
++ video->filter_frame->height = height;
++ video->filter_frame->format = pixfmt;
++ res = av_buffersrc_add_frame(video->buffersrc_ctx, video->filter_frame);
++ if (res < 0)
++ return res;
++ res = av_buffersink_get_frame(video->buffersink_ctx, video->filter_frame);
++ if (res < 0)
++ return res;
++ av_picture_copy(dst, (const AVPicture *) video->filter_frame, pixfmt, width, height);
++ av_frame_unref(video->filter_frame);
++
++ return 0;
++}
++
+ /*
+ * This thread is used to load video frame asynchronously.
+ * It provides a frame caching service.
+@@ -392,7 +465,7 @@
+ {
+ if (video->m_deinterlace)
+ {
+- if (avpicture_deinterlace(
++ if (process_filter_graph(video,
+ (AVPicture*) video->m_frameDeinterlaced,
+ (const AVPicture*) video->m_frame,
+ video->m_codecCtx->pix_fmt,
+@@ -486,14 +559,14 @@
+ {
+ BLI_remlink(&m_frameCacheBase, frame);
+ MEM_freeN(frame->frame->data[0]);
+- av_free(frame->frame);
++ av_frame_free(&frame->frame);
+ delete frame;
+ }
+ while ((frame = (CacheFrame *)m_frameCacheFree.first) != NULL)
+ {
+ BLI_remlink(&m_frameCacheFree, frame);
+ MEM_freeN(frame->frame->data[0]);
+- av_free(frame->frame);
++ av_frame_free(&frame->frame);
+ delete frame;
+ }
+ while ((packet = (CachePacket *)m_packetCacheBase.first) != NULL)
+@@ -1057,7 +1130,7 @@
+
+ if (m_deinterlace)
+ {
+- if (avpicture_deinterlace(
++ if (process_filter_graph(this,
+ (AVPicture*) m_frameDeinterlaced,
+ (const AVPicture*) m_frame,
+ m_codecCtx->pix_fmt,
+diff -ur blender-2.76/source/gameengine/VideoTexture/VideoFFmpeg.h blender-2.76.ffmpeg/source/gameengine/VideoTexture/VideoFFmpeg.h
+--- blender-2.76/source/gameengine/VideoTexture/VideoFFmpeg.h 2015-10-10 10:20:56.000000000 +0200
++++ blender-2.76.ffmpeg/source/gameengine/VideoTexture/VideoFFmpeg.h 2016-04-16 15:31:11.527370628 +0200
+@@ -39,6 +39,9 @@
+ extern "C" {
+ #include <pthread.h>
+ #include "ffmpeg_compat.h"
++#include <libavfilter/avfilter.h>
++#include <libavfilter/buffersrc.h>
++#include <libavfilter/buffersink.h>
+ #include "DNA_listBase.h"
+ #include "BLI_threads.h"
+ #include "BLI_blenlib.h"
+@@ -207,6 +210,18 @@
+
+ AVFrame *allocFrameRGB();
+ static void *cacheThread(void *);
++
++ AVFilterContext *buffersink_ctx;
++ AVFilterContext *buffersrc_ctx;
++ AVFilterGraph *filter_graph;
++ AVFrame *filter_frame;
++ int last_width;
++ int last_height;
++ enum AVPixelFormat last_pixfmt;
++
++ static void delete_filter_graph(VideoFFmpeg* video);
++ static int init_filter_graph(VideoFFmpeg* video, enum AVPixelFormat pixfmt, int width, int height);
++ static int process_filter_graph(VideoFFmpeg* video, AVPicture *dst, const AVPicture *src, enum AVPixelFormat pixfmt, int width, int height);
+ };
+
+ inline VideoFFmpeg *getFFmpeg(PyImage *self)