From: Rob Clark Date: Mon, 30 Aug 2010 19:59:22 +0000 (-0500) Subject: textoverlay: fix Cb/Cr inversion for colored text overlays X-Git-Tag: RELEASE-0.10.31~267 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=54f4aa28c227825e48fd7940b3566630a10cffe9;p=platform%2Fupstream%2Fgst-plugins-base.git 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. --- 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;