FFmpeg
Loading...
Searching...
No Matches
movtextenc.c File Reference
#include <stdarg.h>
#include "avcodec.h"
#include "libavutil/attributes.h"
#include "libavutil/opt.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mem.h"
#include "libavutil/common.h"
#include "ass_split.h"
#include "ass.h"
#include "bytestream.h"
#include "codec_internal.h"

Go to the source code of this file.

Data Structures

struct  StyleBox
 
struct  HighlightBox
 
struct  HilightcolorBox
 
struct  MovTextContext
 
struct  Box
 

Macros

#define STYLE_FLAG_BOLD   (1<<0)
 
#define STYLE_FLAG_ITALIC   (1<<1)
 
#define STYLE_FLAG_UNDERLINE   (1<<2)
 
#define STYLE_RECORD_SIZE   12
 
#define SIZE_ADD   10
 
#define STYL_BOX   (1<<0)
 
#define HLIT_BOX   (1<<1)
 
#define HCLR_BOX   (1<<2)
 
#define DEFAULT_STYLE_FONT_ID   0x01
 
#define DEFAULT_STYLE_FONTSIZE   0x12
 
#define DEFAULT_STYLE_COLOR   0xffffffff
 
#define DEFAULT_STYLE_FLAG   0x00
 
#define BGR_TO_RGB(c)
 
#define FONTSIZE_SCALE(s, fs)
 
#define av_bprint_append_any(buf, data, size)
 
#define OFFSET(x)
 
#define FLAGS   AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_SUBTITLE_PARAM
 

Functions

static void mov_text_cleanup (MovTextContext *s)
 
static void encode_styl (MovTextContext *s)
 
static void encode_hlit (MovTextContext *s)
 
static void encode_hclr (MovTextContext *s)
 
static av_cold int mov_text_encode_close (AVCodecContext *avctx)
 
static int encode_sample_description (AVCodecContext *avctx)
 
static av_cold int mov_text_encode_init (AVCodecContext *avctx)
 
static int mov_text_style_start (MovTextContext *s)
 
static uint8_t mov_text_style_to_flag (const char style)
 
static void mov_text_style_set (MovTextContext *s, uint8_t style_flags)
 
static void mov_text_style_cb (void *priv, const char style, int close)
 
static void mov_text_color_set (MovTextContext *s, uint32_t color)
 
static void mov_text_color_cb (void *priv, unsigned int color, unsigned int color_id)
 
static void mov_text_alpha_set (MovTextContext *s, uint8_t alpha)
 
static void mov_text_alpha_cb (void *priv, int alpha, int alpha_id)
 
static uint16_t find_font_id (MovTextContext *s, const char *name)
 
static void mov_text_font_name_set (MovTextContext *s, const char *name)
 
static void mov_text_font_name_cb (void *priv, const char *name)
 
static void mov_text_font_size_set (MovTextContext *s, int size)
 
static void mov_text_font_size_cb (void *priv, int size)
 
static void mov_text_end_cb (void *priv)
 
static void mov_text_ass_style_set (MovTextContext *s, ASSStyle *style)
 
static void mov_text_dialog (MovTextContext *s, ASSDialog *dialog)
 
static void mov_text_cancel_overrides_cb (void *priv, const char *style_name)
 
static unsigned utf8_strlen (const char *text, int len)
 
static void mov_text_text_cb (void *priv, const char *text, int len)
 
static void mov_text_new_line_cb (void *priv, int forced)
 
static int mov_text_encode_frame (AVCodecContext *avctx, unsigned char *buf, int bufsize, const AVSubtitle *sub)
 

Variables

static const Box box_types []
 
static const size_t box_count = FF_ARRAY_ELEMS(box_types)
 
static const ASSCodesCallbacks mov_text_callbacks
 
static const AVOption options []
 
static const AVClass mov_text_encoder_class
 
const FFCodec ff_movtext_encoder
 

Macro Definition Documentation

◆ STYLE_FLAG_BOLD

#define STYLE_FLAG_BOLD   (1<<0)

