From ad978de549f9d227326f54b1e8903f8c270d7e94 Mon Sep 17 00:00:00 2001 From: nicodvb Date: Mon, 9 Jan 2006 19:35:44 +0000 Subject: [PATCH] added support for external libavformat git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@17355 b3059339-0415-0410-9bf9-f77b7e298cf2 --- cfg-mencoder.h | 8 ++++---- configure | 25 +++++++++++++++++++++++++ libmpcodecs/ae_lavc.c | 4 ++-- libmpdemux/Makefile | 8 ++++++-- libmpdemux/demux_lavf.c | 7 ++++--- libmpdemux/demuxer.c | 4 +++- libmpdemux/muxer.c | 2 +- libmpdemux/muxer_lavf.c | 4 ++++ 8 files changed, 49 insertions(+), 13 deletions(-) diff --git a/cfg-mencoder.h b/cfg-mencoder.h index fa51288305..b18e904e1e 100644 --- a/cfg-mencoder.h +++ b/cfg-mencoder.h @@ -55,7 +55,7 @@ extern m_option_t x264encopts_conf[]; extern m_option_t nuvopts_conf[]; extern m_option_t mpegopts_conf[]; -#ifdef USE_LIBAVFORMAT +#if defined(USE_LIBAVFORMAT) || defined(USE_LIBAVFORMAT_SO) extern m_option_t lavfopts_conf[]; #endif @@ -177,7 +177,7 @@ m_option_t info_conf[]={ m_option_t of_conf[]={ {"avi", &out_file_format, CONF_TYPE_FLAG, 0, 0, MUXER_TYPE_AVI, NULL}, {"mpeg", &out_file_format, CONF_TYPE_FLAG, 0, 0, MUXER_TYPE_MPEG, NULL}, -#ifdef USE_LIBAVFORMAT +#if defined(USE_LIBAVFORMAT) || defined(USE_LIBAVFORMAT_SO) {"lavf", &out_file_format, CONF_TYPE_FLAG, 0, 0, MUXER_TYPE_LAVF, NULL}, #endif {"rawvideo", &out_file_format, CONF_TYPE_FLAG, 0, 0, MUXER_TYPE_RAWVIDEO, NULL}, @@ -185,7 +185,7 @@ m_option_t of_conf[]={ {"help", "\nAvailable output formats:\n" " avi - Microsoft Audio/Video Interleaved\n" " mpeg - MPEG-1/2 system stream format\n" -#ifdef USE_LIBAVFORMAT +#if defined(USE_LIBAVFORMAT) || defined(USE_LIBAVFORMAT_SO) " lavf - FFmpeg libavformat muxers\n" #endif " rawvideo - (video only, one stream only) raw stream, no muxing\n" @@ -298,7 +298,7 @@ m_option_t mencoder_opts[]={ {"nuvopts", nuvopts_conf, CONF_TYPE_SUBCONFIG, CONF_GLOBAL, 0, 0, NULL}, {"mpegopts", mpegopts_conf, CONF_TYPE_SUBCONFIG, CONF_GLOBAL, 0, 0, NULL}, -#ifdef USE_LIBAVFORMAT +#if defined(USE_LIBAVFORMAT) || defined(USE_LIBAVFORMAT_SO) {"lavfopts", lavfopts_conf, CONF_TYPE_SUBCONFIG, CONF_GLOBAL, 0, 0, NULL}, #endif diff --git a/configure b/configure index 6659b44f1e..d47a778314 100755 --- a/configure +++ b/configure @@ -1460,6 +1460,7 @@ _amr_wb=auto _libavcodecs=`grep 'register_avcodec(&[a-z]' libavcodec/allcodecs.c | sed 's/.*&\(.*\)).*/\1/'` _libavcodecso=auto _libavformat=auto +_libavformat_so=auto _fame=auto _mp1e=no _mencoder=yes @@ -6060,6 +6061,19 @@ fi echores "$_libavcodecso" fi +if test "$_libavformat" != yes ; then +echocheck "FFmpeg libavformat (dynamic)" +if test "$_libavformat_so" = auto ; then + _libavformat_so=no + cat > $TMPC < + int main(void) { av_alloc_format_context(); return 0; } +EOF + cc_check $_ld_lm -lavformat && _libavformat_so=yes +fi +echores "$_libavformat_so" +fi + _def_libavcodec='#undef USE_LIBAVCODEC' _def_libavcodecso='#undef USE_LIBAVCODEC_SO' _def_ffpostprocess='#undef FF_POSTPROCESS' @@ -6083,6 +6097,7 @@ else fi _def_libavformat='#undef USE_LIBAVFORMAT' +_def_libavformat_so='#undef USE_LIBAVFORMAT_SO' _def_libavformat_win32='#undef CONFIG_WIN32' if test "$_libavformat" = yes ; then _def_libavformat='#define USE_LIBAVFORMAT 1' @@ -6091,6 +6106,14 @@ if test "$_libavformat" = yes ; then if win32 ; then _def_libavformat_win32='#define CONFIG_WIN32 1' fi +else + if test "$_libavformat_so" = yes ; then + _def_libavformat_so='#define USE_LIBAVFORMAT_SO 1' + _ld_libavformat='-lavformat' + if win32 ; then + _def_libavformat_win32='#define CONFIG_WIN32 1' + fi + fi fi echocheck "amr narrowband" @@ -7184,6 +7207,7 @@ CONFIG_LIBAVUTIL = $_libavutil CONFIG_LIBAVCODEC = $_libavcodec CONFIG_LIBAVCODECSO = $_libavcodecso CONFIG_LIBAVFORMAT = $_libavformat +CONFIG_LIBAVFORMAT_SO = $_libavformat_so ZORAN = $_zr FAME = $_fame FAME_LIB = $_ld_fame @@ -7576,6 +7600,7 @@ $_def_libavcodecso /* ffmpeg's libavformat support (requires libavformat source) */ $_def_libavformat +$_def_libavformat_so $_def_libavformat_win32 /* Use libavcodec's decoders */ diff --git a/libmpcodecs/ae_lavc.c b/libmpcodecs/ae_lavc.c index eab241ed9b..af9b65dffa 100644 --- a/libmpcodecs/ae_lavc.c +++ b/libmpcodecs/ae_lavc.c @@ -26,7 +26,7 @@ extern int lavc_param_abitrate; extern int lavc_param_atag; extern int avcodec_inited; static int compressed_frame_size = 0; -#ifdef USE_LIBAVFORMAT +#if defined(USE_LIBAVFORMAT) || defined(USE_LIBAVFORMAT_SO) extern unsigned int codec_get_wav_tag(int id); #endif @@ -167,7 +167,7 @@ int mpae_init_lavc(audio_encoder_t *encoder) } if(lavc_param_atag == 0) { -#ifdef USE_LIBAVFORMAT +#if defined(USE_LIBAVFORMAT) || defined(USE_LIBAVFORMAT_SO) lavc_param_atag = codec_get_wav_tag(lavc_acodec->id); #else lavc_param_atag = lavc_find_atag(lavc_param_acodec); diff --git a/libmpdemux/Makefile b/libmpdemux/Makefile index 62e65e6c97..12fb6b6f0a 100644 --- a/libmpdemux/Makefile +++ b/libmpdemux/Makefile @@ -64,7 +64,6 @@ SRCS += demuxer.c \ demux_film.c \ demux_fli.c \ demux_gif.c \ - demux_lavf.c \ demux_lmlm4.c \ demux_mf.c \ demux_mov.c \ @@ -117,7 +116,12 @@ LIBAV_INC += -I../libavcodec endif ifeq ($(CONFIG_LIBAVFORMAT),yes) LIBAV_INC += -I../libavformat -SRCS += muxer_lavf.c +SRCS += demux_lavf.c \ + muxer_lavf.c +endif +ifeq ($(CONFIG_LIBAVFORMAT_SO),yes) +SRCS += demux_lavf.c \ + muxer_lavf.c endif ifeq ($(MPLAYER_NETWORK),yes) diff --git a/libmpdemux/demux_lavf.c b/libmpdemux/demux_lavf.c index c31a0a9114..d6cbc55503 100644 --- a/libmpdemux/demux_lavf.c +++ b/libmpdemux/demux_lavf.c @@ -28,10 +28,12 @@ #include "demuxer.h" #include "stheader.h" -#ifdef USE_LIBAVFORMAT - +#ifdef USE_LIBAVFORMAT_SO +#include +#else #include "avformat.h" #include "avi.h" +#endif #define PROBE_BUF_SIZE 2048 @@ -451,4 +453,3 @@ demuxer_desc_t demuxer_desc_lavf = { demux_lavf_control }; -#endif // USE_LIBAVFORMAT diff --git a/libmpdemux/demuxer.c b/libmpdemux/demuxer.c index f54a6532b1..3cd17519a7 100644 --- a/libmpdemux/demuxer.c +++ b/libmpdemux/demuxer.c @@ -62,7 +62,9 @@ extern demuxer_desc_t demuxer_desc_audio; extern demuxer_desc_t demuxer_desc_xmms; extern demuxer_desc_t demuxer_desc_mpeg_ty; extern demuxer_desc_t demuxer_desc_rtp; +#if defined(USE_LIBAVFORMAT) || defined(USE_LIBAVFORMAT_SO) extern demuxer_desc_t demuxer_desc_lavf; +#endif extern demuxer_desc_t demuxer_desc_aac; demuxer_desc_t* demuxer_list[] = { @@ -119,7 +121,7 @@ demuxer_desc_t* demuxer_list[] = { #ifdef STREAMING_LIVE555 &demuxer_desc_rtp, #endif -#ifdef USE_LIBAVFORMAT +#if defined(USE_LIBAVFORMAT) || defined(USE_LIBAVFORMAT_SO) &demuxer_desc_lavf, #endif &demuxer_desc_aac, diff --git a/libmpdemux/muxer.c b/libmpdemux/muxer.c index fa2574c50e..e2da4efa3b 100644 --- a/libmpdemux/muxer.c +++ b/libmpdemux/muxer.c @@ -35,7 +35,7 @@ muxer_t *muxer_new_muxer(int type,FILE *f){ if(! muxer_init_muxer_rawaudio(muxer)) return NULL; break; -#ifdef USE_LIBAVFORMAT +#if defined(USE_LIBAVFORMAT) || defined(USE_LIBAVFORMAT_SO) case MUXER_TYPE_LAVF: if(! muxer_init_muxer_lavf(muxer)) return NULL; diff --git a/libmpdemux/muxer_lavf.c b/libmpdemux/muxer_lavf.c index 55a8a4c7ef..88d08d36ee 100644 --- a/libmpdemux/muxer_lavf.c +++ b/libmpdemux/muxer_lavf.c @@ -17,7 +17,11 @@ #include "demuxer.h" #include "stheader.h" #include "m_option.h" +#ifdef USE_LIBAVFORMAT_SO +#include +#else #include "avformat.h" +#endif extern unsigned int codec_get_wav_tag(int id); extern enum CodecID codec_get_bmp_id(unsigned int tag);