Hi! Attached patch improves the samples from ticket #2933.
Please comment, Carl Eugen
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 2552962..9bd69c5 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -500,6 +500,7 @@ void avcodec_register_all(void) REGISTER_DECODER(MICRODVD, microdvd); REGISTER_ENCDEC (MOVTEXT, movtext); REGISTER_DECODER(MPL2, mpl2); + REGISTER_DECODER(ONCAPTION, oncaption); REGISTER_DECODER(PGSSUB, pgssub); REGISTER_DECODER(PJS, pjs); REGISTER_DECODER(REALTEXT, realtext); diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 8c7c420..be91dcb 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -525,6 +525,7 @@ enum AVCodecID { AV_CODEC_ID_VPLAYER = MKBETAG('V','P','l','r'), AV_CODEC_ID_PJS = MKBETAG('P','h','J','S'), AV_CODEC_ID_ASS = MKBETAG('A','S','S',' '), ///< ASS as defined in Matroska + AV_CODEC_ID_ONCAPTION = MKBETAG('o','n','C','a'), /* 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 c1694f3..c286a01 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -2705,6 +2705,13 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("WebVTT subtitle"), .props = AV_CODEC_PROP_TEXT_SUB, }, + { + .id = AV_CODEC_ID_ONCAPTION, + .type = AVMEDIA_TYPE_SUBTITLE, + .name = "oncaption", + .long_name = NULL_IF_CONFIG_SMALL("OnCaption FLV subtitle"), + .props = AV_CODEC_PROP_TEXT_SUB, + }, /* other kind of codecs and pseudo-codecs */ { diff --git a/libavcodec/textdec.c b/libavcodec/textdec.c index c9f02a2..6b46938 100644 --- a/libavcodec/textdec.c +++ b/libavcodec/textdec.c @@ -88,6 +88,29 @@ AVCodec ff_text_decoder = { }; #endif +#if CONFIG_ONCAPTION_DECODER +#define oncaption_options options +DECLARE_CLASS(oncaption); + +static int oncaption_linebreak_init(AVCodecContext *avctx) +{ + TextContext *text = avctx->priv_data; + text->linebreaks = "<br/>"; + return ff_ass_subtitle_header_default(avctx); +} + +AVCodec ff_oncaption_decoder = { + .name = "oncaption", + .long_name = NULL_IF_CONFIG_SMALL("OnCaption FLV subtitle"), + .priv_data_size = sizeof(TextContext), + .type = AVMEDIA_TYPE_SUBTITLE, + .id = AV_CODEC_ID_ONCAPTION, + .decode = text_decode_frame, + .init = oncaption_linebreak_init, + .priv_class = &oncaption_decoder_class, +}; +#endif + #if CONFIG_VPLAYER_DECODER || CONFIG_PJS_DECODER || CONFIG_SUBVIEWER1_DECODER || CONFIG_STL_DECODER static int linebreak_init(AVCodecContext *avctx) diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index 07f7b68..bce94ea 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -965,7 +965,7 @@ retry_duration: } else if (stream_type == FLV_STREAM_TYPE_VIDEO) { size -= flv_set_video_codec(s, st, flags & FLV_VIDEO_CODECID_MASK, 1); } else if (stream_type == FLV_STREAM_TYPE_DATA) { - st->codec->codec_id = AV_CODEC_ID_TEXT; + st->codec->codec_id = AV_CODEC_ID_ONCAPTION; } if (st->codec->codec_id == AV_CODEC_ID_AAC ||
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel