lavc: add text encoder
This commit is contained in:
committed by
Clément Bœsch
parent
244766e407
commit
f122ba36cb
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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, \
|
||||
|
||||
Reference in New Issue
Block a user