Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] avformat/dvdvideodec: Fix duration logic with 1 chapter and validate chapter range
@ 2024-06-27  3:05 Marth64
  2024-06-30 19:48 ` Marth64
  2024-07-01 20:49 ` Stefano Sabatini
  0 siblings, 2 replies; 5+ messages in thread
From: Marth64 @ 2024-06-27  3:05 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Marth64

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".

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avformat/dvdvideodec: Fix duration logic with 1 chapter and validate chapter range
  2024-06-27  3:05 [FFmpeg-devel] [PATCH] avformat/dvdvideodec: Fix duration logic with 1 chapter and validate chapter range Marth64
@ 2024-06-30 19:48 ` Marth64
  2024-07-01 20:49 ` Stefano Sabatini
  1 sibling, 0 replies; 5+ messages in thread
From: Marth64 @ 2024-06-30 19:48 UTC (permalink / raw)
  To: Marth64; +Cc: ffmpeg-devel

Ping on this one blocking seeking when playing one chapter (and fixing
undefined option behavior).
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avformat/dvdvideodec: Fix duration logic with 1 chapter and validate chapter range
  2024-06-27  3:05 [FFmpeg-devel] [PATCH] avformat/dvdvideodec: Fix duration logic with 1 chapter and validate chapter range Marth64
  2024-06-30 19:48 ` Marth64
@ 2024-07-01 20:49 ` Stefano Sabatini
  2024-07-01 20:56   ` Stefano Sabatini
  1 sibling, 1 reply; 5+ messages in thread
From: Stefano Sabatini @ 2024-07-01 20:49 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Marth64

On date Wednesday 2024-06-26 22:05:46 -0500, Marth64 wrote:
> 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).

What is the meaning of the 0 special case?

> 
> Signed-off-by: Marth64 <marth64@proxyid.net>
> ---
>  libavformat/dvdvideodec.c | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)

[...]

Looks good to me.
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avformat/dvdvideodec: Fix duration logic with 1 chapter and validate chapter range
  2024-07-01 20:49 ` Stefano Sabatini
@ 2024-07-01 20:56   ` Stefano Sabatini
  2024-07-01 21:12     ` Marth64
  0 siblings, 1 reply; 5+ messages in thread
From: Stefano Sabatini @ 2024-07-01 20:56 UTC (permalink / raw)
  To: FFmpeg development discussions and patches, Marth64

On date Monday 2024-07-01 22:49:42 +0200, Stefano Sabatini wrote:
> On date Wednesday 2024-06-26 22:05:46 -0500, Marth64 wrote:
> > 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).
> 
> What is the meaning of the 0 special case?
> 
> > 
> > Signed-off-by: Marth64 <marth64@proxyid.net>
> > ---
> >  libavformat/dvdvideodec.c | 15 ++++++++++++---
> >  1 file changed, 12 insertions(+), 3 deletions(-)
> 
> [...]
> 
> Looks good to me.

Both patches applied.
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avformat/dvdvideodec: Fix duration logic with 1 chapter and validate chapter range
  2024-07-01 20:56   ` Stefano Sabatini
@ 2024-07-01 21:12     ` Marth64
  0 siblings, 0 replies; 5+ messages in thread
From: Marth64 @ 2024-07-01 21:12 UTC (permalink / raw)
  To: FFmpeg development discussions and patches, Marth64

>  What is the meaning of the 0 special case?
If chapter_end is 0, this means "end". So you can say, -chapter_start
5 -chapter_end 0  and demuxer will go from chapter 5 to end of title.
This is also in the public docs since initial demuxer merge.

Thank you!
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-07-01 21:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-27  3:05 [FFmpeg-devel] [PATCH] avformat/dvdvideodec: Fix duration logic with 1 chapter and validate chapter range Marth64
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

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