31 #define STYLE_FLAG_BOLD (1<<0) 32 #define STYLE_FLAG_ITALIC (1<<1) 33 #define STYLE_FLAG_UNDERLINE (1<<2) 35 #define BOX_SIZE_INITIAL 40 37 #define STYL_BOX (1<<0) 38 #define HLIT_BOX (1<<1) 39 #define HCLR_BOX (1<<2) 40 #define TWRP_BOX (1<<3) 43 #define BOTTOM_CENTER 2 44 #define BOTTOM_RIGHT 3 46 #define MIDDLE_CENTER 5 47 #define MIDDLE_RIGHT 6 52 #define RGB_TO_BGR(c) (((c) & 0xff) << 16 | ((c) & 0xff00) | (((c) >> 16) & 0xff)) 129 for(i = 0; i < m->
count_s; i++) {
145 for(i = 0; i < m->
count_f; i++) {
156 int i, box_size, font_length;
157 int8_t v_align, h_align;
169 h_align = *tx3g_ptr++;
170 v_align = *tx3g_ptr++;
243 font_length = *tx3g_ptr++;
245 box_size = box_size + font_length;
264 tx3g_ptr = tx3g_ptr + font_length;
303 int style_entries =
AV_RB16(tsmb);
364 const char *start = text;
375 static int text_to_ass(AVBPrint *buf,
const char *text,
const char *text_end,
381 int style_active = 0;
385 if (text < text_end && m->box_flags &
TWRP_BOX) {
393 while (text < text_end) {
413 color = m->
s[entry]->
color;
440 av_bprintf(buf,
"{\\1c&H000000&}{\\2c&HFFFFFF&}");
458 for (i = 0; i <
len; i++) {
512 char *ptr = avpkt->
data;
514 int text_length, tsmb_type, ret_tsmb;
519 if (!ptr || avpkt->
size < 2)
529 if (avpkt->
size == 2)
538 end = ptr +
FFMIN(2 + text_length, avpkt->
size);
550 if (text_length + 2 != avpkt->
size) {
559 if (tsmb_size == 1) {
569 if (tsmb_size == 0) {
578 if (tsmb_type == box_types[i].
type) {
581 ret_tsmb = box_types[
i].
decode(tsmb, m, avpkt);
616 #define OFFSET(x) offsetof(MovTextContext, x) 617 #define FLAGS AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_SUBTITLE_PARAM 620 {
"height",
"Frame height, usually video height",
OFFSET(frame_height),
AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS },
637 .priv_class = &mov_text_decoder_class,
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
void av_bprintf(AVBPrint *buf, const char *fmt,...)
static const size_t box_count
#define GET_UTF8(val, GET_BYTE, ERROR)
Convert a UTF-8 character (up to 4 bytes) to its 32-bit UCS-4 encoded form.
static int decode_twrp(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt)
static void flush(AVCodecContext *avctx)
#define ASS_DEFAULT_BORDERSTYLE
static const AVOption options[]
#define LIBAVUTIL_VERSION_INT
Memory handling functions.
static av_cold int init(AVCodecContext *avctx)
const char * av_default_item_name(void *ptr)
Return the context name.
int ff_ass_add_rect(AVSubtitle *sub, const char *dialog, int readorder, int layer, const char *style, const char *speaker)
Add an ASS dialog to a subtitle.
static void error(const char *err)
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
int ff_ass_subtitle_header_full(AVCodecContext *avctx, int play_res_x, int play_res_y, const char *font, int font_size, int primary_color, int secondary_color, int outline_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 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.
static int get_utf8_length_at(const char *text, const char *text_end)
static int mov_text_init(AVCodecContext *avctx)
static void mov_text_cleanup(MovTextContext *m)
#define AV_CODEC_FLAG2_RO_FLUSH_NOOP
Do not reset ASS ReadOrder field on flush (subtitles decoding)
#define STYLE_FLAG_UNDERLINE
#define ASS_DEFAULT_PLAYRESY
static const AVClass mov_text_decoder_class
#define i(width, name, range_min, range_max)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#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)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
static int text_to_ass(AVBPrint *buf, const char *text, const char *text_end, AVCodecContext *avctx)
const char * name
Name of the codec implementation.
static void mov_text_flush(AVCodecContext *avctx)
#define STYLE_FLAG_ITALIC
#define FF_ARRAY_ELEMS(a)
static int decode_hlit(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt)
int(* decode)(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt)
Libavcodec external API header.
main external API structure.
Describe the class of an AVClass context structure.
static int decode_hclr(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt)
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)
void av_dynarray_add(void *tab_ptr, int *nb_ptr, void *elem)
Add the pointer to an element to a dynamic array.
static void mov_text_cleanup_ftab(MovTextContext *m)
int flags2
AV_CODEC_FLAG2_*.
static int mov_text_decode_frame(AVCodecContext *avctx, void *data, int *got_sub_ptr, AVPacket *avpkt)
#define ASS_DEFAULT_PLAYRESX
This structure stores compressed data.
static int mov_text_tx3g(AVCodecContext *avctx, MovTextContext *m)
void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
Append char c n times to a print buffer.