Definition at line 34 of file movtextenc.c.

◆ STYLE_FLAG_ITALIC

#define STYLE_FLAG_ITALIC   (1<<1)

Definition at line 35 of file movtextenc.c.

◆ STYLE_FLAG_UNDERLINE

#define STYLE_FLAG_UNDERLINE   (1<<2)

Definition at line 36 of file movtextenc.c.

◆ STYLE_RECORD_SIZE

#define STYLE_RECORD_SIZE   12

Definition at line 37 of file movtextenc.c.

Referenced by encode_styl().

◆ SIZE_ADD

#define SIZE_ADD   10

Definition at line 38 of file movtextenc.c.

Referenced by encode_sample_description(), and encode_styl().

◆ STYL_BOX

#define STYL_BOX   (1<<0)

Definition at line 40 of file movtextenc.c.

◆ HLIT_BOX

#define HLIT_BOX   (1<<1)

Definition at line 41 of file movtextenc.c.

◆ HCLR_BOX

#define HCLR_BOX   (1<<2)

Definition at line 42 of file movtextenc.c.

◆ DEFAULT_STYLE_FONT_ID

#define DEFAULT_STYLE_FONT_ID   0x01

Definition at line 44 of file movtextenc.c.

Referenced by encode_sample_description().

◆ DEFAULT_STYLE_FONTSIZE

#define DEFAULT_STYLE_FONTSIZE   0x12

Definition at line 45 of file movtextenc.c.

Referenced by encode_sample_description().

◆ DEFAULT_STYLE_COLOR

#define DEFAULT_STYLE_COLOR   0xffffffff

Definition at line 46 of file movtextenc.c.

Referenced by encode_sample_description().

◆ DEFAULT_STYLE_FLAG

#define DEFAULT_STYLE_FLAG   0x00

Definition at line 47 of file movtextenc.c.

Referenced by encode_sample_description().

◆ BGR_TO_RGB

#define BGR_TO_RGB ( c)
Value:
(((c) & 0xff) << 16 | ((c) & 0xff00) | (((uint32_t)(c) >> 16) & 0xff))
static double c[64]

Definition at line 49 of file movtextenc.c.

Referenced by encode_sample_description(), mov_text_ass_style_set(), and mov_text_color_cb().

◆ FONTSIZE_SCALE

#define FONTSIZE_SCALE ( s,
fs )
Value:
((fs) * (s)->font_scale_factor + 0.5)
#define s(width, name)
Definition cbs_vp9.c:198
#define fs(width, name, subs,...)
Definition cbs_vp9.c:200

Definition at line 50 of file movtextenc.c.

Referenced by encode_sample_description(), and mov_text_font_size_set().

◆ av_bprint_append_any

#define av_bprint_append_any ( buf,
data,
size )
Value:
av_bprint_append_data(buf, ((const char*)data), size)
void av_bprint_append_data(AVBPrint *buf, const char *data, unsigned size)
Append data to a print buffer.
Definition bprint.c:148
const char data[16]
Definition mxf.c:149
int size

Definition at line 51 of file movtextenc.c.

Referenced by encode_hclr(), encode_hlit(), encode_sample_description(), and encode_styl().

◆ OFFSET

#define OFFSET ( x)
Value:

Definition at line 692 of file movtextenc.c.

◆ FLAGS

Definition at line 693 of file movtextenc.c.

Function Documentation

◆ mov_text_cleanup()

static void mov_text_cleanup ( MovTextContext * s)
static

Definition at line 97 of file movtextenc.c.

Referenced by encode_styl(), and mov_text_style_start().

◆ encode_styl()

static void encode_styl ( MovTextContext * s)
static

Definition at line 103 of file movtextenc.c.

◆ encode_hlit()

static void encode_hlit ( MovTextContext * s)
static

Definition at line 131 of file movtextenc.c.

◆ encode_hclr()

static void encode_hclr ( MovTextContext * s)
static

Definition at line 145 of file movtextenc.c.

◆ mov_text_encode_close()

