X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fwebvttdec.c;h=cf060bd01180066863cad582eaa4eec8d19d4943;hb=ef6a9e5e311f09fa8032974fa4d0c1e166a959bb;hp=0aeb8a63f489bc081f13f8a71e4022346ca1bea2;hpb=398000abcf980d239a789da6f69811913d2fc635;p=ffmpeg diff --git a/libavformat/webvttdec.c b/libavformat/webvttdec.c index 0aeb8a63f48..cf060bd0118 100644 --- a/libavformat/webvttdec.c +++ b/libavformat/webvttdec.c @@ -37,7 +37,7 @@ typedef struct { int kind; } WebVTTContext; -static int webvtt_probe(AVProbeData *p) +static int webvtt_probe(const AVProbeData *p) { const uint8_t *ptr = p->buf; @@ -60,7 +60,7 @@ static int64_t read_ts(const char *s) static int webvtt_read_header(AVFormatContext *s) { WebVTTContext *webvtt = s->priv_data; - AVBPrint header, cue; + AVBPrint cue; int res = 0; AVStream *st = avformat_new_stream(s, NULL); @@ -71,7 +71,6 @@ static int webvtt_read_header(AVFormatContext *s) st->codecpar->codec_id = AV_CODEC_ID_WEBVTT; st->disposition |= webvtt->kind; - av_bprint_init(&header, 0, AV_BPRINT_SIZE_UNLIMITED); av_bprint_init(&cue, 0, AV_BPRINT_SIZE_UNLIMITED); for (;;) { @@ -79,7 +78,7 @@ static int webvtt_read_header(AVFormatContext *s) int64_t pos; AVPacket *sub; const char *p, *identifier, *settings; - int identifier_len, settings_len; + size_t identifier_len, settings_len; int64_t ts_start, ts_end; ff_subtitles_read_chunk(s->pb, &cue); @@ -126,7 +125,7 @@ static int webvtt_read_header(AVFormatContext *s) break; /* optional cue settings */ - p += strcspn(p, "\n\t "); + p += strcspn(p, "\n\r\t "); while (*p == '\t' || *p == ' ') p++; settings = p; @@ -165,8 +164,9 @@ static int webvtt_read_header(AVFormatContext *s) ff_subtitles_queue_finalize(s, &webvtt->q); end: + if (res < 0) + ff_subtitles_queue_clean(&webvtt->q); av_bprint_finalize(&cue, NULL); - av_bprint_finalize(&header, NULL); return res; } @@ -192,14 +192,14 @@ static int webvtt_read_close(AVFormatContext *s) } #define OFFSET(x) offsetof(WebVTTContext, x) -#define KIND_FLAGS AV_OPT_FLAG_SUBTITLE_PARAM +#define KIND_FLAGS AV_OPT_FLAG_SUBTITLE_PARAM|AV_OPT_FLAG_DECODING_PARAM static const AVOption options[] = { { "kind", "Set kind of WebVTT track", OFFSET(kind), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, KIND_FLAGS, "webvtt_kind" }, - { "subtitles", "WebVTT subtitles kind", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, 0, "webvtt_kind" }, - { "captions", "WebVTT captions kind", 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_CAPTIONS }, INT_MIN, INT_MAX, 0, "webvtt_kind" }, - { "descriptions", "WebVTT descriptions kind", 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DESCRIPTIONS }, INT_MIN, INT_MAX, 0, "webvtt_kind" }, - { "metadata", "WebVTT metadata kind", 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_METADATA }, INT_MIN, INT_MAX, 0, "webvtt_kind" }, + { "subtitles", "WebVTT subtitles kind", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, KIND_FLAGS, "webvtt_kind" }, + { "captions", "WebVTT captions kind", 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_CAPTIONS }, INT_MIN, INT_MAX, KIND_FLAGS, "webvtt_kind" }, + { "descriptions", "WebVTT descriptions kind", 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DESCRIPTIONS }, INT_MIN, INT_MAX, KIND_FLAGS, "webvtt_kind" }, + { "metadata", "WebVTT metadata kind", 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_METADATA }, INT_MIN, INT_MAX, KIND_FLAGS, "webvtt_kind" }, { NULL } };