Apply 2036627, fix Debian 487639: for mod_libav, allow the use of libswscale instead...
[synfig.git] / synfig-core / trunk / src / modules / mod_libavcodec / trgt_av.cpp
index f1d9333..e067761 100644 (file)
@@ -36,6 +36,9 @@
 extern "C"
 {
 #include <avformat.h>
+#ifdef HAVE_LIBSWSCALE
+#      include <ffmpeg/swscale.h>
+#endif
 }
 
 #include <synfig/general.h>
@@ -389,9 +392,23 @@ public:
                if ( pict && context->pix_fmt != PIX_FMT_RGB24 )
                {
                        //We're using RGBA at the moment, write custom conversion code later (get less accuracy errors)
+#ifdef HAVE_LIBSWSCALE
+                       struct SwsContext* img_convert_ctx =
+                               sws_getContext(context->width, context->height, PIX_FMT_RGB24,
+                                       context->width, context->height, context->pix_fmt,
+                                       SWS_BICUBIC, NULL, NULL, NULL);
+
+                       sws_scale(img_convert_ctx, pict->data, pict->linesize, 
+                               
+                               0, context->height, encodable->data,
+                               encodable->linesize);
+
+                       sws_freeContext (img_convert_ctx);
+#else
                        img_convert((AVPicture *)encodable, context->pix_fmt,
                                                (AVPicture *)pict, PIX_FMT_RGB24,
                                                context->width, context->height);
+#endif
 
                        pict = encodable;
                }