Sync up FFmpeg -- autoconf
authorSteve Youngs <steve@sxemacs.org>
Mon, 2 Jul 2012 14:05:57 +0000 (00:05 +1000)
committerNelson Ferreira <nelson.ferreira@ieee.org>
Sat, 26 Dec 2015 16:13:37 +0000 (11:13 -0500)
This changeset is the first in a series to sync up our FFmpeg code with a
much more modern and up to date FFmpeg.  This one takes care of the
autoconf side of things.  It is cherry-picked from an earlier ffmpeg-fix
branch, squashing all the configuration related changes.

This changeset also introduces new minimum versions of libavformat and
libavcodec required by SXEmacs:

  libavformat -- 55.12.100
  libavcodec  -- 55.18.102

* configure.ac: Need libs for avcodec as well as avformat. Add
          in libavutil libs.

* m4/sxe-mm.m4 (SXE_MM_CHECK_FFMPEG): Rework it for modern
ffmpeg. Check for av_dict_get() in libavutil.

* m4/sxe-mm.m4 (SXE_CHECK_FFMPEG_HEADERS): Check for avcodec.h
and dict.h as well.

* m4/sxe-mm.m4 (SXE_CHECK_FFMPEG_LIBS): Check for libavutil.

* m4/sxe-mm.m4 (SXE_MM_CHECK_FFMPEG):

configure.ac
m4/sxe-mm.m4

index cdf5e68..f779af5 100644 (file)
@@ -3312,8 +3312,8 @@ if test "$with_media_ffmpeg" != "no"; then
 
        if test "$have_media_ffmpeg" = "yes"; then
                AC_MSG_RESULT([yes])
-               FFMPEG_LIBS=`$PKG_CONFIG --libs libavformat`
-               FFMPEG_CPPFLAGS=`$PKG_CONFIG --cflags libavformat`
+               FFMPEG_LIBS=`$PKG_CONFIG --libs libavformat libavcodec libavutil`
+               FFMPEG_CPPFLAGS=`$PKG_CONFIG --cflags libavformat libavcodec libavutil`
                SXE_PREPEND($FFMPEG_LIBS, MM_LIBS)
                SXE_PREPEND_UNDUP($FFMPEG_CPPFLAGS, MM_CPPFLAGS)
                SXE_ADD_MM_OBJS([media-ffmpeg.o])
