PR #25171 opened by sepro
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25171
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25171.patch

# Summary of changes

When the next VOBU starts later than the previous one ended, the difference of 
the two uint32_t PTM values wraps around.

I hit this on a play-all title that joins several episodes. At two of the 
joins, the next cell starts about 90s later in PTM than the previous one ended. 
Before the patch, the video timestamps jump from 2613s to over 50000s. After 
the patch, they are continuous over the whole title.

I did not upload any samples, as the affected discs are commercial DVDs. If 
this is required, I can privately share them.


>From fb872691df934096d8d51e2a0fc5008c4f189bc1 Mon Sep 17 00:00:00 2001
From: sepro <[email protected]>
Date: Sun, 18 Oct 2026 09:12:08 +0200
Subject: [PATCH] avformat/dvdvideodec: fix PTM offset wraparound on forward
 discontinuities

When the next VOBU starts later than the previous one ended, the
difference of the two uint32_t PTM values wraps around.

Signed-off-by: sepro <[email protected]>
---
 libavformat/dvdvideodec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/dvdvideodec.c b/libavformat/dvdvideodec.c
index cf4c7962df..5be8659423 100644
--- a/libavformat/dvdvideodec.c
+++ b/libavformat/dvdvideodec.c
@@ -479,7 +479,7 @@ static int dvdvideo_menu_next_ps_block(AVFormatContext *s, 
DVDVideoPlaybackState
         if (state->in_pgc) {
             if (state->vobu_e_ptm != pci.pci_gi.vobu_s_ptm) {
                 state->ptm_discont  = 1;
-                state->ptm_offset  += state->vobu_e_ptm - 
pci.pci_gi.vobu_s_ptm;
+                state->ptm_offset  += (int64_t)state->vobu_e_ptm - 
pci.pci_gi.vobu_s_ptm;
             }
         } else {
             state->in_pgc        = 1;
@@ -803,7 +803,7 @@ static int dvdvideo_play_next_ps_block(AVFormatContext *s, 
DVDVideoPlaybackState
                 } else {
                     if (state->vobu_e_ptm != e_pci->pci_gi.vobu_s_ptm) {
                         state->ptm_discont  = 1;
-                        state->ptm_offset  += state->vobu_e_ptm - 
e_pci->pci_gi.vobu_s_ptm;
+                        state->ptm_offset  += (int64_t)state->vobu_e_ptm - 
e_pci->pci_gi.vobu_s_ptm;
                     }
                 }
 
-- 
2.54.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to