mfc: Add plugin and decoder skeleton

This commit is contained in:
Sebastian Dröge 2012-12-23 10:23:16 +01:00
parent b0129f9994
commit 5d6c33d7e4
6 changed files with 354 additions and 2 deletions

View file

@ -753,6 +753,52 @@ AG_GST_CHECK_FEATURE(SHM, [POSIX shared memory source and sink], shm, [
fi
])
dnl *** Video 4 Linux 2 ***
dnl for information about the header/define, see sys/v4l2/gstv4l2element.h
dnl renamed to GST_V4L2 because of some conflict with kernel headers
translit(dnm, m, l) AM_CONDITIONAL(USE_MFC, true)
AG_GST_CHECK_FEATURE(MFC, [Multi Format Codec], mfc, [
AC_MSG_CHECKING([Checking for up to date v4l2 installation])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <sys/types.h>
#ifdef __sun /* Solaris */
#include <sys/types.h>
#include <sys/videodev2.h>
#elif __FreeBSD__
#include <linux/videodev2.h>
#else /* Linux */
#include <linux/types.h>
#define _LINUX_TIME_H
#define __user
#include <linux/videodev2.h>
#endif
#if defined(V4L2_MAJOR_VERSION) || defined(V4L2_MINOR_VERSION)
#error too early v4l2 version or no v4l2 at all
#endif
]], [[
return 0;
]])],[
HAVE_MFC="yes"
AC_MSG_RESULT(yes)
],[
HAVE_MFC="no"
AC_MSG_RESULT(no)
HAVE_VIDEODEV=no
AC_CHECK_HEADER(linux/videodev2.h, [ HAVE_VIDEODEV=yes ],
[
AC_CHECK_HEADER(sys/videodev2.h, [ HAVE_VIDEODEV=yes ])
])
if test "x$HAVE_VIDEODEV" = "xyes"; then
AC_MSG_WARN([video4linux2 headers were found, but they're old.])
AC_MSG_WARN([Please update v4l2 to compile the MFC plugins])
else
AC_MSG_WARN([v4l2 was not found])
fi
])
])
dnl check for Video CD
translit(dnm, m, l) AM_CONDITIONAL(USE_VCD, true)
AG_GST_CHECK_FEATURE(VCD, [Video CD], vcdsrc, [
@ -2230,6 +2276,7 @@ sys/linsys/Makefile
sys/opensles/Makefile
sys/osxvideo/Makefile
sys/qtwrapper/Makefile
sys/mfc/Makefile
sys/shm/Makefile
sys/uvch264/Makefile
sys/vcd/Makefile

View file

@ -154,9 +154,15 @@ else
UVCH264_DIR=
endif
SUBDIRS = $(ACM_DIR) $(ANDROID_MEDIA_DIR) $(APPLE_MEDIA_DIR) $(AVC_DIR) $(D3DVIDEOSINK_DIR) $(DECKLINK_DIR) $(DIRECTDRAW_DIR) $(DIRECTSOUND_DIR) $(DIRECTSHOW_DIR) $(DVB_DIR) $(FBDEV_DIR) $(LINSYS_DIR) $(OPENSLES_DIR) $(OSX_VIDEO_DIR) $(PVR_DIR) $(QT_DIR) $(SHM_DIR) $(UVCH264_DIR) $(VCD_DIR) $(VDPAU_DIR) $(WININET_DIR) $(WINSCREENCAP_DIR) $(WASAPI_DIR)
if USE_MFC
MFC_DIR=mfc
else
MFC_DIR=
endif
SUBDIRS = $(ACM_DIR) $(ANDROID_MEDIA_DIR) $(APPLE_MEDIA_DIR) $(AVC_DIR) $(D3DVIDEOSINK_DIR) $(DECKLINK_DIR) $(DIRECTDRAW_DIR) $(DIRECTSOUND_DIR) $(DIRECTSHOW_DIR) $(DVB_DIR) $(FBDEV_DIR) $(LINSYS_DIR) $(OPENSLES_DIR) $(OSX_VIDEO_DIR) $(PVR_DIR) $(QT_DIR) $(SHM_DIR) $(UVCH264_DIR) $(VCD_DIR) $(VDPAU_DIR) $(WININET_DIR) $(WINSCREENCAP_DIR) $(WASAPI_DIR) $(MFC_DIR)
DIST_SUBDIRS = acmenc acmmp3dec androidmedia applemedia avc d3dvideosink decklink directdraw directsound dvb linsys fbdev dshowdecwrapper dshowsrcwrapper dshowvideosink \
opensles osxvideo pvr2d qtwrapper shm uvch264 vcd vdpau wasapi wininet winks winscreencap
opensles osxvideo pvr2d qtwrapper shm uvch264 vcd vdpau wasapi wininet winks winscreencap mfc
include $(top_srcdir)/common/parallel-subdirs.mak

24
sys/mfc/Makefile.am Normal file
View file

@ -0,0 +1,24 @@
plugin_LTLIBRARIES = libgstmfc.la
libgstmfc_la_SOURCES = \
mfc_decoder/mfc_decoder.c \
gstmfc.c \
gstmfcdec.c
noinst_HEADERS = \
mfc_decoder/mfc_decoder.h \
gstmfcdec.h
libgstmfc_la_CFLAGS = \
$(GST_PLUGINS_BASE_CFLAGS) \
$(GST_BASE_CFLAGS) \
$(GST_CFLAGS) \
-I$(srcdir)
libgstmfc_la_LIBADD = \
$(GST_PLUGINS_BASE_LIBS) \
-lgstvideo-@GST_MAJORMINOR@ \
$(GST_BASE_LIBS) \
$(GST_LIBS)
libgstmfc_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libgstmfc_la_LIBTOOLFLAGS = --tag=disable-static

43
sys/mfc/gstmfc.c Normal file
View file

@ -0,0 +1,43 @@
/*
* Copyright (C) 2012 Collabora Ltd.
* Author: Sebastian Dröge <sebastian.droege@collabora.co.uk>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gst/gst.h>
#include "gstmfcdec.h"
static gboolean
plugin_init (GstPlugin * plugin)
{
if (!gst_element_register (plugin, "mfcdec", GST_RANK_PRIMARY,
GST_TYPE_MFC_DEC))
return FALSE;
return TRUE;
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"mfc",
"Samsung Exynos MFC plugin",
plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)

167
sys/mfc/gstmfcdec.c Normal file
View file

@ -0,0 +1,167 @@
/*
* Copyright (C) 2012 Collabora Ltd.
* Author: Sebastian Dröge <sebastian.droege@collabora.co.uk>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstmfcdec.h"
GST_DEBUG_CATEGORY_STATIC (gst_mfc_dec_debug);
#define GST_CAT_DEFAULT gst_mfc_dec_debug
static gboolean gst_mfc_dec_start (GstVideoDecoder * decoder);
static gboolean gst_mfc_dec_stop (GstVideoDecoder * decoder);
static gboolean gst_mfc_dec_set_format (GstVideoDecoder * decoder,
GstVideoCodecState * state);
static gboolean gst_mfc_dec_reset (GstVideoDecoder * decoder,
gboolean hard);
static GstFlowReturn gst_mfc_dec_handle_frame (GstVideoDecoder * decoder,
GstVideoCodecFrame * frame);
static GstStaticPadTemplate gst_mfc_dec_sink_template =
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/x-h264, "
"parsed = (boolean) true, "
"stream-format = (string) byte-stream, "
"alignment = (string) au")
);
static GstStaticPadTemplate gst_mfc_dec_src_template =
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("NV12"))
);
GST_BOILERPLATE (GstMFCDec, gst_mfc_dec, GstVideoDecoder,
GST_TYPE_VIDEO_DECODER);
static void
gst_mfc_dec_base_init (gpointer g_class)
{
GstElementClass *element_class = (GstElementClass *) g_class;
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_mfc_dec_src_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_mfc_dec_sink_template));
gst_element_class_set_details_simple (element_class,
"Samsung Exynos MFC decoder",
"Codec/Decoder/Video",
"Decode video streams via Samsung Exynos",
"Sebastian Dröge <sebastian.droege@collabora.co.uk>");
}
static void
gst_mfc_dec_class_init (GstMFCDecClass * klass)
{
GstVideoDecoderClass *video_decoder_class;
video_decoder_class = (GstVideoDecoderClass *) klass;
video_decoder_class->start = GST_DEBUG_FUNCPTR (gst_mfc_dec_start);
video_decoder_class->stop = GST_DEBUG_FUNCPTR (gst_mfc_dec_stop);
video_decoder_class->reset = GST_DEBUG_FUNCPTR (gst_mfc_dec_reset);
video_decoder_class->set_format =
GST_DEBUG_FUNCPTR (gst_mfc_dec_set_format);
video_decoder_class->handle_frame =
GST_DEBUG_FUNCPTR (gst_mfc_dec_handle_frame);
GST_DEBUG_CATEGORY_INIT (gst_mfc_dec_debug, "mfcdec", 0,
"Samsung Exynos MFC Decoder");
}
static void
gst_mfc_dec_init (GstMFCDec * self, GstMFCDecClass * klass)
{
GstVideoDecoder *decoder = (GstVideoDecoder *) self;
gst_video_decoder_set_packetized (decoder, TRUE);
}
static gboolean
gst_mfc_dec_start (GstVideoDecoder * decoder)
{
GstMFCDec *self = GST_MFC_DEC (decoder);
GST_DEBUG_OBJECT (self, "Starting");
return TRUE;
}
static gboolean
gst_mfc_dec_stop (GstVideoDecoder * video_decoder)
{
GstMFCDec *self = GST_MFC_DEC (video_decoder);
GST_DEBUG_OBJECT (self, "Stopping");
if (self->input_state) {
gst_video_codec_state_unref (self->input_state);
self->input_state = NULL;
}
GST_DEBUG_OBJECT (self, "Stopped");
return TRUE;
}
static gboolean
gst_mfc_dec_set_format (GstVideoDecoder * decoder,
GstVideoCodecState * state)
{
GstMFCDec *self = GST_MFC_DEC (decoder);
GST_DEBUG_OBJECT (self, "Setting format: %" GST_PTR_FORMAT, state->caps);
if (self->input_state)
gst_video_codec_state_unref (self->input_state);
self->input_state = gst_video_codec_state_ref (state);
return TRUE;
}
static gboolean
gst_mfc_dec_reset (GstVideoDecoder * decoder, gboolean hard)
{
GstMFCDec *self = GST_MFC_DEC (decoder);
GST_DEBUG_OBJECT (self, "Resetting");
return TRUE;
}
static GstFlowReturn
gst_mfc_dec_handle_frame (GstVideoDecoder * decoder,
GstVideoCodecFrame * frame)
{
GstMFCDec *self = GST_MFC_DEC (decoder);
GstFlowReturn ret = GST_FLOW_OK;
GST_DEBUG_OBJECT (self, "Handling frame");
return ret;
}

65
sys/mfc/gstmfcdec.h Normal file
View file

@ -0,0 +1,65 @@
/*
* Copyright (C) 2012 Collabora Ltd.
* Author: Sebastian Dröge <sebastian.droege@collabora.co.uk>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef __GST_MFC_DEC_H__
#define __GST_MFC_DEC_H__
#include <gst/gst.h>
#include <gst/video/video.h>
#include <gst/video/gstvideodecoder.h>
#include "mfc_decoder/mfc_decoder.h"
G_BEGIN_DECLS
#define GST_TYPE_MFC_DEC \
(gst_mfc_dec_get_type())
#define GST_MFC_DEC(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_MFC_DEC,GstMFCDec))
#define GST_MFC_DEC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_MFC_DEC,GstMFCDecClass))
#define GST_IS_MFC_DEC(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_MFC_DEC))
#define GST_IS_MFC_DEC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MFC_DEC))
typedef struct _GstMFCDec GstMFCDec;
typedef struct _GstMFCDecClass GstMFCDecClass;
struct _GstMFCDec
{
GstVideoDecoder parent;
/* < private > */
GstVideoCodecState *input_state;
struct mfc_dec_context* context;
};
struct _GstMFCDecClass
{
GstVideoDecoderClass parent_class;
};
GType gst_mfc_dec_get_type (void);
G_END_DECLS
#endif /* __GST_MFC_DEC_H__ */