diff mbox series

[FFmpeg-devel,05/18] lavf: move AVStream.{pts_wrap_*, update_initial_durations_done} to AVStreamInternal

Message ID 20201009130430.602-5-anton@khirnov.net
State New
Headers show
Series [FFmpeg-devel,01/18] lavf: move AVStream.info to AVStreamInternal
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Anton Khirnov Oct. 9, 2020, 1:04 p.m. UTC
Those are private fields, no reason to have them exposed in a public
header.
---
 libavformat/avformat.h | 22 ----------------------
 libavformat/internal.h | 22 ++++++++++++++++++++++
 libavformat/mpegts.c   |  4 ++--
 libavformat/utils.c    | 38 +++++++++++++++++++-------------------
 4 files changed, 43 insertions(+), 43 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 3d7fe4aadf..7383d0b6e5 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1140,28 +1140,6 @@  typedef struct AVStream {
      */
     int64_t mux_ts_offset;
 
-    /**
-     * Internal data to check for wrapping of the time stamp
-     */
-    int64_t pts_wrap_reference;
-
-    /**
-     * Options for behavior, when a wrap is detected.
-     *
-     * Defined by AV_PTS_WRAP_ values.
-     *
-     * If correction is enabled, there are two possibilities:
-     * If the first time stamp is near the wrap point, the wrap offset
-     * will be subtracted, which will create negative time stamps.
-     * Otherwise the offset will be added.
-     */
-    int pts_wrap_behavior;
-
-    /**
-     * Internal data to prevent doing update_initial_durations() twice
-     */
-    int update_initial_durations_done;
-
     /**
      * An opaque field for libavformat internal usage.
      * Must not be accessed in any way by callers.
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 95cb5b5d60..efa5a8b238 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -225,6 +225,28 @@  struct AVStreamInternal {
 
     } *info;
 
+    /**
+     * Internal data to check for wrapping of the time stamp
+     */
+    int64_t pts_wrap_reference;
+
+    /**
+     * Options for behavior, when a wrap is detected.
+     *
+     * Defined by AV_PTS_WRAP_ values.
+     *
+     * If correction is enabled, there are two possibilities:
+     * If the first time stamp is near the wrap point, the wrap offset
+     * will be subtracted, which will create negative time stamps.
+     * Otherwise the offset will be added.
+     */
+    int pts_wrap_behavior;
+
+    /**
+     * Internal data to prevent doing update_initial_durations() twice
+     */
+    int update_initial_durations_done;
+
     /**
      * Internal data to generate dts from pts
      */
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 50d4d5e9bc..b1b65d3887 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -1325,8 +1325,8 @@  skip:
                                     int64_t pcr = f->last_pcr / 300;
                                     pcr_found = 1;
                                     if (st) {
-                                        pes->st->pts_wrap_reference = st->pts_wrap_reference;
-                                        pes->st->pts_wrap_behavior = st->pts_wrap_behavior;
+                                        pes->st->internal->pts_wrap_reference = st->internal->pts_wrap_reference;
+                                        pes->st->internal->pts_wrap_behavior = st->internal->pts_wrap_behavior;
                                     }
                                     if (pes->dts == AV_NOPTS_VALUE || pes->dts < pcr) {
                                         pes->pts = pes->dts = pcr;
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 3c4d13e1c1..e3f909a252 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -101,13 +101,13 @@  static int is_relative(int64_t ts) {
  */
 static int64_t wrap_timestamp(const AVStream *st, int64_t timestamp)
 {
-    if (st->pts_wrap_behavior != AV_PTS_WRAP_IGNORE &&
-        st->pts_wrap_reference != AV_NOPTS_VALUE && timestamp != AV_NOPTS_VALUE) {
-        if (st->pts_wrap_behavior == AV_PTS_WRAP_ADD_OFFSET &&
-            timestamp < st->pts_wrap_reference)
+    if (st->internal->pts_wrap_behavior != AV_PTS_WRAP_IGNORE &&
+        st->internal->pts_wrap_reference != AV_NOPTS_VALUE && timestamp != AV_NOPTS_VALUE) {
+        if (st->internal->pts_wrap_behavior == AV_PTS_WRAP_ADD_OFFSET &&
+            timestamp < st->internal->pts_wrap_reference)
             return timestamp + (1ULL << st->pts_wrap_bits);
-        else if (st->pts_wrap_behavior == AV_PTS_WRAP_SUB_OFFSET &&
-            timestamp >= st->pts_wrap_reference)
+        else if (st->internal->pts_wrap_behavior == AV_PTS_WRAP_SUB_OFFSET &&
+            timestamp >= st->internal->pts_wrap_reference)
             return timestamp - (1ULL << st->pts_wrap_bits);
     }
     return timestamp;
@@ -732,7 +732,7 @@  static int update_wrap_reference(AVFormatContext *s, AVStream *st, int stream_in
 
     if (ref == AV_NOPTS_VALUE)
         ref = pkt->pts;
-    if (st->pts_wrap_reference != AV_NOPTS_VALUE || st->pts_wrap_bits >= 63 || ref == AV_NOPTS_VALUE || !s->correct_ts_overflow)
+    if (st->internal->pts_wrap_reference != AV_NOPTS_VALUE || st->pts_wrap_bits >= 63 || ref == AV_NOPTS_VALUE || !s->correct_ts_overflow)
         return 0;
     ref &= (1LL << st->pts_wrap_bits)-1;
 
@@ -747,17 +747,17 @@  static int update_wrap_reference(AVFormatContext *s, AVStream *st, int stream_in
 
     if (!first_program) {
         int default_stream_index = av_find_default_stream_index(s);
-        if (s->streams[default_stream_index]->pts_wrap_reference == AV_NOPTS_VALUE) {
+        if (s->streams[default_stream_index]->internal->pts_wrap_reference == AV_NOPTS_VALUE) {
             for (i = 0; i < s->nb_streams; i++) {
                 if (av_find_program_from_stream(s, NULL, i))
                     continue;
-                s->streams[i]->pts_wrap_reference = pts_wrap_reference;
-                s->streams[i]->pts_wrap_behavior = pts_wrap_behavior;
+                s->streams[i]->internal->pts_wrap_reference = pts_wrap_reference;
+                s->streams[i]->internal->pts_wrap_behavior = pts_wrap_behavior;
             }
         }
         else {
-            st->pts_wrap_reference = s->streams[default_stream_index]->pts_wrap_reference;
-            st->pts_wrap_behavior = s->streams[default_stream_index]->pts_wrap_behavior;
+            st->internal->pts_wrap_reference = s->streams[default_stream_index]->internal->pts_wrap_reference;
+            st->internal->pts_wrap_behavior = s->streams[default_stream_index]->internal->pts_wrap_behavior;
         }
     }
     else {
@@ -776,8 +776,8 @@  static int update_wrap_reference(AVFormatContext *s, AVStream *st, int stream_in
         while (program) {
             if (program->pts_wrap_reference != pts_wrap_reference) {
                 for (i = 0; i<program->nb_stream_indexes; i++) {
-                    s->streams[program->stream_index[i]]->pts_wrap_reference = pts_wrap_reference;
-                    s->streams[program->stream_index[i]]->pts_wrap_behavior = pts_wrap_behavior;
+                    s->streams[program->stream_index[i]]->internal->pts_wrap_reference = pts_wrap_reference;
+                    s->streams[program->stream_index[i]]->internal->pts_wrap_behavior = pts_wrap_behavior;
                 }
 
                 program->pts_wrap_reference = pts_wrap_reference;
@@ -859,7 +859,7 @@  int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
 
         st = s->streams[pkt->stream_index];
 
-        if (update_wrap_reference(s, st, pkt->stream_index, pkt) && st->pts_wrap_behavior == AV_PTS_WRAP_SUB_OFFSET) {
+        if (update_wrap_reference(s, st, pkt->stream_index, pkt) && st->internal->pts_wrap_behavior == AV_PTS_WRAP_SUB_OFFSET) {
             // correct first time stamps to negative values
             if (!is_relative(st->first_dts))
                 st->first_dts = wrap_timestamp(st, st->first_dts);
@@ -1147,9 +1147,9 @@  static void update_initial_durations(AVFormatContext *s, AVStream *st,
     int64_t cur_dts    = RELATIVE_TS_BASE;
 
     if (st->first_dts != AV_NOPTS_VALUE) {
-        if (st->update_initial_durations_done)
+        if (st->internal->update_initial_durations_done)
             return;
-        st->update_initial_durations_done = 1;
+        st->internal->update_initial_durations_done = 1;
         cur_dts = st->first_dts;
         for (; pktl; pktl = get_next_pkt(s, st, pktl)) {
             if (pktl->pkt.stream_index == stream_index) {
@@ -4519,8 +4519,8 @@  FF_ENABLE_DEPRECATION_WARNINGS
     st->duration   = AV_NOPTS_VALUE;
     st->first_dts     = AV_NOPTS_VALUE;
     st->probe_packets = s->max_probe_packets;
-    st->pts_wrap_reference = AV_NOPTS_VALUE;
-    st->pts_wrap_behavior = AV_PTS_WRAP_IGNORE;
+    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_dts_for_order_check = AV_NOPTS_VALUE;