--- old-MpVideoBuf.cpp	Tue Oct  7 15:36:14 2008
+++ MpVideoBuf.cpp	Tue Oct  7 17:00:48 2008
@@ -18,7 +18,8 @@
 
 extern "C" {
 #  include <avcodec.h>
-	
+	//paulo
+#include <libswscale/swscale.h>
 }
 
 #endif // SIPX_VIDEO ]
@@ -257,13 +258,32 @@
 	   avpicture_fill(&srcPicture, (uint8_t*)getWriteDataPtr(), srcPixFmt, width, height);
 	   avpicture_fill(&dstPicture, (uint8_t*)pBuffer, dstPixFmt, width, height);
 
-	    // Do convert
-	    if (img_convert(&dstPicture, dstPixFmt,
-	   &srcPicture, srcPixFmt,
-	   width, height) >= 0)
-	   {
-	   retcode =  OS_SUCCESS;
-	   }
+	   //paulo
+
+	   static struct SwsContext *img_convert_ctx;
+	   // Convert the image into YUV format that SDL uses
+	   if(img_convert_ctx == NULL) {//apenas a 1º vez aqui dentro
+		   int w = width;
+		   int h = height;
+
+		   img_convert_ctx = sws_getContext(w, h, 
+			   srcPixFmt, 
+			   w, h, dstPixFmt, SWS_BICUBIC, 
+			   NULL, NULL, NULL);
+		   if(img_convert_ctx == NULL) {
+			   fprintf(stderr, "Cannot initialize the conversion context!\n");
+			   exit(1);
+			   }
+		   }
+	   if(sws_scale(img_convert_ctx, srcPicture.data, 
+		   srcPicture.linesize, 0, 
+		   height, 
+		   dstPicture.data,dstPicture.linesize)){
+
+			   retcode =  OS_SUCCESS;
+		   }
+
+	 
 
 	   }
 
@@ -305,13 +325,30 @@
       avpicture_fill(&dstPicture, (uint8_t*)getWriteDataPtr(), dstPixFmt, width, height);
 
       // Do convert
-      if (img_convert(&dstPicture, dstPixFmt, &srcPicture, srcPixFmt, width, height) >= 0)
-      {
-         retcode =  OS_SUCCESS;
-      }
-    //paulo
+	   
+
+	   static struct SwsContext *img_convert_ctx;
+	   // Convert the image into YUV format that SDL uses
+	   if(img_convert_ctx == NULL) {//apenas a 1º vez aqui dentro
+		   int w = width;
+		   int h = height;
+
+		   img_convert_ctx = sws_getContext(w, h, 
+			   srcPixFmt, 
+			   w, h, dstPixFmt, SWS_BICUBIC, 
+			   NULL, NULL, NULL);
+		   if(img_convert_ctx == NULL) {
+			   fprintf(stderr, "Cannot initialize the conversion context!\n");
+			   exit(1);
+			   }
+		   }
+	   if(sws_scale(img_convert_ctx, srcPicture.data, 
+		   srcPicture.linesize, 0, 
+		   height, 
+		   dstPicture.data,dstPicture.linesize)){
 
-	
+			   retcode =  OS_SUCCESS;
+		   }
 
 
    }
