[FFmpeg-cvslog] avformat/matroskadec: Move WEBVTT code to mkv_parse_subtitle_codec()
Andreas Rheinhardt
git at videolan.org
Thu Sep 7 02:19:06 EEST 2023
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Mon Sep 4 00:22:14 2023 +0200| [b105ad50c5c547fbaa7aa9038025ff446d556e61] | committer: Andreas Rheinhardt
avformat/matroskadec: Move WEBVTT code to mkv_parse_subtitle_codec()
and also perform the remainder of the subtitle parsing directly
after mkv_parse_subtitle_codec().
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b105ad50c5c547fbaa7aa9038025ff446d556e61
---
libavformat/matroskadec.c | 49 ++++++++++++++++++++++++++---------------------
1 file changed, 27 insertions(+), 22 deletions(-)
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index d6545fd30d..51c47e9404 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -2948,7 +2948,8 @@ static int mkv_parse_video(MatroskaTrack *track, AVStream *st,
}
/* Performs the codec-specific part of parsing a subtitle track. */
-static int mkv_parse_subtitle_codec(MatroskaTrack *track, AVCodecParameters *par,
+static int mkv_parse_subtitle_codec(MatroskaTrack *track, AVStream *st,
+ AVCodecParameters *par,
const MatroskaDemuxContext *matroska)
{
switch (par->codec_id) {
@@ -2984,6 +2985,15 @@ static int mkv_parse_subtitle_codec(MatroskaTrack *track, AVCodecParameters *par
track->codec_priv.size = 0;
}
break;
+ case AV_CODEC_ID_WEBVTT:
+ if (!strcmp(track->codec_id, "D_WEBVTT/CAPTIONS")) {
+ st->disposition |= AV_DISPOSITION_CAPTIONS;
+ } else if (!strcmp(track->codec_id, "D_WEBVTT/DESCRIPTIONS")) {
+ st->disposition |= AV_DISPOSITION_DESCRIPTIONS;
+ } else if (!strcmp(track->codec_id, "D_WEBVTT/METADATA")) {
+ st->disposition |= AV_DISPOSITION_METADATA;
+ }
+ break;
}
return 0;
@@ -3001,6 +3011,7 @@ static int matroska_parse_tracks(AVFormatContext *s)
EbmlList *encodings_list = &track->encodings;
MatroskaTrackEncoding *encodings = encodings_list->elem;
AVCodecParameters *par;
+ MatroskaTrackType type;
int extradata_offset = 0;
AVStream *st;
char* key_id_base64 = NULL;
@@ -3174,21 +3185,32 @@ static int matroska_parse_tracks(AVFormatContext *s)
(AVRational){ 1, 1000000000 },
st->time_base);
- if (track->type == MATROSKA_TRACK_TYPE_AUDIO) {
+ type = track->type;
+ if (par->codec_id == AV_CODEC_ID_WEBVTT)
+ type = MATROSKA_TRACK_TYPE_SUBTITLE;
+ switch (type) {
+ case MATROSKA_TRACK_TYPE_AUDIO:
ret = mka_parse_audio(track, st, par, matroska,
s, &extradata_offset);
if (ret < 0)
return ret;
if (ret == SKIP_TRACK)
continue;
- } else if (track->type == MATROSKA_TRACK_TYPE_VIDEO) {
+ break;
+ case MATROSKA_TRACK_TYPE_VIDEO:
ret = mkv_parse_video(track, st, par, matroska, &extradata_offset);
if (ret < 0)
return ret;
- } else if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE) {
- ret = mkv_parse_subtitle_codec(track, par, matroska);
+ break;
+ case MATROSKA_TRACK_TYPE_SUBTITLE:
+ ret = mkv_parse_subtitle_codec(track, st, par, matroska);
if (ret < 0)
return ret;
+ par->codec_type = AVMEDIA_TYPE_SUBTITLE;
+
+ if (track->flag_textdescriptions)
+ st->disposition |= AV_DISPOSITION_DESCRIPTIONS;
+ break;
}
if (par->codec_id == AV_CODEC_ID_NONE)
@@ -3204,23 +3226,6 @@ static int matroska_parse_tracks(AVFormatContext *s)
memcpy(par->extradata, src, extra_size);
}
- if (par->codec_id == AV_CODEC_ID_WEBVTT) {
- par->codec_type = AVMEDIA_TYPE_SUBTITLE;
-
- if (!strcmp(track->codec_id, "D_WEBVTT/CAPTIONS")) {
- st->disposition |= AV_DISPOSITION_CAPTIONS;
- } else if (!strcmp(track->codec_id, "D_WEBVTT/DESCRIPTIONS")) {
- st->disposition |= AV_DISPOSITION_DESCRIPTIONS;
- } else if (!strcmp(track->codec_id, "D_WEBVTT/METADATA")) {
- st->disposition |= AV_DISPOSITION_METADATA;
- }
- } else if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE) {
- par->codec_type = AVMEDIA_TYPE_SUBTITLE;
-
- if (track->flag_textdescriptions)
- st->disposition |= AV_DISPOSITION_DESCRIPTIONS;
- }
-
ret = mkv_parse_block_addition_mappings(s, st, track);
if (ret < 0)
return ret;
More information about the ffmpeg-cvslog
mailing list