CVS Root: /cvs/gstreamer
Module: gst-openmax
Changes by: felipec
Date: Thu Nov 20 2008 16:17:09 UTC
Log message:
Add new jpegenc component wrapper.
Modified files:
omx : Makefile.am gstomx.c
Added files:
omx : gstomx_jpegenc.c gstomx_jpegenc.h
Links:
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-openmax/omx/Makefile.am.diff?r1=1.30&r2=1.31
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-openmax/omx/gstomx.c.diff?r1=1.36&r2=1.37
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-openmax/omx/gstomx_jpegenc.c?rev=1.1&content-type=text/vnd.viewcvs-markup
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-openmax/omx/gstomx_jpegenc.h?rev=1.1&content-type=text/vnd.viewcvs-markup
====Begin Diffs====
Index: Makefile.am
===================================================================
RCS file: /cvs/gstreamer/gst-openmax/omx/Makefile.am,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- Makefile.am 20 Nov 2008 16:11:17 -0000 1.30
+++ Makefile.am 20 Nov 2008 16:16:54 -0000 1.31
@@ -32,6 +32,7 @@
gstomx_g729enc.c gstomx_g729enc.h \
gstomx_ilbcdec.c gstomx_ilbcdec.h \
gstomx_ilbcenc.c gstomx_ilbcenc.h \
+ gstomx_jpegenc.c gstomx_jpegenc.h \
gstomx_base_sink.c gstomx_base_sink.h \
gstomx_audiosink.c gstomx_audiosink.h \
gstomx_videosink.c gstomx_videosink.h \
Index: gstomx.c
RCS file: /cvs/gstreamer/gst-openmax/omx/gstomx.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- gstomx.c 20 Nov 2008 16:11:18 -0000 1.36
+++ gstomx.c 20 Nov 2008 16:16:54 -0000 1.37
@@ -45,6 +45,7 @@
#include "gstomx_g729enc.h"
#include "gstomx_ilbcdec.h"
#include "gstomx_ilbcenc.h"
+#include "gstomx_jpegenc.h"
#include "gstomx_audiosink.h"
#include "gstomx_videosink.h"
#include "gstomx_filereadersrc.h"
@@ -190,6 +191,11 @@
return false;
}
+ if (!gst_element_register (plugin, "omx_jpegenc", DEFAULT_RANK, GST_OMX_JPEGENC_TYPE))
+ {
+ return false;
+ }
+
if (!gst_element_register (plugin, "omx_audiosink", GST_RANK_NONE, GST_OMX_AUDIOSINK_TYPE))
{
--- NEW FILE: gstomx_jpegenc.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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "gstomx_jpegenc.h"
#include "gstomx_base_filter.h"
#include "gstomx.h"
#include <string.h>
#include <stdbool.h>
#define OMX_COMPONENT_NAME "OMX.st.image_encoder.jpeg"
static GstOmxBaseFilterClass *parent_class = NULL;
static GstCaps *
generate_src_template (void)
{
GstCaps *caps;
caps = gst_caps_new_simple ("image/jpeg",
"width", GST_TYPE_INT_RANGE, 16, 4096,
"height", GST_TYPE_INT_RANGE, 16, 4096,
"framerate", GST_TYPE_FRACTION_RANGE, 0, 1, 30, 1,
NULL);
return caps;
}
generate_sink_template (void)
GstStructure *struc;
caps = gst_caps_new_empty ();
struc = gst_structure_new ("video/x-raw-yuv",
"width", GST_TYPE_INT_RANGE, 16, 4096,
"height", GST_TYPE_INT_RANGE, 16, 4096,
"framerate", GST_TYPE_FRACTION_RANGE, 0, 1, 30, 1,
NULL);
{
GValue list = { 0 };
GValue val = { 0 };
g_value_init (&list, GST_TYPE_LIST);
g_value_init (&val, GST_TYPE_FOURCC);
gst_value_set_fourcc (&val, GST_MAKE_FOURCC ('I', '4', '2', '0'));
gst_value_list_append_value (&list, &val);
gst_value_set_fourcc (&val, GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'));
gst_structure_set_value (struc, "format", &list);
g_value_unset (&val);
g_value_unset (&list);
}
gst_caps_append_structure (caps, struc);
static void
type_base_init (gpointer g_class)
GstElementClass *element_class;
element_class = GST_ELEMENT_CLASS (g_class);
GstElementDetails details;
details.longname = "OpenMAX IL JPEG image encoder";
details.klass = "Codec/Encoder/Audio";
details.description = "Encodes image in JPEG 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)
GObjectClass *gobject_class;
gobject_class = G_OBJECT_CLASS (g_class);
parent_class = g_type_class_ref (GST_OMX_BASE_FILTER_TYPE);
settings_changed_cb (GOmxCore *core)
GstOmxBaseFilter *omx_base;
guint width;
guint height;
omx_base = core->client_data;
GST_DEBUG_OBJECT (omx_base, "settings changed");
OMX_PARAM_PORTDEFINITIONTYPE *param;
param = calloc (1, sizeof (OMX_PARAM_PORTDEFINITIONTYPE));
param->nSize = sizeof (OMX_PARAM_PORTDEFINITIONTYPE);
param->nVersion.s.nVersionMajor = 1;
param->nVersion.s.nVersionMinor = 1;
param->nPortIndex = 1;
OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamPortDefinition, param);
width = param->format.image.nFrameWidth;
height = param->format.image.nFrameHeight;
free (param);
GstCaps *new_caps;
new_caps = gst_caps_new_simple ("image/jpeg",
"width", G_TYPE_INT, width,
"height", G_TYPE_INT, height,
"framerate", GST_TYPE_FRACTION, 1, 1,
NULL);
GST_INFO_OBJECT (omx_base, "caps are: %" GST_PTR_FORMAT, new_caps);
gst_pad_set_caps (omx_base->srcpad, new_caps);
static gboolean
sink_setcaps (GstPad *pad,
GstCaps *caps)
GstStructure *structure;
GOmxCore *gomx;
OMX_COLOR_FORMATTYPE color_format;
gint width = 0;
gint height = 0;
omx_base = GST_OMX_BASE_FILTER (GST_PAD_PARENT (pad));
gomx = (GOmxCore *) omx_base->gomx;
GST_INFO_OBJECT (omx_base, "setcaps (sink): %" GST_PTR_FORMAT, caps);
g_return_val_if_fail (gst_caps_get_size (caps) == 1, FALSE);
structure = gst_caps_get_structure (caps, 0);
gst_structure_get_int (structure, "width", &width);
gst_structure_get_int (structure, "height", &height);
if (strcmp (gst_structure_get_name (structure), "video/x-raw-yuv") == 0)
guint32 fourcc;
if (gst_structure_get_fourcc (structure, "format", &fourcc))
{
switch (fourcc)
{
case GST_MAKE_FOURCC ('I', '4', '2', '0'):
color_format = OMX_COLOR_FormatYUV420Planar;
break;
case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
color_format = OMX_COLOR_FormatCbYCrY;
}
}
/* Input port configuration. */
param->nPortIndex = 0;
OMX_GetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, param);
param->format.image.nFrameWidth = width;
param->format.image.nFrameHeight = height;
param->format.image.eColorFormat = color_format;
OMX_SetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, param);
return gst_pad_set_caps (pad, caps);
omx_setup (GstOmxBaseFilter *omx_base)
GstOmxJpegEnc *self;
gint rate, channels;
self = GST_OMX_JPEGENC (omx_base);
GST_INFO_OBJECT (omx_base, "begin");
OMX_COLOR_FORMATTYPE color_format;
gint width, height;
guint framerate;
/* Output port configuration. */
param->nPortIndex = 1;
param->format.image.eCompressionFormat = OMX_IMAGE_CodingJPEG;
/* some workarounds. */
/* required for TI components. */
#if 1
/* the component should do this instead */
width = param->format.image.nFrameWidth;
height = param->format.image.nFrameHeight;
color_format = param->format.image.eColorFormat;
/* this is against the standard; nBufferSize is read-only. */
switch (color_format)
case OMX_COLOR_FormatYCbYCr:
case OMX_COLOR_FormatCbYCrY:
param->nBufferSize = (GST_ROUND_UP_16 (width) * GST_ROUND_UP_16 (height)) * 2;
case OMX_COLOR_FormatYUV420Planar:
param->nBufferSize = (GST_ROUND_UP_16 (width) * GST_ROUND_UP_16 (height)) * 3 / 2;
default:
#endif
GST_INFO_OBJECT (omx_base, "end");
type_instance_init (GTypeInstance *instance,
gpointer g_class)
omx_base = GST_OMX_BASE_FILTER (instance);
self = GST_OMX_JPEGENC (instance);
omx_base->omx_component = g_strdup (OMX_COMPONENT_NAME);
omx_base->omx_setup = omx_setup;
omx_base->gomx->settings_changed_cb = settings_changed_cb;
gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
GType
gst_omx_jpegenc_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 (GstOmxJpegEncClass);
type_info->base_init = type_base_init;
type_info->class_init = type_class_init;
type_info->instance_size = sizeof (GstOmxJpegEnc);
type_info->instance_init = type_instance_init;
type = g_type_register_static (GST_OMX_BASE_FILTER_TYPE, "GstOmxJpegEnc", type_info, 0);
g_free (type_info);
return type;
--- NEW FILE: gstomx_jpegenc.h ---
#ifndef GSTOMX_JPEGENC_H
#define GSTOMX_JPEGENC_H
#include <gst/gst.h>
#include <config.h>
G_BEGIN_DECLS
#define GST_OMX_JPEGENC(obj) (GstOmxJpegEnc *) (obj)
#define GST_OMX_JPEGENC_TYPE (gst_omx_jpegenc_get_type ())
typedef struct GstOmxJpegEnc GstOmxJpegEnc;
typedef struct GstOmxJpegEncClass GstOmxJpegEncClass;
struct GstOmxJpegEnc
GstOmxBaseFilter omx_base;
};
struct GstOmxJpegEncClass
GstOmxBaseFilterClass parent_class;
GType gst_omx_jpegenc_get_type (void);
G_END_DECLS
#endif /* GSTOMX_JPEGENC_H */
-------------------------------------------------------------------------
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.