asademux.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * asademux.c: asa demuxer VM
00003  *****************************************************************************
00004  * Copyright (C) 2007 the VideoLAN team
00005  *
00006  * Originated from asa: portable digital subtitle renderer
00007  *
00008  * Authors: David Lamparter <equinox at diac24 dot net>
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00023  ****************************************************************************/
00024 
00025 /****************************************************************************
00026  * Changes from asa version:
00027  *  - headers adapted
00028  *  - external definition file support dropped
00029  *  - integer timestamps
00030  ****************************************************************************
00031  * Please retain Linux kernel CodingStyle for sync.
00032  * base commit d8c269b0fae9a8f8904e16e92313da165d664c74
00033  ****************************************************************************/
00034 
00035 #ifndef _ASADEMUX_H
00036 #define _ASADEMUX_H
00037 
00038 #include <pcre.h>
00039 
00040 /** parser reuse. imports-to-C uses char *, real VM uses pcre * */
00041 typedef union {
00042     pcre *pcre;
00043     char *str;
00044 } asa_pcre;
00045 
00046 /** pcre_compile wrapper.
00047  * used to allow loading differently for imports-to-C conversion.
00048  * @param out output (parsed pcre)
00049  * @param str regular expression string
00050  * @return 0 on success, any other on error
00051  */
00052 extern int asa_pcre_compile(asa_pcre *out, const char *str);
00053 
00054 /** import instruction code */
00055 enum asa_import_insn_type {
00056     ASAI_COMMIT = 0,    /**< put current buffer as line */
00057     ASAI_DISCARD,       /**< discard current buffer */
00058     ASAI_BREAK,     /**< leave child group */
00059 
00060     ASAI_SELECT,        /**< select source matchgroup */
00061     ASAI_SG,        /**< execute search & replace on selected */
00062     ASAI_SGU,       /**< like ASAI_SG, but update matchgroups */
00063     ASAI_APPEND,        /**< append selected source to buffer */
00064 
00065     ASAI_FPS,       /**< set fixed fps */
00066     ASAI_SHOW,      /**< set start time */
00067     ASAI_HIDE,      /**< set end time */
00068 
00069     ASAI_CHILD      /**< child regex match */
00070 };
00071 
00072 /** replacement element for ASAI_SG / ASAI_SGU */
00073 struct asa_repl {
00074     struct asa_repl *next;  /**< next element */
00075 
00076     int group;      /**< -1 if fixed string, else source group */
00077     char *text;     /**< fixed string for group == -1 */
00078 };
00079 
00080 /** time specification element */
00081 struct asa_tspec {
00082     struct asa_tspec *next; /**< next element */
00083 
00084     int group;      /**< source matchgroup */
00085     double  mult,       /**< ts multiplier. 1.0 = 1 second */
00086         fps_mult;   /**< fps multiplier. probably 0.0 or 1.0 */
00087 };
00088 
00089 /** single import instruction */
00090 struct asa_import_insn {
00091     struct asa_import_insn
00092         *parent,    /**< owner insn, NULL if format child */
00093         *next;      /**< next instruction */
00094 
00095     enum asa_import_insn_type insn; /**< instruction code */
00096     /** instruction parameters */
00097     union {
00098         int break_depth;        /**< depth to break out */
00099         int select;         /**< matchgroup to select */
00100         /** search-replace parameters */
00101         struct {
00102             asa_pcre regex;     /**< search for */
00103             struct asa_repl *repl;  /**< replace by */
00104         } sg;
00105         /** time specification */
00106         struct {
00107             struct asa_tspec *tsp;  /**< sources to sum up */
00108             int delta_select;   /**< -1 or delta index */
00109         } tspec;
00110         /** child instructions */
00111         struct {
00112             asa_pcre regex;     /** <if this matches... */
00113             struct asa_import_insn *insns;  /**< do this. */
00114         } child;
00115         double fps_value;       /**< fixed fps value */
00116     } v;
00117 };
00118 
00119 /** destination format of import rules */
00120 enum asa_import_target {
00121     ASAI_TARGET_TEXT = (1 << 0),        /**< plain text packets */
00122     ASAI_TARGET_SSA = (1 << 1)      /**< MKV ASS packets */
00123 };
00124 
00125 /** importing instructions for format */
00126 struct asa_import_format {
00127     struct asa_import_format *next,     /**< next format */
00128         *prevtgt,           /**< previous target */
00129         *nexttgt;           /**< next target of this*/
00130 
00131     char *name;             /**< format name */
00132 
00133     enum asa_import_target target;      /**< target */
00134     struct asa_import_insn *insns;      /**< instructions */
00135 };
00136 
00137 /** format detection rules */
00138 struct asa_import_detect {
00139     struct asa_import_detect *next;     /**< next rule */
00140 
00141     asa_pcre re;                /**< if this matches... */
00142 
00143     char *name;             /**< use this format */
00144     struct asa_import_format *fmt;      /**< through this pointer */
00145 
00146 };
00147 
00148 extern struct asa_import_detect *asa_det_first, **asa_det_last;
00149 extern struct asa_import_format *asa_fmt_first, **asa_fmt_last;
00150 
00151 typedef int (asa_import_callback)(demux_t *demux, void *arg,
00152     int64_t start, int64_t stop,
00153     const char *buffer, size_t buffer_length);
00154 
00155 extern struct asa_import_detect *asa_imports_detect(const void *data,
00156     size_t dlen);
00157 extern int asa_import(demux_t *d, const void *data, size_t dlen,
00158     int64_t usecperframe, struct asa_import_detect *det,
00159     asa_import_callback *callback, void *arg);
00160 extern void asa_init_import(void);
00161 
00162 #endif

Generated on Sat Nov 21 08:05:18 2009 for VLC by  doxygen 1.5.6