ass_split.h
Go to the documentation of this file.
1 /*
2  * SSA/ASS spliting functions
3  * Copyright (c) 2010 Aurelien Jacobs <aurel@gnuage.org>
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #ifndef AVCODEC_ASS_SPLIT_H
23 #define AVCODEC_ASS_SPLIT_H
24 
25 /**
26  * fields extracted from the [Script Info] section
27  */
28 typedef struct {
29  char *script_type; /**< SSA script format version (eg. v4.00) */
30  char *collisions; /**< how subtitles are moved to prevent collisions */
31  int play_res_x; /**< video width that ASS coords are referring to */
32  int play_res_y; /**< video height that ASS coords are referring to */
33  float timer; /**< time multiplier to apply to SSA clock (in %) */
35 
36 /**
37  * fields extracted from the [V4(+) Styles] section
38  */
39 typedef struct {
40  char *name; /**< name of the tyle (case sensitive) */
41  char *font_name; /**< font face (case sensitive) */
42  int font_size; /**< font height */
43  int primary_color; /**< color that a subtitle will normally appear in */
44  int back_color; /**< color of the subtitle outline or shadow */
45  int bold; /**< whether text is bold (1) or not (0) */
46  int italic; /**< whether text is italic (1) or not (0) */
47  int underline; /**< whether text is underlined (1) or not (0) */
48  int alignment; /**< position of the text (left, center, top...),
49  defined after the layout of the numpad
50  (1-3 sub, 4-6 mid, 7-9 top) */
51 } ASSStyle;
52 
53 /**
54  * fields extracted from the [Events] section
55  */
56 typedef struct {
57  int layer; /**< higher numbered layers are drawn over lower numbered */
58  int start; /**< start time of the dialog in centiseconds */
59  int end; /**< end time of the dialog in centiseconds */
60  char *style; /**< name of the ASSStyle to use with this dialog */
61  char *text; /**< actual text which will be displayed as a subtitle,
62  can include style override control codes (see
63  ff_ass_split_override_codes()) */
64 } ASSDialog;
65 
66 /**
67  * structure containing the whole split ASS data
68  */
69 typedef struct {
70  ASSScriptInfo script_info; /**< general information about the SSA script*/
71  ASSStyle *styles; /**< array of split out styles */
72  int styles_count; /**< number of ASSStyle in the styles array */
73  ASSDialog *dialogs; /**< array of split out dialogs */
74  int dialogs_count; /**< number of ASSDialog in the dialogs array*/
75 } ASS;
76 
77 /**
78  * This struct can be casted to ASS to access to the split data.
79  */
81 
82 /**
83  * Split a full ASS file or a ASS header from a string buffer and store
84  * the split structure in a newly allocated context.
85  *
86  * @param buf String containing the ASS formated data.
87  * @return Newly allocated struct containing split data.
88  */
89 ASSSplitContext *ff_ass_split(const char *buf);
90 
91 /**
92  * Split one or several ASS "Dialogue" lines from a string buffer and store
93  * them in a already initialized context.
94  *
95  * @param ctx Context previously initialized by ff_ass_split().
96  * @param buf String containing the ASS "Dialogue" lines.
97  * @param cache Set to 1 to keep all the previously split ASSDialog in
98  * the context, or set to 0 to free all the previously split
99  * ASSDialog.
100  * @param number If not NULL, the pointed integer will be set to the number
101  * of split ASSDialog.
102  * @return Pointer to the first split ASSDialog.
103  */
105  int cache, int *number);
106 
107 /**
108  * Free all the memory allocated for an ASSSplitContext.
109  *
110  * @param ctx Context previously initialized by ff_ass_split().
111  */
113 
114 
115 /**
116  * Set of callback functions corresponding to each override codes that can
117  * be encountered in a "Dialogue" Text field.
118  */
119 typedef struct {
120  /**
121  * @defgroup ass_styles ASS styles
122  * @{
123  */
124  void (*text)(void *priv, const char *text, int len);
125  void (*new_line)(void *priv, int forced);
126  void (*style)(void *priv, char style, int close);
127  void (*color)(void *priv, unsigned int /* color */, unsigned int color_id);
128  void (*alpha)(void *priv, int alpha, int alpha_id);
129  void (*font_name)(void *priv, const char *name);
130  void (*font_size)(void *priv, int size);
131  void (*alignment)(void *priv, int alignment);
132  void (*cancel_overrides)(void *priv, const char *style);
133  /** @} */
134 
135  /**
136  * @defgroup ass_functions ASS functions
137  * @{
138  */
139  void (*move)(void *priv, int x1, int y1, int x2, int y2, int t1, int t2);
140  void (*origin)(void *priv, int x, int y);
141  /** @} */
142 
143  /**
144  * @defgroup ass_end end of Dialogue Event
145  * @{
146  */
147  void (*end)(void *priv);
148  /** @} */
150 
151 /**
152  * Split override codes out of a ASS "Dialogue" Text field.
153  *
154  * @param callbacks Set of callback functions called for each override code
155  * encountered.
156  * @param priv Opaque pointer passed to the callback functions.
157  * @param buf The ASS "Dialogue" Text field to split.
158  * @return >= 0 on success otherwise an error code <0
159  */
160 int ff_ass_split_override_codes(const ASSCodesCallbacks *callbacks, void *priv,
161  const char *buf);
162 
163 /**
164  * Find an ASSStyle structure by its name.
165  *
166  * @param ctx Context previously initialized by ff_ass_split().
167  * @param style name of the style to search for.
168  * @return the ASSStyle corresponding to style, or NULL if style can't be found
169  */
170 ASSStyle *ff_ass_style_get(ASSSplitContext *ctx, const char *style);
171 
172 #endif /* AVCODEC_ASS_SPLIT_H */
const char * name
Definition: avisynth_c.h:675
char * style
name of the ASSStyle to use with this dialog
Definition: ass_split.h:60
float timer
time multiplier to apply to SSA clock (in %)
Definition: ass_split.h:33
ASSSplitContext * ff_ass_split(const char *buf)
Split a full ASS file or a ASS header from a string buffer and store the split structure in a newly a...
Definition: ass_split.c:303
fields extracted from the [Events] section
Definition: ass_split.h:56
ASSDialog * dialogs
array of split out dialogs
Definition: ass_split.h:73
y1
Definition: lab5.m:33
structure containing the whole split ASS data
Definition: ass_split.h:69
char * script_type
SSA script format version (eg.
Definition: ass_split.h:29
x1
Definition: genspecsines3.m:7
including without damages for loss of work computer failure or loss of data or any commercial damage and lost revenue or even if the UPF has been advised of the possibility of such damage the UPF will be liable under statutory product liability laws as far such laws apply to the Software The foregoing limitations will apply even if the above stated warranty disclaimer fails of its essential purpose Some jurisdictions do not allow the exclusion of indirect or consequential so some of the terms above may not be applicable to you AUDIT Upon days written UPF or a professional designated by UPF may audit your use of the Software You agree to cooperate with UPF s audit and provide reasonable assistance and access to information You agree to pay within days of written notification any fees applicable to your use of the Software in breach of your license rights If you do not UPF can end your license You agree that UPF shall not be responsible for any of your costs incurred in cooperating with the audit TERMINATION This Agreement is effective until terminated You may terminate this Agreement at any time by destroying all copies of Software This Agreement will terminate immediately without notice from UPF if you fail to comply with any provision of this Agreement Either party may terminate this Agreement immediately should any Software or in either party s opinion be likely to the subject of a claim of infringement of any intellectual or industrial property right Upon you must destroy all copies of Software Provisions that survive termination or expiration include those relating to limitation of liability limitation and others which by their nature are intended to and apply to both parties respective successors and assignees EXPORT REGULATIONS Software and technical data delivered under this Agreement may be subject to export or import regulations You agree to comply strictly with all such laws and regulations and acknowledge that you have the responsibility to obtain such licenses to re or import as may be required after delivery to you TRADEMARKS This Licence does not grant permission to use the trade service or names of the except as required for reasonable and customary use in describing the origin of the Software and reproducing the content of the copyright notice GOVERNING LAW JURISDICTION Any action related to this Agreement will be governed by Spanish law No choice of law rules of any jurisdiction will apply Any conflict or dispute resulting from this License and use of the Software will be subject to the exclusive jurisdiction of the courts of the City of Spain SEVERABILITY If any provision of the Licence is invalid or unenforceable under applicable this will not affect the validity or enforceability of the Licence as a whole Such provision will be construed and or reformed so as necessary to make it valid and enforceable If this is not the License will terminate ASSIGNMENT You may not assign this agreement or give or transfer the Software or an interest in it to another individual or entity If you grant a security interest in the the secured party has no right to use or transfer the Software FORCE nor is UPF responsible for any third party claims against Licensee PRIVACY desenvolupament i under the responsibility of Universitat Pompeu Fabra works or projects In but without the data is processed for the purpose of communicating with Licensee regarding any administrative and legal judicial purposes Collection We collect personal data including affiliation and email address Only the data marked with a star is obligatory Users must provide true and accurate personal profile data Users must NOT upload any sensitive data regarding racial origin
text(-8, 1,'a)')
int back_color
color of the subtitle outline or shadow
Definition: ass_split.h:44
char * text
actual text which will be displayed as a subtitle, can include style override control codes (see ff_a...
Definition: ass_split.h:61
int alignment
position of the text (left, center, top...), defined after the layout of the numpad (1-3 sub...
Definition: ass_split.h:48
int layer
higher numbered layers are drawn over lower numbered
Definition: ass_split.h:57
static const uint32_t color[16+AV_CLASS_CATEGORY_NB]
Definition: log.c:77
end end
int bold
whether text is bold (1) or not (0)
Definition: ass_split.h:45
ASSStyle * ff_ass_style_get(ASSSplitContext *ctx, const char *style)
Find an ASSStyle structure by its name.
Definition: ass_split.c:465
Discrete Time axis x
static double alpha(void *priv, double x, double y)
Definition: vf_geq.c:86
#define t1
Definition: regdef.h:29
int play_res_x
video width that ASS coords are referring to
Definition: ass_split.h:31
int font_size
font height
Definition: ass_split.h:42
int end
end time of the dialog in centiseconds
Definition: ass_split.h:59
int size
int play_res_y
video height that ASS coords are referring to
Definition: ass_split.h:32
int italic
whether text is italic (1) or not (0)
Definition: ass_split.h:46
Set of callback functions corresponding to each override codes that can be encountered in a "Dialogue...
Definition: ass_split.h:119
y2
Definition: lab5.m:34
void ff_ass_split_free(ASSSplitContext *ctx)
Free all the memory allocated for an ASSSplitContext.
Definition: ass_split.c:357
int primary_color
color that a subtitle will normally appear in
Definition: ass_split.h:43
typedef void(RENAME(mix_any_func_type))
ASSDialog * ff_ass_split_dialog(ASSSplitContext *ctx, const char *buf, int cache, int *number)
Split one or several ASS "Dialogue" lines from a string buffer and store them in a already initialize...
Definition: ass_split.c:338
static void close(AVCodecParserContext *s)
Definition: h264_parser.c:375
void * buf
Definition: avisynth_c.h:594
x2
Definition: genspecsines3.m:8
int start
start time of the dialog in centiseconds
Definition: ass_split.h:58
char * collisions
how subtitles are moved to prevent collisions
Definition: ass_split.h:30
void(* alignment)(void *priv, int alignment)
Definition: ass_split.h:131
char * font_name
font face (case sensitive)
Definition: ass_split.h:41
ASSScriptInfo script_info
general information about the SSA script
Definition: ass_split.h:70
fields extracted from the [V4(+) Styles] section
Definition: ass_split.h:39
int ff_ass_split_override_codes(const ASSCodesCallbacks *callbacks, void *priv, const char *buf)
Split override codes out of a ASS "Dialogue" Text field.
Definition: ass_split.c:370
void(* alpha)(void *priv, int alpha, int alpha_id)
Definition: ass_split.h:128
char * name
name of the tyle (case sensitive)
Definition: ass_split.h:40
void(* text)(void *priv, const char *text, int len)
Definition: ass_split.h:124
int dialogs_count
number of ASSDialog in the dialogs array
Definition: ass_split.h:74
function y
Definition: D.m:1
int len
int styles_count
number of ASSStyle in the styles array
Definition: ass_split.h:72
About Git write you should know how to use GIT properly Luckily Git comes with excellent documentation git help man git shows you the available git< command > help man git< command > shows information about the subcommand< command > The most comprehensive manual is the website Git Reference visit they are quite exhaustive You do not need a special username or password All you need is to provide a ssh public key to the Git server admin What follows now is a basic introduction to Git and some FFmpeg specific guidelines Read it at least if you are granted commit privileges to the FFmpeg project you are expected to be familiar with these rules I if not You can get git from etc no matter how small Every one of them has been saved from looking like a fool by this many times It s very easy for stray debug output or cosmetic modifications to slip please avoid problems through this extra level of scrutiny For cosmetics only commits you should e g by running git config global user name My Name git config global user email my email which is either set in your personal configuration file through git config core editor or set by one of the following environment VISUAL or EDITOR Log messages should be concise but descriptive Explain why you made a what you did will be obvious from the changes themselves most of the time Saying just bug fix or is bad Remember that people of varying skill levels look at and educate themselves while reading through your code Don t include filenames in log Git provides that information Possibly make the commit message have a descriptive first an empty line and then a full description The first line will be used to name the patch by git format patch Renaming moving copying files or contents of making those normal commits mv cp path file otherpath otherfile git add[-A] git commit Do not move
Definition: git-howto.txt:153
fields extracted from the [Script Info] section
Definition: ass_split.h:28
void(* style)(void *priv, char style, int close)
Definition: ass_split.h:126
#define t2
Definition: regdef.h:30
int underline
whether text is underlined (1) or not (0)
Definition: ass_split.h:47
ASSStyle * styles
array of split out styles
Definition: ass_split.h:71