FFmpeg
Data Structures | Macros | Functions | Variables
movtextdec.c File Reference
#include "avcodec.h"
#include "ass.h"
#include "libavutil/opt.h"
#include "libavutil/avstring.h"
#include "libavutil/common.h"
#include "libavutil/bprint.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mem.h"
#include "bytestream.h"
#include "codec_internal.h"

Go to the source code of this file.

Data Structures

struct  FontRecord
 
struct  StyleBox
 
struct  MovTextDefault
 
struct  HighlightBox
 
struct  HilightcolorBox
 
struct  TextWrapBox
 
struct  MovTextContext
 
struct  Box
 

Macros

#define STYLE_FLAG_BOLD   (1<<0)
 
#define STYLE_FLAG_ITALIC   (1<<1)
 
#define STYLE_FLAG_UNDERLINE   (1<<2)
 
#define BOX_SIZE_INITIAL   40
 
#define STYL_BOX   (1<<0)
 
#define HLIT_BOX   (1<<1)
 
#define HCLR_BOX   (1<<2)
 
#define TWRP_BOX   (1<<3)
 
#define BOTTOM_LEFT   1
 
#define BOTTOM_CENTER   2
 
#define BOTTOM_RIGHT   3
 
#define MIDDLE_LEFT   4
 
#define MIDDLE_CENTER   5
 
#define MIDDLE_RIGHT   6
 
#define TOP_LEFT   7
 
#define TOP_CENTER   8
 
#define TOP_RIGHT   9
 
#define RGB_TO_BGR(c)   (((c) & 0xff) << 16 | ((c) & 0xff00) | (((c) >> 16) & 0xff))
 
#define CMP(field)   ((a)->field == (b)->field)
 
#define OFFSET(x)   offsetof(MovTextContext, x)
 
#define FLAGS   AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_SUBTITLE_PARAM
 

Functions

static void mov_text_cleanup (MovTextContext *m)
 
static void mov_text_cleanup_ftab (MovTextContext *m)
 
static void mov_text_parse_style_record (StyleBox *style, const uint8_t **ptr)
 
static int mov_text_tx3g (AVCodecContext *avctx, MovTextContext *m)
 
static int decode_twrp (const uint8_t *tsmb, MovTextContext *m, uint64_t size)
 
static int decode_hlit (const uint8_t *tsmb, MovTextContext *m, uint64_t size)
 
static int decode_hclr (const uint8_t *tsmb, MovTextContext *m, uint64_t size)
 
static int styles_equivalent (const StyleBox *a, const StyleBox *b)
 
static int decode_styl (const uint8_t *tsmb, MovTextContext *m, uint64_t size)
 
static int get_utf8_length_at (const char *text, const char *text_end)
 
static int text_to_ass (AVBPrint *buf, const char *text, const char *text_end, AVCodecContext *avctx)
 
static int mov_text_init (AVCodecContext *avctx)
 
static int mov_text_decode_frame (AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, const AVPacket *avpkt)
 
static int mov_text_decode_close (AVCodecContext *avctx)
 
static void mov_text_flush (AVCodecContext *avctx)
 

Variables

static const Box box_types []
 
const static size_t box_count = FF_ARRAY_ELEMS(box_types)
 
static const AVOption options []
 
static const AVClass mov_text_decoder_class
 
const FFCodec ff_movtext_decoder
 

Macro Definition Documentation

◆ STYLE_FLAG_BOLD

#define STYLE_FLAG_BOLD   (1<<0)

Definition at line 33 of file movtextdec.c.

◆ STYLE_FLAG_ITALIC

#define STYLE_FLAG_ITALIC   (1<<1)

Definition at line 34 of file movtextdec.c.

◆ STYLE_FLAG_UNDERLINE

#define STYLE_FLAG_UNDERLINE   (1<<2)

Definition at line 35 of file movtextdec.c.

◆ BOX_SIZE_INITIAL

#define BOX_SIZE_INITIAL   40

Definition at line 37 of file movtextdec.c.

◆ STYL_BOX

#define STYL_BOX   (1<<0)

Definition at line 39 of file movtextdec.c.

◆ HLIT_BOX

#define HLIT_BOX   (1<<1)

Definition at line 40 of file movtextdec.c.

