From ae2231624c92953ea3dfb32a36a8ff2fb927da20 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Thu, 17 Oct 2013 12:53:31 +0200 Subject: [PATCH] geometrictransform: Fix setting black background for AYUV buffers When the frame buffer is AYUV writing all zeros does not set it to black, in YUV colorspace 0x10 is the black level for luminance and 0x80 is the black level for chrominance. Fix setting the background to black when the out_frame format is AYUV; in all the other supported formats zeroing the data with memset is still the right thing to do. https://bugzilla.gnome.org/show_bug.cgi?id=710392 --- gst/geometrictransform/gstgeometrictransform.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/gst/geometrictransform/gstgeometrictransform.c b/gst/geometrictransform/gstgeometrictransform.c index 34ce494810..4c08b20ea0 100644 --- a/gst/geometrictransform/gstgeometrictransform.c +++ b/gst/geometrictransform/gstgeometrictransform.c @@ -240,7 +240,16 @@ gst_geometric_transform_transform_frame (GstVideoFilter * vfilter, in_data = GST_VIDEO_FRAME_PLANE_DATA (in_frame, 0); out_data = GST_VIDEO_FRAME_PLANE_DATA (out_frame, 0); - memset (out_data, 0, out_frame->map[0].size); + + if (GST_VIDEO_FRAME_FORMAT (out_frame) == GST_VIDEO_FORMAT_AYUV) { + /* in AYUV black is not just all zeros: + * 0x10 is black for Y, + * 0x80 is black for Cr and Cb */ + for (int i = 0; i < out_frame->map[0].size; i += 4) + GST_WRITE_UINT32_BE (out_data + i, 0xff108080); + } else { + memset (out_data, 0, out_frame->map[0].size); + } GST_OBJECT_LOCK (gt); if (gt->precalc_map) {