[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:22:32 EEST 2024
Signed-off-by: Shiqi Zhu <hiccupzhu at gmail.com>
---
libavformat/demux.c | 4 ++++
tests/ref/seek/lavf-al | 4 ++--
tests/ref/seek/lavf-ul | 4 ++--
3 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/libavformat/demux.c b/libavformat/demux.c
index dc65f9ad91..64b6a1757c 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);
}
@@ -1432,6 +1434,7 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
ff_reduce_index(s, st->index);
av_add_index_entry(st, pkt->pos, pkt->dts,
0, 0, AVINDEX_KEYFRAME);
+ av_log(s, AV_LOG_INFO, "++++++rdin add index entry(dts=%"PRId64", pos=%"PRId64")\n", pkt->dts, pkt->pos);
}
got_packet = 1;
} else if (st->discard < AVDISCARD_ALL) {
@@ -1620,6 +1623,7 @@ return_packet:
if ((s->iformat->flags & AVFMT_GENERIC_INDEX) && pkt->flags & AV_PKT_FLAG_KEY) {
ff_reduce_index(s, st->index);
av_add_index_entry(st, pkt->pos, pkt->dts, 0, 0, AVINDEX_KEYFRAME);
+ av_log(s, AV_LOG_INFO, "-----rdfm add index entry(dts=%" PRId64 ", pos=%" PRId64 ")\n", pkt->dts, pkt->pos);
}
if (is_relative(pkt->dts))
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