summaryrefslogtreecommitdiff
path: root/libavcodec/ass.c
diff options
context:
space:
mode:
authorAurelien Jacobs <aurel@gnuage.org>2010-12-28 23:52:53 +0000
committerAurelien Jacobs <aurel@gnuage.org>2010-12-28 23:52:53 +0000
commit2c77c90684e24ef16f7e7c4462e011434cee6a98 (patch)
tree95a6f69d324c64a8d115e424e76b2fbaf8e669b3 /libavcodec/ass.c
parent312056c54edd6b37a2781f32331d71b7e967342d (diff)
add SubRip decoder
Originally committed as revision 26119 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/ass.c')
-rw-r--r--libavcodec/ass.c40
1 files changed, 40 insertions, 0 deletions
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));