Commit fe4ff4f3 authored by Sebastian Dröge's avatar Sebastian Dröge

videomixer: Add support for ABGR and RGBA

Now all 4 ARGB variants are supported by videomixer.
parent 1fdbfb35
......@@ -214,8 +214,12 @@ _fill_color_loop_##name##_c (guint8 *dest, gint height, gint width, gint c1, gin
A32_COLOR_LOOP_C (ac1c2c3, 0, 1, 2, 3);
A32_COLOR_LOOP_C (c3c2c1a, 3, 2, 1, 0);
A32_COLOR_LOOP_C (ac3c2c1, 0, 3, 2, 1);
A32_COLOR_LOOP_C (c1c2c3a, 1, 2, 3, 0);
A32_COLOR (argb_c, TRUE, _fill_color_loop_ac1c2c3_c);
A32_COLOR (bgra_c, TRUE, _fill_color_loop_c3c2c1a_c);
A32_COLOR (abgr_c, TRUE, _fill_color_loop_ac3c2c1_c);
A32_COLOR (rgba_c, TRUE, _fill_color_loop_c1c2c3a_c);
A32_COLOR (ayuv_c, FALSE, _fill_color_loop_ac1c2c3_c);
/* I420 */
......@@ -517,39 +521,38 @@ _memset_##name##_mmx (guint8* dest, gint red, gint green, gint blue, gint width)
#define A32
#define NAME_BLEND _blend_loop_argb_mmx
#define NAME_FILL_COLOR _fill_color_loop_argb_mmx
#define A_OFF 0
#define C1_OFF 8
#define C2_OFF 16
#define C3_OFF 24
#include "blend_mmx.h"
#undef NAME_BLEND
#undef NAME_FILL_COLOR
#undef A_OFF
#undef C1_OFF
#undef C2_OFF
#undef C3_OFF
#define NAME_BLEND _blend_loop_bgra_mmx
#define NAME_FILL_COLOR _fill_color_loop_bgra_mmx
#define A_OFF 24
#define C1_OFF 16
#define C2_OFF 8
#define C3_OFF 0
#include "blend_mmx.h"
#undef NAME_BLEND
#undef NAME_FILL_COLOR
#undef A_OFF
#undef C1_OFF
#undef C2_OFF
#undef C3_OFF
#undef A32
BLEND_A32 (argb_mmx, _blend_loop_argb_mmx);
BLEND_A32 (bgra_mmx, _blend_loop_bgra_mmx);
#define A32_COLOR_LOOP_MMX(name, A, C1, C2, C3) \
static inline void \
_fill_color_loop_##name##_mmx (guint8 *dest, gint height, gint width, gint c1, gint c2, gint c3) { \
guint32 val = (0xff << A) | (c1 << C1) | (c2 << C2) | (c3 << C3); \
\
_memset_u32_mmx ((guint32 *) dest, val, height*width); \
}
A32_COLOR_LOOP_MMX (argb, 24, 16, 8, 0);
A32_COLOR_LOOP_MMX (abgr, 24, 0, 8, 16);
A32_COLOR_LOOP_MMX (rgba, 0, 24, 16, 8);
A32_COLOR_LOOP_MMX (bgra, 0, 8, 16, 24);
A32_COLOR (argb_mmx, TRUE, _fill_color_loop_argb_mmx);
A32_COLOR (bgra_mmx, TRUE, _fill_color_loop_bgra_mmx);
A32_COLOR (abgr_mmx, TRUE, _fill_color_loop_abgr_mmx);
A32_COLOR (rgba_mmx, TRUE, _fill_color_loop_rgba_mmx);
A32_COLOR (ayuv_mmx, FALSE, _fill_color_loop_argb_mmx);
I420_BLEND (mmx, _memcpy_u8_mmx, _blend_u8_mmx);
......@@ -575,7 +578,7 @@ RGB_FILL_COLOR (bgrx_mmx, 4, _memset_bgrx_mmx);
/* Init function */
BlendFunction gst_video_mixer_blend_argb;
BlendFunction gst_video_mixer_blend_bgra;
/* AYUV is equal to ARGB */
/* AYUV/ABGR is equal to ARGB, RGBA is equal to BGRA */
BlendFunction gst_video_mixer_blend_i420;
BlendFunction gst_video_mixer_blend_rgb;
/* BGR is equal to RGB */
......@@ -584,6 +587,7 @@ BlendFunction gst_video_mixer_blend_rgbx;
FillCheckerFunction gst_video_mixer_fill_checker_argb;
FillCheckerFunction gst_video_mixer_fill_checker_bgra;
/* ABGR is equal to ARGB, RGBA is equal to BGRA */
FillCheckerFunction gst_video_mixer_fill_checker_ayuv;
FillCheckerFunction gst_video_mixer_fill_checker_i420;
FillCheckerFunction gst_video_mixer_fill_checker_rgb;
......@@ -593,6 +597,8 @@ FillCheckerFunction gst_video_mixer_fill_checker_xrgb;
FillColorFunction gst_video_mixer_fill_color_argb;
FillColorFunction gst_video_mixer_fill_color_bgra;
FillColorFunction gst_video_mixer_fill_color_abgr;
FillColorFunction gst_video_mixer_fill_color_rgba;
FillColorFunction gst_video_mixer_fill_color_ayuv;
FillColorFunction gst_video_mixer_fill_color_i420;
FillColorFunction gst_video_mixer_fill_color_rgb;
......@@ -625,6 +631,8 @@ gst_video_mixer_init_blend (void)
gst_video_mixer_fill_color_argb = fill_color_argb_c;
gst_video_mixer_fill_color_bgra = fill_color_bgra_c;
gst_video_mixer_fill_color_abgr = fill_color_abgr_c;
gst_video_mixer_fill_color_rgba = fill_color_rgba_c;
gst_video_mixer_fill_color_ayuv = fill_color_ayuv_c;
gst_video_mixer_fill_color_i420 = fill_color_i420_c;
gst_video_mixer_fill_color_rgb = fill_color_rgb_c;
......@@ -646,6 +654,8 @@ gst_video_mixer_init_blend (void)
gst_video_mixer_fill_color_argb = fill_color_argb_mmx;
gst_video_mixer_fill_color_bgra = fill_color_bgra_mmx;
gst_video_mixer_fill_color_abgr = fill_color_abgr_mmx;
gst_video_mixer_fill_color_rgba = fill_color_rgba_mmx;
gst_video_mixer_fill_color_ayuv = fill_color_ayuv_mmx;
gst_video_mixer_fill_color_i420 = fill_color_i420_mmx;
gst_video_mixer_fill_color_xrgb = fill_color_xrgb_mmx;
......
......@@ -29,6 +29,8 @@ typedef void (*FillColorFunction) (guint8 * dest, gint width, gint height, gint
extern BlendFunction gst_video_mixer_blend_argb;
extern BlendFunction gst_video_mixer_blend_bgra;
#define gst_video_mixer_blend_ayuv gst_video_mixer_blend_argb
#define gst_video_mixer_blend_abgr gst_video_mixer_blend_argb
#define gst_video_mixer_blend_rgba gst_video_mixer_blend_bgra
extern BlendFunction gst_video_mixer_blend_i420;
extern BlendFunction gst_video_mixer_blend_rgb;
#define gst_video_mixer_blend_bgr gst_video_mixer_blend_rgb
......@@ -38,7 +40,9 @@ extern BlendFunction gst_video_mixer_blend_rgbx;
#define gst_video_mixer_blend_xbgr gst_video_mixer_blend_rgbx
extern FillCheckerFunction gst_video_mixer_fill_checker_argb;
#define gst_video_mixer_fill_checker_abgr gst_video_mixer_fill_checker_argb
extern FillCheckerFunction gst_video_mixer_fill_checker_bgra;
#define gst_video_mixer_fill_checker_rgba gst_video_mixer_fill_checker_bgra
extern FillCheckerFunction gst_video_mixer_fill_checker_ayuv;
extern FillCheckerFunction gst_video_mixer_fill_checker_i420;
extern FillCheckerFunction gst_video_mixer_fill_checker_rgb;
......@@ -49,7 +53,9 @@ extern FillCheckerFunction gst_video_mixer_fill_checker_rgbx;
#define gst_video_mixer_fill_checker_xbgr gst_video_mixer_fill_checker_rgbx
extern FillColorFunction gst_video_mixer_fill_color_argb;
extern FillColorFunction gst_video_mixer_fill_color_abgr;
extern FillColorFunction gst_video_mixer_fill_color_bgra;
extern FillColorFunction gst_video_mixer_fill_color_rgba;
extern FillColorFunction gst_video_mixer_fill_color_ayuv;
extern FillColorFunction gst_video_mixer_fill_color_i420;
extern FillColorFunction gst_video_mixer_fill_color_rgb;
......
......@@ -119,46 +119,6 @@ NAME_BLEND (guint8 * dest, const guint8 * src, gint src_height, gint src_width,
}
__asm__ __volatile__ ("emms");
}
static inline void
NAME_FILL_COLOR (guint8 * dest, gint height, gint width, gint c1, gint c2,
gint c3)
{
guint64 val;
guint nvals = width * height;
val = (((guint64) 0xff << A_OFF)) | (((guint64) c1) << C1_OFF) |
(((guint64) c2) << C2_OFF) | (((guint64) c3) << C3_OFF);
val = (val << 32) | val;
/* *INDENT-OFF* */
__asm__ __volatile__ (
"movq %4 , %%mm0 \n\t"
"test $1 , %0 \n\t"
"je 1f \n\t"
"movd %%mm0 , (%1) \n\t"
"add $4 , %1 \n\t"
"dec %0 \n\t"
"1: \n\t"
"sar $1 , %0 \n\t"
"cmp $0 , %0 \n\t"
"je 3f \n\t"
"2: \n\t"
"movq %%mm0 , (%1) \n\t"
"add $8 , %1 \n\t"
"dec %0 \n\t"
"jne 2b \n\t"
"3: \n\t"
"emms \n\t"
: "=r" (nvals), "=r" (dest)
: "0" (nvals), "1" (dest), "m" (val)
: "memory"
#ifdef __MMX__
, "mm0"
#endif
);
/* *INDENT-ON* */
}
#endif
#ifdef GENERIC
......
......@@ -470,20 +470,20 @@ static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AYUV") ";" GST_VIDEO_CAPS_BGRA ";"
GST_VIDEO_CAPS_ARGB ";" GST_VIDEO_CAPS_YUV ("I420")
";" GST_VIDEO_CAPS_RGB ";" GST_VIDEO_CAPS_BGR
";" GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_xBGR
";" GST_VIDEO_CAPS_RGBx ";" GST_VIDEO_CAPS_BGRx)
GST_VIDEO_CAPS_ARGB ";" GST_VIDEO_CAPS_RGBA ";" GST_VIDEO_CAPS_ABGR ";"
GST_VIDEO_CAPS_YUV ("I420") ";" GST_VIDEO_CAPS_RGB ";"
GST_VIDEO_CAPS_BGR ";" GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_xBGR ";"
GST_VIDEO_CAPS_RGBx ";" GST_VIDEO_CAPS_BGRx)
);
static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink_%d",
GST_PAD_SINK,
GST_PAD_REQUEST,
GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AYUV") ";" GST_VIDEO_CAPS_BGRA ";"
GST_VIDEO_CAPS_ARGB ";" GST_VIDEO_CAPS_YUV ("I420")
";" GST_VIDEO_CAPS_RGB ";" GST_VIDEO_CAPS_BGR
";" GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_xBGR
";" GST_VIDEO_CAPS_RGBx ";" GST_VIDEO_CAPS_BGRx)
GST_VIDEO_CAPS_ARGB ";" GST_VIDEO_CAPS_RGBA ";" GST_VIDEO_CAPS_ABGR ";"
GST_VIDEO_CAPS_YUV ("I420") ";" GST_VIDEO_CAPS_RGB ";"
GST_VIDEO_CAPS_BGR ";" GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_xBGR ";"
GST_VIDEO_CAPS_RGBx ";" GST_VIDEO_CAPS_BGRx)
);
static void gst_videomixer_finalize (GObject * object);
......@@ -963,6 +963,18 @@ gst_videomixer_setcaps (GstPad * pad, GstCaps * caps)
mixer->fill_color = gst_video_mixer_fill_color_bgra;
ret = TRUE;
break;
case GST_VIDEO_FORMAT_ABGR:
mixer->blend = gst_video_mixer_blend_abgr;
mixer->fill_checker = gst_video_mixer_fill_checker_abgr;
mixer->fill_color = gst_video_mixer_fill_color_abgr;
ret = TRUE;
break;
case GST_VIDEO_FORMAT_RGBA:
mixer->blend = gst_video_mixer_blend_rgba;
mixer->fill_checker = gst_video_mixer_fill_checker_rgba;
mixer->fill_color = gst_video_mixer_fill_color_rgba;
ret = TRUE;
break;
case GST_VIDEO_FORMAT_I420:
mixer->blend = gst_video_mixer_blend_i420;
mixer->fill_checker = gst_video_mixer_fill_checker_i420;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment