[FFmpeg-devel] [PATCH] avformat/demux: fix pcm read too much when call find_stream_info
Shiqi Zhu
hiccupzhu at gmail.com
Mon Jun 3 13:25:34 EEST 2024
Signed-off-by: Shiqi Zhu <hiccupzhu at gmail.com>
---
libavformat/demux.c | 2 ++
tests/ref/seek/lavf-al | 4 ++--
tests/ref/seek/lavf-ul | 4 ++--
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/libavformat/demux.c b/libavformat/demux.c
index dc65f9ad91..c878839175 100644
--- a/libavformat/demux.c
+++ b/libavformat/demux.c
@@ -1117,6 +1117,8 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
if (pkt->pts == AV_NOPTS_VALUE)
pkt->pts = sti->cur_dts;
pkt->dts = pkt->pts;
+ if (sti->first_dts == AV_NOPTS_VALUE)
+ sti->first_dts = is_relative(pkt->dts) ? pkt->dts - RELATIVE_TS_BASE : pkt->dts;
if (pkt->pts != AV_NOPTS_VALUE && duration.num >= 0)
sti->cur_dts = av_add_stable(st->time_base, pkt->pts, duration, 1);
}
diff --git a/tests/ref/seek/lavf-al b/tests/ref/seek/lavf-al
index 4cf458835a..075bc4e627 100644
--- a/tests/ref/seek/lavf-al
+++ b/tests/ref/seek/lavf-al
@@ -20,7 +20,7 @@ ret: 0 st: 0 flags:1 dts: 1.047483 pts: 1.047483 pos: 23097 size: 2048
ret: 0 st: 0 flags:0 ts:-0.058322
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size: 2048
ret: 0 st: 0 flags:1 ts: 2.835828
-ret: 0 st: 0 flags:1 dts: 1.950476 pts: 1.950476 pos: 43008 size: 1092
+ret: 0 st: 0 flags:1 dts: 1.987029 pts: 1.987029 pos: 43814 size: 286
ret: 0 st:-1 flags:0 ts: 1.730004
ret: 0 st: 0 flags:1 dts: 1.730023 pts: 1.730023 pos: 38147 size: 2048
ret: 0 st:-1 flags:1 ts: 0.624171
@@ -28,7 +28,7 @@ ret: 0 st: 0 flags:1 dts: 0.624172 pts: 0.624172 pos: 13763 size: 2048
ret: 0 st: 0 flags:0 ts:-0.481678
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size: 2048
ret: 0 st: 0 flags:1 ts: 2.412517
-ret: 0 st: 0 flags:1 dts: 1.950476 pts: 1.950476 pos: 43008 size: 1092
+ret: 0 st: 0 flags:1 dts: 1.987029 pts: 1.987029 pos: 43814 size: 286
ret: 0 st:-1 flags:0 ts: 1.306672
ret: 0 st: 0 flags:1 dts: 1.306667 pts: 1.306667 pos: 28812 size: 2048
ret: 0 st:-1 flags:1 ts: 0.200839
diff --git a/tests/ref/seek/lavf-ul b/tests/ref/seek/lavf-ul
index 4cf458835a..549e5c3d19 100644
--- a/tests/ref/seek/lavf-ul
+++ b/tests/ref/seek/lavf-ul
@@ -20,7 +20,7 @@ ret: 0 st: 0 flags:1 dts: 1.047483 pts: 1.047483 pos: 23097 size: 2048
ret: 0 st: 0 flags:0 ts:-0.058322
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size: 2048
ret: 0 st: 0 flags:1 ts: 2.835828
-ret: 0 st: 0 flags:1 dts: 1.950476 pts: 1.950476 pos: 43008 size: 1092
+ret: 0 st: 0 flags:1 dts: 1.987029 pts: 1.987029 pos: 43814 size: 286
ret: 0 st:-1 flags:0 ts: 1.730004
ret: 0 st: 0 flags:1 dts: 1.730023 pts: 1.730023 pos: 38147 size: 2048
ret: 0 st:-1 flags:1 ts: 0.624171
@@ -28,7 +28,7 @@ ret: 0 st: 0 flags:1 dts: 0.624172 pts: 0.624172 pos: 13763 size: 2048
ret: 0 st: 0 flags:0 ts:-0.481678
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size: 2048
ret: 0 st: 0 flags:1 ts: 2.412517
-ret: 0 st: 0 flags:1 dts: 1.950476 pts: 1.950476 pos: 43008 size: 1092
+ret: 0 st: 0 flags:1 dts: 1.987029 pts: 1.987029 pos: 43814 size: 286
ret: 0 st:-1 flags:0 ts: 1.306672
ret: 0 st: 0 flags:1 dts: 1.306667 pts: 1.306667 pos: 28812 size: 2048
ret: 0 st:-1 flags:1 ts: 0.200839
--
2.34.1
More information about the ffmpeg-devel
mailing list