index ef3ca3d..67ebc89 100644 (file)
@@ -318,18 +318,12 @@ AC_DEFUN([SXE_MM_CHECK_FFMPEG], [
        pushdef([ACTION_IF_NOT_FOUND], [$2])
 
        sxe_cv_feat_ffmpeg=
-       ## we can't use that one since we have to check multiple headers
-dnl    _SXE_MM_CHECK_pkgconfig_based([ffmpeg], [libavformat], [49.0.0], [dnl
-dnl            av_open_input_file av_close_input_file av_find_stream_info dnl
-dnl            url_fopen av_probe_input_format avcodec_find_decoder dnl
-dnl            avcodec_open av_read_frame av_seek_frame av_register_all dnl
-dnl            avcodec_decode_audio avcodec_decode_audio2], [avformat.h],
-dnl            [sxe_cv_feat_ffmpeg=yes], [sxe_cv_feat_ffmpeg=no])
 
-dnl    Dropped in favour of sxe-pkgconfig.m4 macros
-dnl    _SXE_CHECK_pkgconfig_based([ffmpeg], [libavformat], [49.0.0])
-
-       SXE_PC_CHECK_VERSION_ATLEAST([libavformat], [51.0.0])
+       ## Minimum versions required matches FFmpeg stable v2.0.1
+       ## released 2013-08-13
+       SXE_PC_CHECK_VERSION_ATLEAST([libavformat], [55.12.100])
+       SXE_PC_CHECK_VERSION_ATLEAST([libavcodec], [55.18.102])
+       SXE_PC_CHECK_VERSION_ATLEAST([libavutil], [52.38.100])
 
        SXE_CHECK_FFMPEG_HEADERS
        SXE_CHECK_FFMPEG_LIBS
@@ -340,110 +334,32 @@ dnl      _SXE_CHECK_pkgconfig_based([ffmpeg], [libavformat], [49.0.0])
                "$ac_cv_header_libavformat_avformat_h" = "yes"; then
                sxe_cv_feat_ffmpeg_headers="yes"
        fi
-       ## make sure either decode_audio or decode_audio2 is there
-       if test "$ac_cv_lib_avformat_avcodec_decode_audio2" = "yes" -o \
-               "$ac_cv_lib_avformat_avcodec_decode_audio" = "yes"; then
+       ## make sure either decode_audio is there
+       if test "$ac_cv_lib_avcodec_avcodec_decode_audio4" = "yes"; then
                sxe_cv_feat_ffmpeg_decoders="yes"
        fi
-       ## make sure we can either use av_register_protocol()
-       ## or register_protocol()
-       if test "$ac_cv_lib_avformat_av_register_protocol" = "yes" -o \
-               "$ac_cv_lib_avformat_register_protocol" = "yes"; then
-               sxe_cv_feat_ffmpeg_proto_reg="yes"
-       fi
        ## make sure this bloody av context allocator is there
-       if test "$ac_cv_lib_avformat_avformat_alloc_context" = "yes" -o \
-               "$ac_cv_lib_avformat_av_alloc_format_context" = "yes"; then
+       if test "$ac_cv_lib_avformat_avformat_alloc_context" = "yes"; then
                sxe_cv_feat_ffmpeg_avformat_alloc="yes"
        fi
        if test "$sxe_cv_feat_ffmpeg_headers" = "yes" -a \
                "$sxe_cv_feat_ffmpeg_decoders" = "yes" -a \
-               "$sxe_cv_feat_ffmpeg_proto_reg" = "yes" -a \
                "$sxe_cv_feat_ffmpeg_avformat_alloc" = "yes" -a \
-               "$ac_cv_lib_avformat_av_close_input_file" = "yes" -a \
-               "$ac_cv_lib_avformat_av_find_stream_info" = "yes" -a \
-               "$ac_cv_lib_avformat_av_open_input_file" = "yes" -a \
+               "$ac_cv_lib_avformat_avformat_close_input" = "yes" -a \
+               "$ac_cv_lib_avformat_avformat_find_stream_info" = "yes" -a \
+               "$ac_cv_lib_avformat_avformat_open_input" = "yes" -a \
                "$ac_cv_lib_avformat_av_probe_input_format" = "yes" -a \
                "$ac_cv_lib_avformat_av_read_frame" = "yes" -a \
                "$ac_cv_lib_avformat_av_register_all" = "yes" -a \
                "$ac_cv_lib_avformat_av_seek_frame" = "yes" -a \
-               "$ac_cv_lib_avformat_avcodec_find_decoder" = "yes" -a \
-               "$ac_cv_lib_avformat_avcodec_open" = "yes" -a \
-               "$ac_cv_lib_avformat_url_fopen" = "yes"; then
+               "$ac_cv_lib_avcodec_avcodec_find_decoder" = "yes" -a \
+               "$ac_cv_lib_avcodec_avcodec_open2" = "yes" -a \
+               "$ac_cv_lib_avutil_av_dict_get" = "yes"; then
                sxe_cv_feat_ffmpeg="yes"
        else
                sxe_cv_feat_ffmpeg="no"
        fi
 
-       ## newer ffmpegs want a bioctx** in url_fopen, check that
-       AC_MSG_CHECKING([what url_fopen() needs])
-       sxe_cv_tmp_ffmpeg_url_fopen="uncertain"
-
-       SXE_DUMP_LIBS
-       CPPFLAGS="$CPPFLAGS ${FFMPEG_CPPFLAGS}"
-       SXE_LANG_WERROR([off])
-       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
-#if defined HAVE_ERRNO_H
-# include <errno.h>
-#endif
-#if defined HAVE_LIBAVFORMAT_AVFORMAT_H
-# include <libavformat/avformat.h>
-#elif defined HAVE_FFMPEG_AVFORMAT_H
-# include <ffmpeg/avformat.h>
-#elif defined HAVE_AVFORMAT_H
-# include <avformat.h>
-#endif
-
-extern int foobar(void);
-int foobar(void)
-{
-       ByteIOContext *bioctx = 0;
-
-       url_fopen(&bioctx, "/foobar", URL_RDONLY);
-       return 0;
-}
-               ]])], [sxe_cv_tmp_ffmpeg_url_fopen="ByteIOContext**"], [:])
-       SXE_RESTORE_LIBS
-
-       SXE_DUMP_LIBS
-       CPPFLAGS="$CPPFLAGS ${FFMPEG_CPPFLAGS}"
-       SXE_LANG_WERROR([on])
-       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
-#if defined HAVE_ERRNO_H
-# include <errno.h>
-#endif
-#if defined HAVE_LIBAVFORMAT_AVFORMAT_H
-# include <libavformat/avformat.h>
-#elif defined HAVE_FFMPEG_AVFORMAT_H
-# include <ffmpeg/avformat.h>
-#elif defined HAVE_AVFORMAT_H
-# include <avformat.h>
-#endif
-
-extern int foobar(void);
-int foobar(void)
-{
-       ByteIOContext *bioctx = 0;
-
-       url_fopen(bioctx, "/foobar", URL_RDONLY);
-       return 0;
-}
-               ]])], [sxe_cv_tmp_ffmpeg_url_fopen="ByteIOContext*"], [:])
-       SXE_RESTORE_LIBS
-
-       ## post the result
-       AC_MSG_RESULT([$sxe_cv_tmp_ffmpeg_url_fopen])
-
-       if test "$sxe_cv_tmp_ffmpeg_url_fopen" = "ByteIOContext**"; then
-               AC_DEFINE([FFMPEG_URL_FOPEN_BIOCTX_STAR_STAR], [1],
-                       [Whether url_fopen want a ByteIOContext**])
-       elif test "$sxe_cv_tmp_ffmpeg_url_fopen" = "ByteIOContext*"; then
-               AC_DEFINE([FFMPEG_URL_FOPEN_BIOCTX_STAR], [1],
-                       [Whether url_fopen want a ByteIOContext*])
-       else
-               sxe_cv_feat_ffmpeg="no"
-       fi
-
        if test "$sxe_cv_feat_ffmpeg" = "yes"; then
                :
                ACTION_IF_FOUND
