From 3d7a50944d938c49f2fd95111abfd47051a17818 Mon Sep 17 00:00:00 2001 From: Julian Scheel Date: Thu, 24 Jan 2013 14:02:36 +0100 Subject: [PATCH] omx: add mpeg2 video decoder This adds a decoder class for mpeg2, as well as an extended configuration for raspberry pi. https://bugzilla.gnome.org/show_bug.cgi?id=692446 Signed-off-by: Julian Scheel --- config/raspberry-pi.conf | 9 +++++ omx/Makefile.am | 2 + omx/gstomx.c | 10 +++-- omx/gstomxmpeg2dec.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++++ omx/gstomxmpeg2dec.h | 59 +++++++++++++++++++++++++++++ 5 files changed, 175 insertions(+), 4 deletions(-) create mode 100644 omx/gstomxmpeg2dec.c create mode 100644 omx/gstomxmpeg2dec.h diff --git a/config/raspberry-pi.conf b/config/raspberry-pi.conf index 8efa838..7e1d3f2 100644 --- a/config/raspberry-pi.conf +++ b/config/raspberry-pi.conf @@ -15,3 +15,12 @@ rank=256 in-port-index=130 out-port-index=131 hacks=no-empty-eos-buffer;no-component-role + +[omxmpeg2dec] +type-name=GstOMXMPEG2Dec +core-name=/opt/vc/lib/libopenmaxil.so +component-name=OMX.broadcom.video_decode +rank=256 +in-port-index=130 +out-port-index=131 +hacks=no-empty-eos-buffer;no-component-role diff --git a/omx/Makefile.am b/omx/Makefile.am index e242c5d..238ff34 100644 --- a/omx/Makefile.am +++ b/omx/Makefile.am @@ -6,6 +6,7 @@ libgstomx_la_SOURCES = \ gstomxvideoenc.c \ gstomxaudioenc.c \ gstomxmpeg4videodec.c \ + gstomxmpeg2dec.c \ gstomxh264dec.c \ gstomxh263dec.c \ gstomxwmvdec.c \ @@ -19,6 +20,7 @@ noinst_HEADERS = \ gstomxvideodec.h \ gstomxvideoenc.h \ gstomxaudioenc.h \ + gstomxmpeg2dec.h \ gstomxmpeg4videodec.h \ gstomxh264dec.h \ gstomxh263dec.h \ diff --git a/omx/gstomx.c b/omx/gstomx.c index b772606..07178dd 100644 --- a/omx/gstomx.c +++ b/omx/gstomx.c @@ -28,6 +28,7 @@ #include #include "gstomx.h" +#include "gstomxmpeg2dec.h" #include "gstomxmpeg4videodec.h" #include "gstomxh264dec.h" #include "gstomxh263dec.h" @@ -2047,10 +2048,11 @@ done: } 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_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}; +gst_omx_mpeg2_dec_get_type, gst_omx_mpeg4_video_dec_get_type, + gst_omx_h264_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, gst_omx_h263_enc_get_type, + gst_omx_aac_enc_get_type}; struct TypeOffest { diff --git a/omx/gstomxmpeg2dec.c b/omx/gstomxmpeg2dec.c new file mode 100644 index 0000000..d6e26fc --- /dev/null +++ b/omx/gstomxmpeg2dec.c @@ -0,0 +1,99 @@ +/* + * 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 "gstomxmpeg2dec.h" + +GST_DEBUG_CATEGORY_STATIC (gst_omx_mpeg2_dec_debug_category); +#define GST_CAT_DEFAULT gst_omx_mpeg2_dec_debug_category + +/* prototypes */ +static gboolean gst_omx_mpeg2_dec_is_format_change (GstOMXVideoDec * dec, + GstOMXPort * port, GstVideoCodecState * state); +static gboolean gst_omx_mpeg2_dec_set_format (GstOMXVideoDec * dec, + GstOMXPort * port, GstVideoCodecState * state); + +enum +{ + PROP_0 +}; + +/* class initialization */ + +#define DEBUG_INIT \ + GST_DEBUG_CATEGORY_INIT (gst_omx_mpeg2_dec_debug_category, "omxmpeg2dec", 0, \ + "debug category for gst-omx video decoder base class"); + +G_DEFINE_TYPE_WITH_CODE (GstOMXMPEG2Dec, gst_omx_mpeg2_dec, + GST_TYPE_OMX_VIDEO_DEC, DEBUG_INIT); + +static void +gst_omx_mpeg2_dec_class_init (GstOMXMPEG2DecClass * 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_mpeg2_dec_is_format_change); + videodec_class->set_format = GST_DEBUG_FUNCPTR (gst_omx_mpeg2_dec_set_format); + + videodec_class->cdata.default_sink_template_caps = "video/mpeg, " + "mpegversion=(int) 2, " + "systemstream=(boolean) false, " "parsed=(boolean) true"; + + gst_element_class_set_static_metadata (element_class, + "OpenMAX MPEG2 Video Decoder", + "Codec/Decoder/Video", + "Decode MPEG2 video streams", + "Sebastian Dröge "); + + gst_omx_set_default_role (&videodec_class->cdata, "video_decoder.mpeg2"); +} + +static void +gst_omx_mpeg2_dec_init (GstOMXMPEG2Dec * self) +{ +} + +static gboolean +gst_omx_mpeg2_dec_is_format_change (GstOMXVideoDec * dec, + GstOMXPort * port, GstVideoCodecState * state) +{ + return FALSE; +} + +static gboolean +gst_omx_mpeg2_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_CodingMPEG2; + ret = gst_omx_port_update_port_definition (port, &port_def); + + return ret; +} diff --git a/omx/gstomxmpeg2dec.h b/omx/gstomxmpeg2dec.h new file mode 100644 index 0000000..d05beff --- /dev/null +++ b/omx/gstomxmpeg2dec.h @@ -0,0 +1,59 @@ +/* + * 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_MPEG2_DEC_H__ +#define __GST_OMX_MPEG2_DEC_H__ + +#include +#include "gstomxvideodec.h" + +G_BEGIN_DECLS + +#define GST_TYPE_OMX_MPEG2_DEC \ + (gst_omx_mpeg2_dec_get_type()) +#define GST_OMX_MPEG2_DEC(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OMX_MPEG2_DEC,GstOMXMPEG2Dec)) +#define GST_OMX_MPEG2_DEC_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OMX_MPEG2_DEC,GstOMXMPEG2DecClass)) +#define GST_OMX_MPEG2_DEC_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_OMX_MPEG2_DEC,GstOMXMPEG2DecClass)) +#define GST_IS_OMX_MPEG2_DEC(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OMX_MPEG2_DEC)) +#define GST_IS_OMX_MPEG2_DEC_CLASS(obj) \ + (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OMX_MPEG2_DEC)) + +typedef struct _GstOMXMPEG2Dec GstOMXMPEG2Dec; +typedef struct _GstOMXMPEG2DecClass GstOMXMPEG2DecClass; + +struct _GstOMXMPEG2Dec +{ + GstOMXVideoDec parent; +}; + +struct _GstOMXMPEG2DecClass +{ + GstOMXVideoDecClass parent_class; +}; + +GType gst_omx_mpeg2_dec_get_type (void); + +G_END_DECLS + +#endif /* __GST_OMX_MPEG2_DEC_H__ */ -- 2.7.4