[FFmpeg-devel] [PATCH 11/18] lavf: move AVStream.pts_buffer to AVStreamInternal

Anton Khirnov anton at khirnov.net
Fri Oct 9 16:04:23 EEST 2020


Those are private fields, no reason to have them exposed in a public
header.
---
 libavformat/avformat.h |  3 +--
 libavformat/internal.h |  4 ++++
 libavformat/mux.c      | 12 ++++++------
 libavformat/utils.c    | 14 +++++++-------
 4 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index dbef1b21dd..ef6d673699 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1062,11 +1062,10 @@ typedef struct AVStream {
      */
     struct AVPacketList *last_in_packet_buffer;
     AVProbeData probe_data;
-#define MAX_REORDER_DELAY 16
-    int64_t pts_buffer[MAX_REORDER_DELAY+1];
 
 #if LIBAVFORMAT_VERSION_MAJOR < 59
     // kept for ABI compatibility only, do not access in any way
+    int64_t      unused5[16+1];
     void         *unused2;
     int          unused3;
     unsigned int unused4;
diff --git a/libavformat/internal.h b/libavformat/internal.h
index ce79da8000..23c2ce0dc3 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -308,12 +308,16 @@ struct AVStreamInternal {
      */
     int update_initial_durations_done;
 
+#define MAX_REORDER_DELAY 16
+
     /**
      * Internal data to generate dts from pts
      */
     int64_t pts_reorder_error[MAX_REORDER_DELAY+1];
     uint8_t pts_reorder_error_count[MAX_REORDER_DELAY+1];
 
+    int64_t pts_buffer[MAX_REORDER_DELAY+1];
+
     /**
      * Internal data to analyze DTS and detect faulty mpeg streams
      */
diff --git a/libavformat/mux.c b/libavformat/mux.c
index 1cf885fbea..1a34ee7e96 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -595,13 +595,13 @@ static int compute_muxer_pkt_fields(AVFormatContext *s, AVStream *st, AVPacket *
 
     //calculate dts from pts
     if (pkt->pts != AV_NOPTS_VALUE && pkt->dts == AV_NOPTS_VALUE && delay <= MAX_REORDER_DELAY) {
-        st->pts_buffer[0] = pkt->pts;
-        for (i = 1; i < delay + 1 && st->pts_buffer[i] == AV_NOPTS_VALUE; i++)
-            st->pts_buffer[i] = pkt->pts + (i - delay - 1) * pkt->duration;
-        for (i = 0; i<delay && st->pts_buffer[i] > st->pts_buffer[i + 1]; i++)
-            FFSWAP(int64_t, st->pts_buffer[i], st->pts_buffer[i + 1]);
+        st->internal->pts_buffer[0] = pkt->pts;
+        for (i = 1; i < delay + 1 && st->internal->pts_buffer[i] == AV_NOPTS_VALUE; i++)
+            st->internal->pts_buffer[i] = pkt->pts + (i - delay - 1) * pkt->duration;
+        for (i = 0; i<delay && st->internal->pts_buffer[i] > st->internal->pts_buffer[i + 1]; i++)
+            FFSWAP(int64_t, st->internal->pts_buffer[i], st->internal->pts_buffer[i + 1]);
 
-        pkt->dts = st->pts_buffer[0];
+        pkt->dts = st->internal->pts_buffer[0];
     }
 
     if (st->cur_dts && st->cur_dts != AV_NOPTS_VALUE &&
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 1e53cae103..6cba0cce8f 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1358,12 +1358,12 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
     }
 
     if (pkt->pts != AV_NOPTS_VALUE && delay <= MAX_REORDER_DELAY) {
-        st->pts_buffer[0] = pkt->pts;
-        for (i = 0; i<delay && st->pts_buffer[i] > st->pts_buffer[i + 1]; i++)
-            FFSWAP(int64_t, st->pts_buffer[i], st->pts_buffer[i + 1]);
+        st->internal->pts_buffer[0] = pkt->pts;
+        for (i = 0; i<delay && st->internal->pts_buffer[i] > st->internal->pts_buffer[i + 1]; i++)
+            FFSWAP(int64_t, st->internal->pts_buffer[i], st->internal->pts_buffer[i + 1]);
 
         if(has_decode_delay_been_guessed(st))
-            pkt->dts = select_from_pts_buffer(st, st->pts_buffer, pkt->dts);
+            pkt->dts = select_from_pts_buffer(st, st->internal->pts_buffer, pkt->dts);
     }
     // We skipped it above so we try here.
     if (!onein_oneout)
@@ -1885,7 +1885,7 @@ void ff_read_frame_flush(AVFormatContext *s)
         st->probe_packets = s->max_probe_packets;
 
         for (j = 0; j < MAX_REORDER_DELAY + 1; j++)
-            st->pts_buffer[j] = AV_NOPTS_VALUE;
+            st->internal->pts_buffer[j] = AV_NOPTS_VALUE;
 
         if (s->internal->inject_global_side_data)
             st->internal->inject_global_side_data = 1;
@@ -2866,7 +2866,7 @@ skip_duration_calc:
         st->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->pts_buffer[j] = AV_NOPTS_VALUE;
+            st->internal->pts_buffer[j] = AV_NOPTS_VALUE;
     }
 }
 
@@ -4525,7 +4525,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
     st->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->pts_buffer[i] = AV_NOPTS_VALUE;
+        st->internal->pts_buffer[i] = AV_NOPTS_VALUE;
 
     st->sample_aspect_ratio = (AVRational) { 0, 1 };
 
-- 
2.28.0



More information about the ffmpeg-devel mailing list