diff options
author | Clément Bœsch <ubitux@gmail.com> | 2012-12-27 22:36:47 +0100 |
---|---|---|
committer | Clément Bœsch <ubitux@gmail.com> | 2012-12-30 22:46:42 +0100 |
commit | 5c68aae90883497d59a2a49cf75816cf5906e14a (patch) | |
tree | 83ede8ebe1751d4d3af4946ff8b8a1bd27a41c54 /libavcodec | |
parent | 5f02844c8d4fc93972932a84f0a5cbb02fe12a00 (diff) | |
download | ffmpeg-5c68aae90883497d59a2a49cf75816cf5906e14a.tar.gz |
Add VPlayer subtitles demuxer and decoder.
Note that the linebreaks text codec option (but not the feature) has
been removed; its main goal was to allow demuxers to configure the text
decoder (and not meant to be used by users), but the AVOption are not a
viable solution. This is solved differently in this commit.
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/Makefile | 1 | ||||
-rw-r--r-- | libavcodec/allcodecs.c | 1 | ||||
-rw-r--r-- | libavcodec/avcodec.h | 1 | ||||
-rw-r--r-- | libavcodec/codec_desc.c | 6 | ||||
-rw-r--r-- | libavcodec/textdec.c | 45 | ||||
-rw-r--r-- | libavcodec/version.h | 2 |
6 files changed, 46 insertions, 10 deletions
diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 00e9f02d8f..949c66b706 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -465,6 +465,7 @@ OBJS-$(CONFIG_VP5_DECODER) += vp5.o vp56.o vp56data.o vp56dsp.o \ OBJS-$(CONFIG_VP6_DECODER) += vp6.o vp56.o vp56data.o vp56dsp.o \ vp6dsp.o vp56rac.o OBJS-$(CONFIG_VP8_DECODER) += vp8.o vp8dsp.o vp56rac.o +OBJS-$(CONFIG_VPLAYER_DECODER) += textdec.o ass.o OBJS-$(CONFIG_VQA_DECODER) += vqavideo.o OBJS-$(CONFIG_WAVPACK_DECODER) += wavpack.o OBJS-$(CONFIG_WEBVTT_DECODER) += webvttdec.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 1194a744a4..314ef37764 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -456,6 +456,7 @@ void avcodec_register_all(void) REGISTER_ENCDEC (SUBRIP, subrip); REGISTER_DECODER(SUBVIEWER, subviewer); REGISTER_DECODER(TEXT, text); + REGISTER_DECODER(VPLAYER, vplayer); REGISTER_DECODER(WEBVTT, webvtt); REGISTER_ENCDEC (XSUB, xsub); diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 69edcc9b48..8730ccbbba 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -467,6 +467,7 @@ enum AVCodecID { AV_CODEC_ID_SUBRIP = MKBETAG('S','R','i','p'), AV_CODEC_ID_WEBVTT = MKBETAG('W','V','T','T'), AV_CODEC_ID_MPL2 = MKBETAG('M','P','L','2'), + AV_CODEC_ID_VPLAYER = MKBETAG('V','P','l','r'), /* other specific kind of codecs (generally used for attachments) */ AV_CODEC_ID_FIRST_UNKNOWN = 0x18000, ///< A dummy ID pointing at the start of various fake codecs. diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index 8de4be107e..2ea5e99629 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -2441,6 +2441,12 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("SubViewer subtitle"), }, { + .id = AV_CODEC_ID_VPLAYER, + .type = AVMEDIA_TYPE_SUBTITLE, + .name = "vplayer", + .long_name = NULL_IF_CONFIG_SMALL("VPlayer subtitle"), + }, + { .id = AV_CODEC_ID_WEBVTT, .type = AVMEDIA_TYPE_SUBTITLE, .name = "webvtt", diff --git a/libavcodec/textdec.c b/libavcodec/textdec.c index 4b3a4ada3c..9e19b37dd9 100644 --- a/libavcodec/textdec.c +++ b/libavcodec/textdec.c @@ -30,25 +30,17 @@ typedef struct { AVClass *class; - char *linebreaks; + const char *linebreaks; int keep_ass_markup; } TextContext; #define OFFSET(x) offsetof(TextContext, x) #define SD AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_DECODING_PARAM static const AVOption options[] = { - { "linebreaks", "Extra line breaks characters", OFFSET(linebreaks), AV_OPT_TYPE_STRING, {.str=NULL}, .flags=SD }, { "keep_ass_markup", "Set if ASS tags must be escaped", OFFSET(keep_ass_markup), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, .flags=SD }, { NULL } }; -static const AVClass text_decoder_class = { - .class_name = "text decoder", - .item_name = av_default_item_name, - .option = options, - .version = LIBAVUTIL_VERSION_INT, -}; - static int text_event_to_ass(const AVCodecContext *avctx, AVBPrint *buf, const char *p, const char *p_end) { @@ -113,6 +105,17 @@ static int text_decode_frame(AVCodecContext *avctx, void *data, return avpkt->size; } +#define DECLARE_CLASS(decname) static const AVClass decname ## _decoder_class = { \ + .class_name = #decname " decoder", \ + .item_name = av_default_item_name, \ + .option = decname ## _options, \ + .version = LIBAVUTIL_VERSION_INT, \ +} + +#if CONFIG_TEXT_DECODER +#define text_options options +DECLARE_CLASS(text); + AVCodec ff_text_decoder = { .name = "text", .priv_data_size = sizeof(TextContext), @@ -123,3 +126,27 @@ AVCodec ff_text_decoder = { .init = ff_ass_subtitle_header_default, .priv_class = &text_decoder_class, }; +#endif + +#if CONFIG_VPLAYER_DECODER +#define vplayer_options options +DECLARE_CLASS(vplayer); + +static int vplayer_init(AVCodecContext *avctx) +{ + TextContext *text = avctx->priv_data; + text->linebreaks = "|"; + return ff_ass_subtitle_header_default(avctx); +} + +AVCodec ff_vplayer_decoder = { + .name = "vplayer", + .priv_data_size = sizeof(TextContext), + .long_name = NULL_IF_CONFIG_SMALL("VPlayer subtitle"), + .type = AVMEDIA_TYPE_SUBTITLE, + .id = AV_CODEC_ID_VPLAYER, + .decode = text_decode_frame, + .init = vplayer_init, + .priv_class = &vplayer_decoder_class, +}; +#endif diff --git a/libavcodec/version.h b/libavcodec/version.h index 32d3650edf..bdd94b4e56 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #include "libavutil/avutil.h" #define LIBAVCODEC_VERSION_MAJOR 54 -#define LIBAVCODEC_VERSION_MINOR 82 +#define LIBAVCODEC_VERSION_MINOR 83 #define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |