felipec gst-openmax: gst-openmax/omx/

[email protected]
Newsgroups gmane.comp.video.gstreamer.cvs
Message-ID <[email protected]>
CVS Root:       /cvs/gstreamer
Module:         gst-openmax
Changes by:     felipec
Date:           Thu Nov 20 2008  16:11:32 UTC

Log message:
Add separate mp2dec element.

Modified files:
    omx             : Makefile.am gstomx.c gstomx_mp3dec.c
Added files:
    omx             : gstomx_mp2dec.c gstomx_mp2dec.h

Links:
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-openmax/omx/Makefile.am.diff?r1=1.29&r2=1.30
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-openmax/omx/gstomx.c.diff?r1=1.35&r2=1.36
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-openmax/omx/gstomx_mp2dec.c?rev=1.1&content-type=text/vnd.viewcvs-markup
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-openmax/omx/gstomx_mp2dec.h?rev=1.1&content-type=text/vnd.viewcvs-markup
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-openmax/omx/gstomx_mp3dec.c.diff?r1=1.14&r2=1.15

====Begin Diffs====
Index: Makefile.am
===================================================================
RCS file: /cvs/gstreamer/gst-openmax/omx/Makefile.am,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- Makefile.am	15 Aug 2008 15:07:04 -0000	1.29
+++ Makefile.am	20 Nov 2008 16:11:17 -0000	1.30
@@ -23,6 +23,7 @@
 		       gstomx_aacdec.c gstomx_aacdec.h \
 		       gstomx_aacenc.c gstomx_aacenc.h \
 		       gstomx_mp3dec.c gstomx_mp3dec.h \
+		       gstomx_mp2dec.c gstomx_mp2dec.h \
 		       gstomx_adpcmdec.c gstomx_adpcmdec.h \
 		       gstomx_adpcmenc.c gstomx_adpcmenc.h \
 		       gstomx_g711dec.c gstomx_g711dec.h \
Index: gstomx.c
RCS file: /cvs/gstreamer/gst-openmax/omx/gstomx.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- gstomx.c	15 Aug 2008 14:36:15 -0000	1.35
+++ gstomx.c	20 Nov 2008 16:11:18 -0000	1.36
@@ -30,6 +30,7 @@
 #include "gstomx_h263enc.h"
 #include "gstomx_vorbisdec.h"
 #include "gstomx_mp3dec.h"
+#include "gstomx_mp2dec.h"
 #include "gstomx_aacdec.h"
 #include "gstomx_aacenc.h"
 #include "gstomx_amrnbdec.h"
@@ -114,6 +115,11 @@
         return false;
     }
 
