Commit 1962cd30 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

avcodec: use automake conditionals for hardware acceleration

parent a7963bfa
...@@ -2232,16 +2232,15 @@ AC_ARG_ENABLE(libva, ...@@ -2232,16 +2232,15 @@ AC_ARG_ENABLE(libva,
AS_IF([test "${enable_libva}" = "yes" -a "${have_avcodec}" != "yes" ], [ 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.]) 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"], [ AS_IF([test "${enable_libva}" != "no"], [
PKG_CHECK_MODULES(LIBVA, [libva libva-x11], [ PKG_CHECK_MODULES(LIBVA, [libva libva-x11], [
VLC_SAVE_FLAGS VLC_SAVE_FLAGS
CPPFLAGS="${CPPFLAGS} ${AVCODEC_CFLAGS}" CPPFLAGS="${CPPFLAGS} ${AVCODEC_CFLAGS}"
CFLAGS="${CFLAGS} ${AVCODEC_CFLAGS}" CFLAGS="${CFLAGS} ${AVCODEC_CFLAGS}"
AC_CHECK_HEADERS(libavcodec/vaapi.h, [ 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]) AC_MSG_NOTICE([VAAPI acceleration activated])
have_avcodec_vaapi="yes"
],[ ],[
AS_IF([test -n "${enable_libva}"], [ AS_IF([test -n "${enable_libva}"], [
AC_MSG_ERROR([libva is present but libavcodec/vaapi.h is missing]) AC_MSG_ERROR([libva is present but libavcodec/vaapi.h is missing])
...@@ -2258,6 +2257,7 @@ AS_IF([test "${enable_libva}" != "no"], [ ...@@ -2258,6 +2257,7 @@ AS_IF([test "${enable_libva}" != "no"], [
]) ])
]) ])
]) ])
AM_CONDITIONAL([HAVE_AVCODEC_VAAPI], [test "${have_avcodec_vaapi}" = "yes"])
dnl dnl
dnl dxva2 needs avcodec dnl dxva2 needs avcodec
...@@ -2265,15 +2265,15 @@ dnl ...@@ -2265,15 +2265,15 @@ dnl
AC_ARG_ENABLE(dxva2, AC_ARG_ENABLE(dxva2,
[ --enable-dxva2 DxVA2 GPU decoding support (default auto)]) [ --enable-dxva2 DxVA2 GPU decoding support (default auto)])
have_avcodec_dxva2="no"
AS_IF([test "${enable_dxva2}" != "no"], [ AS_IF([test "${enable_dxva2}" != "no"], [
if test "${SYS}" = "mingw32"; then if test "${SYS}" = "mingw32"; then
AS_IF([test "x${have_avcodec}" = "xyes"], [ AS_IF([test "x${have_avcodec}" = "xyes"], [
AC_CHECK_HEADERS(dxva2api.h, AC_CHECK_HEADERS(dxva2api.h,
[ [
AC_CHECK_HEADERS(libavcodec/dxva2.h, [ AC_CHECK_HEADERS(libavcodec/dxva2.h, [
VLC_ADD_LIBS([avcodec],[-lole32 -lshlwapi -luuid]) AC_MSG_NOTICE([DxVA2 acceleration activated])
AC_DEFINE(HAVE_AVCODEC_DXVA2, 1, [Define if avcodec has to be built with DxVA2 support.]) have_avcodec_dxva2="yes"
echo "DxVA2 acceleration activated"
],[ ],[
AS_IF([test "${enable_dxva2}" = "yes"], AS_IF([test "${enable_dxva2}" = "yes"],
[AC_MSG_ERROR([dxva2 is present but libavcodec/dxva2.h is missing])], [AC_MSG_ERROR([dxva2 is present but libavcodec/dxva2.h is missing])],
...@@ -2293,6 +2293,7 @@ AS_IF([test "${enable_dxva2}" != "no"], [ ...@@ -2293,6 +2293,7 @@ AS_IF([test "${enable_dxva2}" != "no"], [
]) ])
fi fi
]) ])
AM_CONDITIONAL([HAVE_AVCODEC_DXVA2], [test "${have_avcodec_dxva2}" = "yes"])
dnl dnl
dnl vda needs avcodec dnl vda needs avcodec
...@@ -2300,15 +2301,14 @@ dnl ...@@ -2300,15 +2301,14 @@ dnl
AC_ARG_ENABLE(vda, AC_ARG_ENABLE(vda,
[ --enable-vda VDA support (default auto)]) [ --enable-vda VDA support (default auto)])
have_avcodec_vda="no"
AS_IF([test "${enable_vda}" != "no"], [ AS_IF([test "${enable_vda}" != "no"], [
if test "${SYS}" = "darwin"; then if test "${SYS}" = "darwin"; then
AS_IF([test "x${have_avcodec}" = "xyes"], [ AS_IF([test "x${have_avcodec}" = "xyes"], [
AC_CHECK_HEADERS(VideoDecodeAcceleration/VDADecoder.h, AC_CHECK_HEADERS(VideoDecodeAcceleration/VDADecoder.h,
[ [
AC_CHECK_HEADERS(libavcodec/vda.h, [ AC_CHECK_HEADERS(libavcodec/vda.h, [
VLC_ADD_LIBS([avcodec],[-Wl,-framework,CoreFoundation,-framework,VideoDecodeAcceleration,-framework,QuartzCore]) have_avcodec_vda="yes"
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.])
],[ ],[
AS_IF([test "${enable_vda}" == "yes"], AS_IF([test "${enable_vda}" == "yes"],
[AC_MSG_ERROR([vda is present but libavcodec/vda.h is missing])], [AC_MSG_ERROR([vda is present but libavcodec/vda.h is missing])],
...@@ -2326,6 +2326,7 @@ AS_IF([test "${enable_vda}" != "no"], [ ...@@ -2326,6 +2326,7 @@ AS_IF([test "${enable_vda}" != "no"], [
]) ])
fi fi
]) ])
AM_CONDITIONAL([HAVE_AVCODEC_VDA], [test "${have_avcodec_vda}" = "yes"])
dnl dnl
dnl stream_out switcher needs libavcodec dnl stream_out switcher needs libavcodec
......
...@@ -94,9 +94,6 @@ libavcodec_plugin_la_SOURCES = \ ...@@ -94,9 +94,6 @@ libavcodec_plugin_la_SOURCES = \
avcodec/deinterlace.c \ avcodec/deinterlace.c \
avcodec/fourcc.c \ avcodec/fourcc.c \
avcodec/chroma.c avcodec/chroma.h \ avcodec/chroma.c avcodec/chroma.h \
avcodec/vaapi.c \
avcodec/dxva2.c \
avcodec/vda.c \
avcodec/copy.c avcodec/copy.h \ avcodec/copy.c avcodec/copy.h \
avcodec/va.h \ avcodec/va.h \
avcodec/avcodec.c avcodec/avcodec.h avcodec/avcodec.c avcodec/avcodec.h
...@@ -107,6 +104,21 @@ endif ...@@ -107,6 +104,21 @@ endif
libavcodec_plugin_la_CFLAGS = $(AM_CFLAGS) $(CFLAGS_avcodec) libavcodec_plugin_la_CFLAGS = $(AM_CFLAGS) $(CFLAGS_avcodec)
libavcodec_plugin_la_LIBADD = $(AM_LIBADD) $(LIBS_avcodec) libavcodec_plugin_la_LIBADD = $(AM_LIBADD) $(LIBS_avcodec)
libavcodec_plugin_la_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_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 if MERGE_FFMPEG
libavcodec_plugin_la_SOURCES += \ libavcodec_plugin_la_SOURCES += \
../demux/avformat/demux.c \ ../demux/avformat/demux.c \
......
...@@ -287,12 +287,6 @@ int ffmpeg_OpenCodec( decoder_t *p_dec ); ...@@ -287,12 +287,6 @@ int ffmpeg_OpenCodec( decoder_t *p_dec );
(LIBAVCODEC_VERSION_MICRO >= 100 && LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( a, d, e ) ) (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 /* Ugly ifdefinitions to provide backwards compatibility with older ffmpeg/libav
* versions */ * versions */
#ifndef AV_CPU_FLAG_FORCE #ifndef AV_CPU_FLAG_FORCE
......
...@@ -28,13 +28,11 @@ ...@@ -28,13 +28,11 @@
#endif #endif
#if defined(HAVE_LIBAVCODEC_AVCODEC_H) && defined(HAVE_AVCODEC_DXVA2)
# if _WIN32_WINNT < 0x600 # if _WIN32_WINNT < 0x600
/* dxva2 needs Vista support */ /* dxva2 needs Vista support */
# undef _WIN32_WINNT # undef _WIN32_WINNT
# define _WIN32_WINNT 0x600 # define _WIN32_WINNT 0x600
# endif # endif
#endif
#include <vlc_common.h> #include <vlc_common.h>
#include <vlc_picture.h> #include <vlc_picture.h>
...@@ -43,18 +41,14 @@ ...@@ -43,18 +41,14 @@
#include <assert.h> #include <assert.h>
#include <libavcodec/avcodec.h> #include <libavcodec/avcodec.h>
#ifdef HAVE_AVCODEC_DXVA2
# define DXVA2API_USE_BITFIELDS # define DXVA2API_USE_BITFIELDS
# define COBJMACROS # define COBJMACROS
# include <libavcodec/dxva2.h> # include <libavcodec/dxva2.h>
#endif
#include "avcodec.h" #include "avcodec.h"
#include "va.h" #include "va.h"
#include "copy.h" #include "copy.h"
#ifdef HAVE_AVCODEC_DXVA2
#include <windows.h> #include <windows.h>
#include <windowsx.h> #include <windowsx.h>
#include <ole2.h> #include <ole2.h>
...@@ -1015,4 +1009,3 @@ static void DxDestroyVideoConversion(vlc_va_dxva2_t *va) ...@@ -1015,4 +1009,3 @@ static void DxDestroyVideoConversion(vlc_va_dxva2_t *va)
{ {
CopyCleanCache(&va->surface_cache); CopyCleanCache(&va->surface_cache);
} }
#endif
...@@ -35,8 +35,6 @@ ...@@ -35,8 +35,6 @@
#include "va.h" #include "va.h"
#include "copy.h" #include "copy.h"
#ifdef HAVE_AVCODEC_VAAPI
#include <vlc_xlib.h> #include <vlc_xlib.h>
#include <libavcodec/vaapi.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, ...@@ -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; p_va->va.close = Delete;
return &p_va->va; return &p_va->va;
} }
#endif
...@@ -34,8 +34,6 @@ ...@@ -34,8 +34,6 @@
#include "va.h" #include "va.h"
#include "copy.h" #include "copy.h"
#ifdef HAVE_AVCODEC_VDA
#include <libavcodec/vda.h> #include <libavcodec/vda.h>
#include <VideoDecodeAcceleration/VDADecoder.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, ...@@ -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; return &p_va->va;
} }
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment