FFmpeg
Data Structures | Macros | Functions | Variables
movtextenc.c File Reference
#include <stdarg.h>
#include "avcodec.h"
#include "libavutil/opt.h"
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mem.h"
#include "libavutil/common.h"
#include "ass_split.h"
#include "ass.h"
#include "bytestream.h"
#include "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)   (((c) & 0xff) << 16 | ((c) & 0xff00) | (((uint32_t)(c) >> 16) & 0xff))
 
#define FONTSIZE_SCALE(s, fs)   ((fs) * (s)->font_scale_factor + 0.5)
 
#define av_bprint_append_any(buf, data, size)   av_bprint_append_data(buf, ((const char*)data), size)
 
#define OFFSET(x)   offsetof(MovTextContext, 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 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 uint16_t 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
 
AVCodec ff_movtext_encoder
 

Macro Definition Documentation

#define STYLE_FLAG_BOLD   (1<<0)
#define STYLE_FLAG_ITALIC   (1<<1)
#define STYLE_FLAG_UNDERLINE   (1<<2)
#define STYLE_RECORD_SIZE   12

Definition at line 38 of file movtextenc.c.

Referenced by encode_styl().

#define SIZE_ADD   10

Definition at line 39 of file movtextenc.c.

Referenced by encode_sample_description(), and encode_styl().

#define STYL_BOX   (1<<0)

Definition at line 41 of file movtextenc.c.

Referenced by encode_styl(), and mov_text_style_start().

#define HLIT_BOX   (1<<1)

Definition at line 42 of file movtextenc.c.

Referenced by encode_hlit(), mov_text_alpha_cb(), and mov_text_color_cb().

#define HCLR_BOX   (1<<2)

Definition at line 43 of file movtextenc.c.

Referenced by encode_hclr(), mov_text_alpha_cb(), and mov_text_color_cb().

#define DEFAULT_STYLE_FONT_ID   0x01

Definition at line 45 of file movtextenc.c.

Referenced by encode_sample_description().

#define DEFAULT_STYLE_FONTSIZE   0x12

Definition at line 46 of file movtextenc.c.

Referenced by encode_sample_description().

#define DEFAULT_STYLE_COLOR   0xffffffff

Definition at line 47 of file movtextenc.c.

Referenced by encode_sample_description().

#define DEFAULT_STYLE_FLAG   0x00

Definition at line 48 of file movtextenc.c.

Referenced by encode_sample_description().

#define BGR_TO_RGB (   c)    (((c) & 0xff) << 16 | ((c) & 0xff00) | (((uint32_t)(c) >> 16) & 0xff))
#define FONTSIZE_SCALE (   s,
  fs 
)    ((fs) * (s)->font_scale_factor + 0.5)

Definition at line 51 of file movtextenc.c.

Referenced by encode_sample_description(), and mov_text_font_size_set().

#define av_bprint_append_any (   buf,
  data,
  size 
)    av_bprint_append_data(buf, ((const char*)data), size)

Definition at line 52 of file movtextenc.c.

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

#define OFFSET (   x)    offsetof(MovTextContext, x)

Definition at line 710 of file movtextenc.c.

Definition at line 711 of file movtextenc.c.

Function Documentation

static void mov_text_cleanup ( MovTextContext s)
static

Definition at line 99 of file movtextenc.c.

Referenced by encode_styl(), and mov_text_style_start().

static void encode_styl ( MovTextContext s)
static

Definition at line 105 of file movtextenc.c.

static void encode_hlit ( MovTextContext s)
static

Definition at line 133 of file movtextenc.c.

static void encode_hclr ( MovTextContext s)
static

Definition at line 147 of file movtextenc.c.

static int mov_text_encode_close ( AVCodecContext avctx)
static

Definition at line 168 of file movtextenc.c.

static int encode_sample_description ( AVCodecContext avctx)
static

Definition at line 179 of file movtextenc.c.

Referenced by mov_text_encode_init().

static av_cold int mov_text_encode_init ( AVCodecContext avctx)
static

Definition at line 326 of file movtextenc.c.

static int mov_text_style_start ( MovTextContext s)
static
static uint8_t mov_text_style_to_flag ( const char  style)
static

Definition at line 380 of file movtextenc.c.

Referenced by mov_text_style_cb().

static void mov_text_style_set ( MovTextContext s,
uint8_t  style_flags 
)
static

Definition at line 398 of file movtextenc.c.

Referenced by mov_text_ass_style_set().

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

