summaryrefslogtreecommitdiffstats
path: root/ext/gdk_pixbuf
diff options
context:
space:
mode:
authorJan Schmidt <thaytan@mad.scientist.com>2005-01-12 05:53:46 +0000
committerJan Schmidt <thaytan@mad.scientist.com>2005-01-12 05:53:46 +0000
commitb1ca5dd2e2389ee0e8358a34565a805daea6b0ca (patch)
treec4108e4a7334eeced1d4824ae34a94aebc9cfd62 /ext/gdk_pixbuf
parent3b12894436aaeaafd061caba3e1f222355107b1b (diff)
ext/gdk_pixbuf/pixbufscale.*: to ensure rowstrides are calculated the same way as ffmpegcolorspace.
Original commit message from CVS: * ext/gdk_pixbuf/pixbufscale.c: (gst_pixbufscale_link), (pixbufscale_scale), (gst_pixbufscale_chain): * ext/gdk_pixbuf/pixbufscale.h: Incorporate changes from Tim-Philipp Mueller <t.i.m@orange.net> to ensure rowstrides are calculated the same way as ffmpegcolorspace. Use gst_buffer_stamp instead of copying timestamps manually, so that we pick up duration and offset also.
Diffstat (limited to 'ext/gdk_pixbuf')
-rw-r--r--ext/gdk_pixbuf/pixbufscale.c40
-rw-r--r--ext/gdk_pixbuf/pixbufscale.h3
2 files changed, 33 insertions, 10 deletions
diff --git a/ext/gdk_pixbuf/pixbufscale.c b/ext/gdk_pixbuf/pixbufscale.c
index 45b9c7a9..3cfa17ee 100644
--- a/ext/gdk_pixbuf/pixbufscale.c
+++ b/ext/gdk_pixbuf/pixbufscale.c
@@ -1,6 +1,7 @@
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
* Copyright (C) <2004> Jan Schmidt <thaytan@mad.scientist.com>
+ * Copyright (C) <2004> Tim-Philipp Mueller <t.i.m@orange.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -26,6 +27,15 @@
#include <gst/video/video.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
+#define ROUND_UP_2(x) (((x)+1)&~1)
+#define ROUND_UP_4(x) (((x)+3)&~3)
+#define ROUND_UP_8(x) (((x)+7)&~7)
+
+/* These match the ones gstffmpegcolorspace uses (Tim) */
+#define GST_RGB24_ROWSTRIDE(width) (ROUND_UP_4 ((width)*3))
+#define GST_RGB24_SIZE(width,height) ((height)*GST_RGB24_ROWSTRIDE(width))
+
+
/* debug variable definition */
GST_DEBUG_CATEGORY (pixbufscale_debug);
#define GST_CAT_DEFAULT pixbufscale_debug
@@ -216,8 +226,10 @@ gst_pixbufscale_link (GstPad * pad, const GstCaps * caps)
pixbufscale->from_width = width;
pixbufscale->from_height = height;
- pixbufscale->from_buf_size = width * height * 3;
- pixbufscale->to_buf_size = width * height * 3;
+ pixbufscale->from_buf_size = GST_RGB24_SIZE (width, height);
+ pixbufscale->to_buf_size = GST_RGB24_SIZE (width, height);
+ pixbufscale->from_stride = GST_RGB24_ROWSTRIDE (width);
+ pixbufscale->to_stride = GST_RGB24_ROWSTRIDE (width);
pixbufscale->inited = TRUE;
@@ -253,10 +265,12 @@ gst_pixbufscale_link (GstPad * pad, const GstCaps * caps)
}
if (gst_pad_is_negotiated (otherpad)) {
- pixbufscale->from_buf_size = pixbufscale->from_width *
- pixbufscale->from_height * 3;
- pixbufscale->to_buf_size = pixbufscale->to_width *
- pixbufscale->to_height * 3;
+ pixbufscale->from_buf_size =
+ GST_RGB24_SIZE (pixbufscale->from_width, pixbufscale->from_height);
+ pixbufscale->to_buf_size =
+ GST_RGB24_SIZE (pixbufscale->to_width, pixbufscale->to_height);
+ pixbufscale->from_stride = GST_RGB24_ROWSTRIDE (pixbufscale->from_width);
+ pixbufscale->to_stride = GST_RGB24_ROWSTRIDE (pixbufscale->to_width);
pixbufscale->inited = TRUE;
}
@@ -333,10 +347,11 @@ pixbufscale_scale (GstPixbufScale * scale, unsigned char *dest,
src_pixbuf = gdk_pixbuf_new_from_data
(src, GDK_COLORSPACE_RGB, FALSE,
8, scale->from_width, scale->from_height,
- 3 * scale->from_width, NULL, NULL);
+ GST_RGB24_ROWSTRIDE (scale->from_width), NULL, NULL);
dest_pixbuf = gdk_pixbuf_new_from_data
(dest, GDK_COLORSPACE_RGB, FALSE,
- 8, scale->to_width, scale->to_height, 3 * scale->to_width, NULL, NULL);
+ 8, scale->to_width, scale->to_height,
+ GST_RGB24_ROWSTRIDE (scale->to_width), NULL, NULL);
gdk_pixbuf_scale (src_pixbuf, dest_pixbuf, 0, 0, scale->to_width,
scale->to_height, 0, 0,
(double) scale->to_width / scale->from_width,
@@ -383,12 +398,17 @@ gst_pixbufscale_chain (GstPad * pad, GstData * _data)
pixbufscale->to_width, pixbufscale->to_height, size,
pixbufscale->from_buf_size, pixbufscale->to_buf_size);
- g_return_if_fail (size == pixbufscale->from_buf_size);
+ if (size != pixbufscale->from_buf_size) {
+ GST_ERROR ("Incoming RGB data is %d bytes (expected: %d bytes) (%dx%d)\n",
+ size, pixbufscale->from_buf_size, pixbufscale->from_width,
+ pixbufscale->from_height);
+ return;
+ }
outbuf = gst_pad_alloc_buffer (pixbufscale->srcpad,
GST_BUFFER_OFFSET_NONE, pixbufscale->to_buf_size);
- GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
+ gst_buffer_stamp (outbuf, buf);
pixbufscale_scale (pixbufscale, GST_BUFFER_DATA (outbuf), data);
diff --git a/ext/gdk_pixbuf/pixbufscale.h b/ext/gdk_pixbuf/pixbufscale.h
index 4e154044..0d9b10fe 100644
--- a/ext/gdk_pixbuf/pixbufscale.h
+++ b/ext/gdk_pixbuf/pixbufscale.h
@@ -1,6 +1,7 @@
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
* Copyright (C) <2004> Jan Schmidt <thaytan@mad.scientist.com>
+ * Copyright (C) <2004> Tim-Philipp Mueller <t.i.m@orange.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -66,7 +67,9 @@ struct _GstPixbufScale {
/* private */
gint from_buf_size;
+ gint from_stride;
gint to_buf_size;
+ gint to_stride;
};
struct _GstPixbufScaleClass {