[vlc-devel] commit: Added blend filter helpers. (Laurent Aimar )

git version control git at videolan.org
Fri Jun 5 20:24:28 CEST 2009


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Thu Jun  4 23:44:30 2009 +0200| [a974af8d4fa747fcfff0dbbebfeedf6031930e36] | committer: Laurent Aimar 

Added blend filter helpers.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a974af8d4fa747fcfff0dbbebfeedf6031930e36
---

 include/vlc_filter.h |   23 +++++++++++
 src/Makefile.am      |    1 +
 src/libvlccore.sym   |    4 ++
 src/misc/filter.c    |  108 ++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 136 insertions(+), 0 deletions(-)

diff --git a/include/vlc_filter.h b/include/vlc_filter.h
index 1396008..cb0f745 100644
--- a/include/vlc_filter.h
+++ b/include/vlc_filter.h
@@ -182,6 +182,29 @@ static inline block_t *filter_NewAudioBuffer( filter_t *p_filter, int i_size )
 }
 
 /**
+ * It creates a blend filter
+ */
+VLC_EXPORT( filter_t *, filter_NewBlend, ( vlc_object_t *, vlc_fourcc_t i_chroma_dst ) );
+
+/**
+ * It configures blend filter parameters that are allowed to changed
+ * after the creation.
+ */
+VLC_EXPORT( int, filter_ConfigureBlend, ( filter_t *, int i_dst_width, int i_dst_height, const video_format_t *p_src ) );
+
+/**
+ * It blends a picture into another one.
+ *
+ * The input picture is not modified and not released.
+ */
+VLC_EXPORT( int, filter_Blend, ( filter_t *, picture_t *p_dst, int i_dst_x, int i_dst_y, picture_t *p_src, int i_alpha ) );
+
+/**
+ * It destroys a blend filter created by filter_NewBlend.
+ */
+VLC_EXPORT( void, filter_DeleteBlend, ( filter_t * ) );
+
+/**
  * Create a picture_t *(*)( filter_t *, picture_t * ) compatible wrapper
  * using a void (*)( filter_t *, picture_t *, picture_t * ) function
  *
diff --git a/src/Makefile.am b/src/Makefile.am
index 5ead2ac..42250be 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -409,6 +409,7 @@ SOURCES_libvlc_common = \
 	misc/xml.c \
 	misc/devices.c \
 	extras/libc.c \
+	misc/filter.c \
 	misc/filter_chain.c \
 	$(NULL)
 
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 89bb140..c2f2688 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -122,6 +122,7 @@ es_format_Clean
 es_format_Copy
 es_format_Init
 filename_sanitize
+filter_Blend
 filter_chain_AppendFilter
 filter_chain_AppendFromString
 filter_chain_AudioFilter
@@ -135,6 +136,9 @@ __filter_chain_New
 filter_chain_Reset
 filter_chain_SubFilter
 filter_chain_VideoFilter
+filter_ConfigureBlend
+filter_DeleteBlend
+filter_NewBlend
 FromLocale
 FromLocaleDup
 GetFallbackEncoding
diff --git a/src/misc/filter.c b/src/misc/filter.c
new file mode 100644
index 0000000..4024a12
--- /dev/null
+++ b/src/misc/filter.c
@@ -0,0 +1,108 @@
+/*****************************************************************************
+ * filter.c : filter_t helpers.
+ *****************************************************************************
+ * Copyright (C) 2009 Laurent Aimar
+ * $Id$
+ *
+ * Author: Laurent Aimar <fenrir _AT_ videolan _DOT_ org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <libvlc.h>
+#include <vlc_filter.h>
+
+filter_t *filter_NewBlend( vlc_object_t *p_this,
+                           vlc_fourcc_t i_chroma_dst )
+{
+    filter_t *p_blend = vlc_custom_create( p_this, sizeof(*p_blend),
+                                           VLC_OBJECT_GENERIC, "blend" );
+    if( !p_blend )
+        return NULL;
+
+    es_format_Init( &p_blend->fmt_in, VIDEO_ES, 0 );
+
+    es_format_Init( &p_blend->fmt_out, VIDEO_ES, 0 );
+
+    p_blend->fmt_out.i_codec        = 
+    p_blend->fmt_out.video.i_chroma = i_chroma_dst;
+
+    /* The blend module will be loaded when needed with the real
+    * input format */
+    p_blend->p_module = NULL;
+
+    /* */
+    vlc_object_attach( p_blend, p_this );
+
+    return p_blend;
+}
+
+int filter_ConfigureBlend( filter_t *p_blend,
+                           int i_dst_width, int i_dst_height,
+                           const video_format_t *p_src )
+{
+    /* */
+    if( p_blend->p_module &&
+        p_blend->fmt_in.video.i_chroma != p_src->i_chroma )
+    {
+        /* The chroma is not the same, we need to reload the blend module */
+        module_unneed( p_blend, p_blend->p_module );
+        p_blend->p_module = NULL;
+    }
+
+    /* */
+
+    p_blend->fmt_in.i_codec = p_src->i_chroma;
+    p_blend->fmt_in.video   = *p_src;
+
+    /* */
+    p_blend->fmt_out.video.i_width          =
+    p_blend->fmt_out.video.i_visible_width  = i_dst_width;
+    p_blend->fmt_out.video.i_height         =
+    p_blend->fmt_out.video.i_visible_height = i_dst_height;
+
+    /* */
+    if( !p_blend->p_module )
+        p_blend->p_module = module_need( p_blend, "video blending", NULL, false );
+    if( !p_blend->p_module )
+        return VLC_EGENERIC;
+    return VLC_SUCCESS;
+}
+
+int filter_Blend( filter_t *p_blend,
+                  picture_t *p_dst, int i_dst_x, int i_dst_y,
+                  picture_t *p_src, int i_alpha )
+{
+    if( !p_blend->p_module )
+        return VLC_EGENERIC;
+
+    p_blend->pf_video_blend( p_blend, p_dst, p_src, i_dst_x, i_dst_y, i_alpha );
+    return VLC_SUCCESS;
+}
+
+void filter_DeleteBlend( filter_t *p_blend )
+{
+    if( p_blend->p_module )
+        module_unneed( p_blend, p_blend->p_module );
+
+    vlc_object_detach( p_blend );
+    vlc_object_release( p_blend );
+}
+




More information about the vlc-devel mailing list