2002-03-20 21:45:03 +00:00
|
|
|
/* GStreamer
|
2001-12-22 23:27:17 +00:00
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
2005-07-01 17:03:13 +00:00
|
|
|
* Copyright (C) 2005 David Schleef <ds@schleef.org>
|
2001-12-22 23:27:17 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2003-06-29 19:46:12 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2001-12-22 23:27:17 +00:00
|
|
|
|
2005-07-01 16:55:43 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2005-07-01 17:03:13 +00:00
|
|
|
#include <gst/video/video.h>
|
|
|
|
|
|
|
|
#include "gstvideoscale.h"
|
2005-07-01 16:55:43 +00:00
|
|
|
#include "vs_image.h"
|
2001-12-22 23:27:17 +00:00
|
|
|
|
2005-07-01 17:03:13 +00:00
|
|
|
|
2004-02-25 17:37:26 +00:00
|
|
|
/* debug variable definition */
|
|
|
|
GST_DEBUG_CATEGORY (videoscale_debug);
|
2001-12-22 23:27:17 +00:00
|
|
|
|
|
|
|
/* elementfactory information */
|
2004-03-14 22:34:34 +00:00
|
|
|
static GstElementDetails videoscale_details =
|
|
|
|
GST_ELEMENT_DETAILS ("Video scaler",
|
|
|
|
"Filter/Effect/Video",
|
|
|
|
"Resizes video",
|
|
|
|
"Wim Taymans <wim.taymans@chello.be>");
|
2001-12-22 23:27:17 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
enum
|
|
|
|
{
|
2005-07-01 17:03:13 +00:00
|
|
|
PROP_0,
|
|
|
|
PROP_METHOD
|
2004-05-21 22:39:30 +00:00
|
|
|
/* FILL ME */
|
2001-12-22 23:27:17 +00:00
|
|
|
};
|
|
|
|
|
2005-07-01 16:55:43 +00:00
|
|
|
static GstStaticCaps gst_videoscale_format_caps[] = {
|
|
|
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_RGBx),
|
|
|
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_xRGB),
|
|
|
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_BGRx),
|
|
|
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_xBGR),
|
|
|
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB),
|
|
|
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_BGR),
|
|
|
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AYUV")),
|
|
|
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("YUY2")),
|
|
|
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("YVYU")),
|
|
|
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("UYVY")),
|
|
|
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("Y800")),
|
|
|
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420")),
|
|
|
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("YV12")),
|
|
|
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB_16),
|
|
|
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB_15)
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
GST_VIDEOSCALE_RGBx = 0,
|
|
|
|
GST_VIDEOSCALE_xRGB,
|
|
|
|
GST_VIDEOSCALE_BGRx,
|
|
|
|
GST_VIDEOSCALE_xBGR,
|
|
|
|
GST_VIDEOSCALE_RGB,
|
|
|
|
GST_VIDEOSCALE_BGR,
|
|
|
|
GST_VIDEOSCALE_AYUV,
|
|
|
|
GST_VIDEOSCALE_YUY2,
|
|
|
|
GST_VIDEOSCALE_YVYU,
|
|
|
|
GST_VIDEOSCALE_UYVY,
|
|
|
|
GST_VIDEOSCALE_Y,
|
|
|
|
GST_VIDEOSCALE_I420,
|
|
|
|
GST_VIDEOSCALE_YV12,
|
|
|
|
GST_VIDEOSCALE_RGB565,
|
|
|
|
GST_VIDEOSCALE_RGB555
|
|
|
|
};
|
|
|
|
|
2001-12-22 23:27:17 +00:00
|
|
|
#define GST_TYPE_VIDEOSCALE_METHOD (gst_videoscale_method_get_type())
|
|
|
|
static GType
|
|
|
|
gst_videoscale_method_get_type (void)
|
|
|
|
{
|
|
|
|
static GType videoscale_method_type = 0;
|
|
|
|
static GEnumValue videoscale_methods[] = {
|
2004-07-22 18:07:14 +00:00
|
|
|
{GST_VIDEOSCALE_POINT_SAMPLE, "0", "Point Sample (not implemented)"},
|
2004-03-14 22:34:34 +00:00
|
|
|
{GST_VIDEOSCALE_NEAREST, "1", "Nearest"},
|
2005-07-01 17:03:13 +00:00
|
|
|
{GST_VIDEOSCALE_BILINEAR, "2", "Bilinear"},
|
2004-07-22 18:07:14 +00:00
|
|
|
{GST_VIDEOSCALE_BICUBIC, "3", "Bicubic (not implemented)"},
|
2004-03-14 22:34:34 +00:00
|
|
|
{0, NULL, NULL},
|
2001-12-22 23:27:17 +00:00
|
|
|
};
|
2004-03-15 19:32:28 +00:00
|
|
|
|
2001-12-22 23:27:17 +00:00
|
|
|
if (!videoscale_method_type) {
|
2004-03-14 22:34:34 +00:00
|
|
|
videoscale_method_type =
|
2004-03-15 19:32:28 +00:00
|
|
|
g_enum_register_static ("GstVideoscaleMethod", videoscale_methods);
|
2001-12-22 23:27:17 +00:00
|
|
|
}
|
|
|
|
return videoscale_method_type;
|
|
|
|
}
|
|
|
|
|
2003-11-02 20:48:33 +00:00
|
|
|
static GstCaps *
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_videoscale_get_capslist (void)
|
2001-12-22 23:27:17 +00:00
|
|
|
{
|
2005-07-01 16:55:43 +00:00
|
|
|
static GstCaps *caps;
|
|
|
|
|
|
|
|
if (caps == NULL) {
|
|
|
|
int i;
|
2001-12-22 23:27:17 +00:00
|
|
|
|
2005-07-01 16:55:43 +00:00
|
|
|
caps = gst_caps_new_empty ();
|
2005-07-01 17:03:13 +00:00
|
|
|
for (i = 0; i < G_N_ELEMENTS (gst_videoscale_format_caps); i++)
|
2005-07-01 16:55:43 +00:00
|
|
|
gst_caps_append (caps,
|
2005-07-01 17:03:13 +00:00
|
|
|
gst_caps_make_writable
|
|
|
|
(gst_static_caps_get (&gst_videoscale_format_caps[i])));
|
2003-11-02 20:48:33 +00:00
|
|
|
}
|
2001-12-22 23:27:17 +00:00
|
|
|
|
2005-07-01 17:03:13 +00:00
|
|
|
return caps;
|
2001-12-22 23:27:17 +00:00
|
|
|
}
|
|
|
|
|
2003-04-22 07:32:50 +00:00
|
|
|
static GstPadTemplate *
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_videoscale_src_template_factory (void)
|
2003-04-22 07:32:50 +00:00
|
|
|
{
|
2003-12-22 01:47:09 +00:00
|
|
|
return gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
|
2005-07-01 17:03:13 +00:00
|
|
|
gst_caps_ref (gst_videoscale_get_capslist ()));
|
2003-04-22 07:32:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GstPadTemplate *
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_videoscale_sink_template_factory (void)
|
2001-12-22 23:27:17 +00:00
|
|
|
{
|
2003-12-22 01:47:09 +00:00
|
|
|
return gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
|
2005-07-01 17:03:13 +00:00
|
|
|
gst_caps_ref (gst_videoscale_get_capslist ()));
|
2003-04-22 07:32:50 +00:00
|
|
|
}
|
2001-12-22 23:27:17 +00:00
|
|
|
|
2005-07-01 17:03:13 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
static void gst_videoscale_base_init (gpointer g_class);
|
|
|
|
static void gst_videoscale_class_init (GstVideoscaleClass * klass);
|
|
|
|
static void gst_videoscale_init (GstVideoscale * videoscale);
|
|
|
|
static gboolean gst_videoscale_handle_src_event (GstPad * pad,
|
|
|
|
GstEvent * event);
|
2003-11-02 20:48:33 +00:00
|
|
|
|
2005-08-24 13:32:52 +00:00
|
|
|
/* base transform vmethods */
|
2005-07-01 17:03:13 +00:00
|
|
|
static GstCaps *gst_videoscale_transform_caps (GstBaseTransform * trans,
|
2005-08-24 13:32:52 +00:00
|
|
|
GstPadDirection direction, GstCaps * caps);
|
2005-07-01 17:03:13 +00:00
|
|
|
static gboolean gst_videoscale_set_caps (GstBaseTransform * trans,
|
|
|
|
GstCaps * in, GstCaps * out);
|
2005-08-24 13:32:52 +00:00
|
|
|
static gboolean gst_videoscale_get_unit_size (GstBaseTransform * trans,
|
|
|
|
GstCaps * caps, guint * size);
|
2005-07-01 17:03:13 +00:00
|
|
|
static GstFlowReturn gst_videoscale_transform (GstBaseTransform * trans,
|
2005-07-15 10:44:19 +00:00
|
|
|
GstBuffer * in, GstBuffer * out);
|
2005-07-01 17:03:13 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
static void gst_videoscale_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_videoscale_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec);
|
2003-11-02 20:48:33 +00:00
|
|
|
|
|
|
|
static GstElementClass *parent_class = NULL;
|
2004-03-14 22:34:34 +00:00
|
|
|
|
2003-11-02 20:48:33 +00:00
|
|
|
|
|
|
|
GType
|
|
|
|
gst_videoscale_get_type (void)
|
2003-04-22 07:32:50 +00:00
|
|
|
{
|
2003-11-02 20:48:33 +00:00
|
|
|
static GType videoscale_type = 0;
|
2003-04-22 07:32:50 +00:00
|
|
|
|
2003-11-02 20:48:33 +00:00
|
|
|
if (!videoscale_type) {
|
|
|
|
static const GTypeInfo videoscale_info = {
|
2004-03-14 22:34:34 +00:00
|
|
|
sizeof (GstVideoscaleClass),
|
2003-11-02 20:48:33 +00:00
|
|
|
gst_videoscale_base_init,
|
|
|
|
NULL,
|
2004-03-14 22:34:34 +00:00
|
|
|
(GClassInitFunc) gst_videoscale_class_init,
|
2003-11-02 20:48:33 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2004-03-14 22:34:34 +00:00
|
|
|
sizeof (GstVideoscale),
|
2003-11-02 20:48:33 +00:00
|
|
|
0,
|
2004-03-14 22:34:34 +00:00
|
|
|
(GInstanceInitFunc) gst_videoscale_init,
|
2003-11-02 20:48:33 +00:00
|
|
|
};
|
2004-03-15 19:32:28 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
videoscale_type =
|
2005-07-01 17:03:13 +00:00
|
|
|
g_type_register_static (GST_TYPE_BASE_TRANSFORM, "GstVideoscale",
|
2004-03-15 19:32:28 +00:00
|
|
|
&videoscale_info, 0);
|
2003-04-22 07:32:50 +00:00
|
|
|
}
|
2003-11-02 20:48:33 +00:00
|
|
|
return videoscale_type;
|
|
|
|
}
|
2001-12-22 23:27:17 +00:00
|
|
|
|
2003-11-02 20:48:33 +00:00
|
|
|
static void
|
|
|
|
gst_videoscale_base_init (gpointer g_class)
|
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
|
|
|
|
|
|
|
gst_element_class_set_details (element_class, &videoscale_details);
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_element_class_add_pad_template (element_class,
|
|
|
|
gst_videoscale_sink_template_factory ());
|
|
|
|
gst_element_class_add_pad_template (element_class,
|
|
|
|
gst_videoscale_src_template_factory ());
|
2003-11-02 20:48:33 +00:00
|
|
|
}
|
2005-07-01 17:03:13 +00:00
|
|
|
|
2003-11-02 20:48:33 +00:00
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_videoscale_class_init (GstVideoscaleClass * klass)
|
2003-11-02 20:48:33 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
2005-07-01 17:03:13 +00:00
|
|
|
GstBaseTransformClass *trans_class;
|
2003-11-02 20:48:33 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
gobject_class = (GObjectClass *) klass;
|
2005-07-01 17:03:13 +00:00
|
|
|
trans_class = (GstBaseTransformClass *) klass;
|
2003-11-02 20:48:33 +00:00
|
|
|
|
|
|
|
gobject_class->set_property = gst_videoscale_set_property;
|
|
|
|
gobject_class->get_property = gst_videoscale_get_property;
|
2003-04-22 07:32:50 +00:00
|
|
|
|
2005-07-01 17:03:13 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_METHOD,
|
|
|
|
g_param_spec_enum ("method", "method", "method",
|
|
|
|
GST_TYPE_VIDEOSCALE_METHOD, 0, G_PARAM_READWRITE));
|
|
|
|
|
|
|
|
trans_class->transform_caps = gst_videoscale_transform_caps;
|
|
|
|
trans_class->set_caps = gst_videoscale_set_caps;
|
2005-08-24 13:32:52 +00:00
|
|
|
trans_class->get_unit_size = gst_videoscale_get_unit_size;
|
2005-07-01 17:03:13 +00:00
|
|
|
trans_class->transform = gst_videoscale_transform;
|
|
|
|
|
check/: Add extra tests for basetransform based components.
Original commit message from CVS:
* check/Makefile.am:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (GST_START_TEST), (simple_launch_lines_suite):
Add extra tests for basetransform based components.
Comment out the test_element_negotiation test until we decide
if it's testing correct behaviour.
* ext/libvisual/visual.c: (gst_visual_init), (get_buffer),
(gst_visual_chain), (gst_visual_change_state):
Slightly more correct but still bogus timestamping.
Fix state change function.
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init):
* gst/audioresample/gstaudioresample.c:
* gst/ffmpegcolorspace/gstffmpegcolorspace.c:
(gst_ffmpegcsp_class_init):
* gst/videoscale/gstvideoscale.c: (gst_videoscale_class_init),
(gst_videoscale_prepare_size), (gst_videoscale_set_caps),
(gst_videoscale_prepare_image):
* gst/volume/gstvolume.c: (gst_volume_class_init),
(volume_transform_ip):
Basetransform updates. Enable passthrough modes.
* sys/ximage/ximagesink.c: (gst_ximage_buffer_init),
(gst_ximagesink_renegotiate_size), (gst_ximagesink_xcontext_get),
(gst_ximagesink_setcaps), (gst_ximagesink_buffer_alloc):
Negotiation fix that allows the window to return to the original
size and renegotiate passthrough upstream. Extra debug output.
2005-09-09 17:53:47 +00:00
|
|
|
trans_class->passthrough_on_same_caps = TRUE;
|
|
|
|
|
2005-07-01 17:03:13 +00:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2001-12-22 23:27:17 +00:00
|
|
|
}
|
|
|
|
|
2005-07-01 17:03:13 +00:00
|
|
|
static void
|
|
|
|
gst_videoscale_init (GstVideoscale * videoscale)
|
2001-12-22 23:27:17 +00:00
|
|
|
{
|
2005-07-01 17:03:13 +00:00
|
|
|
GstBaseTransform *trans = GST_BASE_TRANSFORM (videoscale);
|
2001-12-22 23:27:17 +00:00
|
|
|
|
2005-07-01 17:03:13 +00:00
|
|
|
gst_pad_set_event_function (trans->srcpad, gst_videoscale_handle_src_event);
|
2004-03-14 22:34:34 +00:00
|
|
|
|
2005-08-24 15:07:54 +00:00
|
|
|
videoscale->tmp_buf = NULL;
|
2005-07-01 17:03:13 +00:00
|
|
|
videoscale->method = GST_VIDEOSCALE_NEAREST;
|
|
|
|
/*videoscale->method = GST_VIDEOSCALE_BILINEAR; */
|
|
|
|
/*videoscale->method = GST_VIDEOSCALE_POINT_SAMPLE; */
|
|
|
|
}
|
2003-11-11 05:35:31 +00:00
|
|
|
|
|
|
|
|
2005-07-01 17:03:13 +00:00
|
|
|
static void
|
|
|
|
gst_videoscale_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
GstVideoscale *src = GST_VIDEOSCALE (object);
|
2003-12-22 01:47:09 +00:00
|
|
|
|
2005-07-01 17:03:13 +00:00
|
|
|
switch (prop_id) {
|
|
|
|
case PROP_METHOD:
|
|
|
|
src->method = g_value_get_enum (value);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
2003-12-22 01:47:09 +00:00
|
|
|
}
|
2001-12-22 23:27:17 +00:00
|
|
|
}
|
2003-04-22 07:32:50 +00:00
|
|
|
|
2005-07-01 17:03:13 +00:00
|
|
|
static void
|
|
|
|
gst_videoscale_get_property (GObject * object, guint prop_id, GValue * value,
|
|
|
|
GParamSpec * pspec)
|
2005-07-01 16:55:43 +00:00
|
|
|
{
|
2005-07-01 17:03:13 +00:00
|
|
|
GstVideoscale *src = GST_VIDEOSCALE (object);
|
2005-07-01 16:55:43 +00:00
|
|
|
|
2005-07-01 17:03:13 +00:00
|
|
|
switch (prop_id) {
|
|
|
|
case PROP_METHOD:
|
|
|
|
g_value_set_enum (value, src->method);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
2005-07-01 16:55:43 +00:00
|
|
|
}
|
|
|
|
}
|
2001-12-22 23:27:17 +00:00
|
|
|
|
2005-07-01 17:03:13 +00:00
|
|
|
static GstCaps *
|
2005-08-24 13:32:52 +00:00
|
|
|
gst_videoscale_transform_caps (GstBaseTransform * trans,
|
|
|
|
GstPadDirection direction, GstCaps * caps)
|
2001-12-22 23:27:17 +00:00
|
|
|
{
|
|
|
|
GstVideoscale *videoscale;
|
2005-07-01 17:03:13 +00:00
|
|
|
GstCaps *ret;
|
|
|
|
int i;
|
2004-07-27 16:43:24 +00:00
|
|
|
|
2005-07-01 17:03:13 +00:00
|
|
|
videoscale = GST_VIDEOSCALE (trans);
|
2003-12-31 08:02:04 +00:00
|
|
|
|
2005-07-05 09:08:36 +00:00
|
|
|
ret = gst_caps_copy (caps);
|
2003-12-31 08:02:04 +00:00
|
|
|
|
2005-07-01 17:03:13 +00:00
|
|
|
for (i = 0; i < gst_caps_get_size (ret); i++) {
|
|
|
|
GstStructure *structure = gst_caps_get_structure (ret, i);
|
2003-04-22 07:32:50 +00:00
|
|
|
|
2005-07-01 17:03:13 +00:00
|
|
|
gst_structure_set (structure,
|
|
|
|
"width", GST_TYPE_INT_RANGE, 16, 4096,
|
|
|
|
"height", GST_TYPE_INT_RANGE, 16, 4096, NULL);
|
|
|
|
gst_structure_remove_field (structure, "pixel-aspect-ratio");
|
2003-04-22 07:32:50 +00:00
|
|
|
}
|
|
|
|
|
2005-08-24 13:32:52 +00:00
|
|
|
GST_DEBUG_OBJECT (trans, "returning caps: %" GST_PTR_FORMAT, ret);
|
2005-07-01 17:03:13 +00:00
|
|
|
return ret;
|
2004-07-18 18:35:43 +00:00
|
|
|
}
|
|
|
|
|
2005-07-01 17:03:13 +00:00
|
|
|
static int
|
|
|
|
gst_videoscale_get_format (GstCaps * caps)
|
2004-07-27 16:43:24 +00:00
|
|
|
{
|
|
|
|
int i;
|
2005-07-01 17:03:13 +00:00
|
|
|
GstCaps *icaps, *scaps;
|
2004-07-27 16:43:24 +00:00
|
|
|
|
2005-07-01 17:03:13 +00:00
|
|
|
for (i = 0; i < G_N_ELEMENTS (gst_videoscale_format_caps); i++) {
|
|
|
|
scaps = gst_static_caps_get (&gst_videoscale_format_caps[i]);
|
|
|
|
icaps = gst_caps_intersect (caps, scaps);
|
|
|
|
if (!gst_caps_is_empty (icaps)) {
|
|
|
|
gst_caps_unref (icaps);
|
|
|
|
return i;
|
2004-07-27 16:43:24 +00:00
|
|
|
}
|
2005-07-01 17:03:13 +00:00
|
|
|
gst_caps_unref (icaps);
|
2004-07-27 16:43:24 +00:00
|
|
|
}
|
|
|
|
|
2005-07-01 17:03:13 +00:00
|
|
|
return -1;
|
2001-12-22 23:27:17 +00:00
|
|
|
}
|
|
|
|
|
2005-08-24 15:07:54 +00:00
|
|
|
/* calculate the size of a buffer */
|
|
|
|
static gboolean
|
|
|
|
gst_videoscale_prepare_size (gint format,
|
|
|
|
VSImage * img, gint width, gint height, guint * size)
|
2001-12-22 23:27:17 +00:00
|
|
|
{
|
2005-08-24 15:07:54 +00:00
|
|
|
gboolean res = TRUE;
|
2001-12-22 23:27:17 +00:00
|
|
|
|
2005-08-24 15:07:54 +00:00
|
|
|
img->width = width;
|
|
|
|
img->height = height;
|
2005-07-01 16:55:43 +00:00
|
|
|
|
2005-08-24 15:07:54 +00:00
|
|
|
switch (format) {
|
2005-07-01 16:55:43 +00:00
|
|
|
case GST_VIDEOSCALE_RGBx:
|
|
|
|
case GST_VIDEOSCALE_xRGB:
|
|
|
|
case GST_VIDEOSCALE_BGRx:
|
|
|
|
case GST_VIDEOSCALE_xBGR:
|
|
|
|
case GST_VIDEOSCALE_AYUV:
|
2005-08-24 15:07:54 +00:00
|
|
|
img->stride = img->width * 4;
|
|
|
|
*size = img->stride * img->height;
|
2005-07-01 16:55:43 +00:00
|
|
|
break;
|
|
|
|
case GST_VIDEOSCALE_RGB:
|
|
|
|
case GST_VIDEOSCALE_BGR:
|
check/: Add extra tests for basetransform based components.
Original commit message from CVS:
* check/Makefile.am:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (GST_START_TEST), (simple_launch_lines_suite):
Add extra tests for basetransform based components.
Comment out the test_element_negotiation test until we decide
if it's testing correct behaviour.
* ext/libvisual/visual.c: (gst_visual_init), (get_buffer),
(gst_visual_chain), (gst_visual_change_state):
Slightly more correct but still bogus timestamping.
Fix state change function.
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init):
* gst/audioresample/gstaudioresample.c:
* gst/ffmpegcolorspace/gstffmpegcolorspace.c:
(gst_ffmpegcsp_class_init):
* gst/videoscale/gstvideoscale.c: (gst_videoscale_class_init),
(gst_videoscale_prepare_size), (gst_videoscale_set_caps),
(gst_videoscale_prepare_image):
* gst/volume/gstvolume.c: (gst_volume_class_init),
(volume_transform_ip):
Basetransform updates. Enable passthrough modes.
* sys/ximage/ximagesink.c: (gst_ximage_buffer_init),
(gst_ximagesink_renegotiate_size), (gst_ximagesink_xcontext_get),
(gst_ximagesink_setcaps), (gst_ximagesink_buffer_alloc):
Negotiation fix that allows the window to return to the original
size and renegotiate passthrough upstream. Extra debug output.
2005-09-09 17:53:47 +00:00
|
|
|
img->stride = GST_ROUND_UP_4 (img->width * 3);
|
2005-08-24 15:07:54 +00:00
|
|
|
*size = img->stride * img->height;
|
2005-07-01 16:55:43 +00:00
|
|
|
break;
|
|
|
|
case GST_VIDEOSCALE_YUY2:
|
|
|
|
case GST_VIDEOSCALE_YVYU:
|
|
|
|
case GST_VIDEOSCALE_UYVY:
|
check/: Add extra tests for basetransform based components.
Original commit message from CVS:
* check/Makefile.am:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (GST_START_TEST), (simple_launch_lines_suite):
Add extra tests for basetransform based components.
Comment out the test_element_negotiation test until we decide
if it's testing correct behaviour.
* ext/libvisual/visual.c: (gst_visual_init), (get_buffer),
(gst_visual_chain), (gst_visual_change_state):
Slightly more correct but still bogus timestamping.
Fix state change function.
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init):
* gst/audioresample/gstaudioresample.c:
* gst/ffmpegcolorspace/gstffmpegcolorspace.c:
(gst_ffmpegcsp_class_init):
* gst/videoscale/gstvideoscale.c: (gst_videoscale_class_init),
(gst_videoscale_prepare_size), (gst_videoscale_set_caps),
(gst_videoscale_prepare_image):
* gst/volume/gstvolume.c: (gst_volume_class_init),
(volume_transform_ip):
Basetransform updates. Enable passthrough modes.
* sys/ximage/ximagesink.c: (gst_ximage_buffer_init),
(gst_ximagesink_renegotiate_size), (gst_ximagesink_xcontext_get),
(gst_ximagesink_setcaps), (gst_ximagesink_buffer_alloc):
Negotiation fix that allows the window to return to the original
size and renegotiate passthrough upstream. Extra debug output.
2005-09-09 17:53:47 +00:00
|
|
|
img->stride = GST_ROUND_UP_4 (img->width * 2);
|
2005-08-24 15:07:54 +00:00
|
|
|
*size = img->stride * img->height;
|
2005-07-01 16:55:43 +00:00
|
|
|
break;
|
|
|
|
case GST_VIDEOSCALE_Y:
|
check/: Add extra tests for basetransform based components.
Original commit message from CVS:
* check/Makefile.am:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (GST_START_TEST), (simple_launch_lines_suite):
Add extra tests for basetransform based components.
Comment out the test_element_negotiation test until we decide
if it's testing correct behaviour.
* ext/libvisual/visual.c: (gst_visual_init), (get_buffer),
(gst_visual_chain), (gst_visual_change_state):
Slightly more correct but still bogus timestamping.
Fix state change function.
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init):
* gst/audioresample/gstaudioresample.c:
* gst/ffmpegcolorspace/gstffmpegcolorspace.c:
(gst_ffmpegcsp_class_init):
* gst/videoscale/gstvideoscale.c: (gst_videoscale_class_init),
(gst_videoscale_prepare_size), (gst_videoscale_set_caps),
(gst_videoscale_prepare_image):
* gst/volume/gstvolume.c: (gst_volume_class_init),
(volume_transform_ip):
Basetransform updates. Enable passthrough modes.
* sys/ximage/ximagesink.c: (gst_ximage_buffer_init),
(gst_ximagesink_renegotiate_size), (gst_ximagesink_xcontext_get),
(gst_ximagesink_setcaps), (gst_ximagesink_buffer_alloc):
Negotiation fix that allows the window to return to the original
size and renegotiate passthrough upstream. Extra debug output.
2005-09-09 17:53:47 +00:00
|
|
|
img->stride = GST_ROUND_UP_4 (img->width);
|
2005-08-24 15:07:54 +00:00
|
|
|
*size = img->stride * img->height;
|
2005-07-01 16:55:43 +00:00
|
|
|
break;
|
|
|
|
case GST_VIDEOSCALE_I420:
|
|
|
|
case GST_VIDEOSCALE_YV12:
|
2005-07-01 17:03:13 +00:00
|
|
|
{
|
2005-08-24 15:07:54 +00:00
|
|
|
gulong img_u_stride, img_u_height;
|
2001-12-22 23:27:17 +00:00
|
|
|
|
check/: Add extra tests for basetransform based components.
Original commit message from CVS:
* check/Makefile.am:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (GST_START_TEST), (simple_launch_lines_suite):
Add extra tests for basetransform based components.
Comment out the test_element_negotiation test until we decide
if it's testing correct behaviour.
* ext/libvisual/visual.c: (gst_visual_init), (get_buffer),
(gst_visual_chain), (gst_visual_change_state):
Slightly more correct but still bogus timestamping.
Fix state change function.
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init):
* gst/audioresample/gstaudioresample.c:
* gst/ffmpegcolorspace/gstffmpegcolorspace.c:
(gst_ffmpegcsp_class_init):
* gst/videoscale/gstvideoscale.c: (gst_videoscale_class_init),
(gst_videoscale_prepare_size), (gst_videoscale_set_caps),
(gst_videoscale_prepare_image):
* gst/volume/gstvolume.c: (gst_volume_class_init),
(volume_transform_ip):
Basetransform updates. Enable passthrough modes.
* sys/ximage/ximagesink.c: (gst_ximage_buffer_init),
(gst_ximagesink_renegotiate_size), (gst_ximagesink_xcontext_get),
(gst_ximagesink_setcaps), (gst_ximagesink_buffer_alloc):
Negotiation fix that allows the window to return to the original
size and renegotiate passthrough upstream. Extra debug output.
2005-09-09 17:53:47 +00:00
|
|
|
img->stride = GST_ROUND_UP_4 (img->width);
|
2004-03-14 22:34:34 +00:00
|
|
|
|
check/: Add extra tests for basetransform based components.
Original commit message from CVS:
* check/Makefile.am:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (GST_START_TEST), (simple_launch_lines_suite):
Add extra tests for basetransform based components.
Comment out the test_element_negotiation test until we decide
if it's testing correct behaviour.
* ext/libvisual/visual.c: (gst_visual_init), (get_buffer),
(gst_visual_chain), (gst_visual_change_state):
Slightly more correct but still bogus timestamping.
Fix state change function.
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init):
* gst/audioresample/gstaudioresample.c:
* gst/ffmpegcolorspace/gstffmpegcolorspace.c:
(gst_ffmpegcsp_class_init):
* gst/videoscale/gstvideoscale.c: (gst_videoscale_class_init),
(gst_videoscale_prepare_size), (gst_videoscale_set_caps),
(gst_videoscale_prepare_image):
* gst/volume/gstvolume.c: (gst_volume_class_init),
(volume_transform_ip):
Basetransform updates. Enable passthrough modes.
* sys/ximage/ximagesink.c: (gst_ximage_buffer_init),
(gst_ximagesink_renegotiate_size), (gst_ximagesink_xcontext_get),
(gst_ximagesink_setcaps), (gst_ximagesink_buffer_alloc):
Negotiation fix that allows the window to return to the original
size and renegotiate passthrough upstream. Extra debug output.
2005-09-09 17:53:47 +00:00
|
|
|
img_u_height = GST_ROUND_UP_2 (img->height) / 2;
|
|
|
|
img_u_stride = GST_ROUND_UP_4 (img->stride / 2);
|
2005-07-01 16:55:43 +00:00
|
|
|
|
check/: Add extra tests for basetransform based components.
Original commit message from CVS:
* check/Makefile.am:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (GST_START_TEST), (simple_launch_lines_suite):
Add extra tests for basetransform based components.
Comment out the test_element_negotiation test until we decide
if it's testing correct behaviour.
* ext/libvisual/visual.c: (gst_visual_init), (get_buffer),
(gst_visual_chain), (gst_visual_change_state):
Slightly more correct but still bogus timestamping.
Fix state change function.
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init):
* gst/audioresample/gstaudioresample.c:
* gst/ffmpegcolorspace/gstffmpegcolorspace.c:
(gst_ffmpegcsp_class_init):
* gst/videoscale/gstvideoscale.c: (gst_videoscale_class_init),
(gst_videoscale_prepare_size), (gst_videoscale_set_caps),
(gst_videoscale_prepare_image):
* gst/volume/gstvolume.c: (gst_volume_class_init),
(volume_transform_ip):
Basetransform updates. Enable passthrough modes.
* sys/ximage/ximagesink.c: (gst_ximage_buffer_init),
(gst_ximagesink_renegotiate_size), (gst_ximagesink_xcontext_get),
(gst_ximagesink_setcaps), (gst_ximagesink_buffer_alloc):
Negotiation fix that allows the window to return to the original
size and renegotiate passthrough upstream. Extra debug output.
2005-09-09 17:53:47 +00:00
|
|
|
*size = img->stride * GST_ROUND_UP_2 (img->height) +
|
2005-08-24 15:07:54 +00:00
|
|
|
2 * img_u_stride * img_u_height;
|
2005-07-01 16:55:43 +00:00
|
|
|
break;
|
2005-07-01 17:03:13 +00:00
|
|
|
}
|
2005-07-01 16:55:43 +00:00
|
|
|
case GST_VIDEOSCALE_RGB565:
|
check/: Add extra tests for basetransform based components.
Original commit message from CVS:
* check/Makefile.am:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (GST_START_TEST), (simple_launch_lines_suite):
Add extra tests for basetransform based components.
Comment out the test_element_negotiation test until we decide
if it's testing correct behaviour.
* ext/libvisual/visual.c: (gst_visual_init), (get_buffer),
(gst_visual_chain), (gst_visual_change_state):
Slightly more correct but still bogus timestamping.
Fix state change function.
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init):
* gst/audioresample/gstaudioresample.c:
* gst/ffmpegcolorspace/gstffmpegcolorspace.c:
(gst_ffmpegcsp_class_init):
* gst/videoscale/gstvideoscale.c: (gst_videoscale_class_init),
(gst_videoscale_prepare_size), (gst_videoscale_set_caps),
(gst_videoscale_prepare_image):
* gst/volume/gstvolume.c: (gst_volume_class_init),
(volume_transform_ip):
Basetransform updates. Enable passthrough modes.
* sys/ximage/ximagesink.c: (gst_ximage_buffer_init),
(gst_ximagesink_renegotiate_size), (gst_ximagesink_xcontext_get),
(gst_ximagesink_setcaps), (gst_ximagesink_buffer_alloc):
Negotiation fix that allows the window to return to the original
size and renegotiate passthrough upstream. Extra debug output.
2005-09-09 17:53:47 +00:00
|
|
|
img->stride = GST_ROUND_UP_4 (img->width * 2);
|
2005-08-24 15:07:54 +00:00
|
|
|
*size = img->stride * img->height;
|
2005-07-01 16:55:43 +00:00
|
|
|
break;
|
|
|
|
case GST_VIDEOSCALE_RGB555:
|
check/: Add extra tests for basetransform based components.
Original commit message from CVS:
* check/Makefile.am:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (GST_START_TEST), (simple_launch_lines_suite):
Add extra tests for basetransform based components.
Comment out the test_element_negotiation test until we decide
if it's testing correct behaviour.
* ext/libvisual/visual.c: (gst_visual_init), (get_buffer),
(gst_visual_chain), (gst_visual_change_state):
Slightly more correct but still bogus timestamping.
Fix state change function.
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init):
* gst/audioresample/gstaudioresample.c:
* gst/ffmpegcolorspace/gstffmpegcolorspace.c:
(gst_ffmpegcsp_class_init):
* gst/videoscale/gstvideoscale.c: (gst_videoscale_class_init),
(gst_videoscale_prepare_size), (gst_videoscale_set_caps),
(gst_videoscale_prepare_image):
* gst/volume/gstvolume.c: (gst_volume_class_init),
(volume_transform_ip):
Basetransform updates. Enable passthrough modes.
* sys/ximage/ximagesink.c: (gst_ximage_buffer_init),
(gst_ximagesink_renegotiate_size), (gst_ximagesink_xcontext_get),
(gst_ximagesink_setcaps), (gst_ximagesink_buffer_alloc):
Negotiation fix that allows the window to return to the original
size and renegotiate passthrough upstream. Extra debug output.
2005-09-09 17:53:47 +00:00
|
|
|
img->stride = GST_ROUND_UP_4 (img->width * 2);
|
2005-08-24 15:07:54 +00:00
|
|
|
*size = img->stride * img->height;
|
2005-07-01 16:55:43 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_warning ("don't know how to scale");
|
2005-08-24 15:07:54 +00:00
|
|
|
res = FALSE;
|
2005-07-01 17:03:13 +00:00
|
|
|
break;
|
2005-07-01 16:55:43 +00:00
|
|
|
}
|
|
|
|
|
2005-08-24 15:07:54 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
parse_caps (GstCaps * caps, gint * format, gint * width, gint * height)
|
|
|
|
{
|
|
|
|
gboolean ret;
|
|
|
|
GstStructure *structure;
|
|
|
|
|
|
|
|
structure = gst_caps_get_structure (caps, 0);
|
|
|
|
ret = gst_structure_get_int (structure, "width", width);
|
|
|
|
ret &= gst_structure_get_int (structure, "height", height);
|
|
|
|
|
|
|
|
if (format)
|
|
|
|
*format = gst_videoscale_get_format (caps);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_videoscale_set_caps (GstBaseTransform * trans, GstCaps * in, GstCaps * out)
|
|
|
|
{
|
|
|
|
GstVideoscale *videoscale;
|
|
|
|
gboolean ret;
|
|
|
|
|
|
|
|
videoscale = GST_VIDEOSCALE (trans);
|
|
|
|
|
|
|
|
ret = parse_caps (in, &videoscale->format, &videoscale->from_width,
|
|
|
|
&videoscale->from_height);
|
|
|
|
ret &= parse_caps (out, NULL, &videoscale->to_width, &videoscale->to_height);
|
|
|
|
if (!ret)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
ret = gst_videoscale_prepare_size (videoscale->format,
|
|
|
|
&videoscale->src, videoscale->from_width, videoscale->from_height,
|
|
|
|
&videoscale->src_size);
|
|
|
|
|
|
|
|
ret &= gst_videoscale_prepare_size (videoscale->format,
|
|
|
|
&videoscale->dest, videoscale->to_width, videoscale->to_height,
|
|
|
|
&videoscale->dest_size);
|
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
if (videoscale->tmp_buf)
|
|
|
|
g_free (videoscale->tmp_buf);
|
|
|
|
|
|
|
|
videoscale->tmp_buf = g_malloc (videoscale->dest.stride * 2);
|
|
|
|
|
|
|
|
/* FIXME: par */
|
|
|
|
GST_DEBUG_OBJECT (videoscale, "from=%dx%d, size %d -> to=%dx%d, size %d",
|
|
|
|
videoscale->from_width, videoscale->from_height, videoscale->src_size,
|
|
|
|
videoscale->to_width, videoscale->to_height, videoscale->dest_size);
|
check/: Add extra tests for basetransform based components.
Original commit message from CVS:
* check/Makefile.am:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (GST_START_TEST), (simple_launch_lines_suite):
Add extra tests for basetransform based components.
Comment out the test_element_negotiation test until we decide
if it's testing correct behaviour.
* ext/libvisual/visual.c: (gst_visual_init), (get_buffer),
(gst_visual_chain), (gst_visual_change_state):
Slightly more correct but still bogus timestamping.
Fix state change function.
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init):
* gst/audioresample/gstaudioresample.c:
* gst/ffmpegcolorspace/gstffmpegcolorspace.c:
(gst_ffmpegcsp_class_init):
* gst/videoscale/gstvideoscale.c: (gst_videoscale_class_init),
(gst_videoscale_prepare_size), (gst_videoscale_set_caps),
(gst_videoscale_prepare_image):
* gst/volume/gstvolume.c: (gst_volume_class_init),
(volume_transform_ip):
Basetransform updates. Enable passthrough modes.
* sys/ximage/ximagesink.c: (gst_ximage_buffer_init),
(gst_ximagesink_renegotiate_size), (gst_ximagesink_xcontext_get),
(gst_ximagesink_setcaps), (gst_ximagesink_buffer_alloc):
Negotiation fix that allows the window to return to the original
size and renegotiate passthrough upstream. Extra debug output.
2005-09-09 17:53:47 +00:00
|
|
|
|
2005-08-24 15:07:54 +00:00
|
|
|
done:
|
|
|
|
return ret;
|
2005-07-01 17:03:13 +00:00
|
|
|
}
|
|
|
|
|
2005-08-24 13:32:52 +00:00
|
|
|
static gboolean
|
|
|
|
gst_videoscale_get_unit_size (GstBaseTransform * trans, GstCaps * caps,
|
|
|
|
guint * size)
|
2005-07-20 17:30:45 +00:00
|
|
|
{
|
|
|
|
GstVideoscale *videoscale;
|
2005-08-24 15:07:54 +00:00
|
|
|
gint format, width, height;
|
|
|
|
VSImage img;
|
2005-07-20 17:30:45 +00:00
|
|
|
|
2005-08-24 13:32:52 +00:00
|
|
|
g_return_val_if_fail (size, FALSE);
|
2005-08-24 15:07:54 +00:00
|
|
|
|
2005-07-20 17:30:45 +00:00
|
|
|
videoscale = GST_VIDEOSCALE (trans);
|
|
|
|
|
2005-08-24 15:07:54 +00:00
|
|
|
if (!parse_caps (caps, &format, &width, &height))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!gst_videoscale_prepare_size (format, &img, width, height, size))
|
2005-08-24 13:32:52 +00:00
|
|
|
return FALSE;
|
2005-08-04 19:52:32 +00:00
|
|
|
|
2005-08-24 13:32:52 +00:00
|
|
|
return TRUE;
|
2005-07-20 17:30:45 +00:00
|
|
|
}
|
|
|
|
|
2005-08-24 15:07:54 +00:00
|
|
|
static gboolean
|
|
|
|
gst_videoscale_prepare_image (gint format, GstBuffer * buf,
|
|
|
|
VSImage * img, VSImage * img_u, VSImage * img_v)
|
2005-07-01 17:03:13 +00:00
|
|
|
{
|
2005-08-24 15:07:54 +00:00
|
|
|
gboolean res = TRUE;
|
|
|
|
|
|
|
|
img->pixels = GST_BUFFER_DATA (buf);
|
2001-12-22 23:27:17 +00:00
|
|
|
|
2005-08-24 15:07:54 +00:00
|
|
|
switch (format) {
|
2005-07-01 16:55:43 +00:00
|
|
|
case GST_VIDEOSCALE_I420:
|
|
|
|
case GST_VIDEOSCALE_YV12:
|
check/: Add extra tests for basetransform based components.
Original commit message from CVS:
* check/Makefile.am:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (GST_START_TEST), (simple_launch_lines_suite):
Add extra tests for basetransform based components.
Comment out the test_element_negotiation test until we decide
if it's testing correct behaviour.
* ext/libvisual/visual.c: (gst_visual_init), (get_buffer),
(gst_visual_chain), (gst_visual_change_state):
Slightly more correct but still bogus timestamping.
Fix state change function.
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init):
* gst/audioresample/gstaudioresample.c:
* gst/ffmpegcolorspace/gstffmpegcolorspace.c:
(gst_ffmpegcsp_class_init):
* gst/videoscale/gstvideoscale.c: (gst_videoscale_class_init),
(gst_videoscale_prepare_size), (gst_videoscale_set_caps),
(gst_videoscale_prepare_image):
* gst/volume/gstvolume.c: (gst_volume_class_init),
(volume_transform_ip):
Basetransform updates. Enable passthrough modes.
* sys/ximage/ximagesink.c: (gst_ximage_buffer_init),
(gst_ximagesink_renegotiate_size), (gst_ximagesink_xcontext_get),
(gst_ximagesink_setcaps), (gst_ximagesink_buffer_alloc):
Negotiation fix that allows the window to return to the original
size and renegotiate passthrough upstream. Extra debug output.
2005-09-09 17:53:47 +00:00
|
|
|
img_u->pixels = img->pixels + GST_ROUND_UP_2 (img->height) * img->stride;
|
|
|
|
img_u->height = GST_ROUND_UP_2 (img->height) / 2;
|
|
|
|
img_u->width = GST_ROUND_UP_2 (img->width) / 2;
|
|
|
|
img_u->stride = GST_ROUND_UP_4 (img->stride / 2);
|
2005-08-24 15:07:54 +00:00
|
|
|
memcpy (img_v, img_u, sizeof (*img_v));
|
|
|
|
img_v->pixels = img_u->pixels + img_u->height * img_u->stride;
|
2005-07-01 16:55:43 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2005-08-24 15:07:54 +00:00
|
|
|
return res;
|
2005-07-01 17:03:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
gst_videoscale_transform (GstBaseTransform * trans, GstBuffer * in,
|
2005-07-15 10:44:19 +00:00
|
|
|
GstBuffer * out)
|
2005-07-01 17:03:13 +00:00
|
|
|
{
|
|
|
|
GstVideoscale *videoscale;
|
2005-08-24 15:07:54 +00:00
|
|
|
GstFlowReturn ret = GST_FLOW_OK;
|
|
|
|
VSImage *dest;
|
|
|
|
VSImage *src;
|
2005-07-01 17:03:13 +00:00
|
|
|
VSImage dest_u;
|
|
|
|
VSImage dest_v;
|
2005-08-24 15:07:54 +00:00
|
|
|
VSImage src_u;
|
2005-07-01 17:03:13 +00:00
|
|
|
VSImage src_v;
|
|
|
|
|
|
|
|
videoscale = GST_VIDEOSCALE (trans);
|
|
|
|
|
2005-07-15 10:44:19 +00:00
|
|
|
gst_buffer_stamp (out, in);
|
2005-07-01 17:03:13 +00:00
|
|
|
|
2005-08-24 15:07:54 +00:00
|
|
|
src = &videoscale->src;
|
|
|
|
dest = &videoscale->dest;
|
2005-07-01 16:55:43 +00:00
|
|
|
|
2005-08-24 15:07:54 +00:00
|
|
|
gst_videoscale_prepare_image (videoscale->format, in, src, &src_u, &src_v);
|
|
|
|
gst_videoscale_prepare_image (videoscale->format, out, dest, &dest_u,
|
|
|
|
&dest_v);
|
2005-07-01 16:55:43 +00:00
|
|
|
|
|
|
|
switch (videoscale->method) {
|
|
|
|
case GST_VIDEOSCALE_NEAREST:
|
|
|
|
switch (videoscale->format) {
|
|
|
|
case GST_VIDEOSCALE_RGBx:
|
|
|
|
case GST_VIDEOSCALE_xRGB:
|
|
|
|
case GST_VIDEOSCALE_BGRx:
|
|
|
|
case GST_VIDEOSCALE_xBGR:
|
|
|
|
case GST_VIDEOSCALE_AYUV:
|
2005-08-24 15:07:54 +00:00
|
|
|
vs_image_scale_nearest_RGBA (dest, src, videoscale->tmp_buf);
|
2005-07-01 16:55:43 +00:00
|
|
|
break;
|
|
|
|
case GST_VIDEOSCALE_RGB:
|
|
|
|
case GST_VIDEOSCALE_BGR:
|
2005-08-24 15:07:54 +00:00
|
|
|
vs_image_scale_nearest_RGB (dest, src, videoscale->tmp_buf);
|
2005-07-01 16:55:43 +00:00
|
|
|
break;
|
|
|
|
case GST_VIDEOSCALE_YUY2:
|
|
|
|
case GST_VIDEOSCALE_YVYU:
|
2005-08-24 15:07:54 +00:00
|
|
|
vs_image_scale_nearest_YUYV (dest, src, videoscale->tmp_buf);
|
2005-07-01 16:55:43 +00:00
|
|
|
break;
|
|
|
|
case GST_VIDEOSCALE_UYVY:
|
2005-08-24 15:07:54 +00:00
|
|
|
vs_image_scale_nearest_UYVY (dest, src, videoscale->tmp_buf);
|
2005-07-01 16:55:43 +00:00
|
|
|
break;
|
|
|
|
case GST_VIDEOSCALE_Y:
|
2005-08-24 15:07:54 +00:00
|
|
|
vs_image_scale_nearest_Y (dest, src, videoscale->tmp_buf);
|
2005-07-01 16:55:43 +00:00
|
|
|
break;
|
|
|
|
case GST_VIDEOSCALE_I420:
|
|
|
|
case GST_VIDEOSCALE_YV12:
|
2005-08-24 15:07:54 +00:00
|
|
|
vs_image_scale_nearest_Y (dest, src, videoscale->tmp_buf);
|
|
|
|
vs_image_scale_nearest_Y (&dest_u, &src_u, videoscale->tmp_buf);
|
|
|
|
vs_image_scale_nearest_Y (&dest_v, &src_v, videoscale->tmp_buf);
|
2005-07-01 16:55:43 +00:00
|
|
|
break;
|
|
|
|
case GST_VIDEOSCALE_RGB565:
|
2005-08-24 15:07:54 +00:00
|
|
|
vs_image_scale_nearest_RGB565 (dest, src, videoscale->tmp_buf);
|
2005-07-01 16:55:43 +00:00
|
|
|
break;
|
|
|
|
case GST_VIDEOSCALE_RGB555:
|
2005-08-24 15:07:54 +00:00
|
|
|
vs_image_scale_nearest_RGB555 (dest, src, videoscale->tmp_buf);
|
2005-07-01 16:55:43 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_warning ("don't know how to scale");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GST_VIDEOSCALE_BILINEAR:
|
|
|
|
case GST_VIDEOSCALE_BICUBIC:
|
|
|
|
switch (videoscale->format) {
|
|
|
|
case GST_VIDEOSCALE_RGBx:
|
|
|
|
case GST_VIDEOSCALE_xRGB:
|
|
|
|
case GST_VIDEOSCALE_BGRx:
|
|
|
|
case GST_VIDEOSCALE_xBGR:
|
|
|
|
case GST_VIDEOSCALE_AYUV:
|
2005-08-24 15:07:54 +00:00
|
|
|
vs_image_scale_linear_RGBA (dest, src, videoscale->tmp_buf);
|
2005-07-01 16:55:43 +00:00
|
|
|
break;
|
|
|
|
case GST_VIDEOSCALE_RGB:
|
|
|
|
case GST_VIDEOSCALE_BGR:
|
2005-08-24 15:07:54 +00:00
|
|
|
vs_image_scale_linear_RGB (dest, src, videoscale->tmp_buf);
|
2005-07-01 16:55:43 +00:00
|
|
|
break;
|
|
|
|
case GST_VIDEOSCALE_YUY2:
|
|
|
|
case GST_VIDEOSCALE_YVYU:
|
2005-08-24 15:07:54 +00:00
|
|
|
vs_image_scale_linear_YUYV (dest, src, videoscale->tmp_buf);
|
2005-07-01 16:55:43 +00:00
|
|
|
break;
|
|
|
|
case GST_VIDEOSCALE_UYVY:
|
2005-08-24 15:07:54 +00:00
|
|
|
vs_image_scale_linear_UYVY (dest, src, videoscale->tmp_buf);
|
2005-07-01 16:55:43 +00:00
|
|
|
break;
|
|
|
|
case GST_VIDEOSCALE_Y:
|
2005-08-24 15:07:54 +00:00
|
|
|
vs_image_scale_linear_Y (dest, src, videoscale->tmp_buf);
|
2005-07-01 16:55:43 +00:00
|
|
|
break;
|
|
|
|
case GST_VIDEOSCALE_I420:
|
|
|
|
case GST_VIDEOSCALE_YV12:
|
2005-08-24 15:07:54 +00:00
|
|
|
vs_image_scale_linear_Y (dest, src, videoscale->tmp_buf);
|
2005-07-01 16:55:43 +00:00
|
|
|
//memset (dest_u.pixels, 128, dest_u.stride * dest_u.height);
|
|
|
|
//memset (dest_v.pixels, 128, dest_v.stride * dest_v.height);
|
2005-08-24 15:07:54 +00:00
|
|
|
vs_image_scale_linear_Y (&dest_u, &src_u, videoscale->tmp_buf);
|
|
|
|
vs_image_scale_linear_Y (&dest_v, &src_v, videoscale->tmp_buf);
|
2005-07-01 16:55:43 +00:00
|
|
|
break;
|
|
|
|
case GST_VIDEOSCALE_RGB565:
|
2005-08-24 15:07:54 +00:00
|
|
|
vs_image_scale_linear_RGB565 (dest, src, videoscale->tmp_buf);
|
2005-07-01 16:55:43 +00:00
|
|
|
break;
|
|
|
|
case GST_VIDEOSCALE_RGB555:
|
2005-08-24 15:07:54 +00:00
|
|
|
vs_image_scale_linear_RGB555 (dest, src, videoscale->tmp_buf);
|
2005-07-01 16:55:43 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_warning ("don't know how to scale");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2005-08-24 15:07:54 +00:00
|
|
|
ret = GST_FLOW_ERROR;
|
2005-07-01 16:55:43 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-12-22 23:27:17 +00:00
|
|
|
|
2004-07-27 15:56:55 +00:00
|
|
|
GST_LOG_OBJECT (videoscale, "pushing buffer of %d bytes",
|
2005-07-15 10:44:19 +00:00
|
|
|
GST_BUFFER_SIZE (out));
|
2003-04-22 07:32:50 +00:00
|
|
|
|
2005-08-24 15:07:54 +00:00
|
|
|
return ret;
|
2001-12-22 23:27:17 +00:00
|
|
|
}
|
|
|
|
|
2005-07-01 17:03:13 +00:00
|
|
|
static gboolean
|
|
|
|
gst_videoscale_handle_src_event (GstPad * pad, GstEvent * event)
|
2001-12-22 23:27:17 +00:00
|
|
|
{
|
2005-07-01 17:03:13 +00:00
|
|
|
GstVideoscale *videoscale;
|
|
|
|
double a;
|
|
|
|
GstStructure *structure;
|
2001-12-22 23:27:17 +00:00
|
|
|
|
2005-07-01 17:03:13 +00:00
|
|
|
videoscale = GST_VIDEOSCALE (gst_pad_get_parent (pad));
|
2001-12-22 23:27:17 +00:00
|
|
|
|
2005-07-01 17:03:13 +00:00
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
|
|
|
case GST_EVENT_NAVIGATION:
|
|
|
|
event =
|
|
|
|
GST_EVENT (gst_mini_object_make_writable (GST_MINI_OBJECT (event)));
|
examples/seeking/seek.c: Update seek example.
Original commit message from CVS:
* examples/seeking/seek.c: (setup_dynamic_link),
(make_dv_pipeline), (make_vorbis_theora_pipeline), (query_rates),
(query_positions_elems), (query_positions_pads), (do_seek):
Update seek example.
* ext/ogg/gstoggdemux.c: (gst_ogg_pad_event),
(gst_ogg_pad_typefind), (gst_ogg_demux_chain_elem_pad),
(gst_ogg_demux_queue_data), (gst_ogg_demux_chain_peer),
(gst_ogg_pad_submit_packet), (gst_ogg_pad_submit_page),
(gst_ogg_demux_handle_event),
(gst_ogg_demux_deactivate_current_chain),
(gst_ogg_demux_activate_chain), (gst_ogg_demux_perform_seek),
(gst_ogg_demux_collect_chain_info), (gst_ogg_demux_collect_info),
(gst_ogg_demux_chain), (gst_ogg_demux_send_event),
(gst_ogg_demux_loop):
* ext/ogg/gstoggmux.c: (gst_ogg_mux_collected):
* ext/theora/theoradec.c: (theora_dec_src_event),
(theora_dec_src_getcaps), (theora_dec_sink_event),
(theora_dec_push), (theora_dec_chain):
* ext/vorbis/Makefile.am:
* ext/vorbis/vorbisdec.c: (vorbis_dec_src_event),
(vorbis_dec_sink_event), (vorbis_dec_push),
(vorbis_handle_data_packet):
* ext/vorbis/vorbisenc.c: (gst_vorbisenc_sink_event),
(gst_vorbisenc_chain):
* gst/playback/gststreaminfo.c: (cb_probe):
* gst/subparse/gstsubparse.c: (gst_subparse_src_event):
* gst/videorate/gstvideorate.c: (gst_videorate_event):
* gst/videoscale/gstvideoscale.c:
(gst_videoscale_handle_src_event):
* gst/videotestsrc/gstvideotestsrc.c: (gst_videotestsrc_event):
* sys/ximage/ximagesink.c: (gst_ximagesink_show_frame),
(gst_ximagesink_navigation_send_event):
* sys/xvimage/xvimagesink.c:
(gst_xvimagesink_navigation_send_event):
Various event updates and cleanups
2005-07-27 18:34:29 +00:00
|
|
|
|
|
|
|
structure = (GstStructure *) gst_event_get_structure (event);
|
2005-07-01 17:03:13 +00:00
|
|
|
if (gst_structure_get_double (structure, "pointer_x", &a)) {
|
|
|
|
gst_structure_set (structure, "pointer_x", G_TYPE_DOUBLE,
|
|
|
|
a * videoscale->from_width / videoscale->to_width, NULL);
|
|
|
|
}
|
|
|
|
if (gst_structure_get_double (structure, "pointer_y", &a)) {
|
|
|
|
gst_structure_set (structure, "pointer_y", G_TYPE_DOUBLE,
|
|
|
|
a * videoscale->from_height / videoscale->to_height, NULL);
|
|
|
|
}
|
|
|
|
return gst_pad_event_default (pad, event);
|
2001-12-22 23:27:17 +00:00
|
|
|
default:
|
2005-07-01 17:03:13 +00:00
|
|
|
GST_DEBUG_OBJECT (videoscale, "passing on non-NAVIGATION event %p",
|
|
|
|
event);
|
|
|
|
return gst_pad_event_default (pad, event);
|
2001-12-22 23:27:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-14 22:34:34 +00:00
|
|
|
plugin_init (GstPlugin * plugin)
|
2001-12-22 23:27:17 +00:00
|
|
|
{
|
2004-03-14 22:34:34 +00:00
|
|
|
if (!gst_element_register (plugin, "videoscale", GST_RANK_NONE,
|
2004-03-15 19:32:28 +00:00
|
|
|
GST_TYPE_VIDEOSCALE))
|
2004-02-25 17:37:26 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT (videoscale_debug, "videoscale", 0,
|
|
|
|
"videoscale element");
|
2004-02-25 17:37:26 +00:00
|
|
|
|
|
|
|
return TRUE;
|
2001-12-22 23:27:17 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
|
|
|
GST_VERSION_MINOR,
|
|
|
|
"videoscale",
|
2005-10-16 13:54:44 +00:00
|
|
|
"Resizes video", plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME,
|
|
|
|
GST_PACKAGE_ORIGIN)
|