From 0f5e6e967bcaf83af8fde0b51327295666192634 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 18 Mar 2013 16:06:54 +0100 Subject: omx: Add VP8 decoder support --- configure.ac | 9 +++++ omx/Makefile.am | 7 ++++ omx/gstomx.c | 4 +++ omx/gstomxvp8dec.c | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ omx/gstomxvp8dec.h | 60 +++++++++++++++++++++++++++++++++ 5 files changed, 177 insertions(+) create mode 100644 omx/gstomxvp8dec.c create mode 100644 omx/gstomxvp8dec.h diff --git a/configure.ac b/configure.ac index 611a74f..ac83244 100644 --- a/configure.ac +++ b/configure.ac @@ -156,6 +156,15 @@ dnl Check for external OpenMAX IL headers AC_CHECK_HEADER([OMX_Core.h], [HAVE_EXTERNAL_OMX=yes], [HAVE_EXTERNAL_OMX=no], [AC_INCLUDES_DEFAULT]) AM_CONDITIONAL(HAVE_EXTERNAL_OMX, test "x$HAVE_EXTERNAL_OMX" = "xyes") +AC_CHECK_DECLS([OMX_VIDEO_CodingVP8], + [ + AC_DEFINE(HAVE_VP8, 1, [OpenMAX IL has VP8 support]) + HAVE_VP8=yes + ], [ + HAVE_VP8=no + ], [[#include ]]) +AM_CONDITIONAL(HAVE_VP8, test "x$HAVE_VP8" = "xyes") + dnl Check for -Bsymbolic-functions linker flag used to avoid dnl intra-library PLT jumps, if available. AC_ARG_ENABLE(Bsymbolic, diff --git a/omx/Makefile.am b/omx/Makefile.am index da650c8..adbc9ab 100644 --- a/omx/Makefile.am +++ b/omx/Makefile.am @@ -1,5 +1,10 @@ plugin_LTLIBRARIES = libgstomx.la +if HAVE_VP8 +VP8_C_FILES=gstomxvp8dec.c +VP8_H_FILES=gstomxvp8dec.h +endif + libgstomx_la_SOURCES = \ gstomx.c \ gstomxvideodec.c \ @@ -9,6 +14,7 @@ libgstomx_la_SOURCES = \ gstomxmpeg2dec.c \ gstomxh264dec.c \ gstomxh263dec.c \ + $(VP8_C_FILES) \ gstomxwmvdec.c \ gstomxmpeg4videoenc.c \ gstomxh264enc.c \ @@ -24,6 +30,7 @@ noinst_HEADERS = \ gstomxmpeg4videodec.h \ gstomxh264dec.h \ gstomxh263dec.h \ + $(VP8_H_FILES) \ gstomxwmvdec.h \ gstomxmpeg4videoenc.h \ gstomxh264enc.h \ diff --git a/omx/gstomx.c b/omx/gstomx.c index bfbcea1..d440214 100644 --- a/omx/gstomx.c +++ b/omx/gstomx.c @@ -32,6 +32,7 @@ #include "gstomxmpeg4videodec.h" #include "gstomxh264dec.h" #include "gstomxh263dec.h" +#include "gstomxvp8dec.h" #include "gstomxwmvdec.h" #include "gstomxmpeg4videoenc.h" #include "gstomxh264enc.h" @@ -2326,6 +2327,9 @@ static const GGetTypeFunction types[] = { gst_omx_wmv_dec_get_type, gst_omx_mpeg4_video_enc_get_type, gst_omx_h264_enc_get_type, gst_omx_h263_enc_get_type, gst_omx_aac_enc_get_type +#ifdef HAVE_VP8 + , gst_omx_vp8_dec_get_type +#endif }; struct TypeOffest diff --git a/omx/gstomxvp8dec.c b/omx/gstomxvp8dec.c new file mode 100644 index 0000000..0d5a60d --- /dev/null +++ b/omx/gstomxvp8dec.c @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2011, Hewlett-Packard Development Company, L.P. + * Author: Sebastian Dröge , Collabora Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation + * version 2.1 of the License. + * + * 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include "gstomxvp8dec.h" + +GST_DEBUG_CATEGORY_STATIC (gst_omx_vp8_dec_debug_category); +#define GST_CAT_DEFAULT gst_omx_vp8_dec_debug_category + +/* prototypes */ +static gboolean gst_omx_vp8_dec_is_format_change (GstOMXVideoDec * dec, + GstOMXPort * port, GstVideoCodecState * state); +static gboolean gst_omx_vp8_dec_set_format (GstOMXVideoDec * dec, + GstOMXPort * port, GstVideoCodecState * state); + +enum +{ + PROP_0 +}; + +/* class initialization */ + +#define DEBUG_INIT \ + GST_DEBUG_CATEGORY_INIT (gst_omx_vp8_dec_debug_category, "omxvp8dec", 0, \ + "debug category for gst-omx video decoder base class"); + +G_DEFINE_TYPE_WITH_CODE (GstOMXVP8Dec, gst_omx_vp8_dec, + GST_TYPE_OMX_VIDEO_DEC, DEBUG_INIT); + +static void +gst_omx_vp8_dec_class_init (GstOMXVP8DecClass * klass) +{ + GstOMXVideoDecClass *videodec_class = GST_OMX_VIDEO_DEC_CLASS (klass); + GstElementClass *element_class = GST_ELEMENT_CLASS (klass); + + videodec_class->is_format_change = + GST_DEBUG_FUNCPTR (gst_omx_vp8_dec_is_format_change); + videodec_class->set_format = GST_DEBUG_FUNCPTR (gst_omx_vp8_dec_set_format); + + videodec_class->cdata.default_sink_template_caps = "video/x-vp8"; + + gst_element_class_set_static_metadata (element_class, + "OpenMAX VP8 Video Decoder", + "Codec/Decoder/Video", + "Decode VP8 video streams", + "Sebastian Dröge "); + + gst_omx_set_default_role (&videodec_class->cdata, "video_decoder.vp8"); +} + +static void +gst_omx_vp8_dec_init (GstOMXVP8Dec * self) +{ +} + +static gboolean +gst_omx_vp8_dec_is_format_change (GstOMXVideoDec * dec, + GstOMXPort * port, GstVideoCodecState * state) +{ + return FALSE; +} + +static gboolean +gst_omx_vp8_dec_set_format (GstOMXVideoDec * dec, GstOMXPort * port, + GstVideoCodecState * state) +{ + gboolean ret; + OMX_PARAM_PORTDEFINITIONTYPE port_def; + + gst_omx_port_get_port_definition (port, &port_def); + port_def.format.video.eCompressionFormat = OMX_VIDEO_CodingVP8; + ret = gst_omx_port_update_port_definition (port, &port_def) == OMX_ErrorNone; + + return ret; +} diff --git a/omx/gstomxvp8dec.h b/omx/gstomxvp8dec.h new file mode 100644 index 0000000..5b22e71 --- /dev/null +++ b/omx/gstomxvp8dec.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2013, Collabota Ltd. + * Author: Sebastian Dröge + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation + * version 2.1 of the License. + * + * 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef __GST_OMX_VP8_DEC_H__ +#define __GST_OMX_VP8_DEC_H__ + +#include +#include "gstomxvideodec.h" + +G_BEGIN_DECLS + +#define GST_TYPE_OMX_VP8_DEC \ + (gst_omx_VP8_dec_get_type()) +#define GST_OMX_VP8_DEC(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OMX_VP8_DEC,GstOMXVP8Dec)) +#define GST_OMX_VP8_DEC_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OMX_VP8_DEC,GstOMXVP8DecClass)) +#define GST_OMX_VP8_DEC_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_OMX_VP8_DEC,GstOMXVP8DecClass)) +#define GST_IS_OMX_VP8_DEC(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OMX_VP8_DEC)) +#define GST_IS_OMX_VP8_DEC_CLASS(obj) \ + (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OMX_VP8_DEC)) + +typedef struct _GstOMXVP8Dec GstOMXVP8Dec; +typedef struct _GstOMXVP8DecClass GstOMXVP8DecClass; + +struct _GstOMXVP8Dec +{ + GstOMXVideoDec parent; +}; + +struct _GstOMXVP8DecClass +{ + GstOMXVideoDecClass parent_class; +}; + +GType gst_omx_vp8_dec_get_type (void); + +G_END_DECLS + +#endif /* __GST_OMX_VP8_DEC_H__ */ + -- cgit v1.2.1