Remove .gitignore do nothing is ignored.
[synfig.git] / synfig-core / trunk / src / modules / mod_libavcodec / trgt_av.cpp
index c7067d8..5ad733a 100644 (file)
@@ -6,6 +6,8 @@
 **
 **     \legal
 **     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**  Copyright (c) 2008 Paul Wise
+**  Copyright (c) 2008 Gerco Ballintijn
 **
 **     This package is free software; you can redistribute it and/or
 **     modify it under the terms of the GNU General Public License as
 
 extern "C"
 {
-#include <avformat.h>
+
+/*
+       ffmpeg library headers have historically had multiple locations.
+       We should check all of the locations to be more portable.
+*/
+
+#ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
+#      include <libavformat/avformat.h>
+#elif defined(HAVE_AVFORMAT_H)
+#      include <avformat.h>
+#elif defined(HAVE_FFMPEG_AVFORMAT_H)
+#      include <ffmpeg/avformat.h>
+#endif
+
+#ifdef WITH_LIBSWSCALE
+#ifdef HAVE_LIBSWSCALE_SWSCALE_H
+#      include <libswscale/swscale.h>
+#elif defined(HAVE_SWSCALE_H)
+#      include <swscale.h>
+#elif defined(HAVE_FFMPEG_SWSCALE_H)
+#      include <ffmpeg/swscale.h>
+#endif
+#endif
+
 }
 
 #include <synfig/general.h>
@@ -389,9 +414,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 WITH_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;
                }
@@ -642,7 +681,7 @@ public:
 
        void CleanUp()
        {
-               int i;
+               unsigned int i;
 
                if(picture) free_picture(picture);
 
@@ -674,7 +713,11 @@ public:
                        if(!(format->flags & AVFMT_NOFILE))
                        {
                                /* close the output file */
+#if LIBAVFORMAT_VERSION_INT >= (52<<16)
+                               url_fclose(formatc->pb);
+#else
                                url_fclose(&formatc->pb);
+#endif
                        }
 
                        /* free the stream */