@@ -457,65 +373,41 @@ int foobar(void)
 ])dnl SXE_MM_CHECK_FFMPEG
 
 AC_DEFUN([SXE_CHECK_FFMPEG_HEADERS], [dnl
-       FFMPEG_CPPFLAGS="$(${PKG_CONFIG} --cflags libavformat)"
+       FFMPEG_CPPFLAGS="$(${PKG_CONFIG} --cflags libavformat libavcodec libavutil)"
 
        ## backup current configuration
        SXE_DUMP_LIBS
        CPPFLAGS="${CPPFLAGS} ${FFMPEG_CPPFLAGS}"
-       AC_CHECK_HEADERS([avformat.h ffmpeg/avformat.h libavformat/avformat.h])
+       AC_CHECK_HEADERS([libavformat/avformat.h libavcodec/avcodec.h libavutil/dict.h])
+
        ## restore configuration
        SXE_RESTORE_LIBS
 ])dnl SXE_CHECK_FFMPEG_HEADERS
 
 AC_DEFUN([SXE_CHECK_FFMPEG_LIBS], [dnl
-       FFMPEG_LDFLAGS="$(${PKG_CONFIG} --libs-only-other libavformat) \
-               $(${PKG_CONFIG} --libs-only-L libavformat)"
-       FFMPEG_LIBS="$(${PKG_CONFIG} --libs-only-l libavformat)"
+       FFMPEG_LDFLAGS="$(${PKG_CONFIG} --libs-only-other libavformat libavcodec libavutil) \
+               $(${PKG_CONFIG} --libs-only-L libavformat libavcodec libavutil)"
+       FFMPEG_LIBS="$(${PKG_CONFIG} --libs-only-l libavformat libavcodec libavutil)"
 
        ## backup current configuration
        SXE_DUMP_LIBS
        LDFLAGS="${LDFLAGS} ${FFMPEG_LDFLAGS}"
 
-       AC_CHECK_LIB([avformat], [av_open_input_file], [:], [:], [${FFMPEG_LIBS}])
-       AC_CHECK_LIB([avformat], [av_close_input_file], [:], [:], [${FFMPEG_LIBS}])
-       AC_CHECK_LIB([avformat], [av_find_stream_info], [:], [:], [${FFMPEG_LIBS}])
-       AC_CHECK_LIB([avformat], [url_fopen], [:], [:], [${FFMPEG_LIBS}])
+       AC_CHECK_LIB([avcodec], [avcodec_find_decoder], [:], [:], [${FFMPEG_LIBS}])
+       AC_CHECK_LIB([avcodec], [avcodec_open2], [:], [:], [${FFMPEG_LIBS}])
+       AC_CHECK_LIB([avcodec], [avcodec_decode_audio4], [:], [:], [${FFMPEG_LIBS}])
+
+       AC_CHECK_LIB([avformat], [avformat_open_input], [:], [:], [${FFMPEG_LIBS}])
+       AC_CHECK_LIB([avformat], [avformat_close_input], [:], [:], [${FFMPEG_LIBS}])
+       AC_CHECK_LIB([avformat], [avformat_find_stream_info], [:], [:], [${FFMPEG_LIBS}])
        AC_CHECK_LIB([avformat], [av_probe_input_format], [:], [:], [${FFMPEG_LIBS}])
-       AC_CHECK_LIB([avformat], [avcodec_find_decoder], [:], [:], [${FFMPEG_LIBS}])
-       AC_CHECK_LIB([avformat], [avcodec_open], [:], [:], [${FFMPEG_LIBS}])
        AC_CHECK_LIB([avformat], [av_read_frame], [:], [:], [${FFMPEG_LIBS}])
        AC_CHECK_LIB([avformat], [av_seek_frame], [:], [:], [${FFMPEG_LIBS}])
        AC_CHECK_LIB([avformat], [av_register_all], [:], [:], [${FFMPEG_LIBS}])
-       AC_CHECK_LIB([avformat], [avcodec_decode_audio], [:], [:], [${FFMPEG_LIBS}])
-       AC_CHECK_LIB([avformat], [avcodec_decode_audio2], [:], [:], [${FFMPEG_LIBS}])
-
-       AC_CHECK_LIB([avformat], [av_alloc_format_context], [:], [:], [${FFMPEG_LIBS}])
        AC_CHECK_LIB([avformat], [avformat_alloc_context], [:], [:], [${FFMPEG_LIBS}])
-       AC_CHECK_LIB([avformat], [register_protocol], [:], [:], [${FFMPEG_LIBS}])
-       AC_CHECK_LIB([avformat], [av_register_protocol], [:], [:], [${FFMPEG_LIBS}])
 
-       if test "$ac_cv_lib_avformat_av_alloc_format_context" = "yes"; then
-               AC_DEFINE([HAVE_AV_ALLOC_FORMAT_CONTEXT], [1], [Description here!])
-       fi
-       if test "$ac_cv_lib_avformat_avformat_alloc_context" = "yes"; then
-               AC_DEFINE([HAVE_AVFORMAT_ALLOC_CONTEXT], [1], [Description here!])
-       fi
+       AC_CHECK_LIB([avutil], [av_dict_get], [:], [:], [${FFMPEG_LIBS}])
 
-       if test "$ac_cv_lib_avformat___avcodec_decode_audio2" = "yes" -o \
-               "$ac_cv_lib_avformat_avcodec_decode_audio2" = "yes"; then
-               AC_DEFINE([HAVE_AVCODEC_DECODE_AUDIO2], [1], [Description here!])
-       fi
-       if test "$ac_cv_lib_avformat___avcodec_decode_audio" = "yes" -o \
-               "$ac_cv_lib_avformat_avcodec_decode_audio" = "yes"; then
-               AC_DEFINE([HAVE_AVCODEC_DECODE_AUDIO], [1], [Description here!])
-       fi
-
-       if test "$ac_cv_lib_avformat_av_register_protocol" = "yes"; then
-               AC_DEFINE([HAVE_AV_REGISTER_PROTOCOL], [1], [Description here!])
-       fi
-       if test "$ac_cv_lib_avformat_register_protocol" = "yes"; then
-               AC_DEFINE([HAVE_REGISTER_PROTOCOL], [1], [Description here!])
-       fi
 
        ## restore configuration
        SXE_RESTORE_LIBS