Allow conditional build of GStreamer/FFmpeg bitstream parsers.

This commit is contained in:
Gwenole Beauchesne 2011-08-12 10:21:19 +02:00
parent 3360f7f3e3
commit 8f0eda8964
4 changed files with 139 additions and 32 deletions

View file

@ -99,6 +99,16 @@ AC_ARG_ENABLE(vaapisink-glx,
[enable OpenGL/X11 to vaapisink @<:@default=yes@:>@]),
[], [enable_vaapisink_glx="no"])
AC_ARG_ENABLE(ffmpeg,
AC_HELP_STRING([--enable-ffmpeg],
[enable bitstream parsing from FFmpeg @<:@default=yes@:>@]),
[], [enable_ffmpeg="yes"])
AC_ARG_ENABLE(codecparsers,
AC_HELP_STRING([--enable-codecparsers],
[enable adhoc bitstream parsers from GStreamer @<:@default=yes@:>@]),
[], [enable_codecparsers="yes"])
dnl Check for __attribute__((visibility()))
AC_CACHE_CHECK([whether __attribute__((visibility())) is supported],
vaapi_cv_visibility_attribute,
@ -220,6 +230,20 @@ PKG_CHECK_MODULES([GST_BASEVIDEO],
AC_SUBST(GST_BASEVIDEO_CFLAGS)
AC_SUBST(GST_BASEVIDEO_LIBS)
dnl Check for GStreamer codec parsers
USE_CODEC_PARSERS=0
if test "$enable_codecparsers" = "yes"; then
PKG_CHECK_MODULES([GST_CODEC_PARSERS],
[gstreamer-codecparsers-$GST_MAJORMINOR >= $GST_VERSION_REQUIRED],
[enable_codecparsers="yes" USE_CODEC_PARSERS=1],
[enable_codecparsers="no" USE_CODEC_PARSERS=0]
)
fi
AC_DEFINE_UNQUOTED(USE_CODEC_PARSERS, $USE_CODEC_PARSERS,
[Defined to 1 if GStreamer codec parsers are used])
AM_CONDITIONAL(USE_CODEC_PARSERS, test $USE_CODEC_PARSERS -eq 1)
dnl Check for GStreamer interfaces
PKG_CHECK_MODULES([GST_INTERFACES],
[gstreamer-interfaces-$GST_MAJORMINOR >= $GST_PLUGINS_BASE_VERSION_REQUIRED]
@ -338,10 +362,28 @@ else
fi
dnl Check for FFmpeg
PKG_CHECK_MODULES(LIBAVCODEC, [libavcodec])
USE_FFMPEG=0
if test "$enable_ffmpeg" = "yes"; then
PKG_CHECK_MODULES(LIBAVCODEC, [libavcodec],
[enable_ffmpeg="yes" USE_FFMPEG=1],
[enable_ffmpeg="no" USE_FFMPEG=0]
)
fi
if test "$enable_ffmpeg" = "yes"; then
AC_CHECK_HEADERS([libavcodec/avcodec.h ffmpeg/avcodec.h])
AC_CHECK_HEADERS([libavcodec/vaapi.h ffmpeg/vaapi.h], [break],
AC_MSG_ERROR([The system FFmpeg headers do not support VA-API]))
AC_CHECK_HEADERS([libavcodec/vaapi.h ffmpeg/vaapi.h],
[break],
[enable_ffmpeg="no" USE_FFMPEG=0]
)
fi
if test "$enable_ffmpeg:$enable_codecparsers" = "no:no"; then
AC_MSG_ERROR([Found neither suitable FFmpeg with VA-API support nor GStreamer bitstream parsers])
fi
AC_DEFINE_UNQUOTED(USE_FFMPEG, $USE_FFMPEG,
[Defined to 1 if FFmpeg is used])
AM_CONDITIONAL(USE_FFMPEG, test $USE_FFMPEG -eq 1)
AC_DEFINE_UNQUOTED(USE_GLX, $USE_GLX,
[Defined to 1 if GLX is enabled])
@ -414,4 +456,6 @@ echo VA-API version ................... : $VA_VERSION_STR
echo GLX support ...................... : $(yesno $USE_GLX)
echo VA/GLX support ................... : $(yesno $USE_VAAPI_GLX)
echo VaapiSink/GL ..................... : $(yesno $USE_VAAPISINK_GLX)
echo FFmpeg bitstream parsers ......... : $(yesno $USE_FFMPEG)
echo GStreamer bitstream parsers ...... : $(yesno $USE_CODEC_PARSERS)
echo

View file

@ -10,15 +10,21 @@ endif
libgstvaapi_includedir = \
$(includedir)/gstreamer-@GST_MAJORMINOR@/gst/vaapi
libgstvaapi_ffmpeg_source_c = \
gstvaapidecoder_ffmpeg.c \
libgstvaapi_cflags = \
-DGST_USE_UNSTABLE_API \
-I$(top_srcdir)/gst-libs \
$(GST_BASE_CFLAGS) \
$(GST_BASEVIDEO_CFLAGS) \
$(GST_VIDEO_CFLAGS) \
$(GST_CFLAGS) \
$(LIBVA_CFLAGS) \
$(NULL)
libgstvaapi_ffmpeg_source_h = \
gstvaapidecoder_ffmpeg.h \
$(NULL)
libgstvaapi_ffmpeg_source_priv_h = \
libgstvaapi_libs = \
$(GST_BASE_LIBS) \
$(GST_BASEVIDEO_LIBS) \
$(GST_LIBS) \
$(LIBVA_LIBS) \
$(NULL)
libgstvaapi_source_c = \
@ -44,7 +50,6 @@ libgstvaapi_source_c = \
gstvaapivideopool.c \
gstvaapivideosink.c \
gstvaapiwindow.c \
$(libgstvaapi_ffmpeg_source_c) \
$(NULL)
libgstvaapi_source_h = \
@ -68,7 +73,6 @@ libgstvaapi_source_h = \
gstvaapivideopool.h \
gstvaapivideosink.h \
gstvaapiwindow.h \
$(libgstvaapi_ffmpeg_source_h) \
$(NULL)
libgstvaapi_source_priv_h = \
@ -131,6 +135,22 @@ libgstvaapi_glx_source_priv_h = \
gstvaapiutils_x11.h \
$(NULL)
if USE_FFMPEG
libgstvaapi_source_c += gstvaapidecoder_ffmpeg.c
libgstvaapi_source_h += gstvaapidecoder_ffmpeg.h
libgstvaapi_cflags += $(LIBAVCODEC_CFLAGS)
libgstvaapi_libs += $(LIBAVCODEC_LIBS)
endif
if USE_CODEC_PARSERS
libgstvaapi_source_c += \
$(NULL)
libgstvaapi_source_h += \
$(NULL)
libgstvaapi_cflags += $(GST_CODEC_PARSERS_CFLAGS)
libgstvaapi_libs += $(GST_CODEC_PARSERS_LIBS)
endif
libgstvaapi_@GST_MAJORMINOR@_la_SOURCES = \
$(libgstvaapi_source_c) \
$(libgstvaapi_source_priv_h) \
@ -144,22 +164,11 @@ libgstvaapi_@GST_MAJORMINOR@includedir = \
$(libgstvaapi_includedir)
libgstvaapi_@GST_MAJORMINOR@_la_CFLAGS = \
-DGST_USE_UNSTABLE_API \
-I$(top_srcdir)/gst-libs \
$(GST_BASE_CFLAGS) \
$(GST_BASEVIDEO_CFLAGS) \
$(GST_VIDEO_CFLAGS) \
$(GST_CFLAGS) \
$(LIBAVCODEC_CFLAGS) \
$(LIBVA_CFLAGS) \
$(libgstvaapi_cflags) \
$(NULL)
libgstvaapi_@GST_MAJORMINOR@_la_LIBADD = \
$(GST_BASE_LIBS) \
$(GST_BASEVIDEO_LIBS) \
$(GST_LIBS) \
$(LIBAVCODEC_LIBS) \
$(LIBVA_LIBS) \
$(libgstvaapi_libs) \
$(NULL)
libgstvaapi_@GST_MAJORMINOR@_la_LDFLAGS = \

View file

@ -45,6 +45,16 @@
#include "gstvaapidecode.h"
#include "gstvaapipluginutil.h"
#if USE_FFMPEG
# include <gst/vaapi/gstvaapidecoder_ffmpeg.h>
#endif
#if USE_CODEC_PARSERS
#endif
/* Favor codecparsers-based decoders for 0.3.x series */
#define USE_FFMPEG_DEFAULT \
(USE_FFMPEG && !USE_CODEC_PARSERS)
#define GST_PLUGIN_NAME "vaapidecode"
#define GST_PLUGIN_DESC "A VA-API based video decoder"
@ -271,6 +281,9 @@ error_commit_buffer:
static gboolean
gst_vaapidecode_create(GstVaapiDecode *decode, GstCaps *caps)
{
VADisplay dpy;
GstStructure *structure;
if (!gst_vaapi_ensure_display(decode, &decode->display))
return FALSE;
@ -282,8 +295,19 @@ gst_vaapidecode_create(GstVaapiDecode *decode, GstCaps *caps)
if (!decode->decoder_ready)
return FALSE;
if (decode->use_ffmpeg)
decode->decoder = gst_vaapi_decoder_ffmpeg_new(decode->display, caps);
dpy = decode->display;
if (decode->use_ffmpeg) {
#if USE_FFMPEG
decode->decoder = gst_vaapi_decoder_ffmpeg_new(dpy, caps);
#endif
}
else {
#if USE_CODEC_PARSERS
structure = gst_caps_get_structure(caps, 0);
if (!structure)
return FALSE;
#endif
}
if (!decode->decoder)
return FALSE;
@ -504,14 +528,16 @@ gst_vaapidecode_class_init(GstVaapiDecodeClass *klass)
element_class->change_state = gst_vaapidecode_change_state;
#if USE_FFMPEG
g_object_class_install_property
(object_class,
PROP_USE_FFMPEG,
g_param_spec_boolean("use-ffmpeg",
"Use FFmpeg/VAAPI for decoding",
"Uses FFmpeg/VAAPI for decoding",
TRUE,
USE_FFMPEG_DEFAULT,
G_PARAM_READWRITE));
#endif
}
static gboolean
@ -672,7 +698,7 @@ gst_vaapidecode_init(GstVaapiDecode *decode, GstVaapiDecodeClass *klass)
decode->decoder_ready = NULL;
decode->decoder_caps = NULL;
decode->allowed_caps = NULL;
decode->use_ffmpeg = TRUE;
decode->use_ffmpeg = USE_FFMPEG_DEFAULT;
decode->is_ready = FALSE;
/* Pad through which data comes in to the element */

View file

@ -19,16 +19,22 @@
* Boston, MA 02110-1301 USA
*/
#include "config.h"
#include <string.h>
#include <gst/vaapi/gstvaapidisplay_x11.h>
#include <gst/vaapi/gstvaapiwindow_x11.h>
#include <gst/vaapi/gstvaapidecoder.h>
#include <gst/vaapi/gstvaapidecoder_ffmpeg.h>
#include <gst/vaapi/gstvaapisurface.h>
#include "test-mpeg2.h"
#include "test-h264.h"
#include "test-vc1.h"
#if USE_FFMPEG
# include <gst/vaapi/gstvaapidecoder_ffmpeg.h>
#endif
#if USE_CODEC_PARSERS
#endif
/* Set to 1 to check display cache works (shared VA display) */
#define CHECK_DISPLAY_CACHE 1
@ -66,12 +72,21 @@ static inline void pause(void)
}
static gchar *g_codec_str;
static gboolean g_use_ffmpeg = FALSE;
static GOptionEntry g_options[] = {
{ "codec", 'c',
0,
G_OPTION_ARG_STRING, &g_codec_str,
"codec to test", NULL },
{ "ffmpeg", 0,
0,
G_OPTION_ARG_NONE, &g_use_ffmpeg,
"use ffmpeg", NULL },
{ "codecparsers", 0,
G_OPTION_FLAG_REVERSE,
G_OPTION_ARG_NONE, &g_use_ffmpeg,
"use codec parsers", NULL },
{ NULL, }
};
@ -137,9 +152,22 @@ main(int argc, char *argv[])
NULL
);
decoder = gst_vaapi_decoder_ffmpeg_new(display, decoder_caps);
if (g_use_ffmpeg) {
#if USE_FFMPEG
decoder = gst_vaapi_decoder_ffmpeg_new(display, decoder_caps);
#endif
}
else {
#if USE_CODEC_PARSERS
switch (gst_vaapi_profile_get_codec(info.profile)) {
default:
decoder = NULL;
break;
}
#endif
}
if (!decoder)
g_error("could not create FFmpeg decoder");
g_error("could not create decoder");
gst_caps_unref(decoder_caps);
buffer = gst_buffer_new();