* Copyright (C) 2003-2004 Ushodaya Enterprises Limited
* Author: Charles Yates <charles.yates@pandora.be>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful,
+ * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// Local header files
// ffmpeg Header files
#include <avformat.h>
+#ifdef SWSCALE
+#include <swscale.h>
+#endif
// System header files
#include <stdlib.h>
static inline void convert_image( AVFrame *frame, uint8_t *buffer, int pix_fmt, mlt_image_format format, int width, int height )
{
+#ifdef SWSCALE
+ if ( format == mlt_image_yuv420p )
+ {
+ struct SwsContext *context = sws_getContext( width, height, pix_fmt,
+ width, height, PIX_FMT_YUV420P, SWS_FAST_BILINEAR, NULL, NULL, NULL);
+ AVPicture output;
+ output.data[0] = buffer;
+ output.data[1] = buffer + width * height;
+ output.data[2] = buffer + ( 3 * width * height ) / 2;
+ output.linesize[0] = width;
+ output.linesize[1] = width >> 1;
+ output.linesize[2] = width >> 1;
+ sws_scale( context, frame->data, frame->linesize, 0, height,
+ output.data, output.linesize);
+ sws_freeContext( context );
+ }
+ else if ( format == mlt_image_rgb24 )
+ {
+ struct SwsContext *context = sws_getContext( width, height, pix_fmt,
+ width, height, PIX_FMT_RGB24, SWS_FAST_BILINEAR, NULL, NULL, NULL);
+ AVPicture output;
+ avpicture_fill( &output, buffer, PIX_FMT_RGB24, width, height );
+ sws_scale( context, frame->data, frame->linesize, 0, height,
+ output.data, output.linesize);
+ sws_freeContext( context );
+ }
+ else
+ {
+ struct SwsContext *context = sws_getContext( width, height, pix_fmt,
+ width, height, PIX_FMT_YUYV422, SWS_FAST_BILINEAR, NULL, NULL, NULL);
+ AVPicture output;
+ avpicture_fill( &output, buffer, PIX_FMT_YUYV422, width, height );
+ sws_scale( context, frame->data, frame->linesize, 0, height,
+ output.data, output.linesize);
+ sws_freeContext( context );
+ }
+#else
if ( format == mlt_image_yuv420p )
{
AVPicture pict;
avpicture_fill( &output, buffer, PIX_FMT_YUV422, width, height );
img_convert( &output, PIX_FMT_YUV422, (AVPicture *)frame, pix_fmt, width, height );
}
+#endif
}
/** Get an image from a frame.