From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> To: ffmpeg-devel@ffmpeg.org Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Subject: [FFmpeg-devel] [PATCH 19/20] avformat/matroskadec: Move WEBVTT code to mkv_parse_subtitle_codec() Date: Mon, 4 Sep 2023 13:27:58 +0200 Message-ID: <AS8P250MB0744B7182B79314F759F12BE8FE9A@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM> (raw) In-Reply-To: <AS8P250MB0744314AD7A516CFC71F61BF8FE9A@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM> and also perform the remainder of the subtitle parsing directly after mkv_parse_subtitle_codec(). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- 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; -- 2.34.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2023-09-04 11:31 UTC|newest] Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-09-04 11:26 [FFmpeg-devel] [PATCH 01/20] fate/matroska: Add test for remuxing non-rotation displaymatrix Andreas Rheinhardt 2023-09-04 11:27 ` [FFmpeg-devel] [PATCH 02/20] avformat/matroskadec: Set several stream parameters earlier Andreas Rheinhardt 2023-09-04 11:27 ` [FFmpeg-devel] [PATCH 03/20] avformat/matroskadec: Use dedicated pointer for access to codecpar Andreas Rheinhardt 2023-09-04 11:27 ` [FFmpeg-devel] [PATCH 04/20] avformat/matroskadec: Redo handling extradata allocation Andreas Rheinhardt 2023-09-04 11:27 ` [FFmpeg-devel] [PATCH 05/20] avformat/matroskadec: Set AVCodecParameters earlier Andreas Rheinhardt 2023-09-04 11:27 ` [FFmpeg-devel] [PATCH 06/20] avformat/matroskdec: Factor audio parsing out of matroska_parse_tracks() Andreas Rheinhardt 2023-09-04 11:27 ` [FFmpeg-devel] [PATCH 07/20] avformat/matroskadec: Remove redundant checks Andreas Rheinhardt 2023-09-04 11:27 ` [FFmpeg-devel] [PATCH 08/20] avformat/matroskadec: Reindent after the previous commit Andreas Rheinhardt 2023-09-04 11:27 ` [FFmpeg-devel] [PATCH 09/20] avformat/matroskadec: Factor video parsing out of matroska_parse_tracks() Andreas Rheinhardt 2023-09-04 11:27 ` [FFmpeg-devel] [PATCH 10/20] avformat/matroskadec: Reindent after the previous commit Andreas Rheinhardt 2023-09-04 11:27 ` [FFmpeg-devel] [PATCH 11/20] avformat/matroskadec: Move reading color space to a better place Andreas Rheinhardt 2023-09-04 11:27 ` [FFmpeg-devel] [PATCH 12/20] avformat/matroskadec: Avoid clobbering CodecPrivate size Andreas Rheinhardt 2023-09-04 11:27 ` [FFmpeg-devel] [PATCH 13/20] avformat/matroskadec: Use av_dict_set_int() where appropriate Andreas Rheinhardt 2023-09-04 11:27 ` [FFmpeg-devel] [PATCH 14/20] avformat/matroskadec: Factor parsing subtitle codecs out Andreas Rheinhardt 2023-09-04 11:27 ` [FFmpeg-devel] [PATCH 15/20] avformat/matroskadec: Factor generic parsing of video tracks out Andreas Rheinhardt 2023-09-04 11:46 ` James Almer 2023-09-04 11:27 ` [FFmpeg-devel] [PATCH 16/20] avformat/matroskadec: Reindent after the previous commit Andreas Rheinhardt 2023-09-04 11:27 ` [FFmpeg-devel] [PATCH 17/20] avformat/matroskadec: Factor generic parsing of audio tracks out Andreas Rheinhardt 2023-09-04 11:27 ` [FFmpeg-devel] [PATCH 18/20] avformat/matroskdec: Reindent after the previous commit Andreas Rheinhardt 2023-09-04 11:27 ` Andreas Rheinhardt [this message] 2023-09-04 11:27 ` [FFmpeg-devel] [PATCH 20/20] avformat/matroskadec: Factor parsing content encodings out Andreas Rheinhardt 2023-09-06 9:37 ` [FFmpeg-devel] [PATCH 01/20] fate/matroska: Add test for remuxing non-rotation displaymatrix Andreas Rheinhardt
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=AS8P250MB0744B7182B79314F759F12BE8FE9A@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM \ --to=andreas.rheinhardt@outlook.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git