// 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.