diff mbox

[FFmpeg-devel,v5] avformat/utils: Don't create unnecessary references

Message ID 20190928024224.21707-1-andreas.rheinhardt@gmail.com
State Accepted
Headers show

Commit Message

Andreas Rheinhardt Sept. 28, 2019, 2:42 a.m. UTC
When AVFMT_FLAG_GENPTS is set, av_read_frame would put a reference to a
packet in the packet list (via av_packet_ref) and then immediately
thereafter unreference the original packet. This has been changed to
move the reference instead.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
Updated the commit message in light of the fact that ff_packet_list_put
now ensures that the packets are refcounted.

 libavformat/utils.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 1292fef3df..fe40ead438 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1858,10 +1858,11 @@  int av_read_frame(AVFormatContext *s, AVPacket *pkt)
 
         ret = ff_packet_list_put(&s->internal->packet_buffer,
                                  &s->internal->packet_buffer_end,
-                                 pkt, FF_PACKETLIST_FLAG_REF_PACKET);
-        av_packet_unref(pkt);
-        if (ret < 0)
+                                 pkt, 0);
+        if (ret < 0) {
+            av_packet_unref(pkt);
             return ret;
+        }
     }
 
 return_packet: