diff options
author | Clément Bœsch <u@pkh.me> | 2015-12-17 14:23:35 +0300 |
---|---|---|
committer | Clément Bœsch <clement@stupeflix.com> | 2015-12-21 13:14:02 +0300 |
commit | f122ba36cb73596fe69256d66d56c23b2ff3f653 (patch) | |
tree | 601adaa592a1534ecb5f0b76da12589f782addf7 /libavcodec/srtenc.c | |
parent | 244766e407fbed6944ada01e9b57bc6c62e36a0d (diff) |
lavc: add text encoder
Diffstat (limited to 'libavcodec/srtenc.c')
-rw-r--r-- | libavcodec/srtenc.c | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/libavcodec/srtenc.c b/libavcodec/srtenc.c index 328797089c..0a6875a51a 100644 --- a/libavcodec/srtenc.c +++ b/libavcodec/srtenc.c @@ -221,8 +221,14 @@ static const ASSCodesCallbacks srt_callbacks = { .end = srt_end_cb, }; -static int srt_encode_frame(AVCodecContext *avctx, - unsigned char *buf, int bufsize, const AVSubtitle *sub) +static const ASSCodesCallbacks text_callbacks = { + .text = srt_text_cb, + .new_line = srt_new_line_cb, +}; + +static int encode_frame(AVCodecContext *avctx, + unsigned char *buf, int bufsize, const AVSubtitle *sub, + const ASSCodesCallbacks *cb) { SRTContext *s = avctx->priv_data; ASSDialog *dialog; @@ -241,7 +247,7 @@ static int srt_encode_frame(AVCodecContext *avctx, for (; dialog && num--; dialog++) { s->alignment_applied = 0; srt_style_apply(s, dialog->style); - ff_ass_split_override_codes(&srt_callbacks, s, dialog->text); + ff_ass_split_override_codes(cb, s, dialog->text); } } @@ -259,6 +265,18 @@ static int srt_encode_frame(AVCodecContext *avctx, return s->buffer.len; } +static int srt_encode_frame(AVCodecContext *avctx, + unsigned char *buf, int bufsize, const AVSubtitle *sub) +{ + return encode_frame(avctx, buf, bufsize, sub, &srt_callbacks); +} + +static int text_encode_frame(AVCodecContext *avctx, + unsigned char *buf, int bufsize, const AVSubtitle *sub) +{ + return encode_frame(avctx, buf, bufsize, sub, &text_callbacks); +} + static int srt_encode_close(AVCodecContext *avctx) { SRTContext *s = avctx->priv_data; @@ -293,3 +311,16 @@ AVCodec ff_subrip_encoder = { .close = srt_encode_close, }; #endif + +#if CONFIG_TEXT_ENCODER +AVCodec ff_text_encoder = { + .name = "text", + .long_name = NULL_IF_CONFIG_SMALL("Raw text subtitle"), + .type = AVMEDIA_TYPE_SUBTITLE, + .id = AV_CODEC_ID_TEXT, + .priv_data_size = sizeof(SRTContext), + .init = srt_encode_init, + .encode_sub = text_encode_frame, + .close = srt_encode_close, +}; +#endif |