summaryrefslogtreecommitdiff
path: root/gst
diff options
context:
space:
mode:
authorJan Schmidt <thaytan@mad.scientist.com>2007-07-06 11:40:45 +0000
committerJan Schmidt <thaytan@mad.scientist.com>2007-07-06 11:40:45 +0000
commit6fa26a44e35df4395980395227205e0e714f3e00 (patch)
tree4826e08b33385fb3fcb444e8d0b951776bf90caf /gst
parentd03f78d47f23f9e376667ede12b1db0756697b57 (diff)
downloadgstreamer-plugins-base-6fa26a44e35df4395980395227205e0e714f3e00.tar.gz
gst/ffmpegcolorspace/: Add 2 new pixel formats - ABGR32 and ARGB32, which are reflections of the existing BGRA32 and ...
Original commit message from CVS: * gst/ffmpegcolorspace/avcodec.h: * gst/ffmpegcolorspace/gstffmpegcodecmap.c: (gst_ffmpeg_pixfmt_to_caps), (gst_ffmpeg_caps_to_pixfmt), (gst_ffmpegcsp_avpicture_fill): * gst/ffmpegcolorspace/imgconvert.c: (img_convert), (img_get_alpha_info): Add 2 new pixel formats - ABGR32 and ARGB32, which are reflections of the existing BGRA32 and RGBA32 formats with the alpha at the other end of the word. Partially fixes #451908
Diffstat (limited to 'gst')
-rw-r--r--gst/ffmpegcolorspace/avcodec.h10
-rw-r--r--gst/ffmpegcolorspace/gstffmpegcodecmap.c79
-rw-r--r--gst/ffmpegcolorspace/imgconvert.c115
3 files changed, 178 insertions, 26 deletions
diff --git a/gst/ffmpegcolorspace/avcodec.h b/gst/ffmpegcolorspace/avcodec.h
index 1dc58f557..58eb9770b 100644
--- a/gst/ffmpegcolorspace/avcodec.h
+++ b/gst/ffmpegcolorspace/avcodec.h
@@ -61,10 +61,12 @@ enum PixelFormat {
PIX_FMT_YUV444P, ///< Planar YUV 4:4:4 (1 Cr & Cb sample per 1x1 Y samples)
PIX_FMT_RGBA32, ///< Packed pixel, 4 bytes per pixel, BGRABGRA..., stored in cpu endianness
PIX_FMT_BGRA32, ///< Packed pixel, 4 bytes per pixel, ARGBARGB...
- PIX_FMT_RGB32, ///< Packed pixel, 4 bytes per pixel, BGRXBGRX..., stored in cpu endianness
- PIX_FMT_xRGB32, ///< Packed pixel, 4 bytes per pixel, XBGRXBGR..., stored in cpu endianness
- PIX_FMT_BGR32, ///< Packed pixel, 4 bytes per pixel, XRGBXRGB...
- PIX_FMT_BGRx32, ///< Packed pixel, 4 bytes per pixel, RGBXRGBX...
+ PIX_FMT_ARGB32, ///< Packed pixel, 4 bytes per pixel, ABGRABGR..., stored in cpu endianness
+ PIX_FMT_ABGR32, ///< Packed pixel, 4 bytes per pixel, RGBARGBA...
+ PIX_FMT_RGB32, ///< Packed pixel, 4 bytes per pixel, BGRxBGRx..., stored in cpu endianness
+ PIX_FMT_xRGB32, ///< Packed pixel, 4 bytes per pixel, xBGRxBGR..., stored in cpu endianness
+ PIX_FMT_BGR32, ///< Packed pixel, 4 bytes per pixel, xRGBxRGB...
+ PIX_FMT_BGRx32, ///< Packed pixel, 4 bytes per pixel, RGBxRGBx...
PIX_FMT_YUV410P, ///< Planar YUV 4:1:0 (1 Cr & Cb sample per 4x4 Y samples)
PIX_FMT_YVU410P, ///< Planar YVU 4:1:0 (1 Cr & Cb sample per 4x4 Y samples)
PIX_FMT_YUV411P, ///< Planar YUV 4:1:1 (1 Cr & Cb sample per 4x1 Y samples)
diff --git a/gst/ffmpegcolorspace/gstffmpegcodecmap.c b/gst/ffmpegcolorspace/gstffmpegcodecmap.c
index cd7de3788..bb46375c7 100644
--- a/gst/ffmpegcolorspace/gstffmpegcodecmap.c
+++ b/gst/ffmpegcolorspace/gstffmpegcodecmap.c
@@ -287,6 +287,38 @@ gst_ffmpeg_pixfmt_to_caps (enum PixelFormat pix_fmt, AVCodecContext * context)
a_mask = 0xff000000;
#endif
break;
+ case PIX_FMT_ARGB32:
+ bpp = 32;
+ depth = 32;
+ endianness = G_BIG_ENDIAN;
+#if (G_BYTE_ORDER == G_BIG_ENDIAN)
+ r_mask = 0xff000000;
+ g_mask = 0x00ff0000;
+ b_mask = 0x0000ff00;
+ a_mask = 0x000000ff;
+#else
+ r_mask = 0x000000ff;
+ g_mask = 0x0000ff00;
+ b_mask = 0x00ff0000;
+ a_mask = 0xff000000;
+#endif
+ break;
+ case PIX_FMT_ABGR32:
+ bpp = 32;
+ depth = 32;
+ endianness = G_BIG_ENDIAN;
+#if (G_BYTE_ORDER == G_BIG_ENDIAN)
+ r_mask = 0x000000ff;
+ g_mask = 0x0000ff00;
+ b_mask = 0x00ff0000;
+ a_mask = 0xff000000;
+#else
+ r_mask = 0xff000000;
+ g_mask = 0x00ff0000;
+ b_mask = 0x0000ff00;
+ a_mask = 0x000000ff;
+#endif
+ break;
case PIX_FMT_YUV410P:
fmt = GST_MAKE_FOURCC ('Y', 'U', 'V', '9');
break;
@@ -595,40 +627,43 @@ gst_ffmpeg_caps_to_pixfmt (const GstCaps * caps,
if (gst_structure_get_int (structure, "alpha_mask", &amask)) {
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
if (rmask == 0x0000ff00)
+ context->pix_fmt = PIX_FMT_BGRA32;
+ else if (rmask == 0x00ff0000)
+ context->pix_fmt = PIX_FMT_RGBA32;
+ else if (rmask == 0xff000000)
+ context->pix_fmt = PIX_FMT_ARGB32;
+ else // if (r_mask = 0x000000ff)
+ context->pix_fmt = PIX_FMT_ABGR32;
#else
if (rmask == 0x00ff0000)
-#endif
context->pix_fmt = PIX_FMT_BGRA32;
- else
+ else if (rmask == 0x00ff0000)
context->pix_fmt = PIX_FMT_RGBA32;
+ else if (rmask == 0x000000ff)
+ context->pix_fmt = PIX_FMT_ARGB32;
+ else // if (rmask == 0xff000000)
+ context->pix_fmt = PIX_FMT_ABGR32;
+#endif
} else {
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
if (rmask == 0x00ff0000)
+ context->pix_fmt = PIX_FMT_RGB32;
+ elseif (rmask == 0x0000ff00)
+ context->pix_fmt = PIX_FMT_BGR32;
+ elseif (rmask == 0xff000000)
+ context->pix_fmt = PIX_FMT_xRGB32;
+ else // if (rmask == 0x000000ff)
+ context->pix_fmt = PIX_FMT_BGRx32;
#else
if (rmask == 0x0000ff00)
-#endif
context->pix_fmt = PIX_FMT_RGB32;
-
-#if (G_BYTE_ORDER == G_BIG_ENDIAN)
- if (rmask == 0x0000ff00)
-#else
- if (rmask == 0x00ff0000)
-#endif
+ else if (rmask == 0x00ff0000)
context->pix_fmt = PIX_FMT_BGR32;
-
-#if (G_BYTE_ORDER == G_BIG_ENDIAN)
- if (rmask == 0xff000000)
-#else
- if (rmask == 0x000000ff)
-#endif
+ else if (rmask == 0x000000ff)
context->pix_fmt = PIX_FMT_xRGB32;
-
-#if (G_BYTE_ORDER == G_BIG_ENDIAN)
- if (rmask == 0x000000ff)
-#else
- if (rmask == 0xff000000)
-#endif
+ else // if (rmask == 0xff000000)
context->pix_fmt = PIX_FMT_BGRx32;
+#endif
}
break;
case 24:
@@ -776,8 +811,10 @@ gst_ffmpegcsp_avpicture_fill (AVPicture * picture,
case PIX_FMT_AYUV4444:
case PIX_FMT_RGB32:
case PIX_FMT_RGBA32:
+ case PIX_FMT_ARGB32:
case PIX_FMT_BGR32:
case PIX_FMT_BGRA32:
+ case PIX_FMT_ABGR32:
case PIX_FMT_xRGB32:
case PIX_FMT_BGRx32:
stride = width * 4;
diff --git a/gst/ffmpegcolorspace/imgconvert.c b/gst/ffmpegcolorspace/imgconvert.c
index c694bc3e5..c73e16b4c 100644
--- a/gst/ffmpegcolorspace/imgconvert.c
+++ b/gst/ffmpegcolorspace/imgconvert.c
@@ -266,6 +266,28 @@ static PixFmtInfo pix_fmt_info[PIX_FMT_NB] = {
/* .y_chroma_shift = */ 0,
/* .depth = */ 8,
},
+ /* [PIX_FMT_ARGB32] = */ {
+ /* .format = */ PIX_FMT_ARGB32,
+ /* .name = */ "argb32",
+ /* .nb_channels = */ 4,
+ /* .color_type = */ FF_COLOR_RGB,
+ /* .pixel_type = */ FF_PIXEL_PACKED,
+ /* .is_alpha = */ 1,
+ /* .x_chroma_shift = */ 0,
+ /* .y_chroma_shift = */ 0,
+ /* .depth = */ 8,
+ },
+ /* [PIX_FMT_ABGR32] = */ {
+ /* .format = */ PIX_FMT_ABGR32,
+ /* .name = */ "abgr32",
+ /* .nb_channels = */ 4,
+ /* .color_type = */ FF_COLOR_RGB,
+ /* .pixel_type = */ FF_PIXEL_PACKED,
+ /* .is_alpha = */ 1,
+ /* .x_chroma_shift = */ 0,
+ /* .y_chroma_shift = */ 0,
+ /* .depth = */ 8,
+ },
/* [PIX_FMT_RGB565] = */ {
/* .format = */ PIX_FMT_RGB565,
/* .name = */ "rgb565",
@@ -1796,6 +1818,68 @@ bitcopy_n (unsigned int a, int n)
#include "imgconvert_template.h"
+/* argb32 handling */
+
+#define RGB_NAME argb32
+#define FMT_ARGB32
+
+#define RGB_IN(r, g, b, s)\
+{\
+ unsigned int v = ((const uint32_t *)(s))[0];\
+ r = (v >> 24) & 0xff;\
+ g = (v >> 16) & 0xff;\
+ b = (v >> 8) & 0xff;\
+}
+
+#define RGBA_IN(r, g, b, a, s)\
+{\
+ unsigned int v = ((const uint32_t *)(s))[0];\
+ r = (v >> 24) & 0xff;\
+ g = (v >> 16) & 0xff;\
+ b = (v >> 8) & 0xff;\
+ a = v & 0xff;\
+}
+
+#define RGBA_OUT(d, r, g, b, a)\
+{\
+ ((uint32_t *)(d))[0] = (r << 24) | (g << 16) | (b << 8) | a;\
+}
+
+#define BPP 4
+
+#include "imgconvert_template.h"
+
+/* abgr32 handling */
+
+#define RGB_NAME abgr32
+#define FMT_ABGR32
+
+#define RGB_IN(r, g, b, s)\
+{\
+ unsigned int v = ((const uint32_t *)(s))[0];\
+ r = v & 0xff;\
+ g = (v >> 8) & 0xff;\
+ b = (v >> 16) & 0xff;\
+}
+
+#define RGBA_IN(r, g, b, a, s)\
+{\
+ unsigned int v = ((const uint32_t *)(s))[0];\
+ r = v & 0xff;\
+ g = (v >> 8) & 0xff;\
+ b = (v >> 16) & 0xff;\
+ a = (v >> 24) & 0xff;\
+}
+
+#define RGBA_OUT(d, r, g, b, a)\
+{\
+ ((uint32_t *)(d))[0] = r | (g << 8) | (b << 16) | (a << 24 );\
+}
+
+#define BPP 4
+
+#include "imgconvert_template.h"
+
static void
mono_to_gray (AVPicture * dst, const AVPicture * src,
int width, int height, int xor_mask)
@@ -1948,6 +2032,8 @@ static ConvertEntry convert_table[] = {
{PIX_FMT_YUV420P, PIX_FMT_BGRx32, yuv420p_to_bgrx32},
{PIX_FMT_YUV420P, PIX_FMT_RGBA32, yuv420p_to_rgba32},
{PIX_FMT_YUV420P, PIX_FMT_BGRA32, yuv420p_to_bgra32},
+ {PIX_FMT_YUV420P, PIX_FMT_ARGB32, yuv420p_to_argb32},
+ {PIX_FMT_YUV420P, PIX_FMT_ABGR32, yuv420p_to_abgr32},
{PIX_FMT_YUV422P, PIX_FMT_YUV422, yuv422p_to_yuv422},
{PIX_FMT_YUV422P, PIX_FMT_UYVY422, yuv422p_to_uyvy422},
@@ -1964,6 +2050,8 @@ static ConvertEntry convert_table[] = {
{PIX_FMT_YUVJ420P, PIX_FMT_BGR32, yuvj420p_to_bgrx32},
{PIX_FMT_YUVJ420P, PIX_FMT_RGBA32, yuvj420p_to_rgba32},
{PIX_FMT_YUVJ420P, PIX_FMT_BGRA32, yuvj420p_to_bgra32},
+ {PIX_FMT_YUVJ420P, PIX_FMT_ARGB32, yuvj420p_to_argb32},
+ {PIX_FMT_YUVJ420P, PIX_FMT_ABGR32, yuvj420p_to_abgr32},
{PIX_FMT_YUVJ444P, PIX_FMT_RGB24, yuvj444p_to_rgb24},
@@ -1983,6 +2071,8 @@ static ConvertEntry convert_table[] = {
{PIX_FMT_RGB24, PIX_FMT_RGBA32, rgb24_to_rgba32},
{PIX_FMT_RGB24, PIX_FMT_BGR24, rgb24_to_bgr24},
{PIX_FMT_RGB24, PIX_FMT_BGRA32, rgb24_to_bgra32},
+ {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_PAL8, rgb24_to_pal8},
{PIX_FMT_RGB24, PIX_FMT_YUV444P, rgb24_to_yuv444p},
@@ -2002,15 +2092,17 @@ static ConvertEntry convert_table[] = {
{PIX_FMT_xRGB32, PIX_FMT_GRAY8, xrgb32_to_gray},
{PIX_FMT_RGBA32, PIX_FMT_BGRA32, rgba32_to_bgra32},
+ {PIX_FMT_RGBA32, PIX_FMT_ABGR32, rgba32_to_abgr32},
+ {PIX_FMT_RGBA32, PIX_FMT_ARGB32, rgba32_to_argb32},
{PIX_FMT_RGBA32, PIX_FMT_BGR32, rgba32_to_bgr32},
{PIX_FMT_RGBA32, PIX_FMT_BGRx32, rgba32_to_bgrx32},
+ {PIX_FMT_RGBA32, PIX_FMT_ABGR32, rgba32_to_abgr32},
{PIX_FMT_RGBA32, PIX_FMT_RGB24, rgba32_to_rgb24},
{PIX_FMT_RGBA32, PIX_FMT_RGB555, rgba32_to_rgb555},
{PIX_FMT_RGBA32, PIX_FMT_PAL8, rgba32_to_pal8},
{PIX_FMT_RGBA32, PIX_FMT_YUV420P, rgba32_to_yuv420p},
{PIX_FMT_RGBA32, PIX_FMT_GRAY8, rgba32_to_gray},
{PIX_FMT_RGBA32, PIX_FMT_AYUV4444, rgba32_to_ayuv4444},
- {PIX_FMT_BGRA32, PIX_FMT_AYUV4444, bgra32_to_ayuv4444},
{PIX_FMT_BGR24, PIX_FMT_RGB24, bgr24_to_rgb24},
{PIX_FMT_BGR24, PIX_FMT_YUV420P, bgr24_to_yuv420p},
@@ -2030,6 +2122,17 @@ static ConvertEntry convert_table[] = {
{PIX_FMT_BGRA32, PIX_FMT_RGBA32, bgra32_to_rgba32},
{PIX_FMT_BGRA32, PIX_FMT_YUV420P, bgra32_to_yuv420p},
{PIX_FMT_BGRA32, PIX_FMT_GRAY8, bgra32_to_gray},
+ {PIX_FMT_BGRA32, PIX_FMT_AYUV4444, bgra32_to_ayuv4444},
+
+ {PIX_FMT_ABGR32, PIX_FMT_RGB24, abgr32_to_rgb24},
+ {PIX_FMT_ABGR32, PIX_FMT_RGBA32, abgr32_to_rgba32},
+ {PIX_FMT_ABGR32, PIX_FMT_YUV420P, abgr32_to_yuv420p},
+ {PIX_FMT_ABGR32, PIX_FMT_GRAY8, abgr32_to_gray},
+
+ {PIX_FMT_ARGB32, PIX_FMT_RGB24, argb32_to_rgb24},
+ {PIX_FMT_ARGB32, PIX_FMT_RGBA32, argb32_to_rgba32},
+ {PIX_FMT_ARGB32, PIX_FMT_YUV420P, argb32_to_yuv420p},
+ {PIX_FMT_ARGB32, PIX_FMT_GRAY8, argb32_to_gray},
{PIX_FMT_RGB555, PIX_FMT_RGB24, rgb555_to_rgb24},
{PIX_FMT_RGB555, PIX_FMT_RGB32, rgb555_to_rgba32},
@@ -2051,6 +2154,8 @@ static ConvertEntry convert_table[] = {
{PIX_FMT_GRAY8, PIX_FMT_BGRx32, gray_to_bgrx32},
{PIX_FMT_GRAY8, PIX_FMT_RGBA32, gray_to_rgba32},
{PIX_FMT_GRAY8, PIX_FMT_BGRA32, gray_to_bgra32},
+ {PIX_FMT_GRAY8, PIX_FMT_ARGB32, gray_to_argb32},
+ {PIX_FMT_GRAY8, PIX_FMT_ABGR32, gray_to_abgr32},
{PIX_FMT_GRAY8, PIX_FMT_MONOWHITE, gray_to_monowhite},
{PIX_FMT_GRAY8, PIX_FMT_MONOBLACK, gray_to_monoblack},
@@ -2068,6 +2173,8 @@ static ConvertEntry convert_table[] = {
{PIX_FMT_PAL8, PIX_FMT_BGRx32, pal8_to_bgrx32},
{PIX_FMT_PAL8, PIX_FMT_RGBA32, pal8_to_rgba32},
{PIX_FMT_PAL8, PIX_FMT_BGRA32, pal8_to_bgra32},
+ {PIX_FMT_PAL8, PIX_FMT_ARGB32, pal8_to_argb32},
+ {PIX_FMT_PAL8, PIX_FMT_ABGR32, pal8_to_abgr32},
{PIX_FMT_UYVY411, PIX_FMT_YUV411P, uyvy411_to_yuv411p},
@@ -2418,6 +2525,12 @@ img_get_alpha_info (const AVPicture * src, int pix_fmt, int width, int height)
case PIX_FMT_BGRA32:
ret = get_alpha_info_bgra32 (src, width, height);
break;
+ case PIX_FMT_ARGB32:
+ ret = get_alpha_info_argb32 (src, width, height);
+ break;
+ case PIX_FMT_ABGR32:
+ ret = get_alpha_info_abgr32 (src, width, height);
+ break;
case PIX_FMT_RGB555:
ret = get_alpha_info_rgb555 (src, width, height);
break;