◆ HCLR_BOX

#define HCLR_BOX   (1<<2)

Definition at line 41 of file movtextdec.c.

◆ TWRP_BOX

#define TWRP_BOX   (1<<3)

Definition at line 42 of file movtextdec.c.

◆ BOTTOM_LEFT

#define BOTTOM_LEFT   1

Definition at line 44 of file movtextdec.c.

◆ BOTTOM_CENTER

#define BOTTOM_CENTER   2

Definition at line 45 of file movtextdec.c.

◆ BOTTOM_RIGHT

#define BOTTOM_RIGHT   3

Definition at line 46 of file movtextdec.c.

◆ MIDDLE_LEFT

#define MIDDLE_LEFT   4

Definition at line 47 of file movtextdec.c.

◆ MIDDLE_CENTER

#define MIDDLE_CENTER   5

Definition at line 48 of file movtextdec.c.

◆ MIDDLE_RIGHT

#define MIDDLE_RIGHT   6

Definition at line 49 of file movtextdec.c.

◆ TOP_LEFT

#define TOP_LEFT   7

Definition at line 50 of file movtextdec.c.

◆ TOP_CENTER

#define TOP_CENTER   8

Definition at line 51 of file movtextdec.c.

◆ TOP_RIGHT

#define TOP_RIGHT   9

Definition at line 52 of file movtextdec.c.

◆ RGB_TO_BGR

#define RGB_TO_BGR (   c)    (((c) & 0xff) << 16 | ((c) & 0xff00) | (((c) >> 16) & 0xff))

Definition at line 54 of file movtextdec.c.

◆ CMP

#define CMP (   field)    ((a)->field == (b)->field)

◆ OFFSET

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

Definition at line 579 of file movtextdec.c.

◆ FLAGS

Definition at line 580 of file movtextdec.c.

Function Documentation

◆ mov_text_cleanup()

static void mov_text_cleanup ( MovTextContext m)
static

Definition at line 116 of file movtextdec.c.

Referenced by decode_styl(), mov_text_decode_close(), and mov_text_decode_frame().

◆ mov_text_cleanup_ftab()

static void mov_text_cleanup_ftab ( MovTextContext m)
static

Definition at line 124 of file movtextdec.c.

Referenced by mov_text_decode_close(), and mov_text_tx3g().

◆ mov_text_parse_style_record()

static void mov_text_parse_style_record ( StyleBox style,
const uint8_t **  ptr 
)
static

Definition at line 132 of file movtextdec.c.

Referenced by decode_styl(), and mov_text_tx3g().

◆ mov_text_tx3g()

static int mov_text_tx3g ( AVCodecContext avctx,
MovTextContext m 
)
static

Definition at line 149 of file movtextdec.c.

Referenced by mov_text_init().

◆ decode_twrp()

static int decode_twrp ( const uint8_t *  tsmb,
MovTextContext m,
uint64_t  size 
)
static

Definition at line 242 of file movtextdec.c.

◆ decode_hlit()

static int decode_hlit ( const uint8_t *  tsmb,
MovTextContext m,
uint64_t  size 
)
static

Definition at line 249 of file movtextdec.c.

◆ decode_hclr()

static int decode_hclr ( const uint8_t *  tsmb,
MovTextContext m,
uint64_t  size 
)
static

Definition at line 257 of file movtextdec.c.

◆ styles_equivalent()

static int styles_equivalent ( const StyleBox a,
const StyleBox b 
)
static

Definition at line 264 of file movtextdec.c.

Referenced by decode_styl().

◆ decode_styl()

static int decode_styl ( const uint8_t *  tsmb,
MovTextContext m,
uint64_t  size 
)
static

Definition at line 272 of file movtextdec.c.

◆ get_utf8_length_at()

static int get_utf8_length_at ( const char *  text,
const char *  text_end 
)
static

Definition at line 335 of file movtextdec.c.

Referenced by text_to_ass().

◆ text_to_ass()

static int text_to_ass ( AVBPrint *  buf,
const char *  text,
const char *  text_end,
AVCodecContext avctx 
)
static

Definition at line 348 of file movtextdec.c.

Referenced by mov_text_decode_frame().

◆ mov_text_init()

static int mov_text_init ( AVCodecContext avctx)
static

