30 #define STYLE_FLAG_BOLD 1
31 #define STYLE_FLAG_ITALIC 2
32 #define STYLE_FLAG_UNDERLINE 4
34 static int text_to_ass(AVBPrint *
buf,
const char *text,
const char *text_end,
35 char **style_start,
char **style_end,
36 uint8_t **style_flags,
int style_entries)
39 while (text < text_end) {
40 for (i = 0; i < style_entries; i++) {
41 if (*style_flags[i] && text == style_start[i]) {
62 for (i = 0; i < style_entries; i++) {
63 if (*style_flags[i] && text == style_end[i]) {
92 int ret, ts_start, ts_end;
94 char *ptr = avpkt->
data;
97 int text_length, tsmb_type, style_entries;
98 uint64_t tsmb_size, tracksize;
99 char **style_start = { 0, };
100 char **style_end = { 0, };
101 uint8_t **style_flags = { 0, };
103 int index, i, size_var;
107 if (!ptr || avpkt->
size < 2)
117 if (avpkt->
size == 2)
126 end = ptr +
FFMIN(2 + text_length, avpkt->
size);
137 tracksize = 2 + text_length;
140 if (text_length + 2 != avpkt->size) {
141 while (tracksize + 8 <= avpkt->size) {
143 tsmb = ptr + tracksize - 2;
149 if (tsmb_size == 1) {
150 if (tracksize + 16 > avpkt->size)
159 if (tracksize + tsmb_size > avpkt->size)
162 if (tsmb_type ==
MKBETAG(
's',
't',
'y',
'l')) {
163 if (tracksize + size_var > avpkt->size)
169 if (tracksize + size_var + style_entries * 12 > avpkt->size)
172 for(i = 0; i < style_entries; i++) {
173 style_pos = ptr +
AV_RB16(tsmb);
177 style_pos = ptr +
AV_RB16(tsmb);
196 for(i = 0; i < style_entries; i++) {
203 tracksize = tracksize + tsmb_size;
212 *got_sub_ptr = sub->num_rects > 0;
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
void av_bprintf(AVBPrint *buf, const char *fmt,...)
ptrdiff_t const GLvoid * data
memory handling functions
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
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
static av_cold int end(AVCodecContext *avctx)
int ff_ass_subtitle_header_default(AVCodecContext *avctx)
Generate a suitable AVCodecContext.subtitle_header for SUBTITLE_ASS with default style.
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 int mov_text_init(AVCodecContext *avctx)
#define STYLE_FLAG_UNDERLINE
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
#define AV_BPRINT_SIZE_UNLIMITED
static int text_to_ass(AVBPrint *buf, const char *text, const char *text_end, char **style_start, char **style_end, uint8_t **style_flags, int style_entries)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
const char * name
Name of the codec implementation.
void av_dynarray_add(void *tab_ptr, int *nb_ptr, void *elem)
Add an element to a dynamic array.
Libavcodec external API header.
#define STYLE_FLAG_ITALIC
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_WB16 unsigned int_TMPL AV_RB8
int ff_ass_add_rect_bprint(AVSubtitle *sub, AVBPrint *buf, int ts_start, int duration)
Same as ff_ass_add_rect_bprint, but taking an AVBPrint buffer instead of a string, and assuming raw=0.
main external API structure.
rational number numerator/denominator
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_RB64
common internal and external API header
AVCodec ff_movtext_decoder
#define MKBETAG(a, b, c, d)
static int mov_text_decode_frame(AVCodecContext *avctx, void *data, int *got_sub_ptr, AVPacket *avpkt)
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
Append char c n times to a print buffer.