Go to the documentation of this file.
32 #define STYLE_FLAG_BOLD (1<<0)
33 #define STYLE_FLAG_ITALIC (1<<1)
34 #define STYLE_FLAG_UNDERLINE (1<<2)
35 #define STYLE_RECORD_SIZE 12
38 #define STYL_BOX (1<<0)
39 #define HLIT_BOX (1<<1)
40 #define HCLR_BOX (1<<2)
42 #define av_bprint_append_any(buf, data, size) av_bprint_append_data(buf, ((const char*)data), size)
70 uint16_t style_entries;
87 for (j = 0; j <
s->count; j++) {
100 tsmb_size =
AV_RB32(&tsmb_size);
102 s->style_fontID = 0x00 | 0x01<<8;
103 s->style_fontsize = 0x12;
104 s->style_color =
MKTAG(0xFF, 0xFF, 0xFF, 0xFF);
110 for (j = 0; j <
s->count; j++) {
127 tsmb_size =
AV_RB32(&tsmb_size);
140 tsmb_size =
AV_RB32(&tsmb_size);
161 static const uint8_t text_sample_entry[] = {
162 0x00, 0x00, 0x00, 0x00,
165 0x00, 0x00, 0x00, 0x00,
178 0xFF, 0xFF, 0xFF, 0xFF,
181 0x00, 0x00, 0x00, 0x12,
187 'S',
'e',
'r',
'i',
'f',
214 s->style_attributes_temp =
av_malloc(
sizeof(*
s->style_attributes_temp));
216 if (!
s->style_attributes_temp) {
222 s->style_attributes_temp->style_flag = 0;
223 s->style_attributes_temp->style_start =
AV_RB16(&
s->text_pos);
225 if (
s->style_attributes_temp->style_flag) {
226 s->style_attributes_temp->style_end =
AV_RB16(&
s->text_pos);
228 s->style_attributes_temp =
av_malloc(
sizeof(*
s->style_attributes_temp));
229 if (!
s->style_attributes_temp) {
236 s->style_attributes_temp->style_flag =
s->style_attributes[
s->count - 1]->style_flag;
237 s->style_attributes_temp->style_start =
AV_RB16(&
s->text_pos);
239 s->style_attributes_temp->style_flag = 0;
240 s->style_attributes_temp->style_start =
AV_RB16(&
s->text_pos);
254 }
else if (!
s->style_attributes_temp) {
258 s->style_attributes_temp->style_end =
AV_RB16(&
s->text_pos);
261 s->style_attributes_temp =
av_malloc(
sizeof(*
s->style_attributes_temp));
263 if (!
s->style_attributes_temp) {
270 s->style_attributes_temp->style_flag =
s->style_attributes[
s->count - 1]->style_flag;
282 if (
s->style_attributes_temp->style_flag) {
283 s->style_attributes_temp->style_start =
AV_RB16(&
s->text_pos);
299 s->hclr.color =
color | (0xFF << 24);
310 uint16_t
i = 0,
ret = 0;
315 else if ((
c & 0xE0) == 0xC0)
317 else if ((
c & 0xF0) == 0xE0)
319 else if ((
c & 0xF8) == 0xF0)
334 s->text_pos += utf8_len ? utf8_len :
len;
335 s->byte_count +=
len;
365 s->style_entries = 0;
374 #if FF_API_ASS_TIMING
375 if (!strncmp(ass,
"Dialogue: ", 10)) {
378 for (; dialog && num--; dialog++) {
388 #if FF_API_ASS_TIMING
405 if (!
s->buffer.len) {
410 if (
s->buffer.len > bufsize - 3) {
416 memcpy(
buf,
s->buffer.str,
s->buffer.len);
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_BPRINT_SIZE_UNLIMITED
static av_cold int init(AVCodecContext *avctx)
Set of callback functions corresponding to each override codes that can be encountered in a "Dialogue...
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
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 an already initializ...
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
#define MKTAG(a, b, c, d)
uint8_t * subtitle_header
Header containing style information for text subtitles.
static av_cold int mov_text_encode_init(AVCodecContext *avctx)
StyleBox * style_attributes_temp
void av_bprint_append_data(AVBPrint *buf, const char *data, unsigned size)
Append data to a print buffer.
const static size_t box_count
@ SUBTITLE_ASS
Formatted text, the ass field must be set by the decoder and is authoritative.
StyleBox ** style_attributes
static void mov_text_color_cb(void *priv, unsigned int color, unsigned int color_id)
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
char * ass
0 terminated ASS/SSA compatible event line.
void ff_ass_free_dialog(ASSDialog **dialogp)
Free a dialogue obtained from ff_ass_split_dialog2().
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static void mov_text_text_cb(void *priv, const char *text, int len)
static const Box box_types[]
static void mov_text_cleanup(MovTextContext *s)
#define STYLE_FLAG_UNDERLINE
ASSDialog * ff_ass_split_dialog2(ASSSplitContext *ctx, const char *buf)
Split one ASS Dialogue line from a string buffer.
#define STYLE_FLAG_ITALIC
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...
static uint16_t utf8_strlen(const char *text, 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
static int av_bprint_is_complete(const AVBPrint *buf)
Test if the print buffer is complete (not truncated).
void ff_ass_split_free(ASSSplitContext *ctx)
Free all the memory allocated for an ASSSplitContext.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
void av_dynarray_add(void *tab_ptr, int *nb_ptr, void *elem)
Add the pointer to an element to a dynamic array.
char * text
actual text which will be displayed as a subtitle, can include style override control codes (see ff_a...
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
static void encode(AVCodecContext *ctx, AVFrame *frame, AVPacket *pkt, FILE *output)
static int mov_text_encode_close(AVCodecContext *avctx)
static const ASSCodesCallbacks mov_text_callbacks
#define STYLE_RECORD_SIZE
#define i(width, name, range_min, range_max)
AVCodec ff_movtext_encoder
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
static int mov_text_encode_frame(AVCodecContext *avctx, unsigned char *buf, int bufsize, const AVSubtitle *sub)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
const char * name
Name of the codec implementation.
static void mov_text_new_line_cb(void *priv, int forced)
static void encode_hclr(MovTextContext *s, uint32_t tsmb_type)
#define AV_INPUT_BUFFER_PADDING_SIZE
#define FF_ARRAY_ELEMS(a)
main external API structure.
void av_bprint_clear(AVBPrint *buf)
Reset the string to "" but keep internal allocated data.
fields extracted from the [Events] section
static void encode_styl(MovTextContext *s, uint32_t tsmb_type)
#define av_bprint_append_any(buf, data, size)
static void mov_text_style_cb(void *priv, const char style, int close)
static void encode_hlit(MovTextContext *s, uint32_t tsmb_type)
#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.
void(* encode)(MovTextContext *s, uint32_t tsmb_type)
ASSSplitContext * ass_ctx
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_RB16
void(* text)(void *priv, const char *text, int len)