faad: simplify configure check and require faad >= 2.7

Just check whether LATM is defined which is only available
in 2.7 and later. Allows us to simplify the configure check
a little and we can get rid of some hackish workarounds for
problems with earlier version headers.
This commit is contained in:
Tim-Philipp Müller 2016-01-31 14:42:21 +00:00
parent 0770fa4ed5
commit 861ca5ab7b
4 changed files with 16 additions and 102 deletions

View file

@ -2159,60 +2159,27 @@ AG_GST_CHECK_FEATURE(FAAC, [AAC encoder plug-in], faac, [
AC_SUBST(FAAC_LIBS)
])
dnl **** Free AAC Decoder (FAAD) ****
dnl **** Free AAC Decoder (FAAD2) ****
translit(dnm, m, l) AM_CONDITIONAL(USE_FAAD, true)
AG_GST_CHECK_FEATURE(FAAD, [AAC decoder plug-in], faad, [
HAVE_FAAD="yes"
faad_hdr=""
AG_GST_CHECK_LIBHEADER(FAAD, faad, faacDecOpen, $LIBM, faad.h,
FAAD_LIBS="-lfaad $LIBM", HAVE_FAAD="no")
if test $HAVE_FAAD = "no"; then
AG_GST_CHECK_LIBHEADER(FAAD, faad, NeAACDecOpen, $LIBM, neaacdec.h,
[ FAAD_LIBS="-lfaad $LIBM"
AC_DEFINE(FAAD_IS_NEAAC, 1, [Define if AAC is using new api prefix])
faad_hdr="neaacdec.h"
], [
HAVE_FAAD="no"
],)
else
faad_hdr="faad.h"
fi
if test $HAVE_FAAD = "yes"; then
AC_MSG_CHECKING([Checking for FAAD >= 2.0])
AG_GST_CHECK_FEATURE(FAAD, [FAAD2 AAC decoder plug-in], faad, [
AG_GST_CHECK_LIBHEADER(FAAD, faad, NeAACDecOpen, $LIBM, neaacdec.h, [
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <faad.h>]], [[
#if !defined(FAAD2_VERSION) || !defined(FAAD_FMT_DOUBLE)
#error Not faad2
#else
/* Release candidate of 2.0 is not good enough for us. This field
* was added only in 2.0 final and does not exist in 2.0-RC3 */
faacDecConfiguration conf; conf.dontUpSampleImplicitSBR = 1;
#endif
#if !defined(FAAD2_VERSION) || !defined(FAAD_FMT_DOUBLE)
#error Not faad2
#elif !defined(LATM)
#error Not faad2 >= 2.7
#endif
]])],[
HAVE_FAAD="yes"
AC_MSG_CHECKING([Checking FAAD2 version in $faad_hdr])
for minor in 10 9 8 7 6 5 0; do
if test x$faad2_minor_version = "x"; then
AC_EGREP_CPP([\"2\.$minor\"$], [
#include <$faad_hdr>
FAAD2_VERSION
], [
faad2_minor_version=$minor
])
fi
done
if test x$faad2_minor_version = "x"; then
AC_MSG_RESULT([no idea])
else
AC_MSG_RESULT([2.$faad2_minor_version])
AC_DEFINE_UNQUOTED([FAAD2_MINOR_VERSION], [$faad2_minor_version], [The x in 2.x])
fi
],[
FAAD_LIBS="-lfaad"
], [
AC_MSG_WARN([Found libfaad, but version not recent enough. Need faad2 >= 2.7])
HAVE_FAAD="no"
])
fi
], [
HAVE_FAAD="no"
])
AC_SUBST(FAAD_LIBS)
AC_SUBST(FAAD_IS_NEAAC)
])
dnl *** fbdev ***

View file

@ -1,11 +1,11 @@
plugin_LTLIBRARIES = libgstfaad.la
libgstfaad_la_SOURCES = gstfaad.c
libgstfaad_la_CFLAGS = -DGST_USE_UNSTABLE_API \
libgstfaad_la_CFLAGS = \
$(GST_PLUGINS_BASE_CFLAGS) \
$(GST_BASE_CFLAGS) $(GST_CFLAGS) $(FAAD_CFLAGS)
libgstfaad_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) -lgstaudio-@GST_API_VERSION@ \
$(GST_BASE_LIBS) $(GST_LIBS) $(FAAD_LIBS)
$(GST_BASE_LIBS) $(GST_LIBS) $(FAAD_LIBS) $(LIBM)
libgstfaad_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libgstfaad_la_LIBTOOLFLAGS = $(GST_PLUGIN_LIBTOOLFLAGS)

View file

@ -42,49 +42,8 @@
#include <string.h>
#include <gst/audio/audio.h>
/* These are the correct types for these functions, as defined in the source,
* with types changed to match glib types, since those are defined for us.
* However, upstream FAAD is distributed with a broken header file that defined
* these wrongly (in a way which was broken on 64 bit systems).
*
* Upstream CVS still has the bug, but has also renamed all the public symbols
* for Better Corporate Branding (or whatever), so we need to take that
* (FAAD_IS_NEAAC) into account as well.
*
* We must call them using these definitions. Most distributions now have the
* corrected header file (they distribute a patch along with the source),
* but not all, hence this Truly Evil Hack.
*
* Note: The prototypes don't need to be defined conditionaly, as the cpp will
* do that for us.
*/
#if FAAD2_MINOR_VERSION < 7
#ifdef FAAD_IS_NEAAC
#define NeAACDecInit NeAACDecInit_no_definition
#define NeAACDecInit2 NeAACDecInit2_no_definition
#else
#define faacDecInit faacDecInit_no_definition
#define faacDecInit2 faacDecInit2_no_definition
#endif
#endif /* FAAD2_MINOR_VERSION < 7 */
#include "gstfaad.h"
#if FAAD2_MINOR_VERSION < 7
#ifdef FAAD_IS_NEAAC
#undef NeAACDecInit
#undef NeAACDecInit2
#else
#undef faacDecInit
#undef faacDecInit2
#endif
extern long faacDecInit (faacDecHandle, guint8 *, guint32, guint32 *, guint8 *);
extern gint8 faacDecInit2 (faacDecHandle, guint8 *, guint32,
guint32 *, guint8 *);
#endif /* FAAD2_MINOR_VERSION < 7 */
GST_DEBUG_CATEGORY_STATIC (faad_debug);
#define GST_CAT_DEFAULT faad_debug
@ -277,11 +236,7 @@ gst_faad_set_format (GstAudioDecoder * dec, GstCaps * caps)
faad->packetised = FALSE;
if ((value = gst_structure_get_value (str, "codec_data"))) {
#if FAAD2_MINOR_VERSION >= 7
unsigned long samplerate;
#else
guint32 samplerate;
#endif
guint8 channels;
/* We have codec data, means packetised stream */
@ -691,11 +646,7 @@ gst_faad_handle_frame (GstAudioDecoder * dec, GstBuffer * buffer)
init:
/* init if not already done during capsnego */
if (!faad->init) {
#if FAAD2_MINOR_VERSION >= 7
unsigned long rate;
#else
guint32 rate;
#endif
guint8 ch;
GST_DEBUG_OBJECT (faad, "initialising ...");

View file

@ -23,11 +23,7 @@
#include <gst/gst.h>
#include <gst/audio/gstaudiodecoder.h>
#ifdef FAAD_IS_NEAAC
#include <neaacdec.h>
#else
#include <faad.h>
#endif
G_BEGIN_DECLS