]> git.sesse.net Git - vlc/blobdiff - include/vlc_filter.h
Fix menu removal of accelerators. This has yet to be more FIXMEd (jpeg :D)
[vlc] / include / vlc_filter.h
index a1afd34104f50b5df974554b69466e36512d0242..1262126c6b31ccd1e8670221f856fde3741d684b 100644 (file)
@@ -1,10 +1,11 @@
 /*****************************************************************************
- * vlc_filter.h: filter related structures
+ * vlc_filter.h: filter related structures and functions
  *****************************************************************************
- * Copyright (C) 1999-2003 the VideoLAN team
+ * Copyright (C) 1999-2008 the VideoLAN team
  * $Id$
  *
  * Authors: Gildas Bazin <gbazin@videolan.org>
+ *          Antoine Cellerier <dionoea 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
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
-#if !defined( __LIBVLC__ )
-  #error You are not libvlc or one of its plugins. You cannot include this file
-#endif
-
 #ifndef _VLC_FILTER_H
 #define _VLC_FILTER_H 1
 
@@ -55,6 +52,7 @@ struct filter_t
 
     /* Output format of filter */
     es_format_t         fmt_out;
+    bool                b_allow_fmt_out_change;
 
     /* Filter configuration */
     config_chain_t *    p_cfg;
@@ -81,8 +79,8 @@ struct filter_t
     /* Video output callbacks */
     picture_t     * ( * pf_vout_buffer_new) ( filter_t * );
     void            ( * pf_vout_buffer_del) ( filter_t *, picture_t * );
-    void            ( * pf_picture_link)    ( picture_t * );
-    void            ( * pf_picture_unlink)  ( picture_t * );
+    /* void            ( * pf_picture_link)    ( picture_t * );
+    void            ( * pf_picture_unlink)  ( picture_t * ); */
 
     /* SPU output callbacks */
     subpicture_t *  ( * pf_sub_buffer_new) ( filter_t * );
@@ -92,6 +90,66 @@ struct filter_t
     filter_owner_sys_t *p_owner;
 };
 
+/**
+ * This function will return a new picture usable by p_filter as an output
+ * buffer. You have to release it using filter_DeletePicture or by returning
+ * it to the caller as a pf_video_filter return value.
+ * Provided for convenience.
+ */
+static inline picture_t *filter_NewPicture( filter_t *p_filter )
+{
+    picture_t *p_picture = p_filter->pf_vout_buffer_new( p_filter );
+    if( !p_picture )
+        msg_Warn( p_filter, "can't get output picture" );
+    return p_picture;
+}
+
+/**
+ * This function will release a picture create by filter_NewPicture.
+ * Provided for convenience.
+ */
+static inline void filter_DeletePicture( filter_t *p_filter, picture_t *p_picture )
+{
+    p_filter->pf_vout_buffer_del( p_filter, p_picture );
+}
+
+/**
+ * This function will return a new subpicture usable by p_filter as an output
+ * buffer. You have to release it using filter_DeleteSubpicture or by returning
+ * it to the caller as a pf_sub_filter return value.
+ * Provided for convenience.
+ */
+static inline subpicture_t *filter_NewSubpicture( filter_t *p_filter )
+{
+    subpicture_t *p_subpicture = p_filter->pf_sub_buffer_new( p_filter );
+    if( !p_subpicture )
+        msg_Warn( p_filter, "can't get output subpicture" );
+    return p_subpicture;
+}
+
+/**
+ * This function will release a subpicture create by filter_NewSubicture.
+ * Provided for convenience.
+ */
+static inline void filter_DeleteSubpicture( filter_t *p_filter, subpicture_t *p_subpicture )
+{
+    p_filter->pf_sub_buffer_del( p_filter, p_subpicture );
+}
+
+/**
+ * This function will return a new audio buffer usable by p_filter as an
+ * output buffer. You have to release it using block_Release or by returning
+ * it to the caller as a pf_audio_filter return value.
+ * Provided for convenience.
+ */
+static inline block_t *filter_NewAudioBuffer( filter_t *p_filter, int i_size )
+{
+    block_t *p_block = p_filter->pf_audio_buffer_new( p_filter, i_size );
+    if( !p_block )
+        msg_Warn( p_filter, "can't get output block" );
+    return p_block;
+}
+
 
 /**
  * Create a picture_t *(*)( filter_t *, picture_t * ) compatible wrapper
@@ -103,26 +161,45 @@ struct filter_t
     static picture_t *name ## _Filter ( filter_t *p_filter,             \
                                         picture_t *p_pic )              \
     {                                                                   \
-        picture_t *p_outpic = p_filter->pf_vout_buffer_new( p_filter ); \
+        picture_t *p_outpic = filter_NewPicture( p_filter );            \
         if( !p_outpic )                                                 \
         {                                                               \
-            msg_Warn( p_filter, "can't get output picture" );           \
-            if( p_pic->pf_release )                                     \
-                p_pic->pf_release( p_pic );                             \
+            picture_Release( p_pic );                                   \
             return NULL;                                                \
         }                                                               \
                                                                         \
         name( p_filter, p_pic, p_outpic );                              \
                                                                         \
-        p_outpic->date = p_pic->date;                                   \
-        p_outpic->b_force = p_pic->b_force;                             \
-        p_outpic->i_nb_fields = p_pic->i_nb_fields;                     \
-        p_outpic->b_progressive = p_pic->b_progressive;                 \
-        p_outpic->b_top_field_first = p_pic->b_top_field_first;         \
+        picture_CopyProperties( p_outpic, p_pic );                      \
+        picture_Release( p_pic );                                       \
                                                                         \
-        if( p_pic->pf_release )                                         \
-            p_pic->pf_release( p_pic );                                 \
         return p_outpic;                                                \
     }
 
+/**
+ * Filter chain management API
+ */
+
+typedef struct filter_chain_t filter_chain_t;
+
+VLC_EXPORT( filter_chain_t *, __filter_chain_New, ( vlc_object_t *, const char *, bool, int (*)( filter_t *, void * ), void (*)( filter_t * ), void *  ) );
+#define filter_chain_New( a, b, c, d, e, f ) __filter_chain_New( VLC_OBJECT( a ), b, c, d, e, f )
+VLC_EXPORT( void, filter_chain_Delete, ( filter_chain_t * ) );
+VLC_EXPORT( void, filter_chain_Reset, ( filter_chain_t *, const es_format_t *, const es_format_t * ) );
+
+VLC_EXPORT( filter_t *, filter_chain_AppendFilter, ( filter_chain_t *, const char *, config_chain_t *, const es_format_t *, const es_format_t * ) );
+VLC_EXPORT( int, filter_chain_AppendFromString, ( filter_chain_t *, const char * ) );
+VLC_EXPORT( int, filter_chain_DeleteFilter, ( filter_chain_t *, filter_t * ) );
+
+VLC_EXPORT( filter_t *, filter_chain_GetFilter, ( filter_chain_t *, int, const char * ) );
+VLC_EXPORT( int, filter_chain_GetLength, ( filter_chain_t * ) );
+VLC_EXPORT( const es_format_t *, filter_chain_GetFmtOut, ( filter_chain_t * ) );
+
+/**
+ * Apply the filter chain
+ */
+VLC_EXPORT( picture_t *, filter_chain_VideoFilter, ( filter_chain_t *, picture_t * ) );
+VLC_EXPORT( block_t *, filter_chain_AudioFilter, ( filter_chain_t *, block_t * ) );
+VLC_EXPORT( void, filter_chain_SubFilter, ( filter_chain_t *, mtime_t ) );
+
 #endif /* _VLC_FILTER_H */