]> git.sesse.net Git - vlc/commitdiff
avcodec: use automake conditionals for hardware acceleration
authorRémi Denis-Courmont <remi@remlab.net>
Fri, 12 Oct 2012 17:28:28 +0000 (20:28 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Fri, 12 Oct 2012 17:16:20 +0000 (20:16 +0300)
configure.ac
modules/codec/Modules.am
modules/codec/avcodec/avcodec.h
modules/codec/avcodec/dxva2.c
modules/codec/avcodec/vaapi.c
modules/codec/avcodec/vda.c

index 5d316101bbe07078f420e386d6cd242970294589..912c711d20c543a829690ef6a7b1abc60cde37e1 100644 (file)
@@ -2232,16 +2232,15 @@ AC_ARG_ENABLE(libva,
 AS_IF([test "${enable_libva}" = "yes" -a "${have_avcodec}" != "yes" ], [
   AC_MSG_ERROR([--enable-libva and --disable-avcodec options are mutually exclusive. Use --enable-avcodec.])
 ])
+have_avcodec_vaapi="no"
 AS_IF([test "${enable_libva}" != "no"], [
   PKG_CHECK_MODULES(LIBVA, [libva libva-x11], [
     VLC_SAVE_FLAGS
     CPPFLAGS="${CPPFLAGS} ${AVCODEC_CFLAGS}"
     CFLAGS="${CFLAGS} ${AVCODEC_CFLAGS}"
     AC_CHECK_HEADERS(libavcodec/vaapi.h, [
-      VLC_ADD_LIBS([avcodec],[$LIBVA_LIBS ${X_LIBS} ${X_PRE_LIBS} -lX11])
-      VLC_ADD_CFLAGS([avcodec],[$LIBVA_CFLAGS ${X_CFLAGS}])
-      AC_DEFINE(HAVE_AVCODEC_VAAPI, 1, [Define if avcodec has to be built with VAAPI support.])
       AC_MSG_NOTICE([VAAPI acceleration activated])
+      have_avcodec_vaapi="yes"
     ],[
       AS_IF([test -n "${enable_libva}"], [
         AC_MSG_ERROR([libva is present but libavcodec/vaapi.h is missing])
@@ -2258,6 +2257,7 @@ AS_IF([test "${enable_libva}" != "no"], [
     ])
   ])
 ])
+AM_CONDITIONAL([HAVE_AVCODEC_VAAPI], [test "${have_avcodec_vaapi}" = "yes"])
 
 dnl
 dnl dxva2 needs avcodec
@@ -2265,15 +2265,15 @@ dnl
 AC_ARG_ENABLE(dxva2,
   [  --enable-dxva2          DxVA2 GPU decoding support (default auto)])
 
+have_avcodec_dxva2="no"
 AS_IF([test "${enable_dxva2}" != "no"], [
   if test "${SYS}" = "mingw32"; then
   AS_IF([test "x${have_avcodec}" = "xyes"], [
     AC_CHECK_HEADERS(dxva2api.h,
       [
         AC_CHECK_HEADERS(libavcodec/dxva2.h, [
-           VLC_ADD_LIBS([avcodec],[-lole32 -lshlwapi -luuid])
-           AC_DEFINE(HAVE_AVCODEC_DXVA2, 1, [Define if avcodec has to be built with DxVA2 support.])
-           echo "DxVA2 acceleration activated"
+           AC_MSG_NOTICE([DxVA2 acceleration activated])
+           have_avcodec_dxva2="yes"
         ],[
     AS_IF([test "${enable_dxva2}" = "yes"],
           [AC_MSG_ERROR([dxva2 is present but libavcodec/dxva2.h is missing])],
@@ -2293,6 +2293,7 @@ AS_IF([test "${enable_dxva2}" != "no"], [
   ])
   fi
 ])
+AM_CONDITIONAL([HAVE_AVCODEC_DXVA2], [test "${have_avcodec_dxva2}" = "yes"])
 
 dnl
 dnl vda needs avcodec
@@ -2300,15 +2301,14 @@ dnl
 AC_ARG_ENABLE(vda,
   [  --enable-vda          VDA  support (default auto)])
 
+have_avcodec_vda="no"
 AS_IF([test "${enable_vda}" != "no"], [
   if test "${SYS}" = "darwin"; then
   AS_IF([test "x${have_avcodec}" = "xyes"], [
     AC_CHECK_HEADERS(VideoDecodeAcceleration/VDADecoder.h,
       [
         AC_CHECK_HEADERS(libavcodec/vda.h, [
-           VLC_ADD_LIBS([avcodec],[-Wl,-framework,CoreFoundation,-framework,VideoDecodeAcceleration,-framework,QuartzCore])
-           VLC_ADD_LDFLAGS([vda],[-Wl,-framework,CoreFoundation,-framework,VideoDecodeAcceleration,-framework,QuartzCore])
-           AC_DEFINE(HAVE_AVCODEC_VDA, 1, [Define if avcodec has to be built with VDA support.])
+           have_avcodec_vda="yes"
         ],[
        AS_IF([test "${enable_vda}" == "yes"],
              [AC_MSG_ERROR([vda is present but libavcodec/vda.h is missing])],
@@ -2326,6 +2326,7 @@ AS_IF([test "${enable_vda}" != "no"], [
  ])
   fi
 ])
+AM_CONDITIONAL([HAVE_AVCODEC_VDA], [test "${have_avcodec_vda}" = "yes"])
 
 dnl
 dnl stream_out switcher needs libavcodec
index 8a404883b0a3120c0f0b7e23dfe368515918dfa4..fcf987ef4f03b990411e5b49bb991d4a8dda698e 100644 (file)
@@ -94,9 +94,6 @@ libavcodec_plugin_la_SOURCES = \
        avcodec/deinterlace.c \
        avcodec/fourcc.c \
        avcodec/chroma.c avcodec/chroma.h \
-       avcodec/vaapi.c \
-       avcodec/dxva2.c \
-       avcodec/vda.c \
        avcodec/copy.c avcodec/copy.h \
        avcodec/va.h \
        avcodec/avcodec.c avcodec/avcodec.h
@@ -107,6 +104,21 @@ endif
 libavcodec_plugin_la_CFLAGS = $(AM_CFLAGS) $(CFLAGS_avcodec)
 libavcodec_plugin_la_LIBADD = $(AM_LIBADD) $(LIBS_avcodec)
 libavcodec_plugin_la_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_avcodec)
+if HAVE_AVCODEC_VAAPI
+libavcodec_plugin_la_SOURCES += avcodec/vaapi.c
+libavcodec_plugin_la_CFLAGS += $(LIBVA_CFLAGS) $(X_CFLAGS) -DHAVE_AVCODEC_VAAPI
+libavcodec_plugin_la_LIBADD += $(LIBVA_LIBS) $(X_LIBS) $(X_PRE_LIBS) -lX11
+endif
+if HAVE_AVCODEC_DXVA2
+libavcodec_plugin_la_SOURCES += avcodec/dxva2.c
+libavcodec_plugin_la_CFLAGS += -DHAVE_AVCODEC_DXVA2
+libavcodec_plugin_la_LIBADD += -lole32 -lshlwapi -luuid
+endif
+if HAVE_AVCODEC_VDA
+libavcodec_plugin_la_SOURCES += avcodec/vda.c
+libavcodec_plugin_la_CFLAGS += -DHAVE_AVCODEC_VDA
+libavcodec_plugin_la_LDFLAGS += -Wl,-framework,CoreFoundation,-framework,VideoDecodeAcceleration,-framework,QuartzCore
+endif
 if MERGE_FFMPEG
 libavcodec_plugin_la_SOURCES += \
        ../demux/avformat/demux.c \
index a27924cbb0292c5f851b4a688aa91bd43ee71d17..429647d21631796e1663160feecd2e5d0855451c 100644 (file)
@@ -287,12 +287,6 @@ int ffmpeg_OpenCodec( decoder_t *p_dec );
     (LIBAVCODEC_VERSION_MICRO >= 100 && LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( a, d, e ) )
 
 
-/* Uncomment it to enable compilation with vaapi/dxva2/vda (you also must change the build
- * system) */
-//#define HAVE_AVCODEC_VAAPI 1
-//#define HAVE_AVCODEC_DXVA2 1
-//#define HAVE_AVCODEC_VDA 1
-
 /* Ugly ifdefinitions to provide backwards compatibility with older ffmpeg/libav
  * versions */
 #ifndef AV_CPU_FLAG_FORCE
index c4e3e00c58903cf6dc5e774f197be34045ef1c88..2bd612d600df9c93bb10531d20c342fd5b3a28f0 100644 (file)
 #endif
 
 
-#if defined(HAVE_LIBAVCODEC_AVCODEC_H) && defined(HAVE_AVCODEC_DXVA2)
 # if _WIN32_WINNT < 0x600
 /* dxva2 needs Vista support */
 #  undef _WIN32_WINNT
 #  define _WIN32_WINNT 0x600
 # endif
-#endif
 
 #include <vlc_common.h>
 #include <vlc_picture.h>
 #include <assert.h>
 
 #include <libavcodec/avcodec.h>
-#ifdef HAVE_AVCODEC_DXVA2
 #    define DXVA2API_USE_BITFIELDS
 #    define COBJMACROS
 #    include <libavcodec/dxva2.h>
-#endif
 
 #include "avcodec.h"
 #include "va.h"
 #include "copy.h"
 
-#ifdef HAVE_AVCODEC_DXVA2
-
 #include <windows.h>
 #include <windowsx.h>
 #include <ole2.h>
@@ -1015,4 +1009,3 @@ static void DxDestroyVideoConversion(vlc_va_dxva2_t *va)
 {
     CopyCleanCache(&va->surface_cache);
 }
-#endif
index 450f379dcc993aec31364fef0fb5c8d702388346..8ad32874101bfb2285875beeff05aeb0ecaddb7d 100644 (file)
@@ -35,8 +35,6 @@
 #include "va.h"
 #include "copy.h"
 
-#ifdef HAVE_AVCODEC_VAAPI
-
 #include <vlc_xlib.h>
 
 #include <libavcodec/vaapi.h>
@@ -540,4 +538,3 @@ vlc_va_t *vlc_va_New( vlc_object_t *obj, int pixfmt, int i_codec_id,
     p_va->va.close = Delete;
     return &p_va->va;
 }
-#endif
index b8cb1592f779716955564d180c08f119b9453beb..1446667ca044611a53e9b5ae0be4b67493211e48 100644 (file)
@@ -34,8 +34,6 @@
 #include "va.h"
 #include "copy.h"
 
-#ifdef HAVE_AVCODEC_VDA
-
 #include <libavcodec/vda.h>
 #include <VideoDecodeAcceleration/VDADecoder.h>
 
@@ -270,4 +268,3 @@ vlc_va_t *vlc_va_New( vlc_object_t *p_log, int pixfmt, int i_codec_id,
 
     return &p_va->va;
 }
-#endif