[FFmpeg-devel] [PATCH 1/5] avformat: move AVStream.last-IP_{pts, duration} to AVStreamInternal
James Almer
jamrial at gmail.com
Mon May 3 16:31:56 EEST 2021
Those are private fields, no reason to have them exposed in a public
header.
Signed-off-by: James Almer <jamrial at gmail.com>
---
libavformat/avformat.h | 2 --
libavformat/internal.h | 3 +++
libavformat/nutdec.c | 2 +-
libavformat/utils.c | 20 ++++++++++----------
4 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 624d2dae2c..e62c6d1567 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1002,8 +1002,6 @@ typedef struct AVStream {
*/
int64_t first_dts;
int64_t cur_dts;
- int64_t last_IP_pts;
- int last_IP_duration;
/**
* Number of packets to buffer for codec probing
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 7d0eab44ac..10d8f8dfeb 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -365,6 +365,9 @@ struct AVStreamInternal {
* last packet in packet_buffer for this stream when muxing.
*/
struct PacketList *last_in_packet_buffer;
+
+ int64_t last_IP_pts;
+ int last_IP_duration;
};
#ifdef __GNUC__
diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c
index 46f21ddd57..e709257135 100644
--- a/libavformat/nutdec.c
+++ b/libavformat/nutdec.c
@@ -1086,7 +1086,7 @@ static int decode_frame(NUTContext *nut, AVPacket *pkt, int frame_code)
stc->skip_until_key_frame = 0;
discard = s->streams[stream_id]->discard;
- last_IP_pts = s->streams[stream_id]->last_IP_pts;
+ last_IP_pts = s->streams[stream_id]->internal->last_IP_pts;
if ((discard >= AVDISCARD_NONKEY && !(stc->last_flags & FLAG_KEY)) ||
(discard >= AVDISCARD_BIDIR && last_IP_pts != AV_NOPTS_VALUE &&
last_IP_pts > pts) ||
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 49bf19b2b0..b5b0995f32 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1285,28 +1285,28 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
/* DTS = decompression timestamp */
/* PTS = presentation timestamp */
if (pkt->dts == AV_NOPTS_VALUE)
- pkt->dts = st->last_IP_pts;
+ pkt->dts = st->internal->last_IP_pts;
update_initial_timestamps(s, pkt->stream_index, pkt->dts, pkt->pts, pkt);
if (pkt->dts == AV_NOPTS_VALUE)
pkt->dts = st->cur_dts;
/* This is tricky: the dts must be incremented by the duration
* of the frame we are displaying, i.e. the last I- or P-frame. */
- if (st->last_IP_duration == 0 && (uint64_t)pkt->duration <= INT32_MAX)
- st->last_IP_duration = pkt->duration;
+ if (st->internal->last_IP_duration == 0 && (uint64_t)pkt->duration <= INT32_MAX)
+ st->internal->last_IP_duration = pkt->duration;
if (pkt->dts != AV_NOPTS_VALUE)
- st->cur_dts = av_sat_add64(pkt->dts, st->last_IP_duration);
+ st->cur_dts = av_sat_add64(pkt->dts, st->internal->last_IP_duration);
if (pkt->dts != AV_NOPTS_VALUE &&
pkt->pts == AV_NOPTS_VALUE &&
- st->last_IP_duration > 0 &&
+ st->internal->last_IP_duration > 0 &&
((uint64_t)st->cur_dts - (uint64_t)next_dts + 1) <= 2 &&
next_dts != next_pts &&
next_pts != AV_NOPTS_VALUE)
pkt->pts = next_dts;
if ((uint64_t)pkt->duration <= INT32_MAX)
- st->last_IP_duration = pkt->duration;
- st->last_IP_pts = pkt->pts;
+ st->internal->last_IP_duration = pkt->duration;
+ st->internal->last_IP_pts = pkt->pts;
/* Cannot compute PTS if not present (we can compute it only
* by knowing the future. */
} else if (pkt->pts != AV_NOPTS_VALUE ||
@@ -1823,7 +1823,7 @@ void ff_read_frame_flush(AVFormatContext *s)
av_parser_close(st->parser);
st->parser = NULL;
}
- st->last_IP_pts = AV_NOPTS_VALUE;
+ st->internal->last_IP_pts = AV_NOPTS_VALUE;
st->internal->last_dts_for_order_check = AV_NOPTS_VALUE;
if (st->first_dts == AV_NOPTS_VALUE)
st->cur_dts = RELATIVE_TS_BASE;
@@ -2840,7 +2840,7 @@ skip_duration_calc:
st = ic->streams[i];
st->cur_dts = st->first_dts;
- st->last_IP_pts = AV_NOPTS_VALUE;
+ st->internal->last_IP_pts = AV_NOPTS_VALUE;
st->internal->last_dts_for_order_check = AV_NOPTS_VALUE;
for (j = 0; j < MAX_REORDER_DELAY + 1; j++)
st->internal->pts_buffer[j] = AV_NOPTS_VALUE;
@@ -4423,7 +4423,7 @@ AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c)
st->internal->pts_wrap_reference = AV_NOPTS_VALUE;
st->internal->pts_wrap_behavior = AV_PTS_WRAP_IGNORE;
- st->last_IP_pts = AV_NOPTS_VALUE;
+ st->internal->last_IP_pts = AV_NOPTS_VALUE;
st->internal->last_dts_for_order_check = AV_NOPTS_VALUE;
for (i = 0; i < MAX_REORDER_DELAY + 1; i++)
st->internal->pts_buffer[i] = AV_NOPTS_VALUE;
--
2.31.1
More information about the ffmpeg-devel
mailing list