mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 09:40:37 +00:00
69b5aedc58
This option allows the videomixer2 element to output a valid alpha channel when the inputs contain a valid alpha channel. This allows mixing to occur in multiple stages serially. The following pipeline shows an example of such a pipeline: gst-launch videotestsrc background-color=0x000000 pattern=ball ! video/x-raw-yuv,format=\(fourcc\)AYUV ! videomixer2 background=transparent name=mix1 ! videomixer2 name=mix2 ! ffmpegcolorspace ! autovideosink videotestsrc ! video/x-raw-yuv,format=\(fourcc\)AYUV ! mix2. The first videotestsrc in this pipeline creates a moving ball on a transparent background. It is then passed to the first videomixer2. Previously, this videomixer2 would have forced the alpha channel to 1.0 and given a background of checker, black, or white to the stream. With this patch, however, you can now specify the background as transparent, and the alpha channel of the input will be preserved. This allows for further mixing downstream, as is shown in the above pipeline where the a second videomixer2 is used to mix in a background of an smpte videotestsrc. So the result is a ball hovering over the smpte test source. This could, of course, have been accomplished with a single mixer element, but staged mixing is useful when it is not convenient to mix all video at once (e.g. a pipeline where a foreground and background bin exist and are mixed at the final output, but the foreground bin needs an internal mixer to create transitions between clips). Fixes bug #639994.
125 lines
3.5 KiB
C
125 lines
3.5 KiB
C
/* Generic video mixer plugin
|
|
* Copyright (C) 2008 Wim Taymans <wim@fluendo.com>
|
|
* Copyright (C) 2010 Sebastian Dröge <sebastian.droege@collabora.co.uk>
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Library General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Library General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Library General Public
|
|
* License along with this library; if not, write to the
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
* Boston, MA 02111-1307, USA.
|
|
*/
|
|
|
|
#ifndef __GST_VIDEO_MIXER2_H__
|
|
#define __GST_VIDEO_MIXER2_H__
|
|
|
|
#include <gst/gst.h>
|
|
#include <gst/video/video.h>
|
|
|
|
#include "blend.h"
|
|
#include "gstcollectpads2.h"
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
#define GST_TYPE_VIDEO_MIXER2 (gst_videomixer2_get_type())
|
|
#define GST_VIDEO_MIXER2(obj) \
|
|
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VIDEO_MIXER2, GstVideoMixer2))
|
|
#define GST_VIDEO_MIXER2_CLASS(klass) \
|
|
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_VIDEO_MIXER2, GstVideoMixer2Class))
|
|
#define GST_IS_VIDEO_MIXER2(obj) \
|
|
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VIDEO_MIXER2))
|
|
#define GST_IS_VIDEO_MIXER2_CLASS(klass) \
|
|
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VIDEO_MIXER2))
|
|
|
|
typedef struct _GstVideoMixer2 GstVideoMixer2;
|
|
typedef struct _GstVideoMixer2Class GstVideoMixer2Class;
|
|
|
|
/**
|
|
* GstVideoMixer2Background:
|
|
* @VIDEO_MIXER2_BACKGROUND_CHECKER: checker pattern background
|
|
* @VIDEO_MIXER2_BACKGROUND_BLACK: solid color black background
|
|
* @VIDEO_MIXER2_BACKGROUND_WHITE: solid color white background
|
|
* @VIDEO_MIXER2_BACKGROUND_TRANSPARENT: background is left transparent and layers are composited using "A OVER B" composition rules. This is only applicable to AYUV and ARGB (and variants) as it preserves the alpha channel and allows for further mixing.
|
|
*
|
|
* The different backgrounds videomixer can blend over.
|
|
*/
|
|
typedef enum
|
|
{
|
|
VIDEO_MIXER2_BACKGROUND_CHECKER,
|
|
VIDEO_MIXER2_BACKGROUND_BLACK,
|
|
VIDEO_MIXER2_BACKGROUND_WHITE,
|
|
VIDEO_MIXER2_BACKGROUND_TRANSPARENT,
|
|
}
|
|
GstVideoMixer2Background;
|
|
|
|
/**
|
|
* GstVideoMixer2:
|
|
*
|
|
* The opaque #GstVideoMixer2 structure.
|
|
*/
|
|
struct _GstVideoMixer2
|
|
{
|
|
GstElement element;
|
|
|
|
/* < private > */
|
|
|
|
/* pad */
|
|
GstPad *srcpad;
|
|
|
|
/* Lock to prevent the state to change while blending */
|
|
GMutex *lock;
|
|
/* Sink pads using Collect Pads 2*/
|
|
GstCollectPads2 *collect;
|
|
|
|
/* sinkpads, a GSList of GstVideoMixer2Pads */
|
|
GSList *sinkpads;
|
|
gint numpads;
|
|
/* Next available sinkpad index */
|
|
gint next_sinkpad;
|
|
|
|
/* Output caps */
|
|
GstVideoFormat format;
|
|
gint width, height;
|
|
gint fps_n;
|
|
gint fps_d;
|
|
gint par_n;
|
|
gint par_d;
|
|
|
|
gboolean newseg_pending;
|
|
gboolean flush_stop_pending;
|
|
|
|
GstVideoMixer2Background background;
|
|
|
|
/* Current downstream segment */
|
|
GstSegment segment;
|
|
GstClockTime ts_offset;
|
|
guint64 nframes;
|
|
|
|
/* QoS stuff */
|
|
gdouble proportion;
|
|
GstClockTime earliest_time;
|
|
guint64 qos_processed, qos_dropped;
|
|
|
|
BlendFunction blend, overlay;
|
|
FillCheckerFunction fill_checker;
|
|
FillColorFunction fill_color;
|
|
};
|
|
|
|
struct _GstVideoMixer2Class
|
|
{
|
|
GstElementClass parent_class;
|
|
};
|
|
|
|
GType gst_videomixer2_get_type (void);
|
|
gboolean gst_videomixer2_register (GstPlugin * plugin);
|
|
|
|
G_END_DECLS
|
|
#endif /* __GST_VIDEO_MIXER2_H__ */
|