summaryrefslogtreecommitdiffstats
path: root/ext/cairo/gsttimeoverlay.c
diff options
context:
space:
mode:
authorMichael Smith <msmith@xiph.org>2006-05-02 22:34:52 +0000
committerMichael Smith <msmith@xiph.org>2006-05-02 22:34:52 +0000
commit757797ef3ae02660ec29f38bad91761f414ddbf6 (patch)
treee08e78fc4a0b5b25f8af93caa324da9debf667fd /ext/cairo/gsttimeoverlay.c
parent7ce14b6bd89169cdeaadf65f0da74c90d3d67d92 (diff)
ext/cairo/gsttimeoverlay.c: Fix timeoverlay for non-multiple-of-4 widths. This fourcc crap
Original commit message from CVS: * ext/cairo/gsttimeoverlay.c: (gst_cairo_time_overlay_transform): Fix timeoverlay for non-multiple-of-4 widths. This fourcc crap SUCKS.
Diffstat (limited to 'ext/cairo/gsttimeoverlay.c')
-rw-r--r--ext/cairo/gsttimeoverlay.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/ext/cairo/gsttimeoverlay.c b/ext/cairo/gsttimeoverlay.c
index d501a543..d48242d9 100644
--- a/ext/cairo/gsttimeoverlay.c
+++ b/ext/cairo/gsttimeoverlay.c
@@ -181,6 +181,7 @@ gst_cairo_time_overlay_transform (GstBaseTransform * trans, GstBuffer * in,
int width;
int height;
int b_width;
+ int stride_y, stride_u, stride_v;
char *string;
int i, j;
unsigned char *image;
@@ -238,16 +239,22 @@ gst_cairo_time_overlay_transform (GstBaseTransform * trans, GstBuffer * in,
if (b_width > width)
b_width = width;
+ stride_y = GST_VIDEO_I420_Y_ROWSTRIDE (width);
+ stride_u = GST_VIDEO_I420_U_ROWSTRIDE (width);
+ stride_v = GST_VIDEO_I420_V_ROWSTRIDE (width);
+
memcpy (dest, src, GST_BUFFER_SIZE (in));
for (i = 0; i < timeoverlay->text_height; i++) {
for (j = 0; j < b_width; j++) {
- ((unsigned char *) dest)[i * width + j] = image[(i * width + j) * 4 + 0];
+ ((unsigned char *) dest)[i * stride_y + j] =
+ image[(i * width + j) * 4 + 0];
}
}
for (i = 0; i < timeoverlay->text_height / 2; i++) {
- memset (dest + width * height + i * (width / 2), 128, b_width / 2);
- memset (dest + width * height + (width / 2) * (height / 2) +
- i * (width / 2), 128, b_width / 2);
+ memset (dest + GST_VIDEO_I420_U_OFFSET (width, height) + i * stride_u, 128,
+ b_width / 2);
+ memset (dest + GST_VIDEO_I420_V_OFFSET (width, height) + i * stride_v, 128,
+ b_width / 2);
}
cairo_destroy (text_cairo);