summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Clark <rob@ti.com>2010-08-30 19:59:22 (GMT)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>2010-08-30 20:53:26 (GMT)
commit54f4aa28c227825e48fd7940b3566630a10cffe9 (patch)
tree82943b43a1e9129730791920d60afdbe84a4a418
parent6357bdef63b1f6fca0890c1b98132e5ba54f71df (diff)
textoverlay: fix Cb/Cr inversion for colored text overlays
In case of odd values for xpos or ypos, the division by two in CbCr plane would result in an off-by-one error, which in the case of NV12, NV21, or UYVY would cause inversion of blue and red colors. (And would be not so easily noticed for I420 as it would just cause the chroma to be offset slightly from the luma.) This patch also fixes a silly typo from the earlier patch which added NV12 support that broke UYVY support.
-rw-r--r--ext/pango/gsttextoverlay.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/ext/pango/gsttextoverlay.c b/ext/pango/gsttextoverlay.c
index df5701f..aa492e9 100644
--- a/ext/pango/gsttextoverlay.c
+++ b/ext/pango/gsttextoverlay.c
@@ -186,7 +186,7 @@ static GstStaticPadTemplate src_template_factory =
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_VIDEO_CAPS_BGRx ";"
- GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_YUV ("{I420, UYUV, NV12, NV21}"))
+ GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_YUV ("{I420, UYVY, NV12, NV21}"))
);
static GstStaticPadTemplate video_sink_template_factory =
@@ -194,7 +194,7 @@ static GstStaticPadTemplate video_sink_template_factory =
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_VIDEO_CAPS_BGRx ";"
- GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_YUV ("{I420, UYUV, NV12, NV21}"))
+ GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_YUV ("{I420, UYVY, NV12, NV21}"))
);
static GstStaticPadTemplate text_sink_template_factory =
@@ -1450,6 +1450,12 @@ gst_text_overlay_blit_NV12_NV21 (GstTextOverlay * overlay,
int u_offset, v_offset;
int h, w;
+ /* because U/V is 2x2 subsampled, we need to round, either up or down,
+ * to a boundary of integer number of U/V pixels:
+ */
+ xpos = GST_ROUND_UP_2 (xpos);
+ ypos = GST_ROUND_UP_2 (ypos);
+
w = overlay->width;
h = overlay->height;
@@ -1473,6 +1479,12 @@ gst_text_overlay_blit_I420 (GstTextOverlay * overlay,
int u_offset, v_offset;
int h, w;
+ /* because U/V is 2x2 subsampled, we need to round, either up or down,
+ * to a boundary of integer number of U/V pixels:
+ */
+ xpos = GST_ROUND_UP_2 (xpos);
+ ypos = GST_ROUND_UP_2 (ypos);
+
w = overlay->width;
h = overlay->height;
@@ -1502,6 +1514,11 @@ gst_text_overlay_blit_UYVY (GstTextOverlay * overlay,
int h, w;
guchar *pimage, *dest;
+ /* because U/V is 2x horizontally subsampled, we need to round to a
+ * boundary of integer number of U/V pixels in x dimension:
+ */
+ xpos = GST_ROUND_UP_2 (xpos);
+
w = overlay->image_width - 2;
h = overlay->image_height - 2;