From: Marth64 <marth64@proxyid.net> To: ffmpeg-devel@ffmpeg.org Cc: Marth64 <marth64@proxyid.net> Subject: [FFmpeg-devel] [PATCH] avformat/dvdvideodec: Fix duration logic with 1 chapter and validate chapter range Date: Wed, 26 Jun 2024 22:05:46 -0500 Message-ID: <20240627030546.143368-1-marth64@proxyid.net> (raw) Chapters and duration are calculated together in dvdvideo demuxer. Previous chapter calculation logic treated extraction of 1 chapter using chapter_start and chapter_end switches incorrectly, returning the duration of the entire title instead of just the segment. Fix the logic so that it calculates and returns the duration of the chapter segment instead. Additionally, validate that chapter_end exceeds chapter_start (except in the special case of 0). Signed-off-by: Marth64 <marth64@proxyid.net> --- libavformat/dvdvideodec.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/libavformat/dvdvideodec.c b/libavformat/dvdvideodec.c index 8326595e1b..e7132725b7 100644 --- a/libavformat/dvdvideodec.c +++ b/libavformat/dvdvideodec.c @@ -865,8 +865,7 @@ static int dvdvideo_chapters_setup_simple(AVFormatContext *s) int chapter_end = c->opt_chapter_end > 0 ? c->opt_chapter_end : c->play_state.pgc_nb_pg_est - 1; /* dvdnav_describe_title_chapters() describes PGs rather than PTTs, so validate our range */ - if (chapter_start == chapter_end || - c->play_state.pgc_nb_pg_est == 1 || + if (c->play_state.pgc_nb_pg_est == 1 || chapter_start > c->play_state.pgc_nb_pg_est || chapter_end > c->play_state.pgc_nb_pg_est) { @@ -878,8 +877,11 @@ static int dvdvideo_chapters_setup_simple(AVFormatContext *s) for (int i = chapter_start - 1; i < chapter_end; i++) { uint64_t time_effective = c->play_state.pgc_pg_times_est[i] - c->play_state.nav_pts; - if (!avpriv_new_chapter(s, i, DVDVIDEO_TIME_BASE_Q, time_prev, time_effective, NULL)) + if (chapter_start != chapter_end && + !avpriv_new_chapter(s, i, DVDVIDEO_TIME_BASE_Q, time_prev, time_effective, NULL)) { + return AVERROR(ENOMEM); + } time_prev = time_effective; total_duration = time_effective; @@ -1548,6 +1550,13 @@ static int dvdvideo_read_header(AVFormatContext *s) return 0; } + if (c->opt_chapter_end != 0 && c->opt_chapter_start > c->opt_chapter_end) { + av_log(s, AV_LOG_ERROR, "Chapter (PTT) range [%d, %d] is invalid\n", + c->opt_chapter_start, c->opt_chapter_end); + + return AVERROR(EINVAL); + } + if (c->opt_title == 0) { av_log(s, AV_LOG_INFO, "Defaulting to title #1. " "This is not always the main feature, validation suggested.\n"); -- 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 reply other threads:[~2024-06-27 3:07 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-06-27 3:05 Marth64 [this message] 2024-06-30 19:48 ` Marth64 2024-07-01 20:49 ` Stefano Sabatini 2024-07-01 20:56 ` Stefano Sabatini 2024-07-01 21:12 ` Marth64
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=20240627030546.143368-1-marth64@proxyid.net \ --to=marth64@proxyid.net \ --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