summaryrefslogtreecommitdiff
authorSebastian Dröge <sebastian.droege@collabora.co.uk>2009-05-30 12:17:41 (GMT)
committer Sebastian Dröge <sebastian.droege@collabora.co.uk>2009-05-30 12:18:56 (GMT)
commita9c405f5fa24075b3bddc96723f6c6279bea8a13 (patch) (side-by-side diff)
treea2b21b33bf407c24dce591eca65cd09ee46706d6
parent8900ada0eb2ba33c745984134ff119c481a9d98b (diff)
downloadgst-plugins-base-a9c405f5fa24075b3bddc96723f6c6279bea8a13.zip
gst-plugins-base-a9c405f5fa24075b3bddc96723f6c6279bea8a13.tar.gz
ffmpegcolorspace: Add a lot more conversions from/to 16 bit grayscale
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--gst/ffmpegcolorspace/imgconvert.c49
-rw-r--r--gst/ffmpegcolorspace/imgconvert_template.h104
2 files changed, 153 insertions, 0 deletions
diff --git a/gst/ffmpegcolorspace/imgconvert.c b/gst/ffmpegcolorspace/imgconvert.c
index 16740a1..2445138 100644
--- a/gst/ffmpegcolorspace/imgconvert.c
+++ b/gst/ffmpegcolorspace/imgconvert.c
@@ -2530,6 +2530,8 @@ static ConvertEntry convert_table[] = {
{PIX_FMT_RGB24, PIX_FMT_ARGB32, rgb24_to_argb32},
{PIX_FMT_RGB24, PIX_FMT_ABGR32, rgb24_to_abgr32},
{PIX_FMT_RGB24, PIX_FMT_GRAY8, rgb24_to_gray},
+ {PIX_FMT_RGB24, PIX_FMT_GRAY16_L, rgb24_to_gray16_l},
+ {PIX_FMT_RGB24, PIX_FMT_GRAY16_B, rgb24_to_gray16_b},
{PIX_FMT_RGB24, PIX_FMT_PAL8, rgb24_to_pal8},
{PIX_FMT_RGB24, PIX_FMT_YUV444P, rgb24_to_yuv444p},
{PIX_FMT_RGB24, PIX_FMT_YUVJ420P, rgb24_to_yuvj420p},
@@ -2544,6 +2546,8 @@ static ConvertEntry convert_table[] = {
{PIX_FMT_RGB32, PIX_FMT_NV12, rgb32_to_nv12},
{PIX_FMT_RGB32, PIX_FMT_NV21, rgb32_to_nv21},
{PIX_FMT_RGB32, PIX_FMT_GRAY8, rgb32_to_gray},
+ {PIX_FMT_RGB32, PIX_FMT_GRAY16_L, rgb32_to_gray16_l},
+ {PIX_FMT_RGB32, PIX_FMT_GRAY16_B, rgb32_to_gray16_b},
{PIX_FMT_xRGB32, PIX_FMT_RGB24, xrgb32_to_rgb24},
{PIX_FMT_xRGB32, PIX_FMT_PAL8, xrgb32_to_pal8},
@@ -2551,6 +2555,8 @@ static ConvertEntry convert_table[] = {
{PIX_FMT_xRGB32, PIX_FMT_NV12, xrgb32_to_nv12},
{PIX_FMT_xRGB32, PIX_FMT_NV21, xrgb32_to_nv21},
{PIX_FMT_xRGB32, PIX_FMT_GRAY8, xrgb32_to_gray},
+ {PIX_FMT_xRGB32, PIX_FMT_GRAY16_L, xrgb32_to_gray16_l},
+ {PIX_FMT_xRGB32, PIX_FMT_GRAY16_B, xrgb32_to_gray16_b},
{PIX_FMT_RGBA32, PIX_FMT_BGRA32, rgba32_to_bgra32},
{PIX_FMT_RGBA32, PIX_FMT_ABGR32, rgba32_to_abgr32},
@@ -2565,6 +2571,8 @@ static ConvertEntry convert_table[] = {
{PIX_FMT_RGBA32, PIX_FMT_NV12, rgba32_to_nv12},
{PIX_FMT_RGBA32, PIX_FMT_NV21, rgba32_to_nv21},
{PIX_FMT_RGBA32, PIX_FMT_GRAY8, rgba32_to_gray},
+ {PIX_FMT_RGBA32, PIX_FMT_GRAY16_L, rgba32_to_gray16_l},
+ {PIX_FMT_RGBA32, PIX_FMT_GRAY16_B, rgba32_to_gray16_b},
{PIX_FMT_RGBA32, PIX_FMT_AYUV4444, rgba32_to_ayuv4444},
{PIX_FMT_BGR24, PIX_FMT_RGB24, bgr24_to_rgb24},
@@ -2572,6 +2580,8 @@ static ConvertEntry convert_table[] = {
{PIX_FMT_BGR24, PIX_FMT_NV12, bgr24_to_nv12},
{PIX_FMT_BGR24, PIX_FMT_NV21, bgr24_to_nv21},
{PIX_FMT_BGR24, PIX_FMT_GRAY8, bgr24_to_gray},
+ {PIX_FMT_BGR24, PIX_FMT_GRAY16_L, bgr24_to_gray16_l},
+ {PIX_FMT_BGR24, PIX_FMT_GRAY16_B, bgr24_to_gray16_b},
{PIX_FMT_BGR32, PIX_FMT_RGB24, bgr32_to_rgb24},
{PIX_FMT_BGR32, PIX_FMT_RGBA32, bgr32_to_rgba32},
@@ -2579,6 +2589,8 @@ static ConvertEntry convert_table[] = {
{PIX_FMT_BGR32, PIX_FMT_NV12, bgr32_to_nv12},
{PIX_FMT_BGR32, PIX_FMT_NV21, bgr32_to_nv21},
{PIX_FMT_BGR32, PIX_FMT_GRAY8, bgr32_to_gray},
+ {PIX_FMT_BGR32, PIX_FMT_GRAY16_L, bgr32_to_gray16_l},
+ {PIX_FMT_BGR32, PIX_FMT_GRAY16_B, bgr32_to_gray16_b},
{PIX_FMT_BGRx32, PIX_FMT_RGB24, bgrx32_to_rgb24},
{PIX_FMT_BGRx32, PIX_FMT_RGBA32, bgrx32_to_rgba32},
@@ -2586,6 +2598,8 @@ static ConvertEntry convert_table[] = {
{PIX_FMT_BGRx32, PIX_FMT_NV12, bgrx32_to_nv12},
{PIX_FMT_BGRx32, PIX_FMT_NV21, bgrx32_to_nv21},
{PIX_FMT_BGRx32, PIX_FMT_GRAY8, bgrx32_to_gray},
+ {PIX_FMT_BGRx32, PIX_FMT_GRAY16_L, bgrx32_to_gray16_l},
+ {PIX_FMT_BGRx32, PIX_FMT_GRAY16_B, bgrx32_to_gray16_b},
{PIX_FMT_BGRA32, PIX_FMT_RGB24, bgra32_to_rgb24},
{PIX_FMT_BGRA32, PIX_FMT_RGBA32, bgra32_to_rgba32},
@@ -2593,6 +2607,8 @@ static ConvertEntry convert_table[] = {
{PIX_FMT_BGRA32, PIX_FMT_NV12, bgra32_to_nv12},
{PIX_FMT_BGRA32, PIX_FMT_NV21, bgra32_to_nv21},
{PIX_FMT_BGRA32, PIX_FMT_GRAY8, bgra32_to_gray},
+ {PIX_FMT_BGRA32, PIX_FMT_GRAY16_L, bgra32_to_gray16_l},
+ {PIX_FMT_BGRA32, PIX_FMT_GRAY16_B, bgra32_to_gray16_b},
{PIX_FMT_BGRA32, PIX_FMT_AYUV4444, bgra32_to_ayuv4444},
{PIX_FMT_ABGR32, PIX_FMT_RGB24, abgr32_to_rgb24},
@@ -2601,6 +2617,8 @@ static ConvertEntry convert_table[] = {
{PIX_FMT_ABGR32, PIX_FMT_NV12, abgr32_to_nv12},
{PIX_FMT_ABGR32, PIX_FMT_NV21, abgr32_to_nv21},
{PIX_FMT_ABGR32, PIX_FMT_GRAY8, abgr32_to_gray},
+ {PIX_FMT_ABGR32, PIX_FMT_GRAY16_L, abgr32_to_gray16_l},
+ {PIX_FMT_ABGR32, PIX_FMT_GRAY16_B, abgr32_to_gray16_b},
{PIX_FMT_ARGB32, PIX_FMT_RGB24, argb32_to_rgb24},
{PIX_FMT_ARGB32, PIX_FMT_RGBA32, argb32_to_rgba32},
@@ -2608,6 +2626,8 @@ static ConvertEntry convert_table[] = {
{PIX_FMT_ARGB32, PIX_FMT_NV12, argb32_to_nv12},
{PIX_FMT_ARGB32, PIX_FMT_NV21, argb32_to_nv21},
{PIX_FMT_ARGB32, PIX_FMT_GRAY8, argb32_to_gray},
+ {PIX_FMT_ARGB32, PIX_FMT_GRAY16_L, argb32_to_gray16_l},
+ {PIX_FMT_ARGB32, PIX_FMT_GRAY16_B, argb32_to_gray16_b},
{PIX_FMT_RGB555, PIX_FMT_RGB24, rgb555_to_rgb24},
{PIX_FMT_RGB555, PIX_FMT_RGB32, rgb555_to_rgba32},
@@ -2616,12 +2636,16 @@ static ConvertEntry convert_table[] = {
{PIX_FMT_RGB555, PIX_FMT_NV12, rgb555_to_nv12},
{PIX_FMT_RGB555, PIX_FMT_NV21, rgb555_to_nv21},
{PIX_FMT_RGB555, PIX_FMT_GRAY8, rgb555_to_gray},
+ {PIX_FMT_RGB555, PIX_FMT_GRAY16_L, rgb555_to_gray16_l},
+ {PIX_FMT_RGB555, PIX_FMT_GRAY16_B, rgb555_to_gray16_b},
{PIX_FMT_RGB565, PIX_FMT_RGB24, rgb565_to_rgb24},
{PIX_FMT_RGB565, PIX_FMT_YUV420P, rgb565_to_yuv420p},
{PIX_FMT_RGB565, PIX_FMT_NV12, rgb565_to_nv12},
{PIX_FMT_RGB565, PIX_FMT_NV21, rgb565_to_nv21},
{PIX_FMT_RGB565, PIX_FMT_GRAY8, rgb565_to_gray},
+ {PIX_FMT_RGB565, PIX_FMT_GRAY16_L, rgb565_to_gray16_l},
+ {PIX_FMT_RGB565, PIX_FMT_GRAY16_B, rgb565_to_gray16_b},
{PIX_FMT_GRAY8, PIX_FMT_RGB555, gray_to_rgb555},
{PIX_FMT_GRAY8, PIX_FMT_RGB565, gray_to_rgb565},
@@ -2645,8 +2669,33 @@ static ConvertEntry convert_table[] = {
{PIX_FMT_MONOBLACK, PIX_FMT_GRAY8, monoblack_to_gray},
{PIX_FMT_GRAY16_L, PIX_FMT_GRAY8, gray16_l_to_gray},
+ {PIX_FMT_GRAY16_L, PIX_FMT_RGB555, gray16_l_to_rgb555},
+ {PIX_FMT_GRAY16_L, PIX_FMT_RGB565, gray16_l_to_rgb565},
+ {PIX_FMT_GRAY16_L, PIX_FMT_BGR24, gray16_l_to_bgr24},
+ {PIX_FMT_GRAY16_L, PIX_FMT_RGB24, gray16_l_to_rgb24},
+ {PIX_FMT_GRAY16_L, PIX_FMT_BGR32, gray16_l_to_bgr32},
+ {PIX_FMT_GRAY16_L, PIX_FMT_RGB32, gray16_l_to_rgb32},
+ {PIX_FMT_GRAY16_L, PIX_FMT_xRGB32, gray16_l_to_xrgb32},
+ {PIX_FMT_GRAY16_L, PIX_FMT_BGRx32, gray16_l_to_bgrx32},
+ {PIX_FMT_GRAY16_L, PIX_FMT_ABGR32, gray16_l_to_abgr32},
+ {PIX_FMT_GRAY16_L, PIX_FMT_ARGB32, gray16_l_to_argb32},
+ {PIX_FMT_GRAY16_L, PIX_FMT_BGRA32, gray16_l_to_bgra32},
+ {PIX_FMT_GRAY16_L, PIX_FMT_RGBA32, gray16_l_to_rgba32},
{PIX_FMT_GRAY16_L, PIX_FMT_GRAY16_B, gray16_b_to_gray16_l},
+
{PIX_FMT_GRAY16_B, PIX_FMT_GRAY8, gray16_b_to_gray},
+ {PIX_FMT_GRAY16_B, PIX_FMT_RGB555, gray16_b_to_rgb555},
+ {PIX_FMT_GRAY16_B, PIX_FMT_RGB565, gray16_b_to_rgb565},
+ {PIX_FMT_GRAY16_B, PIX_FMT_BGR24, gray16_b_to_bgr24},
+ {PIX_FMT_GRAY16_B, PIX_FMT_RGB24, gray16_b_to_rgb24},
+ {PIX_FMT_GRAY16_B, PIX_FMT_BGR32, gray16_b_to_bgr32},
+ {PIX_FMT_GRAY16_B, PIX_FMT_RGB32, gray16_b_to_rgb32},
+ {PIX_FMT_GRAY16_B, PIX_FMT_xRGB32, gray16_b_to_xrgb32},
+ {PIX_FMT_GRAY16_B, PIX_FMT_BGRx32, gray16_b_to_bgrx32},
+ {PIX_FMT_GRAY16_B, PIX_FMT_ABGR32, gray16_b_to_abgr32},
+ {PIX_FMT_GRAY16_B, PIX_FMT_ARGB32, gray16_b_to_argb32},
+ {PIX_FMT_GRAY16_B, PIX_FMT_BGRA32, gray16_b_to_bgra32},
+ {PIX_FMT_GRAY16_B, PIX_FMT_RGBA32, gray16_b_to_rgba32},
{PIX_FMT_GRAY16_B, PIX_FMT_GRAY16_L, gray16_b_to_gray16_l},
{PIX_FMT_PAL8, PIX_FMT_RGB555, pal8_to_rgb555},
diff --git a/gst/ffmpegcolorspace/imgconvert_template.h b/gst/ffmpegcolorspace/imgconvert_template.h
index b495e60..0ade4fa 100644
--- a/gst/ffmpegcolorspace/imgconvert_template.h
+++ b/gst/ffmpegcolorspace/imgconvert_template.h
@@ -751,6 +751,110 @@ static void glue(gray_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
}
}
+static void glue(RGB_NAME, _to_gray16_l)(AVPicture *dst, const AVPicture *src,
+ int width, int height)
+{
+ const unsigned char *p;
+ unsigned char *q;
+ int r, g, b, dst_wrap, src_wrap;
+ int x, y;
+
+ p = src->data[0];
+ src_wrap = src->linesize[0] - BPP * width;
+
+ q = dst->data[0];
+ dst_wrap = dst->linesize[0] - 2 * width;
+
+ for(y=0;y<height;y++) {
+ for(x=0;x<width;x++) {
+ RGB_IN(r, g, b, p);
+ GST_WRITE_UINT16_LE (q, RGB_TO_Y(r, g, b) << 8);
+ q += 2;
+ p += BPP;
+ }
+ p += src_wrap;
+ q += dst_wrap;
+ }
+}
+
+static void glue(gray16_l_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
+ int width, int height)
+{
+ const unsigned char *p;
+ unsigned char *q;
+ int r, dst_wrap, src_wrap;
+ int x, y;
+
+ p = src->data[0];
+ src_wrap = src->linesize[0] - 2 * width;
+
+ q = dst->data[0];
+ dst_wrap = dst->linesize[0] - BPP * width;
+
+ for(y=0;y<height;y++) {
+ for(x=0;x<width;x++) {
+ r = GST_READ_UINT16_LE (p) >> 8;
+ RGB_OUT(q, r, r, r);
+ q += BPP;
+ p += 2;
+ }
+ p += src_wrap;
+ q += dst_wrap;
+ }
+}
+
+static void glue(RGB_NAME, _to_gray16_b)(AVPicture *dst, const AVPicture *src,
+ int width, int height)
+{
+ const unsigned char *p;
+ unsigned char *q;
+ int r, g, b, dst_wrap, src_wrap;
+ int x, y;
+
+ p = src->data[0];
+ src_wrap = src->linesize[0] - BPP * width;
+
+ q = dst->data[0];
+ dst_wrap = dst->linesize[0] - 2 * width;
+
+ for(y=0;y<height;y++) {
+ for(x=0;x<width;x++) {
+ RGB_IN(r, g, b, p);
+ GST_WRITE_UINT16_BE (q, RGB_TO_Y(r, g, b) << 8);
+ q += 2;
+ p += BPP;
+ }
+ p += src_wrap;
+ q += dst_wrap;
+ }
+}
+
+static void glue(gray16_b_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
+ int width, int height)
+{
+ const unsigned char *p;
+ unsigned char *q;
+ int r, dst_wrap, src_wrap;
+ int x, y;
+
+ p = src->data[0];
+ src_wrap = src->linesize[0] - 2 * width;
+
+ q = dst->data[0];
+ dst_wrap = dst->linesize[0] - BPP * width;
+
+ for(y=0;y<height;y++) {
+ for(x=0;x<width;x++) {
+ r = GST_READ_UINT16_BE (p) >> 8;
+ RGB_OUT(q, r, r, r);
+ q += BPP;
+ p += 2;
+ }
+ p += src_wrap;
+ q += dst_wrap;
+ }
+}
+
static void glue(pal8_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
int width, int height)
{