30 #define STYLE_FLAG_BOLD (1<<0)
31 #define STYLE_FLAG_ITALIC (1<<1)
32 #define STYLE_FLAG_UNDERLINE (1<<2)
34 #define BOX_SIZE_INITIAL 40
36 #define STYL_BOX (1<<0)
37 #define HLIT_BOX (1<<1)
38 #define HCLR_BOX (1<<2)
39 #define TWRP_BOX (1<<3)
42 #define BOTTOM_CENTER 2
43 #define BOTTOM_RIGHT 3
45 #define MIDDLE_CENTER 5
46 #define MIDDLE_RIGHT 6
114 for(i = 0; i < m->
count_s; i++) {
128 for(i = 0; i < m->
count_f; i++) {
139 int i, box_size, font_length;
140 int8_t v_align, h_align;
153 h_align = *tx3g_ptr++;
154 v_align = *tx3g_ptr++;
187 style_fontID =
AV_RB16(tx3g_ptr);
223 font_length = *tx3g_ptr++;
225 box_size = box_size + font_length;
244 tx3g_ptr = tx3g_ptr + font_length;
331 if (text < text_end && m->box_flags &
TWRP_BOX) {
339 while (text < text_end) {
374 av_bprintf(buf,
"{\\1c&H000000&}{\\2c&HFFFFFF&}");
381 av_bprintf(buf,
"{\\1c&HFFFFFF&}{\\2c&H000000&}");
427 int ret, ts_start, ts_end;
429 char *ptr = avpkt->
data;
431 int text_length, tsmb_type, ret_tsmb;
435 if (!ptr || avpkt->
size < 2)
445 if (avpkt->
size == 2)
454 end = ptr +
FFMIN(2 + text_length, avpkt->
size);
465 m->tracksize = 2 + text_length;
466 m->style_entries = 0;
471 if (text_length + 2 != avpkt->size) {
472 while (
m->tracksize + 8 <= avpkt->size) {
474 tsmb = ptr +
m->tracksize - 2;
480 if (tsmb_size == 1) {
481 if (
m->tracksize + 16 > avpkt->size)
490 if (
m->tracksize + tsmb_size > avpkt->size)
494 if (tsmb_type == box_types[i].
type) {
495 if (
m->tracksize +
m->size_var + box_types[i].
base_size > avpkt->size)
497 ret_tsmb = box_types[i].
decode(tsmb,
m, avpkt);
502 m->tracksize =
m->tracksize + tsmb_size;
513 *got_sub_ptr = sub->num_rects > 0;
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
void av_bprintf(AVBPrint *buf, const char *fmt,...)
static const size_t box_count
static int decode_twrp(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt)
ptrdiff_t const GLvoid * data
#define ASS_DEFAULT_BORDERSTYLE
int(* decode)(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt)
memory handling functions
int ff_ass_subtitle_header(AVCodecContext *avctx, const char *font, int font_size, int color, int back_color, int bold, int italic, int underline, int border_style, int alignment)
Generate a suitable AVCodecContext.subtitle_header for SUBTITLE_ASS.
static av_cold int init(AVCodecContext *avctx)
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.
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
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)
static void mov_text_cleanup(MovTextContext *m)
#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 const Box box_types[]
#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.
#define STYLE_FLAG_ITALIC
#define FF_ARRAY_ELEMS(a)
static int decode_hlit(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt)
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
Libavcodec external API header.
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_RB24
int ff_ass_add_rect_bprint(AVSubtitle *sub, AVBPrint *buf, int ts_start, int duration)
Same as ff_ass_add_rect, but taking an AVBPrint buffer instead of a string, and assuming raw=0...
main external API structure.
rational number numerator/denominator
static int decode_hclr(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt)
static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avpkt)
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
static int decode_styl(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt)
static int mov_text_decode_close(AVCodecContext *avctx)
AVCodec ff_movtext_decoder
#define MKBETAG(a, b, c, d)
static void mov_text_cleanup_ftab(MovTextContext *m)
static int mov_text_decode_frame(AVCodecContext *avctx, void *data, int *got_sub_ptr, AVPacket *avpkt)
This structure stores compressed data.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
static int mov_text_tx3g(AVCodecContext *avctx, MovTextContext *m)
static int text_to_ass(AVBPrint *buf, const char *text, const char *text_end, MovTextContext *m)
void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
Append char c n times to a print buffer.