static av_cold int mov_text_encode_close ( AVCodecContext * avctx)
static

Definition at line 166 of file movtextenc.c.

◆ encode_sample_description()

static int encode_sample_description ( AVCodecContext * avctx)
static

Definition at line 176 of file movtextenc.c.

Referenced by mov_text_encode_init().

◆ mov_text_encode_init()

static av_cold int mov_text_encode_init ( AVCodecContext * avctx)
static

Definition at line 330 of file movtextenc.c.

◆ mov_text_style_start()

◆ mov_text_style_to_flag()

static uint8_t mov_text_style_to_flag ( const char style)
static

Definition at line 382 of file movtextenc.c.

Referenced by mov_text_style_cb().

◆ mov_text_style_set()

static void mov_text_style_set ( MovTextContext * s,
uint8_t style_flags )
static

Definition at line 400 of file movtextenc.c.

Referenced by mov_text_ass_style_set().

◆ mov_text_style_cb()

static void mov_text_style_cb ( void * priv,
const char style,
int close )
static

Definition at line 410 of file movtextenc.c.

◆ mov_text_color_set()

static void mov_text_color_set ( MovTextContext * s,
uint32_t color )
static

Definition at line 427 of file movtextenc.c.

Referenced by mov_text_ass_style_set(), and mov_text_color_cb().

◆ mov_text_color_cb()

static void mov_text_color_cb ( void * priv,
unsigned int color,
unsigned int color_id )
static

Definition at line 438 of file movtextenc.c.

◆ mov_text_alpha_set()

static void mov_text_alpha_set ( MovTextContext * s,
uint8_t alpha )
static

Definition at line 465 of file movtextenc.c.

Referenced by mov_text_alpha_cb(), and mov_text_ass_style_set().

◆ mov_text_alpha_cb()

static void mov_text_alpha_cb ( void * priv,
int alpha,
int alpha_id )
static

Definition at line 476 of file movtextenc.c.

◆ find_font_id()

static uint16_t find_font_id ( MovTextContext * s,
const char * name )
static

Definition at line 499 of file movtextenc.c.

Referenced by mov_text_font_name_set().

◆ mov_text_font_name_set()

static void mov_text_font_name_set ( MovTextContext * s,
const char * name )
static

Definition at line 511 of file movtextenc.c.

Referenced by mov_text_ass_style_set(), and mov_text_font_name_cb().

◆ mov_text_font_name_cb()

static void mov_text_font_name_cb ( void * priv,
const char * name )
static

Definition at line 522 of file movtextenc.c.

◆ mov_text_font_size_set()

static void mov_text_font_size_set ( MovTextContext * s,
int size )
static

Definition at line 527 of file movtextenc.c.

Referenced by mov_text_ass_style_set(), and mov_text_font_size_cb().

◆ mov_text_font_size_cb()

static void mov_text_font_size_cb ( void * priv,
int size )
static

Definition at line 538 of file movtextenc.c.

◆ mov_text_end_cb()

static void mov_text_end_cb ( void * priv)
static

Definition at line 543 of file movtextenc.c.

◆ mov_text_ass_style_set()

static void mov_text_ass_style_set ( MovTextContext * s,
ASSStyle * style )
static

Definition at line 549 of file movtextenc.c.

Referenced by mov_text_cancel_overrides_cb(), and mov_text_dialog().

◆ mov_text_dialog()

static void mov_text_dialog ( MovTextContext * s,
ASSDialog * dialog )
static

Definition at line 571 of file movtextenc.c.

Referenced by mov_text_encode_frame().

◆ mov_text_cancel_overrides_cb()

static void mov_text_cancel_overrides_cb ( void * priv,
const char * style_name )
static

Definition at line 579 of file movtextenc.c.

◆ utf8_strlen()

static unsigned utf8_strlen ( const char * text,
int len )
static

Definition at line 592 of file movtextenc.c.

Referenced by mov_text_text_cb().

◆ mov_text_text_cb()

static void mov_text_text_cb ( void * priv,
const char * text,
int len )
static

Definition at line 612 of file movtextenc.c.