+    if (!gst_element_register (plugin, "omx_mp2dec", DEFAULT_RANK, GST_OMX_MP2DEC_TYPE))
+    {
+        return false;
+    }
+
     if (!gst_element_register (plugin, "omx_amrnbdec", DEFAULT_RANK, GST_OMX_AMRNBDEC_TYPE))
     {
--- NEW FILE: gstomx_mp2dec.c ---
/*
 * Copyright (C) 2007-2008 Nokia Corporation.
 *
 * Author: Felipe Contreras <[email protected]>
 * 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
 */

#include "gstomx_mp2dec.h"
#include "gstomx_base_filter.h"
#include "gstomx.h"
#include <stdlib.h> /* For calloc, free */
#define OMX_COMPONENT_NAME "OMX.st.audio_decoder.mp3.mad"
static GstOmxBaseFilterClass *parent_class = NULL;
static GstCaps *
generate_src_template (void)
{
    GstCaps *caps;
    caps = gst_caps_new_simple ("audio/x-raw-int",
                                "endianness", G_TYPE_INT, G_BYTE_ORDER,
                                "width", GST_TYPE_INT_RANGE, 8, 32,
                                "depth", GST_TYPE_INT_RANGE, 8, 32,
                                "rate", GST_TYPE_INT_RANGE, 8000, 48000,
                                "signed", G_TYPE_BOOLEAN, TRUE,
                                "channels", GST_TYPE_INT_RANGE, 1, 8,
                                NULL);
    return caps;
}
generate_sink_template (void)
    caps = gst_caps_new_simple ("audio/mpeg",
                                "mpegversion", G_TYPE_INT, 1,
                                "layer", G_TYPE_INT, 2,
                                "parsed", G_TYPE_BOOLEAN, TRUE,
static void
type_base_init (gpointer g_class)
    GstElementClass *element_class;
    element_class = GST_ELEMENT_CLASS (g_class);
    {
        GstElementDetails details;
        details.longname = "OpenMAX IL MP2 audio decoder";
        details.klass = "Codec/Decoder/Audio";
        details.description = "Decodes audio in MP2 format with OpenMAX IL";
        details.author = "Felipe Contreras";
        gst_element_class_set_details (element_class, &details);
    }
        GstPadTemplate *template;
        template = gst_pad_template_new ("src", GST_PAD_SRC,
                                         GST_PAD_ALWAYS,
                                         generate_src_template ());
        gst_element_class_add_pad_template (element_class, template);
        template = gst_pad_template_new ("sink", GST_PAD_SINK,
                                         generate_sink_template ());
type_class_init (gpointer g_class,
                 gpointer class_data)
    parent_class = g_type_class_ref (GST_OMX_BASE_FILTER_TYPE);
settings_changed_cb (GOmxCore *core)
    GstOmxBaseFilter *omx_base;
    guint rate;
    guint channels;
    omx_base = core->client_data;
    GST_DEBUG_OBJECT (omx_base, "settings changed");
        OMX_AUDIO_PARAM_PCMMODETYPE *param;
        param = calloc (1, sizeof (OMX_AUDIO_PARAM_PCMMODETYPE));
        param->nSize = sizeof (OMX_AUDIO_PARAM_PCMMODETYPE);
        param->nVersion.s.nVersionMajor = 1;
        param->nVersion.s.nVersionMinor = 1;
        param->nPortIndex = 1;
        OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, param);
        rate = param->nSamplingRate;
        channels = param->nChannels;
        if (rate == 0)
        {
            /** @todo: this shouldn't happen. */
            GST_WARNING_OBJECT (omx_base, "Bad samplerate");
            rate = 44100;
        }
        free (param);
        GstCaps *new_caps;
        new_caps = gst_caps_new_simple ("audio/x-raw-int",
                                        "width", G_TYPE_INT, 16,
                                        "depth", G_TYPE_INT, 16,
                                        "rate", G_TYPE_INT, rate,
                                        "signed", G_TYPE_BOOLEAN, TRUE,
                                        "endianness", G_TYPE_INT, G_BYTE_ORDER ? 1234 : 4321,
                                        "channels", G_TYPE_INT, channels,
                                        NULL);
        GST_INFO_OBJECT (omx_base, "caps are: %" GST_PTR_FORMAT, new_caps);
        gst_pad_set_caps (omx_base->srcpad, new_caps);
type_instance_init (GTypeInstance *instance,
                    gpointer g_class)
    omx_base = GST_OMX_BASE_FILTER (instance);
    GST_DEBUG_OBJECT (omx_base, "start");
    omx_base->omx_component = g_strdup (OMX_COMPONENT_NAME);
    omx_base->gomx->settings_changed_cb = settings_changed_cb;
GType
gst_omx_mp2dec_get_type (void)
    static GType type = 0;
    if (G_UNLIKELY (type == 0))
        GTypeInfo *type_info;
        type_info = g_new0 (GTypeInfo, 1);
        type_info->class_size = sizeof (GstOmxMp2DecClass);
        type_info->base_init = type_base_init;
        type_info->class_init = type_class_init;
        type_info->instance_size = sizeof (GstOmxMp2Dec);
        type_info->instance_init = type_instance_init;
        type = g_type_register_static (GST_OMX_BASE_FILTER_TYPE, "GstOmxMp2Dec", type_info, 0);
        g_free (type_info);
    return type;
--- NEW FILE: gstomx_mp2dec.h ---
#ifndef GSTOMX_MP2DEC_H
#define GSTOMX_MP2DEC_H
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_OMX_MP2DEC(obj) (GstOmxMp2Dec *) (obj)
#define GST_OMX_MP2DEC_TYPE (gst_omx_mp2dec_get_type ())
typedef struct GstOmxMp2Dec GstOmxMp2Dec;
typedef struct GstOmxMp2DecClass GstOmxMp2DecClass;
struct GstOmxMp2Dec
    GstOmxBaseFilter omx_base;
};
struct GstOmxMp2DecClass
    GstOmxBaseFilterClass parent_class;
GType gst_omx_mp2dec_get_type (void);
G_END_DECLS
#endif /* GSTOMX_MP2DEC_H */
Index: gstomx_mp3dec.c
RCS file: /cvs/gstreamer/gst-openmax/omx/gstomx_mp3dec.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- gstomx_mp3dec.c	15 Aug 2008 14:49:21 -0000	1.14
+++ gstomx_mp3dec.c	20 Nov 2008 16:11:18 -0000	1.15
@@ -53,7 +53,7 @@
     caps = gst_caps_new_simple ("audio/mpeg",
                                 "mpegversion", G_TYPE_INT, 1,
-                                "layer", GST_TYPE_INT_RANGE, 1, 3,
+                                "layer", G_TYPE_INT, 3,
                                 "rate", GST_TYPE_INT_RANGE, 8000, 48000,
                                 "channels", GST_TYPE_INT_RANGE, 1, 8,
                                 "parsed", G_TYPE_BOOLEAN, TRUE,

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.