Commit bc93903d authored by Wim Taymans's avatar Wim Taymans

Added the base framework for the SMPTE transitions and wipes.

Original commit message from CVS:
Added the base framework for the SMPTE transitions and wipes.
parent 91dd5fe4
plugindir = $(libdir)/gst
plugin_LTLIBRARIES = libgstsmpte.la
libgstsmpte_la_SOURCES = gstsmpte.c gstmask.c barboxwipes.c paint.c
noinst_HEADERS = gstsmpte.h gstmask.h paint.h
libgstsmpte_la_CFLAGS = -O2 -ffast-math $(GST_CFLAGS)
libgstsmpte_la_LIBADD =
libgstsmpte_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
EXTRA_DIST =
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
*
* 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.
*/
#include "paint.h"
#include "gstmask.h"
static void
gst_bar_wipe_lr_update (GstMask *mask,
GstClockTime position,
GstClockTime duration)
{
gint width = mask->width;
gint height = mask->height;
gint split = (position * width) / duration;
gst_smpte_paint_rect (mask->data, width, split, 0, width - split, height, 0);
gst_smpte_paint_rect (mask->data, width, 0, 0, split, height, 255);
}
static void
gst_bar_wipe_tb_update (GstMask *mask,
GstClockTime position,
GstClockTime duration)
{
gint width = mask->width;
gint height = mask->height;
gint split = (position * height) / duration;
gst_smpte_paint_rect (mask->data, width, 0, 0, width, split, 255);
gst_smpte_paint_rect (mask->data, width, 0, split, width, height - split, 0);
}
static void
gst_box_wipe_update (GstMask *mask,
GstClockTime position,
GstClockTime duration)
{
static gint box_wipe_impacts[8][4] =
{
/* 3 -> 6 */
{ 0, 0, 0, 0 },
{ 2, 2, 0, 0 },
{ 2, 2, 2, 2 },
{ 0, 0, 2, 2 },
/* 23 -> 26 */
{ 1, 1, 0, 0 },
{ 2, 2, 1, 1 },
{ 1, 1, 2, 2 },
{ 0, 0, 1, 1 },
};
gint *impacts = box_wipe_impacts[(mask->type & 0x0F) - 3];
gint width = mask->width;
gint height = mask->height;
gint splitx = (position * width) / duration;
gint splity = (position * height) / duration;
gst_smpte_paint_rect (mask->data, width, 0, 0, width, height, 0);
gst_smpte_paint_rect (mask->data, width,
(impacts[0] * width)/2 - (impacts[1] * splitx)/2,
(impacts[2] * height)/2 - (impacts[3] * splity)/2,
splitx, splity, 255);
}
static void
gst_fourc_box_wipe_update (GstMask *mask,
GstClockTime position,
GstClockTime duration)
{
static gint box_wipe_impacts[8][4] =
{
{ 0, 0, 0, 0 },
{ 1, 1, 1, 1 },
{ 4, 2, 0, 0 },
{ 3, 1, 1, 1 },
{ 4, 2, 4, 2 },
{ 1, 1, 3, 1 },
{ 0, 0, 4, 2 },
{ 3, 1, 3, 1 },
};
gint *impacts;
gint width = mask->width;
gint height = mask->height;
gint splitx = (position * width/2) / duration;
gint splity = (position * height/2) / duration;
gint i;
gst_smpte_paint_rect (mask->data, width, 0, 0, width, height, 0);
for (i = 7; i > 0; i -= 2) {
impacts = box_wipe_impacts[mask->type - i];
gst_smpte_paint_rect (mask->data, width,
(impacts[0] * width)/4 - (impacts[1] * splitx)/2,
(impacts[2] * height)/4 - (impacts[3] * splity)/2,
splitx, splity, 255);
}
}
static GstMaskDefinition definitions[] = {
{ 1, "bar_wipe_lr", "A bar moves from left to right",
_gst_mask_default_new, _gst_mask_default_destroy, gst_bar_wipe_lr_update },
{ 2, "bar_wipe_tb", "A bar moves from top to bottom",
_gst_mask_default_new, _gst_mask_default_destroy, gst_bar_wipe_tb_update },
{ 3, "box_wipe_tl", "A box expands from the upper-left corner to the lower-right corner",
_gst_mask_default_new, _gst_mask_default_destroy, gst_box_wipe_update },
{ 4, "box_wipe_tr", "A box expands from the upper-right corner to the lower-left corner",
_gst_mask_default_new, _gst_mask_default_destroy, gst_box_wipe_update },
{ 5, "box_wipe_br", "A box expands from the lower-right corner to the upper-left corner",
_gst_mask_default_new, _gst_mask_default_destroy, gst_box_wipe_update },
{ 6, "box_wipe_bl", "A box expands from the lower-left corner to the upper-right corner",
_gst_mask_default_new, _gst_mask_default_destroy, gst_box_wipe_update },
{ 23, "box_wipe_tc", "A box expands from the top edge's midpoint to the bottom corners",
_gst_mask_default_new, _gst_mask_default_destroy, gst_box_wipe_update },
{ 24, "box_wipe_rc", "A box expands from the right edge's midpoint to the left corners",
_gst_mask_default_new, _gst_mask_default_destroy, gst_box_wipe_update },
{ 25, "box_wipe_bc", "A box expands from the bottom edge's midpoint to the top corners",
_gst_mask_default_new, _gst_mask_default_destroy, gst_box_wipe_update },
{ 26, "box_wipe_lc", "A box expands from the left edge's midpoint to the right corners",
_gst_mask_default_new, _gst_mask_default_destroy, gst_box_wipe_update },
{ 7 , "four_box_wipe_ci", "A box shape expands from each of the four corners toward the center",
_gst_mask_default_new, _gst_mask_default_destroy, gst_fourc_box_wipe_update },
{ 8 , "four_box_wipe_co", "A box shape expands from the center of each quadrant toward the corners of each quadrant",
_gst_mask_default_new, _gst_mask_default_destroy, gst_fourc_box_wipe_update },
{ 0, NULL, NULL, NULL }
};
void
_gst_barboxwipes_register (void)
{
gint i = 0;
while (definitions[i].short_name) {
_gst_mask_register (&definitions[i]);
i++;
}
}
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
*
* 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.
*/
#include "gstmask.h"
extern void _gst_barboxwipes_register (void);
static GList *masks = NULL;
void
_gst_mask_init (void)
{
_gst_barboxwipes_register ();
}
static gint
gst_mask_compare (GstMaskDefinition *def1,
GstMaskDefinition *def2)
{
return (def1->type - def2->type);
}
void
_gst_mask_register (GstMaskDefinition *definition)
{
masks = g_list_insert_sorted (masks, definition, (GCompareFunc) gst_mask_compare);
}
const GList*
gst_mask_get_definitions (void)
{
return masks;
}
static GstMaskDefinition*
gst_mask_find_definition (gint type)
{
GList *walk = masks;
while (walk) {
GstMaskDefinition *def = (GstMaskDefinition *) walk->data;
if (def->type == type)
return def;
walk = g_list_next (walk);
}
return NULL;
}
GstMask*
gst_mask_factory_new (gint type, gint bpp, gint width, gint height)
{
GstMaskDefinition *definition;
GstMask *mask = NULL;
definition = gst_mask_find_definition (type);
if (definition) {
mask = definition->new_func (definition, bpp, width, height);
}
return mask;
}
GstMask*
_gst_mask_default_new (GstMaskDefinition *definition,
gint bpp, gint width, gint height)
{
GstMask *mask;
mask = g_new0 (GstMask, 1);
mask->type = definition->type;
mask->bpp = bpp;
mask->width = width;
mask->height = height;
mask->update_func = definition->update_func;
mask->destroy_func = definition->destroy_func;
mask->data = g_malloc (width * height * (bpp+7)>>3);
return mask;
}
void
_gst_mask_default_destroy (GstMask *mask)
{
g_free (mask->data);
g_free (mask);
}
void
gst_mask_destroy (GstMask *mask)
{
if (mask->destroy_func)
mask->destroy_func (mask);
}
void
gst_mask_update (GstMask *mask,
GstClockTime position,
GstClockTime duration)
{
g_return_if_fail (mask != NULL);
if (mask->update_func)
mask->update_func (mask, position, duration);
}
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
*
* 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_MASK_H__
#define __GST_MASK_H__
#include <gst/gst.h>
typedef struct _GstMask GstMask;
typedef struct _GstMaskDefinition GstMaskDefinition;
typedef GstMask* (*GstMaskNewFunc) (GstMaskDefinition *definition,
gint bpp, gint width, gint height);
typedef void (*GstMaskDestroyFunc) (GstMask *mask);
typedef void (*GstMaskUpdateFunc) (GstMask *mask,
GstClockTime position,
GstClockTime duration);
struct _GstMaskDefinition {
gint type;
gchar *short_name;
gchar *long_name;
GstMaskNewFunc new_func;
GstMaskDestroyFunc destroy_func;
GstMaskUpdateFunc update_func;
};
struct _GstMask {
gint type;
guint8 *data;
gint width;
gint height;
gint bpp;
GstMaskUpdateFunc update_func;
GstMaskDestroyFunc destroy_func;
};
void _gst_mask_init (void);
void _gst_mask_register (GstMaskDefinition *definition);
GstMask* _gst_mask_default_new (GstMaskDefinition *definition,
gint bpp, gint width, gint height);
void _gst_mask_default_destroy (GstMask *mask);
const GList* gst_mask_get_definitions (void);
GstMask* gst_mask_factory_new (gint type, gint bpp, gint width, gint height);
void gst_mask_destroy (GstMask *mask);
void gst_mask_update (GstMask *mask,
GstClockTime position,
GstClockTime duration);
#endif /* __GST_MASK_H__ */
This diff is collapsed.
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
*
* 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_SMPTE_H__
#define __GST_SMPTE_H__
#include <gst/gst.h>
#include <gstmask.h>
#define GST_TYPE_SMPTE \
(gst_smpte_get_type())
#define GST_SMPTE(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_SMPTE,GstSMPTE))
#define GST_SMPTE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_SMPTE,GstSMPTE))
#define GST_IS_SMPTE(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SMPTE))
#define GST_IS_SMPTE_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SMPTE))
typedef struct _GstSMPTE GstSMPTE;
typedef struct _GstSMPTEClass GstSMPTEClass;
struct _GstSMPTE {
GstElement element;
gint format;
gint width;
gint height;
gint duration;
gint position;
GstPad *srcpad,
*sinkpad1,
*sinkpad2;
gint type;
GstMask *mask;
};
struct _GstSMPTEClass {
GstElementClass parent_class;
};
#endif /* __GST_SMPTE_H__ */
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
*
* 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.
*/
#include "paint.h"
void
gst_smpte_paint_rect (guint8 *dest, gint stride, gint x, gint y, gint w, gint h, guint8 color)
{
guint8 *d = dest + stride * y + x;
gint i;
for (i = 0; i < h; i++) {
memset (d, color, w);
d += stride;
}
}
void
gst_smpte_paint_rect_s (guint8 *dest, gint stride, gint x, gint y, gint w, gint h, guint8 color)
{
guint8 *d = dest + stride * y + x;
gint i, j;
gint border = 100;
for (i = 0; i < h; i++) {
if (w - border > 0) {
memset (d, color, w - border);
}
for (j = 0; j < border - w; j++) {
*(d+w+j) = (color*(border-j)/border);
}
d += stride;
}
}
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
*
* 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_SMPTE_PAINT_H__
#define __GST_SMPTE_PAINT_H__
#include <glib.h>
void gst_smpte_paint_rect (guint8 *dest, gint stride,
gint x, gint y, gint w, gint h,
guint8 color);
void gst_smpte_paint_rect_s (guint8 *dest, gint stride,
gint x, gint y, gint w, gint h,
guint8 color);
#endif /* __GST_SMPTE_PAINT_H__ */
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