FFmpeg
Data Structures | Typedefs | Enumerations | Functions | Variables
ass_split.c File Reference
#include <limits.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "libavutil/error.h"
#include "libavutil/macros.h"
#include "libavutil/mem.h"
#include "ass_split.h"

Go to the source code of this file.

Data Structures

struct  ASSFields
 
struct  ASSSection
 
struct  ASSSplitContext
 This struct can be casted to ASS to access to the split data. More...
 

Typedefs

typedef int(* ASSConvertFunc) (void *dest, const char *buf, int len)
 

Enumerations

enum  ASSFieldType {
  ASS_STR, ASS_INT, ASS_FLT, ASS_COLOR,
  ASS_TIMESTAMP, ASS_ALGN
}
 

Functions

static int convert_str (void *dest, const char *buf, int len)
 
static int convert_int (void *dest, const char *buf, int len)
 
static int convert_flt (void *dest, const char *buf, int len)
 
static int convert_color (void *dest, const char *buf, int len)
 
static int convert_timestamp (void *dest, const char *buf, int len)
 
static int convert_alignment (void *dest, const char *buf, int len)
 
static uint8_t * realloc_section_array (ASSSplitContext *ctx)
 
static int is_eol (char buf)
 
static const char * skip_space (const char *buf)
 
static intget_default_field_orders (const ASSSection *section, int *number)
 
static const char * ass_split_section (ASSSplitContext *ctx, const char *buf)
 
static int ass_split (ASSSplitContext *ctx, const char *buf)
 
ASSSplitContextff_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 allocated context. More...
 
static void free_section (ASSSplitContext *ctx, const ASSSection *section)
 
void ff_ass_free_dialog (ASSDialog **dialogp)
 Free a dialogue obtained from ff_ass_split_dialog(). More...
 
ASSDialogff_ass_split_dialog (ASSSplitContext *ctx, const char *buf)
 Split one ASS Dialogue line from a string buffer. More...
 
void ff_ass_split_free (ASSSplitContext *ctx)
 Free all the memory allocated for an ASSSplitContext. More...
 
int ff_ass_split_override_codes (const ASSCodesCallbacks *callbacks, void *priv, const char *buf)
 Split override codes out of a ASS "Dialogue" Text field. More...
 
ASSStyleff_ass_style_get (ASSSplitContext *ctx, const char *style)
 Find an ASSStyle structure by its name. More...
 

Variables

static const ASSSection ass_sections []
 
static const ASSConvertFunc convert_func []
 

Typedef Documentation

◆ ASSConvertFunc

typedef int(* ASSConvertFunc) (void *dest, const char *buf, int len)

Definition at line 150 of file ass_split.c.

Enumeration Type Documentation

◆ ASSFieldType

Enumerator
ASS_STR 
ASS_INT 
ASS_FLT 
ASS_COLOR 
ASS_TIMESTAMP 
ASS_ALGN 

Definition at line 33 of file ass_split.c.

Function Documentation

◆ convert_str()

static int convert_str ( void *  dest,
const char *  buf,
int  len 
)
static

Definition at line 152 of file ass_split.c.

◆ convert_int()

static int convert_int ( void *  dest,
const char *  buf,
int  len 
)
static

Definition at line 164 of file ass_split.c.

◆ convert_flt()

static int convert_flt ( void *  dest,
const char *  buf,
int  len 
)
static

Definition at line 168 of file ass_split.c.

◆ convert_color()

static int convert_color ( void *  dest,
const char *  buf,
int  len 
)
static

Definition at line 172 of file ass_split.c.

◆ convert_timestamp()

static int convert_timestamp ( void *  dest,
const char *  buf,
int  len 
)
static

Definition at line 177 of file ass_split.c.

◆ convert_alignment()

static int convert_alignment ( void *  dest,
const char *  buf,
int  len 
)
static

Definition at line 184 of file ass_split.c.

◆ realloc_section_array()

static uint8_t* realloc_section_array ( ASSSplitContext ctx)
static

Definition at line 213 of file ass_split.c.

Referenced by ass_split_section().

◆ is_eol()

static int is_eol ( char  buf)
inlinestatic

Definition at line 228 of file ass_split.c.

Referenced by ass_split_section().

◆ skip_space()

static const char* skip_space ( const char *  buf)
inlinestatic

Definition at line 233 of file ass_split.c.

Referenced by ass_split_section(), and ff_ass_split_dialog().

◆ get_default_field_orders()

static int* get_default_field_orders ( const ASSSection section,
int number 
)
static

Definition at line 240 of file ass_split.c.

Referenced by ass_split_section().

◆ ass_split_section()

static const char* ass_split_section ( ASSSplitContext ctx,
const char *  buf 
)
static

