+2007-02-07 Dan Dennedy <dan@dennedy.org>
+ Added ffmpeg libswscale support to avformat module (requires configure
+ option --avformat-swscale)
+
2006-12-07 Dan Dennedy <dan@dennedy.org
Applied patch from Stephane Fillod to make configure run with bash
since it uses bash-specific features. Also, patches headers to
LDFLAGS+=-lavformat$(AVFORMAT_SUFFIX) -lavcodec$(AVFORMAT_SUFFIX) -lavutil$(AVFORMAT_SUFFIX) $(EXTRA_LIBS) -lmlt
+ifdef MMX_FLAGS
+ CFLAGS+=-DSWSCALE
+ LDFLAGS+=-lswscale$(AVFORMAT_SUFFIX)
+endif
+
SRCS := $(OBJS:.o=.c)
all: $(TARGET)
--avformat-static=path - Link against a static ffmpeg dev tree
--avformat-ldextra=libs - Provide additional libs to link with
--avformat-suffix=suff - Specify a custom suffix for an ffmpeg shared build
+ --avformat-swscale - Use ffmpeg libswcale instead of img_convert
EOF
export extra_libs=
export svn_ffmpeg=
export avformat_suffix=
+ export swscale=false
if [ "$shared_ffmpeg" != "" -a -f "$shared_ffmpeg" ]
then
--avformat-svn ) svn_ffmpeg=true ;;
--avformat-cvs ) svn_ffmpeg=true ;;
--avformat-suffix=* ) avformat_suffix="${i#--avformat-suffix=}" ;;
+ --avformat-swscale ) swscale=true ;;
esac
done
echo "LDFLAGS+=-L$static_ffmpeg/libavformat -L$static_ffmpeg/libavcodec -L$static_ffmpeg/libavutil" >> config.mak
[ $targetos = "Darwin" ] &&
echo "LDFLAGS+=-single_module" >> config.mak
+ [ "$swscale" != "" ] && echo "SWSCALE=1" >> config.mak
else
echo "avformat: Invalid path specified: $static_ffmpeg"
touch ../disable-avformat
then
echo "CFLAGS+=-I$shared_ffmpeg/include/ffmpeg " >> config.mak
echo "LDFLAGS+=-L$shared_ffmpeg/$LIBDIR" >> config.mak
+ [ "$swscale" != "" ] && echo "SWSCALE=1" >> config.mak
else
echo "avformat: No build environment found. "
echo " Try configuring mlt with --avformat-svn."
// avformat header files
#include <avformat.h>
+#ifdef SWSCALE
+#include <swscale.h>
+#endif
//
// This structure should be extended and made globally available in mlt
}
// Do the colour space conversion
+#ifdef SWSCALE
+ struct SwsContext *context = sws_getContext( width, height, PIX_FMT_YUV422,
+ width, height, video_st->codec->pix_fmt, SWS_FAST_BILINEAR, NULL, NULL, NULL);
+ sws_scale( context, input->data, input->linesize, 0, height,
+ output->data, output->linesize);
+ sws_freeContext( context );
+#else
img_convert( ( AVPicture * )output, video_st->codec->pix_fmt, ( AVPicture * )input, PIX_FMT_YUV422, width, height );
+#endif
// Apply the alpha if applicable
if ( video_st->codec->pix_fmt == PIX_FMT_RGBA32 )
// ffmpeg Header files
#include <avformat.h>
+#ifdef SWSCALE
+#include <swscale.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
{
AVPicture input;
AVPicture output;
- avpicture_fill( &output, out, out_fmt, width, height );
avpicture_fill( &input, in, in_fmt, width, height );
+ avpicture_fill( &output, out, out_fmt, width, height );
+#ifdef SWSCALE
+ struct SwsContext *context = sws_getContext( width, height, in_fmt,
+ width, height, out_fmt, SWS_FAST_BILINEAR, NULL, NULL, NULL);
+ sws_scale( context, input.data, input.linesize, 0, height,
+ output.data, output.linesize);
+ sws_freeContext( context );
+#else
img_convert( &output, out_fmt, &input, in_fmt, width, height );
+#endif
}
/** Do it :-).
// 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.