diff options
author | Philip Langdale <philipl@overt.org> | 2012-08-12 14:18:35 -0700 |
---|---|---|
committer | Philip Langdale <philipl@overt.org> | 2012-08-15 20:46:54 -0700 |
commit | 6057de19b5e0075fea55a3a0cb9d225ba3a6f9a4 (patch) | |
tree | 0240e9ba5e109ca680013d6c4b221f4c95b7d8f6 /libavcodec | |
parent | 6af680fa070ebc5081045e4b24ceaa4fccfa89b4 (diff) | |
download | ffmpeg-6057de19b5e0075fea55a3a0cb9d225ba3a6f9a4.tar.gz |
srtenc: Add timing-less "subrip" encoder.
Unsurprisingly, if a timing-less subrip decoder is desireable, an
encoder is as well. With this in place, we can move on to remove
the use of the old encoder/decoder with embedded timing and move
all timing handling the (de)muxer where they belong.
Signed-off-by: Philip Langdale <philipl@overt.org>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/Makefile | 1 | ||||
-rw-r--r-- | libavcodec/allcodecs.c | 2 | ||||
-rw-r--r-- | libavcodec/srtenc.c | 39 | ||||
-rw-r--r-- | libavcodec/version.h | 2 |
4 files changed, 31 insertions, 13 deletions
diff --git a/libavcodec/Makefile b/libavcodec/Makefile index bab97e4767..ed861aeaa6 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -409,6 +409,7 @@ OBJS-$(CONFIG_SP5X_DECODER) += sp5xdec.o mjpegdec.o mjpeg.o OBJS-$(CONFIG_SRT_DECODER) += srtdec.o ass.o OBJS-$(CONFIG_SRT_ENCODER) += srtenc.o ass_split.o OBJS-$(CONFIG_SUBRIP_DECODER) += srtdec.o ass.o +OBJS-$(CONFIG_SUBRIP_ENCODER) += srtenc.o ass_split.o OBJS-$(CONFIG_SUBVIEWER_DECODER) += subviewerdec.o ass.o OBJS-$(CONFIG_SUNRAST_DECODER) += sunrast.o OBJS-$(CONFIG_SUNRAST_ENCODER) += sunrastenc.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index f7ae4498b3..98147732ed 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -415,7 +415,7 @@ void avcodec_register_all(void) REGISTER_DECODER (REALTEXT, realtext); REGISTER_DECODER (SAMI, sami); REGISTER_ENCDEC (SRT, srt); - REGISTER_DECODER (SUBRIP, subrip); + REGISTER_ENCDEC (SUBRIP, subrip); REGISTER_DECODER (SUBVIEWER, subviewer); REGISTER_ENCDEC (XSUB, xsub); diff --git a/libavcodec/srtenc.c b/libavcodec/srtenc.c index 9e152c70c7..dfc4e6c47c 100644 --- a/libavcodec/srtenc.c +++ b/libavcodec/srtenc.c @@ -252,16 +252,18 @@ static int srt_encode_frame(AVCodecContext *avctx, dialog = ff_ass_split_dialog(s->ass_ctx, sub->rects[i]->ass, 0, &num); for (; dialog && num--; dialog++) { - int sh, sm, ss, sc = 10 * dialog->start; - int eh, em, es, ec = 10 * dialog->end; - sh = sc/3600000; sc -= 3600000*sh; - sm = sc/ 60000; sc -= 60000*sm; - ss = sc/ 1000; sc -= 1000*ss; - eh = ec/3600000; ec -= 3600000*eh; - em = ec/ 60000; ec -= 60000*em; - es = ec/ 1000; ec -= 1000*es; - srt_print(s,"%d\r\n%02d:%02d:%02d,%03d --> %02d:%02d:%02d,%03d\r\n", - ++s->count, sh, sm, ss, sc, eh, em, es, ec); + if (avctx->codec->id == CODEC_ID_SRT) { + int sh, sm, ss, sc = 10 * dialog->start; + int eh, em, es, ec = 10 * dialog->end; + sh = sc/3600000; sc -= 3600000*sh; + sm = sc/ 60000; sc -= 60000*sm; + ss = sc/ 1000; sc -= 1000*ss; + eh = ec/3600000; ec -= 3600000*eh; + em = ec/ 60000; ec -= 60000*em; + es = ec/ 1000; ec -= 1000*es; + srt_print(s,"%d\r\n%02d:%02d:%02d,%03d --> %02d:%02d:%02d,%03d\r\n", + ++s->count, sh, sm, ss, sc, eh, em, es, ec); + } s->alignment_applied = 0; s->dialog_start = s->ptr - 2; srt_style_apply(s, dialog->style); @@ -289,9 +291,10 @@ static int srt_encode_close(AVCodecContext *avctx) return 0; } +#if CONFIG_SRT_ENCODER AVCodec ff_srt_encoder = { .name = "srt", - .long_name = NULL_IF_CONFIG_SMALL("SubRip subtitle"), + .long_name = NULL_IF_CONFIG_SMALL("SubRip subtitle with embedded timing"), .type = AVMEDIA_TYPE_SUBTITLE, .id = AV_CODEC_ID_SRT, .priv_data_size = sizeof(SRTContext), @@ -299,3 +302,17 @@ AVCodec ff_srt_encoder = { .encode = srt_encode_frame, .close = srt_encode_close, }; +#endif + +#if CONFIG_SUBRIP_ENCODER +AVCodec ff_subrip_encoder = { + .name = "subrip", + .long_name = NULL_IF_CONFIG_SMALL("SubRip subtitle"), + .type = AVMEDIA_TYPE_SUBTITLE, + .id = AV_CODEC_ID_SUBRIP, + .priv_data_size = sizeof(SRTContext), + .init = srt_encode_init, + .encode = srt_encode_frame, + .close = srt_encode_close, +}; +#endif diff --git a/libavcodec/version.h b/libavcodec/version.h index f2c5151a3e..7f4db0b566 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -27,7 +27,7 @@ */ #define LIBAVCODEC_VERSION_MAJOR 54 -#define LIBAVCODEC_VERSION_MINOR 52 +#define LIBAVCODEC_VERSION_MINOR 53 #define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |