diff --git a/libavformat/assdec.c b/libavformat/assdec.c index 5f71fcb024..2ab7fb9efb 100644 --- a/libavformat/assdec.c +++ b/libavformat/assdec.c @@ -50,13 +50,6 @@ static int ass_probe(const AVProbeData *p) return 0; } -static int ass_read_close(AVFormatContext *s) -{ - ASSContext *ass = s->priv_data; - ff_subtitles_queue_clean(&ass->q); - return 0; -} - static int read_dialogue(ASSContext *ass, AVBPrint *dst, const uint8_t *p, int64_t *start, int *duration) { @@ -166,20 +159,6 @@ end: return res; } -static int ass_read_packet(AVFormatContext *s, AVPacket *pkt) -{ - ASSContext *ass = s->priv_data; - return ff_subtitles_queue_read_packet(&ass->q, pkt); -} - -static int ass_read_seek(AVFormatContext *s, int stream_index, - int64_t min_ts, int64_t ts, int64_t max_ts, int flags) -{ - ASSContext *ass = s->priv_data; - return ff_subtitles_queue_seek(&ass->q, s, stream_index, - min_ts, ts, max_ts, flags); -} - const AVInputFormat ff_ass_demuxer = { .name = "ass", .long_name = NULL_IF_CONFIG_SMALL("SSA (SubStation Alpha) subtitle"), @@ -187,7 +166,7 @@ const AVInputFormat ff_ass_demuxer = { .priv_data_size = sizeof(ASSContext), .read_probe = ass_probe, .read_header = ass_read_header, - .read_packet = ass_read_packet, - .read_close = ass_read_close, - .read_seek2 = ass_read_seek, + .read_packet = ff_subtitles_read_packet, + .read_close = ff_subtitles_read_close, + .read_seek2 = ff_subtitles_read_seek, }; diff --git a/libavformat/jacosubdec.c b/libavformat/jacosubdec.c index 510219224f..8cb918ccee 100644 --- a/libavformat/jacosubdec.c +++ b/libavformat/jacosubdec.c @@ -35,9 +35,9 @@ #include "libavutil/intreadwrite.h" typedef struct { + FFDemuxSubtitlesQueue q; int shift; unsigned timeres; - FFDemuxSubtitlesQueue q; } JACOsubContext; static int timed_line(const char *ptr) @@ -93,13 +93,6 @@ static int get_jss_cmd(char k) return -1; } -static int jacosub_read_close(AVFormatContext *s) -{ - JACOsubContext *jacosub = s->priv_data; - ff_subtitles_queue_clean(&jacosub->q); - return 0; -} - static const char *read_ts(JACOsubContext *jacosub, const char *buf, int64_t *start, int64_t *duration) { @@ -258,20 +251,6 @@ static int jacosub_read_header(AVFormatContext *s) return 0; } -static int jacosub_read_packet(AVFormatContext *s, AVPacket *pkt) -{ - JACOsubContext *jacosub = s->priv_data; - return ff_subtitles_queue_read_packet(&jacosub->q, pkt); -} - -static int jacosub_read_seek(AVFormatContext *s, int stream_index, - int64_t min_ts, int64_t ts, int64_t max_ts, int flags) -{ - JACOsubContext *jacosub = s->priv_data; - return ff_subtitles_queue_seek(&jacosub->q, s, stream_index, - min_ts, ts, max_ts, flags); -} - const AVInputFormat ff_jacosub_demuxer = { .name = "jacosub", .long_name = NULL_IF_CONFIG_SMALL("JACOsub subtitle format"), @@ -279,7 +258,7 @@ const AVInputFormat ff_jacosub_demuxer = { .flags_internal = FF_FMT_INIT_CLEANUP, .read_probe = jacosub_probe, .read_header = jacosub_read_header, - .read_packet = jacosub_read_packet, - .read_seek2 = jacosub_read_seek, - .read_close = jacosub_read_close, + .read_packet = ff_subtitles_read_packet, + .read_seek2 = ff_subtitles_read_seek, + .read_close = ff_subtitles_read_close, }; diff --git a/libavformat/lrcdec.c b/libavformat/lrcdec.c index 309014d630..fff39495f8 100644 --- a/libavformat/lrcdec.c +++ b/libavformat/lrcdec.c @@ -218,27 +218,6 @@ static int lrc_read_header(AVFormatContext *s) return 0; } -static int lrc_read_packet(AVFormatContext *s, AVPacket *pkt) -{ - LRCContext *lrc = s->priv_data; - return ff_subtitles_queue_read_packet(&lrc->q, pkt); -} - -static int lrc_read_seek(AVFormatContext *s, int stream_index, - int64_t min_ts, int64_t ts, int64_t max_ts, int flags) -{ - LRCContext *lrc = s->priv_data; - return ff_subtitles_queue_seek(&lrc->q, s, stream_index, - min_ts, ts, max_ts, flags); -} - -static int lrc_read_close(AVFormatContext *s) -{ - LRCContext *lrc = s->priv_data; - ff_subtitles_queue_clean(&lrc->q); - return 0; -} - const AVInputFormat ff_lrc_demuxer = { .name = "lrc", .long_name = NULL_IF_CONFIG_SMALL("LRC lyrics"), @@ -246,7 +225,7 @@ const AVInputFormat ff_lrc_demuxer = { .flags_internal = FF_FMT_INIT_CLEANUP, .read_probe = lrc_probe, .read_header = lrc_read_header, - .read_packet = lrc_read_packet, - .read_close = lrc_read_close, - .read_seek2 = lrc_read_seek + .read_packet = ff_subtitles_read_packet, + .read_close = ff_subtitles_read_close, + .read_seek2 = ff_subtitles_read_seek }; diff --git a/libavformat/mccdec.c b/libavformat/mccdec.c index 0bc13ceaa6..8c36b27f12 100644 --- a/libavformat/mccdec.c +++ b/libavformat/mccdec.c @@ -200,27 +200,6 @@ static int mcc_read_header(AVFormatContext *s) return ret; } -static int mcc_read_packet(AVFormatContext *s, AVPacket *pkt) -{ - MCCContext *mcc = s->priv_data; - return ff_subtitles_queue_read_packet(&mcc->q, pkt); -} - -static int mcc_read_seek(AVFormatContext *s, int stream_index, - int64_t min_ts, int64_t ts, int64_t max_ts, int flags) -{ - MCCContext *mcc = s->priv_data; - return ff_subtitles_queue_seek(&mcc->q, s, stream_index, - min_ts, ts, max_ts, flags); -} - -static int mcc_read_close(AVFormatContext *s) -{ - MCCContext *mcc = s->priv_data; - ff_subtitles_queue_clean(&mcc->q); - return 0; -} - const AVInputFormat ff_mcc_demuxer = { .name = "mcc", .long_name = NULL_IF_CONFIG_SMALL("MacCaption"), @@ -228,8 +207,8 @@ const AVInputFormat ff_mcc_demuxer = { .flags_internal = FF_FMT_INIT_CLEANUP, .read_probe = mcc_probe, .read_header = mcc_read_header, - .read_packet = mcc_read_packet, - .read_seek2 = mcc_read_seek, - .read_close = mcc_read_close, .extensions = "mcc", + .read_packet = ff_subtitles_read_packet, + .read_seek2 = ff_subtitles_read_seek, + .read_close = ff_subtitles_read_close, }; diff --git a/libavformat/mpl2dec.c b/libavformat/mpl2dec.c index 0beb9ca388..912a707d1a 100644 --- a/libavformat/mpl2dec.c +++ b/libavformat/mpl2dec.c @@ -122,27 +122,6 @@ static int mpl2_read_header(AVFormatContext *s) return 0; } -static int mpl2_read_packet(AVFormatContext *s, AVPacket *pkt) -{ - MPL2Context *mpl2 = s->priv_data; - return ff_subtitles_queue_read_packet(&mpl2->q, pkt); -} - -static int mpl2_read_seek(AVFormatContext *s, int stream_index, - int64_t min_ts, int64_t ts, int64_t max_ts, int flags) -{ - MPL2Context *mpl2 = s->priv_data; - return ff_subtitles_queue_seek(&mpl2->q, s, stream_index, - min_ts, ts, max_ts, flags); -} - -static int mpl2_read_close(AVFormatContext *s) -{ - MPL2Context *mpl2 = s->priv_data; - ff_subtitles_queue_clean(&mpl2->q); - return 0; -} - const AVInputFormat ff_mpl2_demuxer = { .name = "mpl2", .long_name = NULL_IF_CONFIG_SMALL("MPL2 subtitles"), @@ -150,8 +129,8 @@ const AVInputFormat ff_mpl2_demuxer = { .flags_internal = FF_FMT_INIT_CLEANUP, .read_probe = mpl2_probe, .read_header = mpl2_read_header, - .read_packet = mpl2_read_packet, - .read_seek2 = mpl2_read_seek, - .read_close = mpl2_read_close, .extensions = "txt,mpl2", + .read_packet = ff_subtitles_read_packet, + .read_seek2 = ff_subtitles_read_seek, + .read_close = ff_subtitles_read_close, }; diff --git a/libavformat/mpsubdec.c b/libavformat/mpsubdec.c index abf0e7fb9a..d290a41fb9 100644 --- a/libavformat/mpsubdec.c +++ b/libavformat/mpsubdec.c @@ -169,27 +169,6 @@ end: return res; } -static int mpsub_read_packet(AVFormatContext *s, AVPacket *pkt) -{ - MPSubContext *mpsub = s->priv_data; - return ff_subtitles_queue_read_packet(&mpsub->q, pkt); -} - -static int mpsub_read_seek(AVFormatContext *s, int stream_index, - int64_t min_ts, int64_t ts, int64_t max_ts, int flags) -{ - MPSubContext *mpsub = s->priv_data; - return ff_subtitles_queue_seek(&mpsub->q, s, stream_index, - min_ts, ts, max_ts, flags); -} - -static int mpsub_read_close(AVFormatContext *s) -{ - MPSubContext *mpsub = s->priv_data; - ff_subtitles_queue_clean(&mpsub->q); - return 0; -} - const AVInputFormat ff_mpsub_demuxer = { .name = "mpsub", .long_name = NULL_IF_CONFIG_SMALL("MPlayer subtitles"), @@ -197,8 +176,8 @@ const AVInputFormat ff_mpsub_demuxer = { .flags_internal = FF_FMT_INIT_CLEANUP, .read_probe = mpsub_probe, .read_header = mpsub_read_header, - .read_packet = mpsub_read_packet, - .read_seek2 = mpsub_read_seek, - .read_close = mpsub_read_close, .extensions = "sub", + .read_packet = ff_subtitles_read_packet, + .read_seek2 = ff_subtitles_read_seek, + .read_close = ff_subtitles_read_close, }; diff --git a/libavformat/pjsdec.c b/libavformat/pjsdec.c index 1fc16831ea..5b2111f726 100644 --- a/libavformat/pjsdec.c +++ b/libavformat/pjsdec.c @@ -105,27 +105,6 @@ static int pjs_read_header(AVFormatContext *s) return 0; } -static int pjs_read_packet(AVFormatContext *s, AVPacket *pkt) -{ - PJSContext *pjs = s->priv_data; - return ff_subtitles_queue_read_packet(&pjs->q, pkt); -} - -static int pjs_read_seek(AVFormatContext *s, int stream_index, - int64_t min_ts, int64_t ts, int64_t max_ts, int flags) -{ - PJSContext *pjs = s->priv_data; - return ff_subtitles_queue_seek(&pjs->q, s, stream_index, - min_ts, ts, max_ts, flags); -} - -static int pjs_read_close(AVFormatContext *s) -{ - PJSContext *pjs = s->priv_data; - ff_subtitles_queue_clean(&pjs->q); - return 0; -} - const AVInputFormat ff_pjs_demuxer = { .name = "pjs", .long_name = NULL_IF_CONFIG_SMALL("PJS (Phoenix Japanimation Society) subtitles"), @@ -133,8 +112,8 @@ const AVInputFormat ff_pjs_demuxer = { .flags_internal = FF_FMT_INIT_CLEANUP, .read_probe = pjs_probe, .read_header = pjs_read_header, - .read_packet = pjs_read_packet, - .read_seek2 = pjs_read_seek, - .read_close = pjs_read_close, .extensions = "pjs", + .read_packet = ff_subtitles_read_packet, + .read_seek2 = ff_subtitles_read_seek, + .read_close = ff_subtitles_read_close, }; diff --git a/libavformat/realtextdec.c b/libavformat/realtextdec.c index e0e2cc90e6..c281dec346 100644 --- a/libavformat/realtextdec.c +++ b/libavformat/realtextdec.c @@ -127,27 +127,6 @@ end: return res; } -static int realtext_read_packet(AVFormatContext *s, AVPacket *pkt) -{ - RealTextContext *rt = s->priv_data; - return ff_subtitles_queue_read_packet(&rt->q, pkt); -} - -static int realtext_read_seek(AVFormatContext *s, int stream_index, - int64_t min_ts, int64_t ts, int64_t max_ts, int flags) -{ - RealTextContext *rt = s->priv_data; - return ff_subtitles_queue_seek(&rt->q, s, stream_index, - min_ts, ts, max_ts, flags); -} - -static int realtext_read_close(AVFormatContext *s) -{ - RealTextContext *rt = s->priv_data; - ff_subtitles_queue_clean(&rt->q); - return 0; -} - const AVInputFormat ff_realtext_demuxer = { .name = "realtext", .long_name = NULL_IF_CONFIG_SMALL("RealText subtitle format"), @@ -155,8 +134,8 @@ const AVInputFormat ff_realtext_demuxer = { .flags_internal = FF_FMT_INIT_CLEANUP, .read_probe = realtext_probe, .read_header = realtext_read_header, - .read_packet = realtext_read_packet, - .read_seek2 = realtext_read_seek, - .read_close = realtext_read_close, .extensions = "rt", + .read_packet = ff_subtitles_read_packet, + .read_seek2 = ff_subtitles_read_seek, + .read_close = ff_subtitles_read_close, }; diff --git a/libavformat/samidec.c b/libavformat/samidec.c index c23335cf4d..698164b6a2 100644 --- a/libavformat/samidec.c +++ b/libavformat/samidec.c @@ -119,27 +119,6 @@ end: return res; } -static int sami_read_packet(AVFormatContext *s, AVPacket *pkt) -{ - SAMIContext *sami = s->priv_data; - return ff_subtitles_queue_read_packet(&sami->q, pkt); -} - -static int sami_read_seek(AVFormatContext *s, int stream_index, - int64_t min_ts, int64_t ts, int64_t max_ts, int flags) -{ - SAMIContext *sami = s->priv_data; - return ff_subtitles_queue_seek(&sami->q, s, stream_index, - min_ts, ts, max_ts, flags); -} - -static int sami_read_close(AVFormatContext *s) -{ - SAMIContext *sami = s->priv_data; - ff_subtitles_queue_clean(&sami->q); - return 0; -} - const AVInputFormat ff_sami_demuxer = { .name = "sami", .long_name = NULL_IF_CONFIG_SMALL("SAMI subtitle format"), @@ -147,8 +126,8 @@ const AVInputFormat ff_sami_demuxer = { .flags_internal = FF_FMT_INIT_CLEANUP, .read_probe = sami_probe, .read_header = sami_read_header, - .read_packet = sami_read_packet, - .read_seek2 = sami_read_seek, - .read_close = sami_read_close, .extensions = "smi,sami", + .read_packet = ff_subtitles_read_packet, + .read_seek2 = ff_subtitles_read_seek, + .read_close = ff_subtitles_read_close, }; diff --git a/libavformat/sccdec.c b/libavformat/sccdec.c index e59e015bbc..e95fd881a3 100644 --- a/libavformat/sccdec.c +++ b/libavformat/sccdec.c @@ -177,27 +177,6 @@ static int scc_read_header(AVFormatContext *s) return 0; } -static int scc_read_packet(AVFormatContext *s, AVPacket *pkt) -{ - SCCContext *scc = s->priv_data; - return ff_subtitles_queue_read_packet(&scc->q, pkt); -} - -static int scc_read_seek(AVFormatContext *s, int stream_index, - int64_t min_ts, int64_t ts, int64_t max_ts, int flags) -{ - SCCContext *scc = s->priv_data; - return ff_subtitles_queue_seek(&scc->q, s, stream_index, - min_ts, ts, max_ts, flags); -} - -static int scc_read_close(AVFormatContext *s) -{ - SCCContext *scc = s->priv_data; - ff_subtitles_queue_clean(&scc->q); - return 0; -} - const AVInputFormat ff_scc_demuxer = { .name = "scc", .long_name = NULL_IF_CONFIG_SMALL("Scenarist Closed Captions"), @@ -205,8 +184,8 @@ const AVInputFormat ff_scc_demuxer = { .flags_internal = FF_FMT_INIT_CLEANUP, .read_probe = scc_probe, .read_header = scc_read_header, - .read_packet = scc_read_packet, - .read_seek2 = scc_read_seek, - .read_close = scc_read_close, .extensions = "scc", + .read_packet = ff_subtitles_read_packet, + .read_seek2 = ff_subtitles_read_seek, + .read_close = ff_subtitles_read_close, }; diff --git a/libavformat/srtdec.c b/libavformat/srtdec.c index 2f8a677b9f..bf02450555 100644 --- a/libavformat/srtdec.c +++ b/libavformat/srtdec.c @@ -211,27 +211,6 @@ end: return res; } -static int srt_read_packet(AVFormatContext *s, AVPacket *pkt) -{ - SRTContext *srt = s->priv_data; - return ff_subtitles_queue_read_packet(&srt->q, pkt); -} - -static int srt_read_seek(AVFormatContext *s, int stream_index, - int64_t min_ts, int64_t ts, int64_t max_ts, int flags) -{ - SRTContext *srt = s->priv_data; - return ff_subtitles_queue_seek(&srt->q, s, stream_index, - min_ts, ts, max_ts, flags); -} - -static int srt_read_close(AVFormatContext *s) -{ - SRTContext *srt = s->priv_data; - ff_subtitles_queue_clean(&srt->q); - return 0; -} - const AVInputFormat ff_srt_demuxer = { .name = "srt", .long_name = NULL_IF_CONFIG_SMALL("SubRip subtitle"), @@ -239,7 +218,7 @@ const AVInputFormat ff_srt_demuxer = { .flags_internal = FF_FMT_INIT_CLEANUP, .read_probe = srt_probe, .read_header = srt_read_header, - .read_packet = srt_read_packet, - .read_seek2 = srt_read_seek, - .read_close = srt_read_close, + .read_packet = ff_subtitles_read_packet, + .read_seek2 = ff_subtitles_read_seek, + .read_close = ff_subtitles_read_close, }; diff --git a/libavformat/stldec.c b/libavformat/stldec.c index 48e18d865e..b5c8439dc2 100644 --- a/libavformat/stldec.c +++ b/libavformat/stldec.c @@ -107,26 +107,6 @@ static int stl_read_header(AVFormatContext *s) ff_subtitles_queue_finalize(s, &stl->q); return 0; } -static int stl_read_packet(AVFormatContext *s, AVPacket *pkt) -{ - STLContext *stl = s->priv_data; - return ff_subtitles_queue_read_packet(&stl->q, pkt); -} - -static int stl_read_seek(AVFormatContext *s, int stream_index, - int64_t min_ts, int64_t ts, int64_t max_ts, int flags) -{ - STLContext *stl = s->priv_data; - return ff_subtitles_queue_seek(&stl->q, s, stream_index, - min_ts, ts, max_ts, flags); -} - -static int stl_read_close(AVFormatContext *s) -{ - STLContext *stl = s->priv_data; - ff_subtitles_queue_clean(&stl->q); - return 0; -} const AVInputFormat ff_stl_demuxer = { .name = "stl", @@ -135,8 +115,8 @@ const AVInputFormat ff_stl_demuxer = { .flags_internal = FF_FMT_INIT_CLEANUP, .read_probe = stl_probe, .read_header = stl_read_header, - .read_packet = stl_read_packet, - .read_seek2 = stl_read_seek, - .read_close = stl_read_close, .extensions = "stl", + .read_packet = ff_subtitles_read_packet, + .read_seek2 = ff_subtitles_read_seek, + .read_close = ff_subtitles_read_close, }; diff --git a/libavformat/subtitles.c b/libavformat/subtitles.c index 6368ec74f9..82aaa358c0 100644 --- a/libavformat/subtitles.c +++ b/libavformat/subtitles.c @@ -314,6 +314,27 @@ void ff_subtitles_queue_clean(FFDemuxSubtitlesQueue *q) q->nb_subs = q->allocated_size = q->current_sub_idx = 0; } +int ff_subtitles_read_packet(AVFormatContext *s, AVPacket *pkt) +{ + FFDemuxSubtitlesQueue *q = s->priv_data; + return ff_subtitles_queue_read_packet(q, pkt); +} + +int ff_subtitles_read_seek(AVFormatContext *s, int stream_index, + int64_t min_ts, int64_t ts, int64_t max_ts, int flags) +{ + FFDemuxSubtitlesQueue *q = s->priv_data; + return ff_subtitles_queue_seek(q, s, stream_index, + min_ts, ts, max_ts, flags); +} + +int ff_subtitles_read_close(AVFormatContext *s) +{ + FFDemuxSubtitlesQueue *q = s->priv_data; + ff_subtitles_queue_clean(q); + return 0; +} + int ff_smil_extract_next_text_chunk(FFTextReader *tr, AVBPrint *buf, char *c) { int i = 0; diff --git a/libavformat/subtitles.h b/libavformat/subtitles.h index ca769639be..37ca7b19b1 100644 --- a/libavformat/subtitles.h +++ b/libavformat/subtitles.h @@ -143,6 +143,13 @@ int ff_subtitles_queue_seek(FFDemuxSubtitlesQueue *q, AVFormatContext *s, int st */ void ff_subtitles_queue_clean(FFDemuxSubtitlesQueue *q); +int ff_subtitles_read_packet(AVFormatContext *s, AVPacket *pkt); + +int ff_subtitles_read_seek(AVFormatContext *s, int stream_index, + int64_t min_ts, int64_t ts, int64_t max_ts, int flags); + +int ff_subtitles_read_close(AVFormatContext *s); + /** * SMIL helper to load next chunk ("<...>" or untagged content) in buf. * diff --git a/libavformat/subviewer1dec.c b/libavformat/subviewer1dec.c index f1267031f8..bdcbef30ef 100644 --- a/libavformat/subviewer1dec.c +++ b/libavformat/subviewer1dec.c @@ -90,27 +90,6 @@ static int subviewer1_read_header(AVFormatContext *s) return 0; } -static int subviewer1_read_packet(AVFormatContext *s, AVPacket *pkt) -{ - SubViewer1Context *subviewer1 = s->priv_data; - return ff_subtitles_queue_read_packet(&subviewer1->q, pkt); -} - -static int subviewer1_read_seek(AVFormatContext *s, int stream_index, - int64_t min_ts, int64_t ts, int64_t max_ts, int flags) -{ - SubViewer1Context *subviewer1 = s->priv_data; - return ff_subtitles_queue_seek(&subviewer1->q, s, stream_index, - min_ts, ts, max_ts, flags); -} - -static int subviewer1_read_close(AVFormatContext *s) -{ - SubViewer1Context *subviewer1 = s->priv_data; - ff_subtitles_queue_clean(&subviewer1->q); - return 0; -} - const AVInputFormat ff_subviewer1_demuxer = { .name = "subviewer1", .long_name = NULL_IF_CONFIG_SMALL("SubViewer v1 subtitle format"), @@ -118,8 +97,8 @@ const AVInputFormat ff_subviewer1_demuxer = { .flags_internal = FF_FMT_INIT_CLEANUP, .read_probe = subviewer1_probe, .read_header = subviewer1_read_header, - .read_packet = subviewer1_read_packet, - .read_seek2 = subviewer1_read_seek, - .read_close = subviewer1_read_close, .extensions = "sub", + .read_packet = ff_subtitles_read_packet, + .read_seek2 = ff_subtitles_read_seek, + .read_close = ff_subtitles_read_close, }; diff --git a/libavformat/subviewerdec.c b/libavformat/subviewerdec.c index 2ef3c088eb..bcd103bd86 100644 --- a/libavformat/subviewerdec.c +++ b/libavformat/subviewerdec.c @@ -180,27 +180,6 @@ end: return res; } -static int subviewer_read_packet(AVFormatContext *s, AVPacket *pkt) -{ - SubViewerContext *subviewer = s->priv_data; - return ff_subtitles_queue_read_packet(&subviewer->q, pkt); -} - -static int subviewer_read_seek(AVFormatContext *s, int stream_index, - int64_t min_ts, int64_t ts, int64_t max_ts, int flags) -{ - SubViewerContext *subviewer = s->priv_data; - return ff_subtitles_queue_seek(&subviewer->q, s, stream_index, - min_ts, ts, max_ts, flags); -} - -static int subviewer_read_close(AVFormatContext *s) -{ - SubViewerContext *subviewer = s->priv_data; - ff_subtitles_queue_clean(&subviewer->q); - return 0; -} - const AVInputFormat ff_subviewer_demuxer = { .name = "subviewer", .long_name = NULL_IF_CONFIG_SMALL("SubViewer subtitle format"), @@ -208,8 +187,8 @@ const AVInputFormat ff_subviewer_demuxer = { .flags_internal = FF_FMT_INIT_CLEANUP, .read_probe = subviewer_probe, .read_header = subviewer_read_header, - .read_packet = subviewer_read_packet, - .read_seek2 = subviewer_read_seek, - .read_close = subviewer_read_close, .extensions = "sub", + .read_packet = ff_subtitles_read_packet, + .read_seek2 = ff_subtitles_read_seek, + .read_close = ff_subtitles_read_close, }; diff --git a/libavformat/vplayerdec.c b/libavformat/vplayerdec.c index 8c9ff81163..b37f6c8f64 100644 --- a/libavformat/vplayerdec.c +++ b/libavformat/vplayerdec.c @@ -95,27 +95,6 @@ static int vplayer_read_header(AVFormatContext *s) return 0; } -static int vplayer_read_packet(AVFormatContext *s, AVPacket *pkt) -{ - VPlayerContext *vplayer = s->priv_data; - return ff_subtitles_queue_read_packet(&vplayer->q, pkt); -} - -static int vplayer_read_seek(AVFormatContext *s, int stream_index, - int64_t min_ts, int64_t ts, int64_t max_ts, int flags) -{ - VPlayerContext *vplayer = s->priv_data; - return ff_subtitles_queue_seek(&vplayer->q, s, stream_index, - min_ts, ts, max_ts, flags); -} - -static int vplayer_read_close(AVFormatContext *s) -{ - VPlayerContext *vplayer = s->priv_data; - ff_subtitles_queue_clean(&vplayer->q); - return 0; -} - const AVInputFormat ff_vplayer_demuxer = { .name = "vplayer", .long_name = NULL_IF_CONFIG_SMALL("VPlayer subtitles"), @@ -123,8 +102,8 @@ const AVInputFormat ff_vplayer_demuxer = { .flags_internal = FF_FMT_INIT_CLEANUP, .read_probe = vplayer_probe, .read_header = vplayer_read_header, - .read_packet = vplayer_read_packet, - .read_seek2 = vplayer_read_seek, - .read_close = vplayer_read_close, .extensions = "txt", + .read_packet = ff_subtitles_read_packet, + .read_seek2 = ff_subtitles_read_seek, + .read_close = ff_subtitles_read_close, };