From 8977906f4be412db47dbd3afff5fd38c58315dcb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 25 Jul 2011 12:01:05 +0200 Subject: [PATCH] omxwmvdec: Add WMV video decoder element --- omx/Makefile.am | 2 + omx/gstomx.c | 3 +- omx/gstomxwmvdec.c | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++++ omx/gstomxwmvdec.h | 60 +++++++++++++++++++++++++++ 4 files changed, 183 insertions(+), 1 deletion(-) create mode 100644 omx/gstomxwmvdec.c create mode 100644 omx/gstomxwmvdec.h diff --git a/omx/Makefile.am b/omx/Makefile.am index 4dae210..ede5277 100644 --- a/omx/Makefile.am +++ b/omx/Makefile.am @@ -7,6 +7,7 @@ libgstopenmax_la_SOURCES = \ gstomxmpeg4videodec.c \ gstomxh264dec.c \ gstomxh263dec.c \ + gstomxwmvdec.c \ gstomxmpeg4videoenc.c \ gstomxh264enc.c \ gstbasevideocodec.c \ @@ -21,6 +22,7 @@ noinst_HEADERS = \ gstomxmpeg4videodec.h \ gstomxh264dec.h \ gstomxh263dec.h \ + gstomxwmvdec.h \ gstomxmpeg4videoenc.h \ gstomxh264enc.h \ gstbasevideocodec.h \ diff --git a/omx/gstomx.c b/omx/gstomx.c index 348efd4..5dbfc9f 100644 --- a/omx/gstomx.c +++ b/omx/gstomx.c @@ -29,6 +29,7 @@ #include "gstomxmpeg4videodec.h" #include "gstomxh264dec.h" #include "gstomxh263dec.h" +#include "gstomxwmvdec.h" #include "gstomxmpeg4videoenc.h" #include "gstomxh264enc.h" @@ -1634,7 +1635,7 @@ GQuark gst_omx_element_name_quark = 0; static GType (*types[]) (void) = { gst_omx_mpeg4_video_dec_get_type, gst_omx_h264_dec_get_type, - gst_omx_h263_dec_get_type, + gst_omx_h263_dec_get_type, gst_omx_wmv_dec_get_type, gst_omx_mpeg4_video_enc_get_type, gst_omx_h264_enc_get_type}; static GKeyFile *config = NULL; diff --git a/omx/gstomxwmvdec.c b/omx/gstomxwmvdec.c new file mode 100644 index 0000000..5cb62ae --- /dev/null +++ b/omx/gstomxwmvdec.c @@ -0,0 +1,119 @@ +/* + * 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 "gstomxwmvdec.h" + +GST_DEBUG_CATEGORY_STATIC (gst_omx_wmv_dec_debug_category); +#define GST_CAT_DEFAULT gst_omx_wmv_dec_debug_category + +/* prototypes */ +static void gst_omx_wmv_dec_finalize (GObject * object); +static gboolean gst_omx_wmv_dec_is_format_change (GstOMXVideoDec * dec, + GstOMXPort * port, GstVideoState * state); +static gboolean gst_omx_wmv_dec_set_format (GstOMXVideoDec * dec, + GstOMXPort * port, GstVideoState * state); + +enum +{ + PROP_0 +}; + +/* class initialization */ + +#define DEBUG_INIT(bla) \ + GST_DEBUG_CATEGORY_INIT (gst_omx_wmv_dec_debug_category, "omxwmvdec", 0, \ + "debug category for gst-omx video decoder base class"); + +GST_BOILERPLATE_FULL (GstOMXWMVDec, gst_omx_wmv_dec, + GstOMXVideoDec, GST_TYPE_OMX_VIDEO_DEC, DEBUG_INIT); + +static void +gst_omx_wmv_dec_base_init (gpointer g_class) +{ + GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); + GstOMXVideoDecClass *videodec_class = GST_OMX_VIDEO_DEC_CLASS (g_class); + + gst_element_class_set_details_simple (element_class, + "OpenMAX WMV Video Decoder", + "Codec/Decoder/Video", + "Decode WMV video streams", + "Sebastian Dröge "); + + /* If no role was set from the config file we set the + * default WMV video decoder role */ + if (!videodec_class->component_role) + videodec_class->component_role = "video_decoder.wmv"; +} + +static void +gst_omx_wmv_dec_class_init (GstOMXWMVDecClass * klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + GstOMXVideoDecClass *videodec_class = GST_OMX_VIDEO_DEC_CLASS (klass); + + gobject_class->finalize = gst_omx_wmv_dec_finalize; + + videodec_class->is_format_change = + GST_DEBUG_FUNCPTR (gst_omx_wmv_dec_is_format_change); + videodec_class->set_format = GST_DEBUG_FUNCPTR (gst_omx_wmv_dec_set_format); + + videodec_class->default_sink_template_caps = "video/x-wmv"; + videodec_class->default_src_template_caps = GST_VIDEO_CAPS_YUV ("I420"); +} + +static void +gst_omx_wmv_dec_init (GstOMXWMVDec * self, GstOMXWMVDecClass * klass) +{ +} + +static void +gst_omx_wmv_dec_finalize (GObject * object) +{ + /* GstOMXWMVDec *self = GST_OMX_WMV_DEC (object); */ + + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +static gboolean +gst_omx_wmv_dec_is_format_change (GstOMXVideoDec * dec, + GstOMXPort * port, GstVideoState * state) +{ + return FALSE; +} + +static gboolean +gst_omx_wmv_dec_set_format (GstOMXVideoDec * dec, GstOMXPort * port, + GstVideoState * state) +{ + gboolean ret; + OMX_PARAM_PORTDEFINITIONTYPE port_def; + + gst_omx_port_get_port_definition (port, &port_def); + port_def.format.video.eCompressionFormat = OMX_VIDEO_CodingWMV; + ret = gst_omx_port_update_port_definition (port, &port_def); + + return ret; +} diff --git a/omx/gstomxwmvdec.h b/omx/gstomxwmvdec.h new file mode 100644 index 0000000..9375dc5 --- /dev/null +++ b/omx/gstomxwmvdec.h @@ -0,0 +1,60 @@ +/* + * 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 + * + */ + +#ifndef __GST_OMX_WMV_DEC_H__ +#define __GST_OMX_WMV_DEC_H__ + +#include +#include "gstomxvideodec.h" + +G_BEGIN_DECLS + +#define GST_TYPE_OMX_WMV_DEC \ + (gst_omx_wmv_dec_get_type()) +#define GST_OMX_WMV_DEC(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OMX_WMV_DEC,GstOMXWMVDec)) +#define GST_OMX_WMV_DEC_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OMX_WMV_DEC,GstOMXWMVDecClass)) +#define GST_OMX_WMV_DEC_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_OMX_WMV_DEC,GstOMXWMVDecClass)) +#define GST_IS_OMX_WMV_DEC(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OMX_WMV_DEC)) +#define GST_IS_OMX_WMV_DEC_CLASS(obj) \ + (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OMX_WMV_DEC)) + +typedef struct _GstOMXWMVDec GstOMXWMVDec; +typedef struct _GstOMXWMVDecClass GstOMXWMVDecClass; + +struct _GstOMXWMVDec +{ + GstOMXVideoDec parent; +}; + +struct _GstOMXWMVDecClass +{ + GstOMXVideoDecClass parent_class; +}; + +GType gst_omx_wmv_dec_get_type (void); + +G_END_DECLS + +#endif /* __GST_OMX_WMV_DEC_H__ */ + -- 2.7.4