[FFmpeg-cvslog] avformat/dvdvideodec: drop packets with unset PTS or DTS

Marth64 git at videolan.org
Sat Nov 16 22:48:56 EET 2024


ffmpeg | branch: master | Marth64 <marth64 at proxyid.net> | Mon Oct  7 18:05:03 2024 -0500| [f2f238c3a4855cd0919889940c2f45958ac47be6] | committer: Marth64

avformat/dvdvideodec: drop packets with unset PTS or DTS

The packets effectively serve no purpose and we are already
dropping packets with PTS less than 0. This also creates
for a smoother seeking experience after the subdemuxer
reset fix.

Signed-off-by: Marth64 <marth64 at proxyid.net>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f2f238c3a4855cd0919889940c2f45958ac47be6
---

 libavformat/dvdvideodec.c | 29 ++++++++++++-----------------
 1 file changed, 12 insertions(+), 17 deletions(-)

diff --git a/libavformat/dvdvideodec.c b/libavformat/dvdvideodec.c
index d64a678589..f20d2aa5cb 100644
--- a/libavformat/dvdvideodec.c
+++ b/libavformat/dvdvideodec.c
@@ -1643,28 +1643,23 @@ static int dvdvideo_read_packet(AVFormatContext *s, AVPacket *pkt)
         }
     }
 
-    if (!st_mapped)
+    if (!st_mapped || pkt->pts == AV_NOPTS_VALUE || pkt->dts == AV_NOPTS_VALUE)
         goto discard;
 
-    if (pkt->pts != AV_NOPTS_VALUE && pkt->dts != AV_NOPTS_VALUE) {
-        if (!c->play_started) {
-            /* try to start at the beginning of a GOP */
-            if (st_subdemux->codecpar->codec_type != AVMEDIA_TYPE_VIDEO || !is_key)
-                goto discard;
+    if (!c->play_started) {
+        /* try to start at the beginning of a GOP */
+        if (st_subdemux->codecpar->codec_type != AVMEDIA_TYPE_VIDEO || !is_key)
+            goto discard;
 
-            c->first_pts = pkt->pts;
-            c->play_started = 1;
-        }
+        c->first_pts = pkt->pts;
+        c->play_started = 1;
+    }
 
-        pkt->pts += c->pts_offset - c->first_pts;
-        pkt->dts += c->pts_offset - c->first_pts;
+    pkt->pts += c->pts_offset - c->first_pts;
+    pkt->dts += c->pts_offset - c->first_pts;
 
-        if (pkt->pts < 0)
-            goto discard;
-    } else {
-        av_log(s, AV_LOG_WARNING, "Unset PTS or DTS @ st=%d pts=%" PRId64 " dts=%" PRId64 "\n",
-                                  pkt->stream_index, pkt->pts, pkt->dts);
-    }
+    if (pkt->pts < 0)
+        goto discard;
 
     av_log(s, AV_LOG_TRACE, "st=%d pts=%" PRId64 " dts=%" PRId64 " "
                             "pts_offset=%" PRId64 " first_pts=%" PRId64 "\n",



More information about the ffmpeg-cvslog mailing list