37 char *f = strchr(s, c);
38 return f ? (f -
s) : -1;
50 #define MICRODVD_PERSISTENT_OFF 0
51 #define MICRODVD_PERSISTENT_ON 1
52 #define MICRODVD_PERSISTENT_OPENED 2
55 #define MICRODVD_TAGS "cfshyYpo"
63 memcpy(&tags[tag_index], &tag,
sizeof(tag));
67 #define MICRODVD_STYLES "ibus"
89 char tag_char = *(s + 1);
92 if (!tag_char || *(s + 2) !=
':')
102 while (*s && *s !=
'}') {
105 if (style_index >= 0)
106 tag.
data1 |= (1 << style_index);
120 while (*s ==
'$' || *s ==
'#')
122 tag.
data1 = strtol(s, &s, 16) & 0x00ffffff;
146 tag.
data1 = strtol(s, &s, 10);
170 tag.
data1 = (*s++ ==
'1');
179 tag.
data1 = strtol(s, &s, 10);
183 tag.
data2 = strtol(s, &s, 10);
208 switch (tags[i].
key) {
212 if (tags[i].
data1 & (1 << sidx))
226 av_bprintf(new_line,
"{\\fs%d}", tags[i].data1);
230 if (tags[i].data1 == 0)
236 tags[i].data1, tags[i].
data2);
252 switch (tags[i].
key) {
256 if (tags[i].
data1 & (1 << sidx))
283 struct microdvd_tag tags[sizeof(MICRODVD_TAGS) - 1] = {{0}};
285 if (avpkt->
size <= 0)
291 while (line < end && *line) {
298 while (line < end && *line && *line !=
'|') {
304 if (line < end && *line ==
'|') {
324 *got_sub_ptr = sub->num_rects > 0;
338 struct microdvd_tag tags[sizeof(MICRODVD_TAGS) - 1] = {{0}};
349 if (tags[i].
data1 & (1 << sidx)) {
351 case 'i': italic = 1;
break;
352 case 'b': bold = 1;
break;
353 case 'u': underline = 1;
break;
359 case 'c': color = tags[i].
data1;
break;
360 case 's': font_size = tags[i].
data1;
break;
361 case 'p': alignment = 8;
break;
static void microdvd_set_tag(struct microdvd_tag *tags, struct microdvd_tag tag)
void av_bprintf(AVBPrint *buf, const char *fmt,...)
ptrdiff_t const GLvoid * data
#define ASS_DEFAULT_BORDERSTYLE
AVCodec ff_microdvd_decoder
int ff_ass_subtitle_header(AVCodecContext *avctx, const char *font, int font_size, int color, int back_color, int bold, int italic, int underline, int border_style, int alignment)
Generate a suitable AVCodecContext.subtitle_header for SUBTITLE_ASS.
#define MICRODVD_PERSISTENT_ON
static int microdvd_decode_frame(AVCodecContext *avctx, void *data, int *got_sub_ptr, AVPacket *avpkt)
static char * microdvd_load_tags(struct microdvd_tag *tags, char *s)
#define MICRODVD_PERSISTENT_OFF
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
#define ASS_DEFAULT_ALIGNMENT
static av_cold int end(AVCodecContext *avctx)
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
static av_const int av_tolower(int c)
Locale-independent conversion of ASCII characters to lowercase.
#define ASS_DEFAULT_BACK_COLOR
#define ASS_DEFAULT_UNDERLINE
#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)
const char * name
Name of the codec implementation.
#define ASS_DEFAULT_FONT_SIZE
static void microdvd_open_tags(AVBPrint *new_line, struct microdvd_tag *tags)
static void microdvd_close_no_persistent_tags(AVBPrint *new_line, struct microdvd_tag *tags)
static int microdvd_init(AVCodecContext *avctx)
#define AV_BPRINT_SIZE_AUTOMATIC
Libavcodec external API header.
#define MICRODVD_PERSISTENT_OPENED
int ff_ass_add_rect_bprint(AVSubtitle *sub, AVBPrint *buf, int ts_start, int duration)
Same as ff_ass_add_rect, but taking an AVBPrint buffer instead of a string, and assuming raw=0...
main external API structure.
rational number numerator/denominator
void av_bprint_clear(AVBPrint *buf)
Reset the string to "" but keep internal allocated data.
static int indexof(const char *s, int c)
#define ASS_DEFAULT_COLOR
#define ASS_DEFAULT_ITALIC
static char * check_for_italic_slash_marker(struct microdvd_tag *tags, char *s)
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
Append char c n times to a print buffer.