Definition at line 255 of file ass_split.c.

Referenced by ass_split().

◆ ass_split()

static int ass_split ( ASSSplitContext ctx,
const char *  buf 
)
static

Definition at line 357 of file ass_split.c.

Referenced by ff_ass_split().

◆ ff_ass_split()

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 allocated context.

Parameters
bufString containing the ASS formatted data.
Returns
Newly allocated struct containing split data.

Definition at line 382 of file ass_split.c.

Referenced by mov_text_encode_init(), srt_encode_init(), ttml_encode_init(), and webvtt_encode_init().

◆ free_section()

static void free_section ( ASSSplitContext ctx,
const ASSSection section 
)
static

Definition at line 397 of file ass_split.c.

Referenced by ff_ass_split_free().

◆ ff_ass_free_dialog()

void ff_ass_free_dialog ( ASSDialog **  dialogp)

Free a dialogue obtained from ff_ass_split_dialog().

Definition at line 421 of file ass_split.c.

Referenced by encode_frame(), ff_ass_split_dialog(), mov_text_encode_frame(), ttml_encode_frame(), and webvtt_encode_frame().

◆ ff_ass_split_dialog()

ASSDialog* ff_ass_split_dialog ( ASSSplitContext ctx,
const char *  buf 
)

Split one ASS Dialogue line from a string buffer.

Parameters
ctxContext previously initialized by ff_ass_split().
bufString containing the ASS "Dialogue" line.
Returns
Pointer to the split ASSDialog. Must be freed with ff_ass_free_dialog()

Definition at line 433 of file ass_split.c.

Referenced by encode_frame(), mov_text_encode_frame(), ttml_encode_frame(), and webvtt_encode_frame().

◆ ff_ass_split_free()

void ff_ass_split_free ( ASSSplitContext ctx)

Free all the memory allocated for an ASSSplitContext.

Parameters
ctxContext previously initialized by ff_ass_split().

Definition at line 470 of file ass_split.c.

Referenced by ff_ass_split(), mov_text_encode_close(), srt_encode_close(), ttml_encode_close(), and webvtt_encode_close().

◆ ff_ass_split_override_codes()

int ff_ass_split_override_codes ( const ASSCodesCallbacks callbacks,
void *  priv,
const char *  buf 
)

Split override codes out of a ASS "Dialogue" Text field.

Parameters
callbacksSet of callback functions called for each override code encountered.
privOpaque pointer passed to the callback functions.
bufThe ASS "Dialogue" Text field to split.
Returns
>= 0 on success otherwise an error code <0

Definition at line 483 of file ass_split.c.

Referenced by encode_frame(), mov_text_encode_frame(), ttml_encode_frame(), and webvtt_encode_frame().

◆ ff_ass_style_get()

ASSStyle* ff_ass_style_get ( ASSSplitContext ctx,
const char *  style 
)

Find an ASSStyle structure by its name.

Parameters
ctxContext previously initialized by ff_ass_split().
stylename of the style to search for.
Returns
the ASSStyle corresponding to style, or NULL if style can't be found

Definition at line 578 of file ass_split.c.

Referenced by encode_sample_description(), mov_text_cancel_overrides_cb(), mov_text_dialog(), srt_style_apply(), and webvtt_style_apply().

Variable Documentation

◆ ass_sections

const ASSSection ass_sections[]
static

Definition at line 58 of file ass_split.c.

Referenced by ass_split(), ass_split_section(), ff_ass_split_free(), and realloc_section_array().

◆ convert_func

const ASSConvertFunc convert_func[]
static
ASS_TIMESTAMP
@ ASS_TIMESTAMP
Definition: ass_split.c:38
convert_str
static int convert_str(void *dest, const char *buf, int len)
Definition: ass_split.c:152
convert_flt
static int convert_flt(void *dest, const char *buf, int len)
Definition: ass_split.c:168
ASS_ALGN
@ ASS_ALGN
Definition: ass_split.c:39
convert_color
static int convert_color(void *dest, const char *buf, int len)
Definition: ass_split.c:172
ASS_STR
@ ASS_STR
Definition: ass_split.c:34
convert_alignment
static int convert_alignment(void *dest, const char *buf, int len)
Definition: ass_split.c:184
ASS_FLT
@ ASS_FLT
Definition: ass_split.c:36
convert_timestamp
static int convert_timestamp(void *dest, const char *buf, int len)
Definition: ass_split.c:177
ASS_COLOR
@ ASS_COLOR
Definition: ass_split.c:37
convert_int
static int convert_int(void *dest, const char *buf, int len)
Definition: ass_split.c:164
ASS_INT
@ ASS_INT
Definition: ass_split.c:35