diff mbox

[FFmpeg-devel,08/11] avformat/mux: Restore original ts in write_packet on error

Message ID 1470144262-13167-9-git-send-email-sebechlebskyjan@gmail.com
State Accepted
Commit 2fc9a3eb7a8c606bd403dc9fbdb8463144b243cf
Headers show

Commit Message

sebechlebskyjan@gmail.com Aug. 2, 2016, 1:24 p.m. UTC
From: Jan Sebechlebsky <sebechlebskyjan@gmail.com>

Restore original timestamps in write_packet() if the
actual write operation was not successfull. This allows
to pass the same packet to nonblocking muxer repeatedly
without corrupting the timestamps.

Signed-off-by: Jan Sebechlebsky <sebechlebskyjan@gmail.com>
---
 libavformat/mux.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Michael Niedermayer Aug. 22, 2016, 11:02 a.m. UTC | #1
On Tue, Aug 02, 2016 at 03:24:19PM +0200, sebechlebskyjan@gmail.com wrote:
> From: Jan Sebechlebsky <sebechlebskyjan@gmail.com>
> 
> Restore original timestamps in write_packet() if the
> actual write operation was not successfull. This allows
> to pass the same packet to nonblocking muxer repeatedly
> without corrupting the timestamps.
> 
> Signed-off-by: Jan Sebechlebsky <sebechlebskyjan@gmail.com>
> ---
>  libavformat/mux.c | 9 +++++++++
>  1 file changed, 9 insertions(+)

applied

thanks

[...]
diff mbox

Patch

diff --git a/libavformat/mux.c b/libavformat/mux.c
index 888a9f1..ef4720a 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -657,6 +657,10 @@  FF_ENABLE_DEPRECATION_WARNINGS
 static int write_packet(AVFormatContext *s, AVPacket *pkt)
 {
     int ret, did_split;
+    int64_t pts_backup, dts_backup;
+
+    pts_backup = pkt->pts;
+    dts_backup = pkt->dts;
 
     if (s->output_ts_offset) {
         AVStream *st = s->streams[pkt->stream_index];
@@ -743,6 +747,11 @@  fail:
     if (did_split)
         av_packet_merge_side_data(pkt);
 
+    if (ret < 0) {
+        pkt->pts = pts_backup;
+        pkt->dts = dts_backup;
+    }
+
     return ret;
 }