diff options
author | Sebastian Dröge <sebastian.droege@collabora.co.uk> | 2010-10-31 23:44:20 +0100 |
---|---|---|
committer | Sebastian Dröge <sebastian.droege@collabora.co.uk> | 2010-10-31 23:44:20 +0100 |
commit | a2eb43fade4439243283dd51ae2e086bc9423f57 (patch) | |
tree | 7a285eea97445bdecb9cd4997e56343fceb07a1f | |
parent | 3c8e0286dcf240bf2f50ff67e0348794c60222a3 (diff) |
colorspace: Add support for RGB16 and BGR16
-rw-r--r-- | gst/colorspace/colorspace.c | 58 | ||||
-rw-r--r-- | gst/colorspace/gstcolorspace.c | 1 |
2 files changed, 57 insertions, 2 deletions
diff --git a/gst/colorspace/colorspace.c b/gst/colorspace/colorspace.c index 26e752414..98a8f827c 100644 --- a/gst/colorspace/colorspace.c +++ b/gst/colorspace/colorspace.c @@ -541,6 +541,60 @@ putline_Y16 (ColorspaceConvert * convert, guint8 * dest, const guint8 * src, } static void +getline_RGB16 (ColorspaceConvert * convert, guint8 * dest, const guint8 * src, + int j) +{ + int i; + const guint16 *srcline = (const guint16 *) FRAME_GET_LINE (src, 0, j); + for (i = 0; i < convert->width; i++) { + dest[i * 4 + 0] = 0xff; + dest[i * 4 + 1] = ((srcline[i] >> 11) & 0x1f) << 3; + dest[i * 4 + 2] = ((srcline[i] >> 5) & 0x3f) << 2; + dest[i * 4 + 3] = ((srcline[i]) & 0x1f) << 3; + } +} + +static void +putline_RGB16 (ColorspaceConvert * convert, guint8 * dest, const guint8 * src, + int j) +{ + int i; + guint16 *destline = (guint16 *) FRAME_GET_LINE (dest, 0, j); + for (i = 0; i < convert->width; i++) { + destline[i] = + ((src[i * 4 + 1] >> 3) << 11) | ((src[i * 4 + + 2] >> 2) << 5) | (src[i * 4 + 3] >> 3); + } +} + +static void +getline_BGR16 (ColorspaceConvert * convert, guint8 * dest, const guint8 * src, + int j) +{ + int i; + const guint16 *srcline = (const guint16 *) FRAME_GET_LINE (src, 0, j); + for (i = 0; i < convert->width; i++) { + dest[i * 4 + 0] = 0xff; + dest[i * 4 + 3] = ((srcline[i] >> 11) & 0x1f) << 3; + dest[i * 4 + 2] = ((srcline[i] >> 5) & 0x3f) << 2; + dest[i * 4 + 1] = ((srcline[i]) & 0x1f) << 3; + } +} + +static void +putline_BGR16 (ColorspaceConvert * convert, guint8 * dest, const guint8 * src, + int j) +{ + int i; + guint16 *destline = (guint16 *) FRAME_GET_LINE (dest, 0, j); + for (i = 0; i < convert->width; i++) { + destline[i] = + ((src[i * 4 + 3] >> 3) << 11) | ((src[i * 4 + + 2] >> 2) << 5) | (src[i * 4 + 1] >> 3); + } +} + +static void getline_BGRA (ColorspaceConvert * convert, guint8 * dest, const guint8 * src, int j) { @@ -780,8 +834,8 @@ static const ColorspaceLine lines[] = { {GST_VIDEO_FORMAT_v308, getline_v308, putline_v308}, {GST_VIDEO_FORMAT_Y800, getline_Y800, putline_Y800}, {GST_VIDEO_FORMAT_Y16, getline_Y16, putline_Y16}, - //{GST_VIDEO_FORMAT_RGB16, getline_RGB16, putline_RGB16}, - //{GST_VIDEO_FORMAT_BGR16, getline_BGR16, putline_BGR16}, + {GST_VIDEO_FORMAT_RGB16, getline_RGB16, putline_RGB16}, + {GST_VIDEO_FORMAT_BGR16, getline_BGR16, putline_BGR16}, //{GST_VIDEO_FORMAT_RGB15, getline_RGB15, putline_RGB15}, //{GST_VIDEO_FORMAT_BGR15, getline_BGR15, putline_BGR15}, {GST_VIDEO_FORMAT_UYVP, getline_UYVP, putline_UYVP}, diff --git a/gst/colorspace/gstcolorspace.c b/gst/colorspace/gstcolorspace.c index 690013544..a4e9493d5 100644 --- a/gst/colorspace/gstcolorspace.c +++ b/gst/colorspace/gstcolorspace.c @@ -59,6 +59,7 @@ GST_DEBUG_CATEGORY (colorspace_performance); GST_VIDEO_CAPS_BGRA";" \ GST_VIDEO_CAPS_ABGR";" \ GST_VIDEO_CAPS_RGB_16";" \ + GST_VIDEO_CAPS_BGR_16";" \ GST_VIDEO_CAPS_RGB_15";" \ "video/x-raw-rgb, bpp = (int)8, depth = (int)8, " \ "width = "GST_VIDEO_SIZE_RANGE" , " \ |