diff mbox series

[FFmpeg-devel,2/2] avformat/mux: Unify setting number of muxed packets

Message ID 20200312175408.31391-2-andreas.rheinhardt@gmail.com
State Accepted
Headers show
Series [FFmpeg-devel,1/2] avformat/mux: Remove redundant checks for write errors
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork success Applied patch
andriy/ffmpeg-patchwork success Configure finished
andriy/ffmpeg-patchwork success Make finished
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Andreas Rheinhardt March 12, 2020, 5:54 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/mux.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/mux.c b/libavformat/mux.c
index bc2eab0c96..bfd1bf491b 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -763,7 +763,8 @@  static int write_packet(AVFormatContext *s, AVPacket *pkt)
     if (ret < 0) {
         pkt->pts = pts_backup;
         pkt->dts = dts_backup;
-    }
+    } else
+        s->streams[pkt->stream_index]->nb_frames++;
 
     return ret;
 }
@@ -912,11 +913,7 @@  int av_write_frame(AVFormatContext *s, AVPacket *pkt)
         return ret;
 #endif
 
-    ret = write_packet(s, pkt);
-
-    if (ret >= 0)
-        s->streams[pkt->stream_index]->nb_frames++;
-    return ret;
+    return write_packet(s, pkt);
 }
 
 #define CHUNK_START 0x1000
@@ -1237,8 +1234,6 @@  int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt)
             return ret;
 
         ret = write_packet(s, &opkt);
-        if (ret >= 0)
-            s->streams[opkt.stream_index]->nb_frames++;
 
         av_packet_unref(&opkt);
 
@@ -1263,8 +1258,6 @@  int av_write_trailer(AVFormatContext *s)
             break;
 
         ret = write_packet(s, &pkt);
-        if (ret >= 0)
-            s->streams[pkt.stream_index]->nb_frames++;
 
         av_packet_unref(&pkt);