mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
gst/videoscale/gstvideoscale.*: Refactor, make use of BaseTranform really well.
Original commit message from CVS: * gst/videoscale/gstvideoscale.c: (gst_videoscale_init), (gst_videoscale_prepare_size), (parse_caps), (gst_videoscale_set_caps), (gst_videoscale_get_size), (gst_videoscale_prepare_image), (gst_videoscale_transform_ip), (gst_videoscale_transform): * gst/videoscale/gstvideoscale.h: Refactor, make use of BaseTranform really well.
This commit is contained in:
parent
752a59192c
commit
da25385ed2
3 changed files with 155 additions and 142 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2005-08-24 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
|
* gst/videoscale/gstvideoscale.c: (gst_videoscale_init),
|
||||||
|
(gst_videoscale_prepare_size), (parse_caps),
|
||||||
|
(gst_videoscale_set_caps), (gst_videoscale_get_size),
|
||||||
|
(gst_videoscale_prepare_image), (gst_videoscale_transform_ip),
|
||||||
|
(gst_videoscale_transform):
|
||||||
|
* gst/videoscale/gstvideoscale.h:
|
||||||
|
Refactor, make use of BaseTranform really well.
|
||||||
|
|
||||||
2005-08-24 Thomas Vander Stichele <thomas at apestaart dot org>
|
2005-08-24 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||||
|
|
||||||
* configure.ac:
|
* configure.ac:
|
||||||
|
|
|
@ -234,6 +234,7 @@ gst_videoscale_init (GstVideoscale * videoscale)
|
||||||
|
|
||||||
gst_pad_set_event_function (trans->srcpad, gst_videoscale_handle_src_event);
|
gst_pad_set_event_function (trans->srcpad, gst_videoscale_handle_src_event);
|
||||||
|
|
||||||
|
videoscale->tmp_buf = NULL;
|
||||||
videoscale->method = GST_VIDEOSCALE_NEAREST;
|
videoscale->method = GST_VIDEOSCALE_NEAREST;
|
||||||
/*videoscale->method = GST_VIDEOSCALE_BILINEAR; */
|
/*videoscale->method = GST_VIDEOSCALE_BILINEAR; */
|
||||||
/*videoscale->method = GST_VIDEOSCALE_POINT_SAMPLE; */
|
/*videoscale->method = GST_VIDEOSCALE_POINT_SAMPLE; */
|
||||||
|
@ -316,112 +317,127 @@ gst_videoscale_get_format (GstCaps * caps)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
gst_videoscale_set_caps (GstBaseTransform * trans, GstCaps * in, GstCaps * out)
|
|
||||||
{
|
|
||||||
GstVideoscale *videoscale;
|
|
||||||
gboolean ret;
|
|
||||||
GstStructure *structure;
|
|
||||||
|
|
||||||
videoscale = GST_VIDEOSCALE (trans);
|
|
||||||
|
|
||||||
structure = gst_caps_get_structure (in, 0);
|
|
||||||
ret = gst_structure_get_int (structure, "width", &videoscale->from_width);
|
|
||||||
ret &= gst_structure_get_int (structure, "height", &videoscale->from_height);
|
|
||||||
|
|
||||||
structure = gst_caps_get_structure (out, 0);
|
|
||||||
ret &= gst_structure_get_int (structure, "width", &videoscale->to_width);
|
|
||||||
ret &= gst_structure_get_int (structure, "height", &videoscale->to_height);
|
|
||||||
|
|
||||||
/* fixme: par */
|
|
||||||
GST_DEBUG_OBJECT (videoscale, "from=%dx%d to=%dx%d",
|
|
||||||
videoscale->from_width, videoscale->from_height,
|
|
||||||
videoscale->to_width, videoscale->to_height);
|
|
||||||
|
|
||||||
videoscale->format = gst_videoscale_get_format (in);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define ROUND_UP_2(x) (((x)+1)&~1)
|
#define ROUND_UP_2(x) (((x)+1)&~1)
|
||||||
#define ROUND_UP_4(x) (((x)+3)&~3)
|
#define ROUND_UP_4(x) (((x)+3)&~3)
|
||||||
#define ROUND_UP_8(x) (((x)+7)&~7)
|
#define ROUND_UP_8(x) (((x)+7)&~7)
|
||||||
|
|
||||||
/* returns size of output buffer */
|
/* calculate the size of a buffer */
|
||||||
static gulong
|
static gboolean
|
||||||
gst_videoscale_prepare_sizes (GstVideoscale * videoscale, VSImage * src,
|
gst_videoscale_prepare_size (gint format,
|
||||||
VSImage * dest, gboolean reset_source)
|
VSImage * img, gint width, gint height, guint * size)
|
||||||
{
|
{
|
||||||
gulong size = 0;
|
gboolean res = TRUE;
|
||||||
|
|
||||||
if (reset_source) {
|
img->width = width;
|
||||||
src->width = videoscale->from_width;
|
img->height = height;
|
||||||
src->height = videoscale->from_height;
|
|
||||||
}
|
|
||||||
|
|
||||||
dest->width = videoscale->to_width;
|
switch (format) {
|
||||||
dest->height = videoscale->to_height;
|
|
||||||
|
|
||||||
switch (videoscale->format) {
|
|
||||||
case GST_VIDEOSCALE_RGBx:
|
case GST_VIDEOSCALE_RGBx:
|
||||||
case GST_VIDEOSCALE_xRGB:
|
case GST_VIDEOSCALE_xRGB:
|
||||||
case GST_VIDEOSCALE_BGRx:
|
case GST_VIDEOSCALE_BGRx:
|
||||||
case GST_VIDEOSCALE_xBGR:
|
case GST_VIDEOSCALE_xBGR:
|
||||||
case GST_VIDEOSCALE_AYUV:
|
case GST_VIDEOSCALE_AYUV:
|
||||||
src->stride = src->width * 4;
|
img->stride = img->width * 4;
|
||||||
dest->stride = dest->width * 4;
|
*size = img->stride * img->height;
|
||||||
size = dest->stride * dest->height;
|
|
||||||
break;
|
break;
|
||||||
case GST_VIDEOSCALE_RGB:
|
case GST_VIDEOSCALE_RGB:
|
||||||
case GST_VIDEOSCALE_BGR:
|
case GST_VIDEOSCALE_BGR:
|
||||||
src->stride = ROUND_UP_4 (src->width * 3);
|
img->stride = ROUND_UP_4 (img->width * 3);
|
||||||
dest->stride = ROUND_UP_4 (dest->width * 3);
|
*size = img->stride * img->height;
|
||||||
size = dest->stride * dest->height;
|
|
||||||
break;
|
break;
|
||||||
case GST_VIDEOSCALE_YUY2:
|
case GST_VIDEOSCALE_YUY2:
|
||||||
case GST_VIDEOSCALE_YVYU:
|
case GST_VIDEOSCALE_YVYU:
|
||||||
case GST_VIDEOSCALE_UYVY:
|
case GST_VIDEOSCALE_UYVY:
|
||||||
src->stride = ROUND_UP_4 (src->width * 2);
|
img->stride = ROUND_UP_4 (img->width * 2);
|
||||||
dest->stride = ROUND_UP_4 (dest->width * 2);
|
*size = img->stride * img->height;
|
||||||
size = dest->stride * dest->height;
|
|
||||||
break;
|
break;
|
||||||
case GST_VIDEOSCALE_Y:
|
case GST_VIDEOSCALE_Y:
|
||||||
src->stride = ROUND_UP_4 (src->width);
|
img->stride = ROUND_UP_4 (img->width);
|
||||||
dest->stride = ROUND_UP_4 (dest->width);
|
*size = img->stride * img->height;
|
||||||
size = dest->stride * dest->height;
|
|
||||||
break;
|
break;
|
||||||
case GST_VIDEOSCALE_I420:
|
case GST_VIDEOSCALE_I420:
|
||||||
case GST_VIDEOSCALE_YV12:
|
case GST_VIDEOSCALE_YV12:
|
||||||
{
|
{
|
||||||
gulong dest_u_stride;
|
gulong img_u_stride, img_u_height;
|
||||||
gulong dest_u_height;
|
|
||||||
|
|
||||||
src->stride = ROUND_UP_4 (src->width);
|
img->stride = ROUND_UP_4 (img->width);
|
||||||
dest->stride = ROUND_UP_4 (dest->width);
|
|
||||||
|
|
||||||
dest_u_height = ROUND_UP_2 (dest->height) / 2;
|
img_u_height = ROUND_UP_2 (img->height) / 2;
|
||||||
dest_u_stride = ROUND_UP_4 (dest->stride / 2);
|
img_u_stride = ROUND_UP_4 (img->stride / 2);
|
||||||
|
|
||||||
size = dest->stride * ROUND_UP_2 (dest->height) +
|
*size = img->stride * ROUND_UP_2 (img->height) +
|
||||||
2 * dest_u_stride * dest_u_height;
|
2 * img_u_stride * img_u_height;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GST_VIDEOSCALE_RGB565:
|
case GST_VIDEOSCALE_RGB565:
|
||||||
src->stride = ROUND_UP_4 (src->width * 2);
|
img->stride = ROUND_UP_4 (img->width * 2);
|
||||||
dest->stride = ROUND_UP_4 (dest->width * 2);
|
*size = img->stride * img->height;
|
||||||
size = dest->stride * dest->height;
|
|
||||||
break;
|
break;
|
||||||
case GST_VIDEOSCALE_RGB555:
|
case GST_VIDEOSCALE_RGB555:
|
||||||
src->stride = ROUND_UP_4 (src->width * 2);
|
img->stride = ROUND_UP_4 (img->width * 2);
|
||||||
dest->stride = ROUND_UP_4 (dest->width * 2);
|
*size = img->stride * img->height;
|
||||||
size = dest->stride * dest->height;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
g_warning ("don't know how to scale");
|
g_warning ("don't know how to scale");
|
||||||
|
res = FALSE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return size;
|
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);
|
||||||
|
done:
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -429,54 +445,50 @@ gst_videoscale_get_unit_size (GstBaseTransform * trans, GstCaps * caps,
|
||||||
guint * size)
|
guint * size)
|
||||||
{
|
{
|
||||||
GstVideoscale *videoscale;
|
GstVideoscale *videoscale;
|
||||||
VSImage dest;
|
gint format, width, height;
|
||||||
VSImage src;
|
VSImage img;
|
||||||
|
|
||||||
g_return_val_if_fail (size, FALSE);
|
g_return_val_if_fail (size, FALSE);
|
||||||
|
|
||||||
videoscale = GST_VIDEOSCALE (trans);
|
videoscale = GST_VIDEOSCALE (trans);
|
||||||
|
|
||||||
if (gst_caps_is_equal (caps, GST_PAD_CAPS (trans->srcpad)))
|
if (!parse_caps (caps, &format, &width, &height))
|
||||||
*size = gst_videoscale_prepare_sizes (videoscale, &src, &dest, TRUE);
|
return FALSE;
|
||||||
/* don't have an easy way of getting the size on the sink side for now... */
|
|
||||||
else
|
if (!gst_videoscale_prepare_size (format, &img, width, height, size))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static gboolean
|
||||||
gst_videoscale_prepare_images (GstVideoscale * videoscale, GstBuffer * in,
|
gst_videoscale_prepare_image (gint format, GstBuffer * buf,
|
||||||
GstBuffer * out, VSImage * src, VSImage * src_u, VSImage * src_v,
|
VSImage * img, VSImage * img_u, VSImage * img_v)
|
||||||
VSImage * dest, VSImage * dest_u, VSImage * dest_v)
|
|
||||||
{
|
{
|
||||||
src->pixels = GST_BUFFER_DATA (in);
|
gboolean res = TRUE;
|
||||||
dest->pixels = GST_BUFFER_DATA (out);
|
|
||||||
|
|
||||||
switch (videoscale->format) {
|
img->pixels = GST_BUFFER_DATA (buf);
|
||||||
|
|
||||||
|
switch (format) {
|
||||||
case GST_VIDEOSCALE_I420:
|
case GST_VIDEOSCALE_I420:
|
||||||
case GST_VIDEOSCALE_YV12:
|
case GST_VIDEOSCALE_YV12:
|
||||||
src_u->pixels = src->pixels + ROUND_UP_2 (src->height) * src->stride;
|
img_u->pixels = img->pixels + ROUND_UP_2 (img->height) * img->stride;
|
||||||
src_u->height = ROUND_UP_2 (src->height) / 2;
|
img_u->height = ROUND_UP_2 (img->height) / 2;
|
||||||
src_u->width = ROUND_UP_2 (src->width) / 2;
|
img_u->width = ROUND_UP_2 (img->width) / 2;
|
||||||
src_u->stride = ROUND_UP_4 (src->stride / 2);
|
img_u->stride = ROUND_UP_4 (img->stride / 2);
|
||||||
memcpy (src_v, src_u, sizeof (*src_v));
|
memcpy (img_v, img_u, sizeof (*img_v));
|
||||||
src_v->pixels = src_u->pixels + src_u->height * src_u->stride;
|
img_v->pixels = img_u->pixels + img_u->height * img_u->stride;
|
||||||
|
|
||||||
dest_u->pixels = dest->pixels + ROUND_UP_2 (dest->height) * dest->stride;
|
|
||||||
dest_u->height = ROUND_UP_2 (dest->height) / 2;
|
|
||||||
dest_u->width = ROUND_UP_2 (dest->width) / 2;
|
|
||||||
dest_u->stride = ROUND_UP_4 (dest->stride / 2);
|
|
||||||
memcpy (dest_v, dest_u, sizeof (*dest_v));
|
|
||||||
dest_v->pixels = dest_u->pixels + dest_u->height * dest_u->stride;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_videoscale_transform_ip (GstBaseTransform * trans, GstBuffer * in)
|
gst_videoscale_transform_ip (GstBaseTransform * trans, GstBuffer * in)
|
||||||
{
|
{
|
||||||
|
/* nothing to be done in passthrough */
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -485,32 +497,24 @@ gst_videoscale_transform (GstBaseTransform * trans, GstBuffer * in,
|
||||||
GstBuffer * out)
|
GstBuffer * out)
|
||||||
{
|
{
|
||||||
GstVideoscale *videoscale;
|
GstVideoscale *videoscale;
|
||||||
GstFlowReturn ret;
|
GstFlowReturn ret = GST_FLOW_OK;
|
||||||
gulong size;
|
VSImage *dest;
|
||||||
VSImage dest;
|
VSImage *src;
|
||||||
VSImage src;
|
|
||||||
VSImage dest_u;
|
VSImage dest_u;
|
||||||
VSImage src_u;
|
|
||||||
VSImage dest_v;
|
VSImage dest_v;
|
||||||
|
VSImage src_u;
|
||||||
VSImage src_v;
|
VSImage src_v;
|
||||||
guint8 *tmpbuf;
|
|
||||||
|
|
||||||
videoscale = GST_VIDEOSCALE (trans);
|
videoscale = GST_VIDEOSCALE (trans);
|
||||||
|
|
||||||
/* FIXME: I can't figure out how passthru would work in 0.9 */
|
|
||||||
|
|
||||||
size = gst_videoscale_prepare_sizes (videoscale, &src, &dest, TRUE);
|
|
||||||
if (!size) {
|
|
||||||
ret = GST_FLOW_UNEXPECTED;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
gst_buffer_stamp (out, in);
|
gst_buffer_stamp (out, in);
|
||||||
|
|
||||||
gst_videoscale_prepare_images (videoscale, in, out, &src, &src_u, &src_v,
|
src = &videoscale->src;
|
||||||
&dest, &dest_u, &dest_v);
|
dest = &videoscale->dest;
|
||||||
|
|
||||||
tmpbuf = g_malloc (dest.stride * 2);
|
gst_videoscale_prepare_image (videoscale->format, in, src, &src_u, &src_v);
|
||||||
|
gst_videoscale_prepare_image (videoscale->format, out, dest, &dest_u,
|
||||||
|
&dest_v);
|
||||||
|
|
||||||
switch (videoscale->method) {
|
switch (videoscale->method) {
|
||||||
case GST_VIDEOSCALE_NEAREST:
|
case GST_VIDEOSCALE_NEAREST:
|
||||||
|
@ -520,33 +524,33 @@ gst_videoscale_transform (GstBaseTransform * trans, GstBuffer * in,
|
||||||
case GST_VIDEOSCALE_BGRx:
|
case GST_VIDEOSCALE_BGRx:
|
||||||
case GST_VIDEOSCALE_xBGR:
|
case GST_VIDEOSCALE_xBGR:
|
||||||
case GST_VIDEOSCALE_AYUV:
|
case GST_VIDEOSCALE_AYUV:
|
||||||
vs_image_scale_nearest_RGBA (&dest, &src, tmpbuf);
|
vs_image_scale_nearest_RGBA (dest, src, videoscale->tmp_buf);
|
||||||
break;
|
break;
|
||||||
case GST_VIDEOSCALE_RGB:
|
case GST_VIDEOSCALE_RGB:
|
||||||
case GST_VIDEOSCALE_BGR:
|
case GST_VIDEOSCALE_BGR:
|
||||||
vs_image_scale_nearest_RGB (&dest, &src, tmpbuf);
|
vs_image_scale_nearest_RGB (dest, src, videoscale->tmp_buf);
|
||||||
break;
|
break;
|
||||||
case GST_VIDEOSCALE_YUY2:
|
case GST_VIDEOSCALE_YUY2:
|
||||||
case GST_VIDEOSCALE_YVYU:
|
case GST_VIDEOSCALE_YVYU:
|
||||||
vs_image_scale_nearest_YUYV (&dest, &src, tmpbuf);
|
vs_image_scale_nearest_YUYV (dest, src, videoscale->tmp_buf);
|
||||||
break;
|
break;
|
||||||
case GST_VIDEOSCALE_UYVY:
|
case GST_VIDEOSCALE_UYVY:
|
||||||
vs_image_scale_nearest_UYVY (&dest, &src, tmpbuf);
|
vs_image_scale_nearest_UYVY (dest, src, videoscale->tmp_buf);
|
||||||
break;
|
break;
|
||||||
case GST_VIDEOSCALE_Y:
|
case GST_VIDEOSCALE_Y:
|
||||||
vs_image_scale_nearest_Y (&dest, &src, tmpbuf);
|
vs_image_scale_nearest_Y (dest, src, videoscale->tmp_buf);
|
||||||
break;
|
break;
|
||||||
case GST_VIDEOSCALE_I420:
|
case GST_VIDEOSCALE_I420:
|
||||||
case GST_VIDEOSCALE_YV12:
|
case GST_VIDEOSCALE_YV12:
|
||||||
vs_image_scale_nearest_Y (&dest, &src, tmpbuf);
|
vs_image_scale_nearest_Y (dest, src, videoscale->tmp_buf);
|
||||||
vs_image_scale_nearest_Y (&dest_u, &src_u, tmpbuf);
|
vs_image_scale_nearest_Y (&dest_u, &src_u, videoscale->tmp_buf);
|
||||||
vs_image_scale_nearest_Y (&dest_v, &src_v, tmpbuf);
|
vs_image_scale_nearest_Y (&dest_v, &src_v, videoscale->tmp_buf);
|
||||||
break;
|
break;
|
||||||
case GST_VIDEOSCALE_RGB565:
|
case GST_VIDEOSCALE_RGB565:
|
||||||
vs_image_scale_nearest_RGB565 (&dest, &src, tmpbuf);
|
vs_image_scale_nearest_RGB565 (dest, src, videoscale->tmp_buf);
|
||||||
break;
|
break;
|
||||||
case GST_VIDEOSCALE_RGB555:
|
case GST_VIDEOSCALE_RGB555:
|
||||||
vs_image_scale_nearest_RGB555 (&dest, &src, tmpbuf);
|
vs_image_scale_nearest_RGB555 (dest, src, videoscale->tmp_buf);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
g_warning ("don't know how to scale");
|
g_warning ("don't know how to scale");
|
||||||
|
@ -560,52 +564,49 @@ gst_videoscale_transform (GstBaseTransform * trans, GstBuffer * in,
|
||||||
case GST_VIDEOSCALE_BGRx:
|
case GST_VIDEOSCALE_BGRx:
|
||||||
case GST_VIDEOSCALE_xBGR:
|
case GST_VIDEOSCALE_xBGR:
|
||||||
case GST_VIDEOSCALE_AYUV:
|
case GST_VIDEOSCALE_AYUV:
|
||||||
vs_image_scale_linear_RGBA (&dest, &src, tmpbuf);
|
vs_image_scale_linear_RGBA (dest, src, videoscale->tmp_buf);
|
||||||
break;
|
break;
|
||||||
case GST_VIDEOSCALE_RGB:
|
case GST_VIDEOSCALE_RGB:
|
||||||
case GST_VIDEOSCALE_BGR:
|
case GST_VIDEOSCALE_BGR:
|
||||||
vs_image_scale_linear_RGB (&dest, &src, tmpbuf);
|
vs_image_scale_linear_RGB (dest, src, videoscale->tmp_buf);
|
||||||
break;
|
break;
|
||||||
case GST_VIDEOSCALE_YUY2:
|
case GST_VIDEOSCALE_YUY2:
|
||||||
case GST_VIDEOSCALE_YVYU:
|
case GST_VIDEOSCALE_YVYU:
|
||||||
vs_image_scale_linear_YUYV (&dest, &src, tmpbuf);
|
vs_image_scale_linear_YUYV (dest, src, videoscale->tmp_buf);
|
||||||
break;
|
break;
|
||||||
case GST_VIDEOSCALE_UYVY:
|
case GST_VIDEOSCALE_UYVY:
|
||||||
vs_image_scale_linear_UYVY (&dest, &src, tmpbuf);
|
vs_image_scale_linear_UYVY (dest, src, videoscale->tmp_buf);
|
||||||
break;
|
break;
|
||||||
case GST_VIDEOSCALE_Y:
|
case GST_VIDEOSCALE_Y:
|
||||||
vs_image_scale_linear_Y (&dest, &src, tmpbuf);
|
vs_image_scale_linear_Y (dest, src, videoscale->tmp_buf);
|
||||||
break;
|
break;
|
||||||
case GST_VIDEOSCALE_I420:
|
case GST_VIDEOSCALE_I420:
|
||||||
case GST_VIDEOSCALE_YV12:
|
case GST_VIDEOSCALE_YV12:
|
||||||
vs_image_scale_linear_Y (&dest, &src, tmpbuf);
|
vs_image_scale_linear_Y (dest, src, videoscale->tmp_buf);
|
||||||
//memset (dest_u.pixels, 128, dest_u.stride * dest_u.height);
|
//memset (dest_u.pixels, 128, dest_u.stride * dest_u.height);
|
||||||
//memset (dest_v.pixels, 128, dest_v.stride * dest_v.height);
|
//memset (dest_v.pixels, 128, dest_v.stride * dest_v.height);
|
||||||
vs_image_scale_linear_Y (&dest_u, &src_u, tmpbuf);
|
vs_image_scale_linear_Y (&dest_u, &src_u, videoscale->tmp_buf);
|
||||||
vs_image_scale_linear_Y (&dest_v, &src_v, tmpbuf);
|
vs_image_scale_linear_Y (&dest_v, &src_v, videoscale->tmp_buf);
|
||||||
break;
|
break;
|
||||||
case GST_VIDEOSCALE_RGB565:
|
case GST_VIDEOSCALE_RGB565:
|
||||||
vs_image_scale_linear_RGB565 (&dest, &src, tmpbuf);
|
vs_image_scale_linear_RGB565 (dest, src, videoscale->tmp_buf);
|
||||||
break;
|
break;
|
||||||
case GST_VIDEOSCALE_RGB555:
|
case GST_VIDEOSCALE_RGB555:
|
||||||
vs_image_scale_linear_RGB555 (&dest, &src, tmpbuf);
|
vs_image_scale_linear_RGB555 (dest, src, videoscale->tmp_buf);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
g_warning ("don't know how to scale");
|
g_warning ("don't know how to scale");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
g_assert_not_reached ();
|
ret = GST_FLOW_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (tmpbuf);
|
|
||||||
|
|
||||||
GST_LOG_OBJECT (videoscale, "pushing buffer of %d bytes",
|
GST_LOG_OBJECT (videoscale, "pushing buffer of %d bytes",
|
||||||
GST_BUFFER_SIZE (out));
|
GST_BUFFER_SIZE (out));
|
||||||
|
|
||||||
done:
|
return ret;
|
||||||
return GST_FLOW_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
#include <gst/base/gstbasetransform.h>
|
#include <gst/base/gstbasetransform.h>
|
||||||
|
|
||||||
|
#include "vs_image.h"
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
@ -60,20 +61,21 @@ typedef struct _GstVideoscaleClass GstVideoscaleClass;
|
||||||
struct _GstVideoscale {
|
struct _GstVideoscale {
|
||||||
GstBaseTransform element;
|
GstBaseTransform element;
|
||||||
|
|
||||||
/* video state */
|
GstVideoScaleMethod method;
|
||||||
gboolean inited;
|
|
||||||
|
/* negotiated stuff */
|
||||||
int format;
|
int format;
|
||||||
|
VSImage src;
|
||||||
|
VSImage dest;
|
||||||
|
guint src_size;
|
||||||
|
guint dest_size;
|
||||||
gint to_width;
|
gint to_width;
|
||||||
gint to_height;
|
gint to_height;
|
||||||
gint from_width;
|
gint from_width;
|
||||||
gint from_height;
|
gint from_height;
|
||||||
gboolean passthru;
|
|
||||||
float framerate;
|
|
||||||
|
|
||||||
GstVideoScaleMethod method;
|
|
||||||
|
|
||||||
/* private */
|
/* private */
|
||||||
gint to_buf_size;
|
guint8 *tmp_buf;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstVideoscaleClass {
|
struct _GstVideoscaleClass {
|
||||||
|
|
Loading…
Reference in a new issue