omx: Add VP8 decoder support
authorSebastian Dröge <sebastian.droege@collabora.co.uk>
Mon, 18 Mar 2013 15:06:54 +0000 (16:06 +0100)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Mon, 18 Mar 2013 15:34:51 +0000 (16:34 +0100)
configure.ac
omx/Makefile.am
omx/gstomx.c
omx/gstomxvp8dec.c [new file with mode: 0644]
omx/gstomxvp8dec.h [new file with mode: 0644]

index 611a74f919d8697e747ebf3df057c65e9ec36fcf..ac83244171e369ddcdf3cc7bbb038229b6609910 100644 (file)
@@ -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 <OMX_Video.h>]])
+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,
index da650c87197b476f92f53d5db21012e9c6f686ab..adbc9ab86d9cb1bb577c64e9906f653f036535ec 100644 (file)
@@ -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 \
index bfbcea1ad7b1212dd3384bb04ce677bf5e02af12..d440214dac0e72e1d11fc5d8a9cc398c780ed432 100644 (file)
@@ -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 (file)
index 0000000..0d5a60d
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2011, Hewlett-Packard Development Company, L.P.
+ *   Author: Sebastian Dröge <sebastian.droege@collabora.co.uk>, 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 <gst/gst.h>
+
+#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 <sebastian.droege@collabora.co.uk>");
+
+  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 (file)
index 0000000..5b22e71
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2013, Collabota 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 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 <gst/gst.h>
+#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__ */
+