[vlc-commits] avcodec: use automake conditionals for hardware acceleration

Rémi Denis-Courmont git at videolan.org
Fri Oct 12 20:27:26 CEST 2012


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri Oct 12 20:28:28 2012 +0300| [1962cd3095652e676cea7830da863cc6f2b621d6] | committer: Rémi Denis-Courmont

avcodec: use automake conditionals for hardware acceleration

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1962cd3095652e676cea7830da863cc6f2b621d6
---

 configure.ac                    |   19 ++++++++++---------
 modules/codec/Modules.am        |   18 +++++++++++++++---
 modules/codec/avcodec/avcodec.h |    6 ------
 modules/codec/avcodec/dxva2.c   |    7 -------
 modules/codec/avcodec/vaapi.c   |    3 ---
 modules/codec/avcodec/vda.c     |    3 ---
 6 files changed, 25 insertions(+), 31 deletions(-)

diff --git a/configure.ac b/configure.ac
index 5d31610..912c711 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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
diff --git a/modules/codec/Modules.am b/modules/codec/Modules.am
index 8a40488..fcf987e 100644
--- a/modules/codec/Modules.am
+++ b/modules/codec/Modules.am
@@ -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 \
diff --git a/modules/codec/avcodec/avcodec.h b/modules/codec/avcodec/avcodec.h
index a27924c..429647d 100644
--- a/modules/codec/avcodec/avcodec.h
+++ b/modules/codec/avcodec/avcodec.h
@@ -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
diff --git a/modules/codec/avcodec/dxva2.c b/modules/codec/avcodec/dxva2.c
index c4e3e00..2bd612d 100644
--- a/modules/codec/avcodec/dxva2.c
+++ b/modules/codec/avcodec/dxva2.c
@@ -28,13 +28,11 @@
 #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>
@@ -43,18 +41,14 @@
 #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
diff --git a/modules/codec/avcodec/vaapi.c b/modules/codec/avcodec/vaapi.c
index 450f379..8ad3287 100644
--- a/modules/codec/avcodec/vaapi.c
+++ b/modules/codec/avcodec/vaapi.c
@@ -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
diff --git a/modules/codec/avcodec/vda.c b/modules/codec/avcodec/vda.c
index b8cb159..1446667 100644
--- a/modules/codec/avcodec/vda.c
+++ b/modules/codec/avcodec/vda.c
@@ -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



More information about the vlc-commits mailing list