Index: OpenSceneGraph/trunk/src/osgPlugins/ffmpeg/FFmpegDecoderVideo.cpp
===================================================================
--- OpenSceneGraph/trunk/src/osgPlugins/ffmpeg/FFmpegDecoderVideo.cpp (revision 9837)
+++ OpenSceneGraph/trunk/src/osgPlugins/ffmpeg/FFmpegDecoderVideo.cpp (revision 9854)
@@ -6,4 +6,5 @@
 #include <string.h>
 
+#if 0
 extern "C" 
 {
@@ -12,4 +13,5 @@
 
 };
+#endif
 
 namespace osgFFmpeg {
@@ -28,5 +30,6 @@
     m_user_data(0),
     m_publish_func(0),
-    m_exit(false)
+    m_exit(false),
+    m_swscale_ctx(0)
 {
 
@@ -41,4 +44,10 @@
         m_exit = true;
         join();
+    }
+    
+    if (m_swscale_ctx)
+    {
+        sws_freeContext(m_swscale_ctx);
+        m_swscale_ctx = 0;
     }
 }
@@ -211,4 +220,23 @@
 }
 
+int FFmpegDecoderVideo::convert(AVPicture *dst, int dst_pix_fmt, const AVPicture *src,
+            int src_pix_fmt, int src_width, int src_height)
+{
+#ifdef USE_SWSCALE
+    if (m_swscale_ctx==0)
+    {
+        m_swscale_ctx = sws_getContext(src_width, src_height, src_pix_fmt,
+                                      src_width, src_height, dst_pix_fmt,                                    
+                                      SWS_BILINEAR, NULL, NULL, NULL);
+    }
+    
+    return sws_scale(m_swscale_ctx,
+           src->data, src->linesize, 0, src_height,
+           dst->data, dst->linesize);
+#else
+    return convert(dst, dst_pix_fmt, src,
+                   src_pix_fmt, src_width, src_height)
+#endif
+}
 
 
@@ -231,5 +259,5 @@
         yuva420pToRgba(dst, src, width(), height());
     else
-        img_convert(dst, PIX_FMT_RGB32, src, m_context->pix_fmt, width(), height());
+        convert(dst, PIX_FMT_RGB32, src, m_context->pix_fmt, width(), height());
 
     // Flip and swap buffer
@@ -267,5 +295,5 @@
 void FFmpegDecoderVideo::yuva420pToRgba(AVPicture * const dst, const AVPicture * const src, int width, int height)
 {
-    img_convert(dst, PIX_FMT_RGB32, src, m_context->pix_fmt, width, height);
+    convert(dst, PIX_FMT_RGB32, src, m_context->pix_fmt, width, height);
 
     const size_t bpp = 4;
