From 2c77c90684e24ef16f7e7c4462e011434cee6a98 Mon Sep 17 00:00:00 2001 From: Aurelien Jacobs Date: Tue, 28 Dec 2010 23:52:53 +0000 Subject: add SubRip decoder Originally committed as revision 26119 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/ass.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'libavcodec/ass.c') diff --git a/libavcodec/ass.c b/libavcodec/ass.c index cd5e652c56..7553bf0778 100644 --- a/libavcodec/ass.c +++ b/libavcodec/ass.c @@ -22,6 +22,46 @@ #include "avcodec.h" #include "ass.h" +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 alignment) +{ + char header[512]; + + snprintf(header, sizeof(header), + "[Script Info]\r\n" + "ScriptType: v4.00+\r\n" + "\r\n" + "[V4+ Styles]\r\n" + "Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, AlphaLevel, Encoding\r\n" + "Style: Default,%s,%d,&H%x,&H%x,&H%x,&H%x,%d,%d,%d,1,1,0,%d,10,10,10,0,0\r\n" + "\r\n" + "[Events]\r\n" + "Format: Layer, Start, End, Text\r\n", + font, font_size, color, color, back_color, back_color, + -bold, -italic, -underline, alignment); + + avctx->subtitle_header = av_strdup(header); + if (!avctx->subtitle_header) + return AVERROR(ENOMEM); + avctx->subtitle_header_size = strlen(avctx->subtitle_header); + return 0; +} + +int ff_ass_subtitle_header_default(AVCodecContext *avctx) +{ + return ff_ass_subtitle_header(avctx, ASS_DEFAULT_FONT, + ASS_DEFAULT_FONT_SIZE, + ASS_DEFAULT_COLOR, + ASS_DEFAULT_BACK_COLOR, + ASS_DEFAULT_BOLD, + ASS_DEFAULT_ITALIC, + ASS_DEFAULT_UNDERLINE, + ASS_DEFAULT_ALIGNMENT); +} + void ff_ass_init(AVSubtitle *sub) { memset(sub, 0, sizeof(*sub)); -- cgit v1.2.3