Definition at line 408 of file movtextenc.c.

static void mov_text_color_set ( MovTextContext s,
uint32_t  color 
)
static

Definition at line 425 of file movtextenc.c.

Referenced by mov_text_ass_style_set(), and mov_text_color_cb().

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

Definition at line 436 of file movtextenc.c.

static void mov_text_alpha_set ( MovTextContext s,
uint8_t  alpha 
)
static

Definition at line 463 of file movtextenc.c.

Referenced by mov_text_alpha_cb(), and mov_text_ass_style_set().

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

Definition at line 474 of file movtextenc.c.

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

Definition at line 497 of file movtextenc.c.

Referenced by mov_text_font_name_set().

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

Definition at line 507 of file movtextenc.c.

Referenced by mov_text_ass_style_set(), and mov_text_font_name_cb().

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

Definition at line 518 of file movtextenc.c.

static void mov_text_font_size_set ( MovTextContext s,
int  size 
)
static

Definition at line 523 of file movtextenc.c.

Referenced by mov_text_ass_style_set(), and mov_text_font_size_cb().

static void mov_text_font_size_cb ( void priv,
int  size 
)
static

Definition at line 534 of file movtextenc.c.

static void mov_text_end_cb ( void priv)
static

Definition at line 539 of file movtextenc.c.

static void mov_text_ass_style_set ( MovTextContext s,
ASSStyle style 
)
static

Definition at line 545 of file movtextenc.c.

Referenced by mov_text_cancel_overrides_cb(), and mov_text_dialog().

static void mov_text_dialog ( MovTextContext s,
ASSDialog dialog 
)
static

Definition at line 567 of file movtextenc.c.

Referenced by mov_text_encode_frame().

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

Definition at line 575 of file movtextenc.c.

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

Definition at line 588 of file movtextenc.c.

Referenced by mov_text_text_cb().

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

Definition at line 608 of file movtextenc.c.

static void mov_text_new_line_cb ( void priv,
int  forced 
)
static

Definition at line 618 of file movtextenc.c.

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

Definition at line 638 of file movtextenc.c.

Variable Documentation

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

Definition at line 160 of file movtextenc.c.

const size_t box_count = FF_ARRAY_ELEMS(box_types)
static

Definition at line 166 of file movtextenc.c.

Referenced by mov_text_encode_frame().

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_cancel_overrides_cb(void *priv, const char *style_name)
Definition: movtextenc.c:575
static void mov_text_color_cb(void *priv, unsigned int color, unsigned int color_id)
Definition: movtextenc.c:436
static void mov_text_text_cb(void *priv, const char *text, int len)
Definition: movtextenc.c:608
static void mov_text_font_name_cb(void *priv, const char *name)
Definition: movtextenc.c:518
static void mov_text_end_cb(void *priv)
Definition: movtextenc.c:539
static void mov_text_font_size_cb(void *priv, int size)
Definition: movtextenc.c:534
static void mov_text_new_line_cb(void *priv, int forced)
Definition: movtextenc.c:618
static void mov_text_style_cb(void *priv, const char style, int close)
Definition: movtextenc.c:408
static void mov_text_alpha_cb(void *priv, int alpha, int alpha_id)
Definition: movtextenc.c:474

Definition at line 626 of file movtextenc.c.

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 NULL
Definition: coverity.c:32
#define OFFSET(x)
Definition: movtextenc.c:710
#define FLAGS
Definition: movtextenc.c:711

Definition at line 712 of file movtextenc.c.

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

Definition at line 717 of file movtextenc.c.

AVCodec ff_movtext_encoder
Initial value:
= {
.name = "mov_text",
.long_name = NULL_IF_CONFIG_SMALL("3GPP Timed Text subtitle"),
.priv_data_size = sizeof(MovTextContext),
.priv_class = &mov_text_encoder_class,
.encode_sub = mov_text_encode_frame,
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
}
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: internal.h:48
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
static av_cold int mov_text_encode_init(AVCodecContext *avctx)
Definition: movtextenc.c:326
static const AVClass mov_text_encoder_class
Definition: movtextenc.c:717
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:153
static int mov_text_encode_frame(AVCodecContext *avctx, unsigned char *buf, int bufsize, const AVSubtitle *sub)
Definition: movtextenc.c:638
static int mov_text_encode_close(AVCodecContext *avctx)
Definition: movtextenc.c:168

Definition at line 724 of file movtextenc.c.