diff options
author | Clément Bœsch <u@pkh.me> | 2015-12-17 12:23:35 +0100 |
---|---|---|
committer | Clément Bœsch <clement@stupeflix.com> | 2015-12-21 11:14:02 +0100 |
commit | f122ba36cb73596fe69256d66d56c23b2ff3f653 (patch) | |
tree | 601adaa592a1534ecb5f0b76da12589f782addf7 /libavcodec | |
parent | 244766e407fbed6944ada01e9b57bc6c62e36a0d (diff) | |
download | ffmpeg-f122ba36cb73596fe69256d66d56c23b2ff3f653.tar.gz |
lavc: add text encoder
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/Makefile | 1 | ||||
-rw-r--r-- | libavcodec/allcodecs.c | 2 | ||||
-rw-r--r-- | libavcodec/srtenc.c | 37 | ||||
-rw-r--r-- | libavcodec/version.h | 2 |
4 files changed, 37 insertions, 5 deletions
diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 5bcd35b979..b924a72845 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -499,6 +499,7 @@ OBJS-$(CONFIG_SVQ1_ENCODER) += svq1enc.o svq1.o \ h263.o ituh263enc.o OBJS-$(CONFIG_SVQ3_DECODER) += svq3.o svq13.o mpegutils.o OBJS-$(CONFIG_TEXT_DECODER) += textdec.o ass.o +OBJS-$(CONFIG_TEXT_ENCODER) += srtenc.o ass_split.o OBJS-$(CONFIG_TAK_DECODER) += takdec.o tak.o takdsp.o OBJS-$(CONFIG_TARGA_DECODER) += targa.o OBJS-$(CONFIG_TARGA_ENCODER) += targaenc.o rle.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 245332eb1f..6361a38537 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -550,7 +550,7 @@ void avcodec_register_all(void) REGISTER_ENCDEC (SUBRIP, subrip); REGISTER_DECODER(SUBVIEWER, subviewer); REGISTER_DECODER(SUBVIEWER1, subviewer1); - REGISTER_DECODER(TEXT, text); + REGISTER_ENCDEC (TEXT, text); REGISTER_DECODER(VPLAYER, vplayer); REGISTER_ENCDEC (WEBVTT, webvtt); REGISTER_ENCDEC (XSUB, xsub); 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 diff --git a/libavcodec/version.h b/libavcodec/version.h index 72b54beaeb..b875c5954d 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #include "libavutil/version.h" #define LIBAVCODEC_VERSION_MAJOR 57 -#define LIBAVCODEC_VERSION_MINOR 18 +#define LIBAVCODEC_VERSION_MINOR 19 #define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |