[FFmpeg-cvslog] avformat/mux: Remove pointless timestamp backups

Andreas Rheinhardt git at videolan.org
Sat Apr 18 02:17:59 EEST 2020


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Tue Aug 13 04:47:26 2019 +0200| [148bcc0bc5ff9ce10dbfaf2f3054c267bcbdf91a] | committer: Andreas Rheinhardt

avformat/mux: Remove pointless timestamp backups

write_packet() currently saves the original timestamps of the packet it
got and restores them in case writing fails. This is unnecessary as we
are no longer working directly with the user-supplied AVPacket here; and
it is also pointless because the timestamps may already have been
altered before write_packet().

So remove this and add a general comment to the function that timestamps
may be modified; also remove a long outdated comment about side data.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=148bcc0bc5ff9ce10dbfaf2f3054c267bcbdf91a
---

 libavformat/mux.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/libavformat/mux.c b/libavformat/mux.c
index 1427ec94fa..3d63d59faf 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -664,8 +664,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 #endif
 
 /**
- * Make timestamps non negative, move side data from payload to internal struct, call muxer, and restore
- * sidedata.
+ * Shift timestamps and call muxer; the original pts/dts are not kept.
  *
  * FIXME: this function should NEVER get undefined pts/dts beside when the
  * AVFMT_NOTIMESTAMPS is set.
@@ -675,10 +674,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
 static int write_packet(AVFormatContext *s, AVPacket *pkt)
 {
     int ret;
-    int64_t pts_backup, dts_backup;
-
-    pts_backup = pkt->pts;
-    dts_backup = pkt->dts;
 
     // If the timestamp offsetting below is adjusted, adjust
     // ff_interleaved_peek similarly.
@@ -753,10 +748,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
             ret = s->pb->error;
     }
 
-    if (ret < 0) {
-        pkt->pts = pts_backup;
-        pkt->dts = dts_backup;
-    } else
+    if (ret >= 0)
         s->streams[pkt->stream_index]->nb_frames++;
 
     return ret;



More information about the ffmpeg-cvslog mailing list