Definition at line 446 of file movtextdec.c.

◆ mov_text_decode_frame()

static int mov_text_decode_frame ( AVCodecContext avctx,
AVSubtitle sub,
int got_sub_ptr,
const AVPacket avpkt 
)
static

Definition at line 475 of file movtextdec.c.

◆ mov_text_decode_close()

static int mov_text_decode_close ( AVCodecContext avctx)
static

Definition at line 564 of file movtextdec.c.

◆ mov_text_flush()

static void mov_text_flush ( AVCodecContext avctx)
static

Definition at line 572 of file movtextdec.c.

Variable Documentation

◆ box_types

const Box box_types[]
static
Initial value:
= {
{ MKBETAG('s','t','y','l'), 2, decode_styl },
{ MKBETAG('h','l','i','t'), 4, decode_hlit },
{ MKBETAG('h','c','l','r'), 4, decode_hclr },
{ MKBETAG('t','w','r','p'), 1, decode_twrp }
}

Definition at line 325 of file movtextdec.c.

Referenced by mov_text_decode_frame().

◆ box_count

const static size_t box_count = FF_ARRAY_ELEMS(box_types)
static

Definition at line 332 of file movtextdec.c.

Referenced by mov_text_decode_frame().

◆ options

const AVOption options[]
static
Initial value:
= {
{ "width", "Frame width, usually video width", OFFSET(frame_width), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS },
{ "height", "Frame height, usually video height", OFFSET(frame_height), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS },
{ NULL },
}

Definition at line 581 of file movtextdec.c.

◆ mov_text_decoder_class

const AVClass mov_text_decoder_class
static
Initial value:
= {
.class_name = "MOV text decoder",
.item_name = av_default_item_name,
.option = options,
}

Definition at line 587 of file movtextdec.c.

◆ ff_movtext_decoder

const FFCodec ff_movtext_decoder
Initial value:
= {
.p.name = "mov_text",
CODEC_LONG_NAME("3GPP Timed Text subtitle"),
.priv_data_size = sizeof(MovTextContext),
.p.priv_class = &mov_text_decoder_class,
.init = mov_text_init,
.flush = mov_text_flush,
}

Definition at line 594 of file movtextdec.c.

AVMEDIA_TYPE_SUBTITLE
@ AVMEDIA_TYPE_SUBTITLE
Definition: avutil.h:204
OFFSET
#define OFFSET(x)
Definition: movtextdec.c:579
options
static const AVOption options[]
Definition: movtextdec.c:581
mov_text_init
static int mov_text_init(AVCodecContext *avctx)
Definition: movtextdec.c:446
mov_text_flush
static void mov_text_flush(AVCodecContext *avctx)
Definition: movtextdec.c:572
mov_text_decoder_class
static const AVClass mov_text_decoder_class
Definition: movtextdec.c:587
FLAGS
#define FLAGS
Definition: movtextdec.c:580
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:272
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
NULL
#define NULL
Definition: coverity.c:32
AV_CODEC_ID_MOV_TEXT
@ AV_CODEC_ID_MOV_TEXT
Definition: codec_id.h:555
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
MKBETAG
#define MKBETAG(a, b, c, d)
Definition: macros.h:56
decode_hclr
static int decode_hclr(const uint8_t *tsmb, MovTextContext *m, uint64_t size)
Definition: movtextdec.c:257
decode_styl
static int decode_styl(const uint8_t *tsmb, MovTextContext *m, uint64_t size)
Definition: movtextdec.c:272
decode_hlit
static int decode_hlit(const uint8_t *tsmb, MovTextContext *m, uint64_t size)
Definition: movtextdec.c:249
decode_twrp
static int decode_twrp(const uint8_t *tsmb, MovTextContext *m, uint64_t size)
Definition: movtextdec.c:242
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
FF_CODEC_DECODE_SUB_CB
#define FF_CODEC_DECODE_SUB_CB(func)
Definition: codec_internal.h:309
mov_text_decode_close
static int mov_text_decode_close(AVCodecContext *avctx)
Definition: movtextdec.c:564
mov_text_decode_frame
static int mov_text_decode_frame(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, const AVPacket *avpkt)
Definition: movtextdec.c:475
MovTextContext
Definition: movtextdec.c:95