◆ mov_text_new_line_cb()

static void mov_text_new_line_cb ( void * priv,
int forced )
static

Definition at line 621 of file movtextenc.c.

◆ mov_text_encode_frame()

static int mov_text_encode_frame ( AVCodecContext * avctx,
unsigned char * buf,
int bufsize,
const AVSubtitle * sub )
static

Definition at line 640 of file movtextenc.c.

Variable Documentation

◆ box_types

const Box box_types[]
static
Initial value:
= {
}
static void encode_hclr(MovTextContext *s)
Definition movtextenc.c:145
static void encode_hlit(MovTextContext *s)
Definition movtextenc.c:131
static void encode_styl(MovTextContext *s)
Definition movtextenc.c:103

Definition at line 158 of file movtextenc.c.

◆ box_count

const size_t box_count = FF_ARRAY_ELEMS(box_types)
static

Definition at line 164 of file movtextenc.c.

◆ mov_text_callbacks

const ASSCodesCallbacks mov_text_callbacks
static
Initial value:
= {
.new_line = mov_text_new_line_cb,
.font_name = mov_text_font_name_cb,
.font_size = mov_text_font_size_cb,
.cancel_overrides = mov_text_cancel_overrides_cb,
}
static void mov_text_font_size_cb(void *priv, int size)
Definition movtextenc.c:538
static void mov_text_font_name_cb(void *priv, const char *name)
Definition movtextenc.c:522
static void mov_text_color_cb(void *priv, unsigned int color, unsigned int color_id)
Definition movtextenc.c:438
static void mov_text_end_cb(void *priv)
Definition movtextenc.c:543
static void mov_text_text_cb(void *priv, const char *text, int len)
Definition movtextenc.c:612
static void mov_text_cancel_overrides_cb(void *priv, const char *style_name)
Definition movtextenc.c:579
static void mov_text_style_cb(void *priv, const char style, int close)
Definition movtextenc.c:410
static void mov_text_new_line_cb(void *priv, int forced)
Definition movtextenc.c:621
static void mov_text_alpha_cb(void *priv, int alpha, int alpha_id)
Definition movtextenc.c:476

Definition at line 628 of file movtextenc.c.

Referenced by mov_text_encode_frame().

◆ options

const AVOption options[]
static
Initial value:
= {
{ "height", "Frame height, usually video height", OFFSET(frame_height), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS },
{ NULL },
}
#define FLAGS
Definition cmdutils.c:598
#define NULL
Definition coverity.c:32
#define OFFSET(x)
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258

Definition at line 694 of file movtextenc.c.

◆ mov_text_encoder_class

const AVClass mov_text_encoder_class
static
Initial value:
= {
.class_name = "MOV text enoder",
.item_name = av_default_item_name,
.option = options,
}
const char * av_default_item_name(void *ptr)
Return the context name.
Definition log.c:241
#define LIBAVUTIL_VERSION_INT
Definition version.h:85

Definition at line 699 of file movtextenc.c.

◆ ff_movtext_encoder

const FFCodec ff_movtext_encoder
Initial value:
= {
.p.name = "mov_text",
CODEC_LONG_NAME("3GPP Timed Text subtitle"),
.priv_data_size = sizeof(MovTextContext),
.p.priv_class = &mov_text_encoder_class,
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
}
#define FF_CODEC_ENCODE_SUB_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
@ AV_CODEC_ID_MOV_TEXT
Definition codec_id.h:571
@ AVMEDIA_TYPE_SUBTITLE
Definition avutil.h:203
static int mov_text_encode_frame(AVCodecContext *avctx, unsigned char *buf, int bufsize, const AVSubtitle *sub)
Definition movtextenc.c:640
static const AVClass mov_text_encoder_class
Definition movtextenc.c:699
static av_cold int mov_text_encode_close(AVCodecContext *avctx)
Definition movtextenc.c:166
static av_cold int mov_text_encode_init(AVCodecContext *avctx)
Definition movtextenc.c:330

Definition at line 706 of file movtextenc.c.