28 #include "libavutil/bprint.h"
29 #include "libavutil/opt.h"
37 #define OFFSET(x) offsetof(TextContext, x)
38 #define SD AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_DECODING_PARAM
40 {
"keep_ass_markup",
"Set if ASS tags must be escaped",
OFFSET(keep_ass_markup),
AV_OPT_TYPE_INT, {.i64=0}, 0, 1, .flags=
SD },
45 const char *p,
const char *p_end)
49 for (; p < p_end && *p; p++) {
66 }
else if (p[0] ==
'\n') {
70 }
else if (p[0] ==
'\r' && p < p_end - 1 && p[1] ==
'\n') {
89 const char *ptr = avpkt->
data;
91 const int ts_duration = avpkt->duration != -1 ?
95 if (ptr && avpkt->size > 0 && *ptr &&
103 *got_sub_ptr = sub->num_rects > 0;
108 #define DECLARE_CLASS(decname) static const AVClass decname ## _decoder_class = { \
109 .class_name = #decname " decoder", \
110 .item_name = av_default_item_name, \
111 .option = decname ## _options, \
112 .version = LIBAVUTIL_VERSION_INT, \
115 #if CONFIG_TEXT_DECODER
116 #define text_options options
127 .priv_class = &text_decoder_class,
131 #if CONFIG_VPLAYER_DECODER || CONFIG_PJS_DECODER || CONFIG_SUBVIEWER1_DECODER
140 #if CONFIG_VPLAYER_DECODER
141 #define vplayer_options options
151 .
init = linebreak_init,
152 .priv_class = &vplayer_decoder_class,
156 #if CONFIG_PJS_DECODER
157 #define pjs_options options
167 .
init = linebreak_init,
168 .priv_class = &pjs_decoder_class,
172 #if CONFIG_SUBVIEWER1_DECODER
173 #define subviewer1_options options
176 AVCodec ff_subviewer1_decoder = {
177 .
name =
"subviewer1",
183 .
init = linebreak_init,
184 .priv_class = &subviewer1_decoder_class,
void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
Append char c n times to a print buffer.
static av_cold int init(AVCodecContext *avctx)
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
int ff_ass_subtitle_header_default(AVCodecContext *avctx)
Generate a suitable AVCodecContext.subtitle_header for SUBTITLE_ASS with default style.
const char * name
Name of the codec implementation.
const OptionDef options[]
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) av_const
Rescale a 64-bit integer by 2 rational numbers.
#define AV_BPRINT_SIZE_UNLIMITED
Convenience macros for special values for av_bprint_init() size_max parameter.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
Libavcodec external API header.
int ff_ass_add_rect(AVSubtitle *sub, const char *dialog, int ts_start, int duration, int raw)
Add an ASS dialog line to an AVSubtitle as a new AVSubtitleRect.
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
Init a print buffer.
Buffer to print data progressively.
static int av_bprint_is_complete(AVBPrint *buf)
Test if the print buffer is complete (not truncated).
main external API structure.
#define DECLARE_CLASS(decname)
Describe the class of an AVClass context structure.
rational number numerator/denominator
void av_bprintf(AVBPrint *buf, const char *fmt,...) av_printf_format(2
Append a formatted string to a print buffer.
static int decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
static int text_event_to_ass(const AVCodecContext *avctx, AVBPrint *buf, const char *p, const char *p_end)
static int text_decode_frame(AVCodecContext *avctx, void *data, int *got_sub_ptr, AVPacket *avpkt)
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...