Commit 9d510ebe authored by Jean-Paul Saman's avatar Jean-Paul Saman

avcodec: use automake conditionals for hardware acceleration

This is a manual backport of commit-id: 1962cd3095652e676cea7830da863cc6f2b621d6
parent 4f49cd25
......@@ -2452,16 +2452,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])
......@@ -2478,22 +2477,22 @@ AS_IF([test "${enable_libva}" != "no"], [
])
])
])
AM_CONDITIONAL([HAVE_AVCODEC_VAAPI], [test "${have_avcodec_vaapi}" = "yes"])
dnl
dnl dxva2 needs avcodec
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])],
......@@ -2513,7 +2512,7 @@ AS_IF([test "${enable_dxva2}" != "no"], [
])
fi
])
AM_CONDITIONAL([HAVE_AVCODEC_DXVA2], [test "${have_avcodec_dxva2}" = "yes"])
dnl
dnl stream_out switcher needs libavcodec
......@@ -3061,7 +3060,8 @@ AC_ARG_ENABLE(glx,
])
have_xcb="no"
have_glx="no"
have_vaapi_glx="no"
have_vaapi_xcb="no"
AS_IF([test "${enable_xcb}" != "no"], [
dnl libxcb
PKG_CHECK_MODULES(XCB, [xcb >= 1.6])
......@@ -3097,10 +3097,15 @@ AS_IF([test "${enable_xcb}" != "no"], [
dnl avcodec (vaapi-xcb)
AS_IF([test "${enable_libva}" != "no"], [
AS_IF([test "${have_avcodec}" != "no"], [
PKG_CHECK_MODULES(XLIB_XCB, [x11-xcb])
VLC_ADD_CFLAGS([avcodec], [${XLIB_XCB_CFLAGS} ${XCB_CFLAGS}])
VLC_ADD_LIBS([avcodec], [${XLIB_XCB_LIBS} ${XCB_LIBS}])
AC_DEFINE(HAVE_XCB, 1, [Define if avcodec has to be built with XCB support.])
PKG_CHECK_MODULES(XLIB_XCB, [x11-xcb], [
PKG_CHECK_MODULES(LIBVA_X11, [libva-x11], [
have_vaapi_xcb="yes"
], [
AC_MSG_WARN([libva present, but no libva-x11.])
])
], [
AC_MSG_WARN([libva present, but no libva-x11.])
])
])
])
......@@ -3113,10 +3118,8 @@ AS_IF([test "${enable_xcb}" != "no"], [
dnl avcodec (vaapi-glx)
AS_IF([test "${enable_libva}" != "no"], [
AS_IF([test "${have_avcodec}" != "no"], [
PKG_CHECK_MODULES(LIBVA, [libva libva-x11 libva-glx], [
VLC_ADD_CFLAGS([avcodec], [${GL_CFLAGS} ${GL_CFLAGS}])
VLC_ADD_LIBS([avcodec], [${GL_LIBS} ${GL_LIBS} -lva-glx])
AC_DEFINE(HAVE_GLX, 1, [Define if avcodec has to be built with GL support.])
PKG_CHECK_MODULES(LIBVA_GLX, [libva-glx], [
have_vaapi_glx="yes"
], [
AC_MSG_WARN([libva XCB and GLX present, but not libva-glx.])
])
......@@ -3126,7 +3129,8 @@ AS_IF([test "${enable_xcb}" != "no"], [
])
])
AM_CONDITIONAL([HAVE_XCB], [test "${have_xcb}" = "yes"])
AM_CONDITIONAL([HAVE_GLX], [test "${have_glx}" = "yes"])
AM_CONDITIONAL([HAVE_VAAPI_XCB], [test "${have_vaapi_xcb}" = "yes"])
AM_CONDITIONAL([HAVE_VAAPI_GLX], [test "${have_vaapi_glx}" = "yes"])
dnl
dnl SDL module
......
......@@ -8,16 +8,28 @@ libavcodec_plugin_la_SOURCES = \
fourcc.c \
chroma.h \
chroma.c \
vaapi.h \
vaapi.c \
dxva2.c \
copy.c \
copy.h \
va.c \
va.h \
$(NULL)
if HAVE_XCB
libavcodec_plugin_la_CFLAGS = $(AM_CFLAGS) $(CFLAGS_avcodec)
libavcodec_plugin_la_LIBADD = $(AM_LIBADD) $(LIBS_avcodec)
libavcodec_plugin_la_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_avcodec)
libavcodec_plugin_la_DEPENDENCIES =
if HAVE_AVCODEC_VAAPI
libavcodec_plugin_la_SOURCES += vaapi.c vaapi.c va.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 += dxva2.c
libavcodec_plugin_la_CFLAGS += -DHAVE_AVCODEC_DXVA2
libavcodec_plugin_la_LIBADD += -lole32 -lshlwapi -luuid
endif
if HAVE_VAAPI_XCB
libavcodec_plugin_la_SOURCES += \
../../video_output/vaapi/spu.h \
../../video_output/vaapi/spu.c \
......@@ -28,22 +40,22 @@ libavcodec_plugin_la_SOURCES += \
../../video_output/xcb/events.c \
../../video_output/xcb/xcb_events_vlc.h \
$(NULL)
libavcodec_plugin_la_CFLAGS += $(LIBVA_X11_CFLAGS) ${XLIB_XCB_CFLAGS} ${XCB_CFLAGS} -DHAVE_VAAPI_XCB
libavcodec_plugin_la_LIBADD += $(LIBVA_X11_LIBS) ${XLIB_XCB_LIBS} ${XCB_LIBS}
endif
if HAVE_GLX
if HAVE_VAAPI_GLX
libavcodec_plugin_la_SOURCES += \
../../video_output/vaapi/glx.h \
../../video_output/vaapi/glx.c \
$(NULL)
libavcodec_plugin_la_CFLAGS += $(LIBVA_GLX_CFLAGS) ${GL_CFLAGS} -DHAVE_VAAPI_GLX
libavcodec_plugin_la_LIBADD += $(LIBVA_GLX_LIBS) ${GL_LIBS}
endif
if ENABLE_SOUT
libavcodec_plugin_la_SOURCES += \
encoder.c
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)
libavcodec_plugin_la_DEPENDENCIES =
if MERGE_FFMPEG
libavcodec_plugin_la_SOURCES += \
......
......@@ -81,9 +81,9 @@ static const char *const enc_hq_list_text[] = {
# include "../../access/avio.h"
#endif
#if defined(HAVE_AVCODEC_VAAPI) && defined(HAVE_XCB)
#if defined(HAVE_AVCODEC_VAAPI) && defined(HAVE_VAAPI_XCB)
# include "../../video_output/vaapi/xcb.h"
# ifdef HAVE_GLX
# ifdef HAVE_VAAPI_GLX
# include "../../video_output/vaapi/glx.h"
# endif
#endif
......@@ -222,7 +222,7 @@ vlc_module_begin ()
AVIO_MODULE
#endif
#if defined(HAVE_AVCODEC_VAAPI) && defined(HAVE_XCB)
#if defined(HAVE_AVCODEC_VAAPI) && defined(HAVE_VAAPI_XCB)
/* vaapi_xcb submodule */
add_submodule()
set_description (N_("VAAPI X11 video output (XCB)"))
......@@ -236,7 +236,7 @@ vlc_module_begin ()
VOUT_RECYCLE_TEXT, VOUT_RECYCLE_LONGTEXT, true )
/* vaapi_glx submodule */
# ifdef HAVE_GLX
# ifdef HAVE_VAAPI_GLX
add_submodule()
set_description (N_("VAAPI GLX video output (XCB)"))
set_category (CAT_VIDEO)
......@@ -248,8 +248,6 @@ vlc_module_begin ()
add_bool( VOUT_CFG_PREFIX "recycle", false,
VOUT_RECYCLE_TEXT, VOUT_RECYCLE_LONGTEXT, true )
# endif
#endif
vlc_module_end ()
......
......@@ -294,11 +294,6 @@ int ffmpeg_OpenCodec( decoder_t *p_dec );
# define HAVE_AVCODEC_MT
#endif
/* Uncomment it to enable compilation with vaapi/dxva2 (you also must change the build
* system) */
//#define HAVE_AVCODEC_VAAPI 1
//#define HAVE_AVCODEC_DXVA2 1
/* Ugly ifdefinitions to provide backwards compatibility with older ffmpeg/libav
* versions */
#ifndef AV_CPU_FLAG_FORCE
......
......@@ -27,13 +27,10 @@
# include "config.h"
#endif
#if defined(HAVE_LIBAVCODEC_AVCODEC_H) && defined(HAVE_AVCODEC_DXVA2)
# if _WIN32_WINNT < 0x600
#if _WIN32_WINNT < 0x600
/* dxva2 needs Vista support */
# undef _WIN32_WINNT
# define _WIN32_WINNT 0x600
# endif
# undef _WIN32_WINNT
# define _WIN32_WINNT 0x600
#endif
#include <vlc_common.h>
......@@ -44,11 +41,9 @@
#ifdef HAVE_LIBAVCODEC_AVCODEC_H
# include <libavcodec/avcodec.h>
# ifdef HAVE_AVCODEC_DXVA2
# define DXVA2API_USE_BITFIELDS
# define COBJMACROS
# include <libavcodec/dxva2.h>
# endif
# define DXVA2API_USE_BITFIELDS
# define COBJMACROS
# include <libavcodec/dxva2.h>
#else
# include <avcodec.h>
#endif
......@@ -57,8 +52,6 @@
#include "va.h"
#include "copy.h"
#ifdef HAVE_AVCODEC_DXVA2
#include <windows.h>
#include <windowsx.h>
#include <ole2.h>
......@@ -1018,4 +1011,3 @@ static void DxDestroyVideoConversion(vlc_va_dxva2_t *va)
{
CopyCleanCache(&va->surface_cache);
}
#endif
......@@ -42,15 +42,13 @@
# include <libavcodec/vaapi.h>
# include <va/va.h>
# include <va/va_x11.h>
# if HAVE_GLX
# ifdef HAVE_VAAPI_GLX
# include <va/va_glx.h>
# endif
#endif
#include "va.h"
#include "vaapi.h"
#ifdef HAVE_AVCODEC_VAAPI
static vlc_mutex_t vlc_va_conn_lock = VLC_STATIC_MUTEX;
static vlc_va_conn_t vlc_va_conn;
......@@ -519,5 +517,3 @@ void vlc_va_Terminate( vlc_va_conn_t *conn )
vlc_mutex_unlock( &vlc_va_conn_lock );
}
#endif
......@@ -31,25 +31,24 @@
#include <vlc_arrays.h>
#include <assert.h>
#include "avcodec.h"
#ifdef HAVE_LIBAVCODEC_AVCODEC_H
# include <libavcodec/avcodec.h>
# include <libavcodec/vaapi.h>
#else
# include <avcodec.h>
# include <vaapi.h>
#endif
#include "avcodec.h"
#ifdef HAVE_AVCODEC_VAAPI
# include <vlc_xlib.h>
# include <libavcodec/vaapi.h>
# include <va/va.h>
# include <va/va_x11.h>
#endif
#include <vlc_xlib.h>
#include <va/va.h>
#include <va/va_x11.h>
#include "va.h"
#include "vaapi.h"
#include "copy.h"
#ifdef HAVE_AVCODEC_VAAPI
typedef struct
{
vlc_va_t va;
......@@ -665,12 +664,3 @@ vlc_va_t *vlc_va_NewVaapi( vlc_object_t *obj, int i_codec_id )
p_va->va.close = Delete;
return &p_va->va;
}
#else
vlc_va_t *vlc_va_NewVaapi( vlc_object_t *obj, int i_codec_id )
{
VLC_UNUSED( obj );
VLC_UNUSED( i_codec_id );
return NULL;
}
#endif
......@@ -39,16 +39,15 @@
#include <X11/Xutil.h>
#include "../../video_output/xcb/xcb_events_vlc.h"
#if defined(HAVE_AVCODEC_VAAPI) && defined(HAVE_XCB)
#ifdef HAVE_LIBAVCODEC_AVCODEC_H
# include <libavcodec/avcodec.h>
# include <libavcodec/vaapi.h>
#else
# include <avcodec.h>
# include <vaapi.h>
#endif
#include "../../codec/avcodec/avcodec.h"
#include <libavcodec/vaapi.h>
#include <va/va.h>
#include <va/va_x11.h>
......@@ -290,5 +289,3 @@ error:
return NULL;
}
#endif /* HAVE_AVCODEC_VAAPI */
/**
* @file vaapi/glx.c
* @brief VA API using GLX video output module for VLC media player
*/
/*****************************************************************************
* Copyright © 2013, M2X BV
* Author: Jean-Paul Saman
......@@ -34,12 +38,12 @@
#include <vlc_arrays.h>
#if defined(HAVE_AVCODEC_VAAPI) && defined(HAVE_XCB) && defined(HAVE_GLX)
#ifdef HAVE_LIBAVCODEC_AVCODEC_H
# include <libavcodec/avcodec.h>
# include <libavcodec/vaapi.h>
#else
# include <avcodec.h>
# include <vaapi.h>
#endif
#include "../../codec/avcodec/avcodec.h"
......@@ -54,7 +58,6 @@
#include <GL/glxext.h>
#include <vlc_opengl.h>
#include <libavcodec/vaapi.h>
#include <va/va.h>
#include <va/va_x11.h>
#include <va/va_glx.h>
......@@ -872,5 +875,3 @@ static picture_pool_t *Pool(vout_display_t *vd, unsigned requested)
return sys->pool;
}
#endif /* HAVE_AVCODEC_VAAPI */
......@@ -33,8 +33,6 @@
#include <vlc_arrays.h>
#ifdef HAVE_AVCODEC_VAAPI
#include <xcb/xcb.h>
#include <X11/Xlib-xcb.h>
......@@ -863,4 +861,3 @@ void vlc_va_spu_cache_Delete(vlc_va_conn_t *va, vlc_va_spu_cache_t *restrict spu
vlc_mutex_destroy(&spu->lock);
}
#endif
......@@ -20,8 +20,6 @@
#ifndef VLC_VAAPI_SPU_H
#define VLC_VAAPI_SPU_H 1
#ifdef HAVE_AVCODEC_VAAPI
/* Available subtitle formats */
static const vlc_fourcc_t va_subpicture_chromas[] = {
VLC_CODEC_RGBA,
......@@ -62,5 +60,3 @@ int vlc_va_spu_cache_Get(vlc_object_t *obj, vlc_va_spu_cache_t *spu, const unsig
void vlc_va_spu_cache_Put(vlc_va_spu_cache_t *spu, spu_cache_t *cache);
#endif
#endif
......@@ -38,12 +38,12 @@
#include <vlc_arrays.h>
#if defined(HAVE_AVCODEC_VAAPI) && defined(HAVE_XCB)
#ifdef HAVE_LIBAVCODEC_AVCODEC_H
# include <libavcodec/avcodec.h>
# include <libavcodec/vaapi.h>
#else
# include <avcodec.h>
# include <vaapi.h>
#endif
#include "../../codec/avcodec/avcodec.h"
......@@ -54,7 +54,6 @@
#include <vlc_xlib.h>
#include "../../video_output/xcb/xcb_events_vlc.h"
#include <libavcodec/vaapi.h>
#include <va/va.h>
#include <va/va_x11.h>
#include "../../codec/avcodec/va.h"
......@@ -561,5 +560,3 @@ static picture_pool_t *Pool(vout_display_t *vd, unsigned requested)
return sys->pool;
}
#endif /* HAVE_AVCODEC_VAAPI */
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