mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
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.
This commit is contained in:
parent
6357bdef63
commit
54f4aa28c2
1 changed files with 19 additions and 2 deletions
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue