Go to the documentation of this file.
54 .offset = offsetof(
ASS, script_info),
63 { .section =
"V4+ Styles",
64 .format_header =
"Format",
65 .fields_header =
"Style",
68 .offset_count = offsetof(
ASS, styles_count),
95 { .section =
"V4 Styles",
96 .format_header =
"Format",
97 .fields_header =
"Style",
100 .offset_count = offsetof(
ASS, styles_count),
122 { .section =
"Events",
123 .format_header =
"Format",
124 .fields_header =
"Dialogue",
127 .offset_count = offsetof(
ASS, dialogs_count),
154 *(
char **)dest =
str;
160 return sscanf(buf,
"%d", (
int *)dest) == 1;
164 return sscanf(buf,
"%f", (
float *)dest) == 1;
168 return sscanf(buf,
"&H%8x", (
int *)dest) == 1 ||
169 sscanf(buf,
"%d", (
int *)dest) == 1;
174 if ((
c = sscanf(buf,
"%d:%02d:%02d.%02d", &
h, &m, &
s, &cs)) == 4)
175 *(
int *)dest = 360000*
h + 6000*m + 100*
s + cs;
181 if (sscanf(buf,
"%d", &
a) == 1) {
183 *(
int *)dest =
a + ((
a&4) >> 1) - 5*!!(
a&8);
210 int *count = (
int *)((uint8_t *)&
ctx->ass +
section->offset_count);
211 void **section_ptr = (
void **)((uint8_t *)&
ctx->ass +
section->offset);
224 return buf ==
'\r' || buf ==
'\n' || buf == 0;
252 int *number = &
ctx->field_number[
ctx->current_section];
253 int *order =
ctx->field_order[
ctx->current_section];
256 while (buf && *buf) {
258 ctx->current_section = -1;
261 if (buf[0] ==
';' || (buf[0] ==
'!' && buf[1] ==
':'))
264 len = strcspn(buf,
":\r\n");
265 if (buf[
len] ==
':' &&
270 ctx->current_section =
i;
272 number = &
ctx->field_number[
ctx->current_section];
273 order =
ctx->field_order[
ctx->current_section];
278 if (
section->format_header && !order) {
280 if (!strncmp(buf,
section->format_header,
len) && buf[
len] ==
':') {
284 len = strcspn(buf,
", \r\n");
297 ctx->field_order[
ctx->current_section] = order;
303 if (!strncmp(buf,
section->fields_header,
len) && buf[
len] ==
':') {
305 if (!struct_ptr)
return NULL;
312 ctx->field_order[
ctx->current_section] = order;
316 for (
i=0; !
is_eol(*buf) &&
i < *number;
i++) {
317 int last =
i == *number - 1;
319 len = strcspn(buf, last ?
"\r\n" :
",\r\n");
322 ptr = struct_ptr +
section->fields[order[
i]].offset;
326 if (!last && *buf) buf++;
331 len = strcspn(buf,
":\r\n");
332 if (buf[
len] ==
':') {
336 uint8_t *ptr = (uint8_t *)&
ctx->ass +
section->offset;
345 buf += strcspn(buf,
"\n");
356 if (
ctx->current_section >= 0)
359 while (buf && *buf) {
360 if (sscanf(buf,
"[%15[0-9A-Za-z+ ]]%c",
section, &
c) == 2) {
361 buf += strcspn(buf,
"\n");
365 ctx->current_section =
i;
369 buf += strcspn(buf,
"\n");
381 if (buf && !strncmp(buf,
"\xef\xbb\xbf", 3))
383 ctx->current_section = -1;
393 uint8_t *ptr = (uint8_t *)&
ctx->ass +
section->offset;
394 int i, j, *count,
c = 1;
398 count = (
int *)((uint8_t *)&
ctx->ass +
section->offset_count);
403 for (
i=0;
i<*count;
i++, ptr +=
section->size)
452 len = last ? strlen(buf) : strcspn(buf,
",");
453 if (
len >= INT_MAX) {
480 const char *text =
NULL;
484 while (buf && *buf) {
486 (sscanf(buf,
"\\%1[nN]", new_line) == 1 ||
487 !strncmp(buf,
"{\\", 2))) {
491 if (sscanf(buf,
"\\%1[nN]", new_line) == 1) {
493 callbacks->new_line(priv, new_line[0] ==
'N');
495 }
else if (!strncmp(buf,
"{\\", 2)) {
497 while (*buf ==
'\\') {
498 char style[2],
c[2], sep[2], c_num[2] =
"0",
tmp[128] = {0};
499 unsigned int color = 0xFFFFFFFF;
501 int x1, y1, x2, y2,
t1 = -1,
t2 = -1;
502 if (sscanf(buf,
"\\%1[bisu]%1[01\\}]%n", style,
c, &
len) > 1) {
503 int close =
c[0] ==
'0' ? 1 :
c[0] ==
'1' ? 0 : -1;
507 }
else if (sscanf(buf,
"\\c%1[\\}]%n", sep, &
len) > 0 ||
508 sscanf(buf,
"\\c&H%X&%1[\\}]%n", &
color, sep, &
len) > 1 ||
509 sscanf(buf,
"\\%1[1234]c%1[\\}]%n", c_num, sep, &
len) > 1 ||
510 sscanf(buf,
"\\%1[1234]c&H%X&%1[\\}]%n", c_num, &
color, sep, &
len) > 2) {
513 }
else if (sscanf(buf,
"\\alpha%1[\\}]%n", sep, &
len) > 0 ||
514 sscanf(buf,
"\\alpha&H%2X&%1[\\}]%n", &
alpha, sep, &
len) > 1 ||
515 sscanf(buf,
"\\%1[1234]a%1[\\}]%n", c_num, sep, &
len) > 1 ||
516 sscanf(buf,
"\\%1[1234]a&H%2X&%1[\\}]%n", c_num, &
alpha, sep, &
len) > 2) {
519 }
else if (sscanf(buf,
"\\fn%1[\\}]%n", sep, &
len) > 0 ||
520 sscanf(buf,
"\\fn%127[^\\}]%1[\\}]%n",
tmp, sep, &
len) > 1) {
523 }
else if (sscanf(buf,
"\\fs%1[\\}]%n", sep, &
len) > 0 ||
524 sscanf(buf,
"\\fs%u%1[\\}]%n", &
size, sep, &
len) > 1) {
527 }
else if (sscanf(buf,
"\\a%1[\\}]%n", sep, &
len) > 0 ||
528 sscanf(buf,
"\\a%2u%1[\\}]%n", &an, sep, &
len) > 1 ||
529 sscanf(buf,
"\\an%1[\\}]%n", sep, &
len) > 0 ||
530 sscanf(buf,
"\\an%1u%1[\\}]%n", &an, sep, &
len) > 1) {
531 if (an != -1 && buf[2] !=
'n')
532 an = (an&3) + (an&4 ? 6 : an&8 ? 3 : 0);
535 }
else if (sscanf(buf,
"\\r%1[\\}]%n", sep, &
len) > 0 ||
536 sscanf(buf,
"\\r%127[^\\}]%1[\\}]%n",
tmp, sep, &
len) > 1) {
539 }
else if (sscanf(buf,
"\\move(%d,%d,%d,%d)%1[\\}]%n", &x1, &y1, &x2, &y2, sep, &
len) > 4 ||
540 sscanf(buf,
"\\move(%d,%d,%d,%d,%d,%d)%1[\\}]%n", &x1, &y1, &x2, &y2, &
t1, &
t2, sep, &
len) > 6) {
543 }
else if (sscanf(buf,
"\\pos(%d,%d)%1[\\}]%n", &x1, &y1, sep, &
len) > 2) {
545 callbacks->move(priv, x1, y1, x1, y1, -1, -1);
546 }
else if (sscanf(buf,
"\\org(%d,%d)%1[\\}]%n", &x1, &y1, sep, &
len) > 2) {
550 len = strcspn(buf+1,
"\\}") + 2;
577 if (!style || !*style)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Set of callback functions corresponding to each override codes that can be encountered in a "Dialogue...
static int convert_str(void *dest, const char *buf, int len)
static int is_eol(char buf)
static const ASSConvertFunc convert_func[]
static const OMX_CALLBACKTYPE callbacks
ASSDialog * ff_ass_split_dialog(ASSSplitContext *ctx, const char *buf)
Split one ASS Dialogue line from a string buffer.
static int convert_flt(void *dest, const char *buf, int len)
ASSStyle * styles
array of split out styles
char * style
name of the ASSStyle to use with this dialog
static const char * ass_split_section(ASSSplitContext *ctx, const char *buf)
static void free_section(ASSSplitContext *ctx, const ASSSection *section)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
static int convert_color(void *dest, const char *buf, int len)
void ff_ass_free_dialog(ASSDialog **dialogp)
Free a dialogue obtained from ff_ass_split_dialog().
#define FF_ARRAY_ELEMS(a)
static int convert_alignment(void *dest, const char *buf, int len)
const char * fields_header
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
static uint8_t * realloc_section_array(ASSSplitContext *ctx)
static const ASSSection ass_sections[]
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this field
the definition of that something depends on the semantic of the filter The callback must examine the status of the filter s links and proceed accordingly The status of output links is stored in the status_in and status_out fields and tested by the then the processing requires a frame on this link and the filter is expected to make efforts in that direction The status of input links is stored by the fifo and status_out fields
structure containing the whole split ASS data
fields extracted from the [Script Info] section
static int convert_timestamp(void *dest, const char *buf, int len)
This struct can be casted to ASS to access to the split data.
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...
int(* ASSConvertFunc)(void *dest, const char *buf, int len)
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
fields extracted from the [V4(+) Styles] section
void ff_ass_split_free(ASSSplitContext *ctx)
Free all the memory allocated for an ASSSplitContext.
char * text
actual text which will be displayed as a subtitle, can include style override control codes (see ff_a...
char * name
name of the tyle (case sensitive)
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
int av_reallocp_array(void *ptr, size_t nmemb, size_t size)
Allocate, reallocate, or free an array through a pointer to a pointer.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
ASSStyle * ff_ass_style_get(ASSSplitContext *ctx, const char *style)
Find an ASSStyle structure by its name.
#define i(width, name, range_min, range_max)
#define av_malloc_array(a, b)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
int styles_count
number of ASSStyle in the styles array
static int convert_int(void *dest, const char *buf, int len)
fields extracted from the [Events] section
static int ass_split(ASSSplitContext *ctx, const char *buf)
static const int16_t alpha[]
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int ff_ass_split_override_codes(const ASSCodesCallbacks *callbacks, void *priv, const char *buf)
Split override codes out of a ASS "Dialogue" Text field.
const char * format_header
static const char * skip_space(const char *buf)
int * field_order[FF_ARRAY_ELEMS(ass_sections)]
int field_number[FF_ARRAY_ELEMS(ass_sections)]
static int * get_default_field_orders(const ASSSection *section, int *number)