summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRavi Kiran K N <ravi.kiran@samsung.com>2015-02-06 15:39:14 +0530
committerWim Taymans <wtaymans@redhat.com>2015-02-06 11:43:49 +0100
commitbd836e12a1ed4d2227903cce44617303caa159d0 (patch)
treeb7988400fec536a735c48dbbb7dd8622cc23435b
parentc78bdbfecb66281a37ff5728ed32ad5ceb98889d (diff)
video-converter: support AYUV border
Convert the border color from ARGB to AYUV, using colorimetry matrix when output format is YUV. https://bugzilla.gnome.org/show_bug.cgi?id=741640
-rw-r--r--gst-libs/gst/video/video-converter.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/gst-libs/gst/video/video-converter.c b/gst-libs/gst/video/video-converter.c
index 29832172c..e5313cc6a 100644
--- a/gst-libs/gst/video/video-converter.c
+++ b/gst-libs/gst/video/video-converter.c
@@ -1654,8 +1654,33 @@ setup_borderline (GstVideoConverter * convert)
out_finfo = convert->out_info.finfo;
if (GST_VIDEO_INFO_IS_YUV (&convert->out_info)) {
- /* FIXME, convert to AYUV, just black for now */
- border_val = GINT32_FROM_BE (0x00007f7f);
+
+ MatrixData cm;
+ gint a, r, g, b;
+ gint y, u, v;
+
+ /* Get Color matrix. */
+ color_matrix_set_identity (&cm);
+ compute_matrix_to_YUV (convert, &cm);
+ color_matrix_convert (&cm);
+
+ border_val = GINT32_FROM_BE (convert->border_argb);
+
+ b = (0xFF000000 & border_val) >> 24;
+ g = (0x00FF0000 & border_val) >> 16;
+ r = (0x0000FF00 & border_val) >> 8;
+ a = (0x000000FF & border_val);
+
+ y = 16 + ((r * cm.im[0][0] + g * cm.im[0][1] + b * cm.im[0][2]) >> 8);
+ u = 128 + ((r * cm.im[1][0] + g * cm.im[1][1] + b * cm.im[1][2]) >> 8);
+ v = 128 + ((r * cm.im[2][0] + g * cm.im[2][1] + b * cm.im[2][2]) >> 8);
+
+ a = CLAMP (a, 0, 255);
+ y = CLAMP (y, 0, 255);
+ u = CLAMP (u, 0, 255);
+ v = CLAMP (v, 0, 255);
+
+ border_val = a | (y << 8) | (u << 16) | (v << 24);
} else {
border_val = GINT32_FROM_BE (convert->border_argb);
}